void Manager::View::cleanClause(Clause & clause) { exprView.sort(clause.begin(), clause.end()); for (Clause::iterator it = clause.begin(); it != clause.end(); ) { if (*it == exprView.btrue()) // [true lit] throw Trivial(true); else if (*it == exprView.bfalse()) // [false lit] clause.erase(it); else if (it+1 != clause.end()) { if (*it == *(it+1)) { // [repetition of lit] clause.erase(it); } else if (*it == exprView.apply(Expr::Not, *(it+1))) // [var with both phases] // Relies on how Expr handles negation, so possibly a hack. // However, I meant for this property to be usable, so it // will be maintained. throw Trivial(true); else it++; } else it++; } if (clause.size() == 0) // empty clause throw Trivial(false); }
void test() { int i = 0; const int k = 0; auto captures_nothing = [] {}; auto captures_nothing_by_value = [=] {}; auto captures_nothing_by_reference = [&] {}; auto implicit_by_value = [=]() mutable { i++; }; auto implicit_by_reference = [&] { i++; }; auto explicit_by_value_used = [i] { return i + 1; }; auto explicit_by_value_used_void = [i] { (void)i; }; auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}} auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // expected-warning{{lambda capture 'i' is not required to be captured for this use}} auto explicit_by_value_unused_decltype = [i] { decltype(i) j = 0; }; // expected-warning{{lambda capture 'i' is not required to be captured for this use}} auto explicit_by_value_unused_const = [k] { return k + 1; }; // expected-warning{{lambda capture 'k' is not required to be captured for this use}} auto explicit_by_reference_used = [&i] { i++; }; auto explicit_by_reference_unused = [&i] {}; // expected-warning{{lambda capture 'i' is not used}} auto explicit_initialized_reference_used = [&j = i] { return j + 1; }; auto explicit_initialized_reference_unused = [&j = i]{}; // expected-warning{{lambda capture 'j' is not used}} auto explicit_initialized_value_used = [j = 1] { return j + 1; }; auto explicit_initialized_value_unused = [j = 1] {}; // expected-warning{{lambda capture 'j' is not used}} auto explicit_initialized_value_non_trivial_constructor = [j = NonTrivialConstructor()]{}; auto explicit_initialized_value_non_trivial_destructor = [j = NonTrivialDestructor()]{}; auto explicit_initialized_value_trivial_init = [j = Trivial()]{}; // expected-warning{{lambda capture 'j' is not used}} auto explicit_initialized_value_non_trivial_init = [j = Trivial(42)]{}; auto explicit_initialized_value_with_side_effect = [j = side_effect()]{}; auto nested = [&i] { auto explicit_by_value_used = [i] { return i + 1; }; auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}} }; Trivial trivial; auto explicit_by_value_trivial = [trivial] {}; // expected-warning{{lambda capture 'trivial' is not used}} NonTrivialConstructor cons; auto explicit_by_value_non_trivial_constructor = [cons] {}; // expected-warning{{lambda capture 'cons' is not used}} NonTrivialCopyConstructor copy_cons; auto explicit_by_value_non_trivial_copy_constructor = [copy_cons] {}; NonTrivialDestructor dest; auto explicit_by_value_non_trivial_destructor = [dest] {}; volatile int v; auto explicit_by_value_volatile = [v] {}; }
const Trivial &getTrivialRef() { return Trivial(42); // expected-warning {{Address of stack memory associated with temporary object of type 'Trivial' returned to caller}} }
Trivial getTrivial() { return Trivial(42); // no-warning }
Group Group::trivial() {return Group(Trivial()); }