[clang-tidy] Fix an assertion failure in misc-redundant-expression.

Summary:
The assertion "isIntegerConstantExpr" is triggered in the
isIntegerConstantExpr(), we should not call it if the expression is value
dependent.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D62947

llvm-svn: 362701
This commit is contained in:
Haojian Wu 2019-06-06 12:58:48 +00:00
parent 559e69a821
commit df95e6109e
2 changed files with 13 additions and 1 deletions

View File

@ -291,7 +291,7 @@ static void transformSubToCanonicalAddExpr(BinaryOperatorKind &Opcode,
}
AST_MATCHER(Expr, isIntegerConstantExpr) {
if (Node.isInstantiationDependent())
if (Node.isInstantiationDependent() || Node.isValueDependent())
return false;
return Node.isIntegerConstantExpr(Finder->getASTContext());
}

View File

@ -725,3 +725,15 @@ int operatorConfusion(int X, int Y, long Z)
#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;
}
};
}