[PATCH] D146376: Update static_assert message for redundant cases
Krishna Narayanan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 22 09:59:05 PDT 2023
Krishna-13-cyber updated this revision to Diff 507413.
Krishna-13-cyber added a comment.
Have worked on the top level with Boolean literals unlike the previous diffs.I have updated the test case as well with this new upcoming change.
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
@@ -259,7 +259,6 @@
return !b;
}
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}}
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;
+ // Don't print obvious boolean literals.
+ if (LHS->getType()->isBooleanType() && RHS->getType()->isBooleanType())
+ return;
+
struct {
const clang::Expr *Cond;
Expr::EvalResult Result;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146376.507413.patch
Type: text/x-patch
Size: 1071 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230322/f4b0f345/attachment-0001.bin>
More information about the cfe-commits
mailing list