Author: hokein Date: Thu Jun 6 05:58:48 2019 New Revision: 362701 URL: http://llvm.org/viewvc/llvm-project?rev=362701&view=rev Log: [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 Modified: clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp Modified: clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp?rev=362701&r1=362700&r2=362701&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp Thu Jun 6 05:58:48 2019 @@ -291,7 +291,7 @@ static void transformSubToCanonicalAddEx } AST_MATCHER(Expr, isIntegerConstantExpr) { - if (Node.isInstantiationDependent()) + if (Node.isInstantiationDependent() || Node.isValueDependent()) return false; return Node.isIntegerConstantExpr(Finder->getASTContext()); } Modified: clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp?rev=362701&r1=362700&r2=362701&view=diff ============================================================================== --- clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp Thu Jun 6 05:58:48 2019 @@ -725,3 +725,15 @@ int operatorConfusion(int X, int Y, long #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; + } +}; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits