[PATCH] D146376: Update static_assert message for redundant cases

Krishna Narayanan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 24 06:34:13 PDT 2023


Krishna-13-cyber added a comment.

The above Binary operator test case says that there are two Boolean expressions,**UsefulToPrintExpr** says we can avoid to print these expressions as they are don't need a note and are understandable.

So if we go by this we will have to remove the note.By this we are removing note for boolean literals as well as expressions.It will be nice to make it generic rather than specifically target cases of false || false , false && false. As the warning note print out the boolean values which can be avoided giving preference to the other diagnostics in terms of boolean literals and expressions.

Yes, I making a **new diff for test cases** of conjunction and disjunction as well.



================
Comment at: clang/test/SemaCXX/static-assert.cpp:261-265
   static_assert(invert(true) == invert(false), ""); // expected-error {{failed}} \
-                                                    // expected-note {{evaluates to 'false == true'}}
 
   /// No notes here since we compare a bool expression with a bool literal.
   static_assert(invert(true) == true, ""); // expected-error {{failed}}
----------------
cjdb wrote:
> We should also have a test for conjunctions, disjunctions, and negations.
Yes, I making a new diff for test cases of conjunction and disjunction as well.


================
Comment at: clang/test/SemaCXX/static-assert.cpp:262
   static_assert(invert(true) == invert(false), ""); // expected-error {{failed}} \
-                                                    // expected-note {{evaluates to 'false == true'}}
 
----------------
tbaeder wrote:
> This diagnostic should be kept. From looking at the condition, it is not obvious what the two functions evaluate to.
The above Binary operator test case says that there are two Boolean expressions,**UsefulToPrintExpr** says we can avoid to print these expressions as they are don't need a note and are understandable.

So if we go by this we will have to remove the note.By this we are removing note for boolean literals as well as expressions.It will be nice to make it generic rather than specifically target cases of false || false , false && false. As the warning note print out the boolean values which can be avoided giving preference to the other diagnostics in terms of boolean literals and expressions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146376/new/

https://reviews.llvm.org/D146376



More information about the cfe-commits mailing list