[PATCH] D146376: Update static_assert message for redundant cases
Krishna Narayanan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 29 01:47:22 PDT 2023
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 {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146376.509249.patch
Type: text/x-patch
Size: 1207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230329/45831ccc/attachment.bin>
More information about the cfe-commits
mailing list