[PATCH] D146376: Update static_assert message for redundant cases

Krishna Narayanan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 21 13:59:26 PDT 2023


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

I have updated the patch without removing the whole of the previous block.I have added a condition to find the case where we don't need a diagnostic message to be printed or warned.


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


Index: clang/lib/Sema/SemaDeclCXX.cpp
===================================================================
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -16723,7 +16723,7 @@
     if ((isa<CXXBoolLiteralExpr>(LHS) && RHS->getType()->isBooleanType()) ||
         (isa<CXXBoolLiteralExpr>(RHS) && LHS->getType()->isBooleanType()))
       return;
-
+      
     // Don't print obvious expressions.
     if (!UsefulToPrintExpr(LHS) && !UsefulToPrintExpr(RHS))
       return;
@@ -16744,9 +16744,16 @@
           DiagSide[I].Result.Val, Side->getType(), DiagSide[I].ValueString);
     }
     if (DiagSide[0].Print && DiagSide[1].Print) {
+      if (DiagSide[0].ValueString == SmallString<12>("false") && DiagSide[1].ValueString == SmallString<12>("false"))
+      {
+        return;
+      }
+      else
+      {
       Diag(Op->getExprLoc(), diag::note_expr_evaluates_to)
           << DiagSide[0].ValueString << Op->getOpcodeStr()
           << DiagSide[1].ValueString << Op->getSourceRange();
+      }
     }
   }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146376.507113.patch
Type: text/x-patch
Size: 1039 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230321/c5a6195c/attachment.bin>


More information about the cfe-commits mailing list