Krishna-13-cyber updated this revision to Diff 509589.
Krishna-13-cyber edited the summary of this revision.
Krishna-13-cyber added a comment.
This patch aims to remove some redundant cases of static assert messages where
the expansions are particularly unhelpful. In this particular patch, we have
ignored the printing of diagnostic warnings for binary operators with logical
OR operations.
This is done to prioritise and prefer to emit longer diagnostic warnings for
more important concerns elsewhere.
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
@@ -16715,7 +16715,7 @@
/// Try to print more useful information about a failed static_assert
/// with expression \E
void Sema::DiagnoseStaticAssertDetails(const Expr *E) {
- if (const auto *Op = dyn_cast<BinaryOperator>(E)) {
+ if (const auto *Op = dyn_cast<BinaryOperator>(E);Op && Op->getOpcode() !=
BO_LOr) {
const Expr *LHS = Op->getLHS()->IgnoreParenImpCasts();
const Expr *RHS = Op->getRHS()->IgnoreParenImpCasts();
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
@@ -16715,7 +16715,7 @@
/// Try to print more useful information about a failed static_assert
/// with expression \E
void Sema::DiagnoseStaticAssertDetails(const Expr *E) {
- if (const auto *Op = dyn_cast<BinaryOperator>(E)) {
+ if (const auto *Op = dyn_cast<BinaryOperator>(E);Op && Op->getOpcode() != BO_LOr) {
const Expr *LHS = Op->getLHS()->IgnoreParenImpCasts();
const Expr *RHS = Op->getRHS()->IgnoreParenImpCasts();
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits