Krishna-13-cyber updated this revision to Diff 508297. Krishna-13-cyber added a comment.
Updated with the new test cases and implemented the logic suggested for ignoring the BO_LOr operators at the top level. My sincere apologies @tbaeder that I could not place this logic at the first instance. Thanks! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D146376/new/ https://reviews.llvm.org/D146376 Files: clang/lib/Sema/SemaDeclCXX.cpp clang/test/SemaCXX/static-assert.cpp Index: clang/test/SemaCXX/static-assert.cpp =================================================================== --- clang/test/SemaCXX/static-assert.cpp +++ clang/test/SemaCXX/static-assert.cpp @@ -258,9 +258,17 @@ constexpr bool invert(bool b) { return !b; } + + /// Bools are printed with disjunction. + static_assert(invert(true) || invert(true), ""); // expected-error {{failed}} \ + + /// Bools are printed with an expected note. static_assert(invert(true) == invert(false), ""); // expected-error {{failed}} \ // expected-note {{evaluates to 'false == true'}} + /// Bools are printed with conjunction. + static_assert(true && false, ""); // expected-error {{failed}} \ + /// No notes here since we compare a bool expression with a bool literal. static_assert(invert(true) == true, ""); // expected-error {{failed}} Index: clang/lib/Sema/SemaDeclCXX.cpp =================================================================== --- clang/lib/Sema/SemaDeclCXX.cpp +++ clang/lib/Sema/SemaDeclCXX.cpp @@ -16728,6 +16728,10 @@ if (!UsefulToPrintExpr(LHS) && !UsefulToPrintExpr(RHS)) return; + // Ignore BO_LOr operators at the toplevel. + if (Op->getOpcode() == BO_LOr) + return; + struct { const clang::Expr *Cond; Expr::EvalResult Result;
Index: clang/test/SemaCXX/static-assert.cpp =================================================================== --- clang/test/SemaCXX/static-assert.cpp +++ clang/test/SemaCXX/static-assert.cpp @@ -258,9 +258,17 @@ constexpr bool invert(bool b) { return !b; } + + /// Bools are printed with disjunction. + static_assert(invert(true) || invert(true), ""); // expected-error {{failed}} \ + + /// Bools are printed with an expected note. static_assert(invert(true) == invert(false), ""); // expected-error {{failed}} \ // expected-note {{evaluates to 'false == true'}} + /// Bools are printed with conjunction. + static_assert(true && false, ""); // expected-error {{failed}} \ + /// No notes here since we compare a bool expression with a bool literal. static_assert(invert(true) == true, ""); // expected-error {{failed}} Index: clang/lib/Sema/SemaDeclCXX.cpp =================================================================== --- clang/lib/Sema/SemaDeclCXX.cpp +++ clang/lib/Sema/SemaDeclCXX.cpp @@ -16728,6 +16728,10 @@ if (!UsefulToPrintExpr(LHS) && !UsefulToPrintExpr(RHS)) return; + // Ignore BO_LOr operators at the toplevel. + if (Op->getOpcode() == BO_LOr) + return; + struct { const clang::Expr *Cond; Expr::EvalResult Result;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits