[PATCH] D62947: [clang-tidy] Fix an assertion failure in misc-redundant-expression.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 6 04:27:43 PDT 2019
hokein created this revision.
hokein added a reviewer: gribozavr.
Herald added a subscriber: xazax.hun.
Herald added a project: clang.
The assertion "isIntegerConstantExpr" is triggered in the
isIntegerConstantExpr(), we should not call it if the expression is value
dependent.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D62947
Files:
clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tools-extra/test/clang-tidy/misc-redundant-expression.cpp
Index: clang-tools-extra/test/clang-tidy/misc-redundant-expression.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/misc-redundant-expression.cpp
+++ clang-tools-extra/test/clang-tidy/misc-redundant-expression.cpp
@@ -725,3 +725,15 @@
#undef FLAG1
#undef FLAG2
#undef FLAG3
+
+namespace no_crash {
+struct Foo {};
+bool operator<(const Foo&, const Foo&);
+template <class T>
+struct Bar {
+ static const Foo &GetFoo();
+ static bool Test(const T & maybe_foo, const Foo& foo) {
+ return foo < GetFoo() && foo < maybe_foo;
+ }
+};
+}
Index: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -291,7 +291,7 @@
}
AST_MATCHER(Expr, isIntegerConstantExpr) {
- if (Node.isInstantiationDependent())
+ if (Node.isInstantiationDependent() || Node.isValueDependent())
return false;
return Node.isIntegerConstantExpr(Finder->getASTContext());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62947.203331.patch
Type: text/x-patch
Size: 1135 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190606/415d4223/attachment.bin>
More information about the cfe-commits
mailing list