diff --git a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp index 47d6df7bf667..fd6c4ca92fcb 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 e63d7f9236b4..e17a701b06a2 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() {