[clang-tidy] Fix assertion when a dependent expression is used in an assert.
authorAlexander Kornienko <alexfh@google.com>
Mon, 9 Mar 2015 02:27:57 +0000 (02:27 +0000)
committerAlexander Kornienko <alexfh@google.com>
Mon, 9 Mar 2015 02:27:57 +0000 (02:27 +0000)
llvm-svn: 231620

clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
clang-tools-extra/test/clang-tidy/misc-static-assert.cpp

index 47d6df7..fd6c4ca 100644 (file)
@@ -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.
index e63d7f9..e17a701 100644 (file)
@@ -34,6 +34,8 @@ template <class T> void doSomething(T t) {
 
   assert(t.method());
   // CHECK-FIXES: {{^  }}assert(t.method());
+
+  assert(sizeof(T) == 123);
 }
 
 int main() {