Krishna-13-cyber updated this revision to Diff 509249.
Krishna-13-cyber added a comment.

I have removed the redundant comments and have moved the `if' condition above 
with the ongoing conditional statement (to avoid printing obvious expressions).

- Updated static_assert warning message
- Added Test cases




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,14 @@
   constexpr bool invert(bool b) {
     return !b;
   }
+
+  static_assert(invert(true) || invert(true), ""); // expected-error {{failed}}
+
   static_assert(invert(true) == invert(false), ""); // expected-error 
{{failed}} \
                                                     // expected-note 
{{evaluates to 'false == true'}}
 
+  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
@@ -16725,7 +16725,7 @@
       return;
 
     // Don't print obvious expressions.
-    if (!UsefulToPrintExpr(LHS) && !UsefulToPrintExpr(RHS))
+    if ((!UsefulToPrintExpr(LHS) && !UsefulToPrintExpr(RHS)) || 
Op->getOpcode() == BO_LOr)
       return;
 
     struct {


Index: clang/test/SemaCXX/static-assert.cpp
===================================================================
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -258,9 +258,14 @@
   constexpr bool invert(bool b) {
     return !b;
   }
+
+  static_assert(invert(true) || invert(true), ""); // expected-error {{failed}}
+
   static_assert(invert(true) == invert(false), ""); // expected-error {{failed}} \
                                                     // expected-note {{evaluates to 'false == true'}}
 
+  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
@@ -16725,7 +16725,7 @@
       return;
 
     // Don't print obvious expressions.
-    if (!UsefulToPrintExpr(LHS) && !UsefulToPrintExpr(RHS))
+    if ((!UsefulToPrintExpr(LHS) && !UsefulToPrintExpr(RHS)) || Op->getOpcode() == BO_LOr)
       return;
 
     struct {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to