From b2ddb8ac4d6a20329a484a6763e0662318390eef Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Mon, 9 Mar 2015 02:27:57 +0000 Subject: [PATCH] [clang-tidy] Fix assertion when a dependent expression is used in an assert. llvm-svn: 231620 --- clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp | 4 +++- clang-tools-extra/test/clang-tidy/misc-static-assert.cpp | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp index 47d6df7..fd6c4ca 100644 --- a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp @@ -69,7 +69,9 @@ void StaticAssertCheck::check(const MatchFinder::MatchResult &Result) { StringRef MacroName = Lexer::getImmediateMacroName(AssertExpansionLoc, SM, Opts); - if (MacroName != "assert" || !Condition->isEvaluatable(*ASTCtx)) + if (MacroName != "assert" || Condition->isValueDependent() || + Condition->isTypeDependent() || Condition->isInstantiationDependent() || + !Condition->isEvaluatable(*ASTCtx)) return; // False literal is not the result of macro expansion. diff --git a/clang-tools-extra/test/clang-tidy/misc-static-assert.cpp b/clang-tools-extra/test/clang-tidy/misc-static-assert.cpp index e63d7f9..e17a701 100644 --- a/clang-tools-extra/test/clang-tidy/misc-static-assert.cpp +++ b/clang-tools-extra/test/clang-tidy/misc-static-assert.cpp @@ -34,6 +34,8 @@ template void doSomething(T t) { assert(t.method()); // CHECK-FIXES: {{^ }}assert(t.method()); + + assert(sizeof(T) == 123); } int main() { -- 2.7.4