[clang-tools-extra] r231620 - [clang-tidy] Fix assertion when a dependent expression is used in an assert.

Alexander Kornienko alexfh at google.com
Sun Mar 8 19:27:58 PDT 2015


Author: alexfh
Date: Sun Mar  8 21:27:57 2015
New Revision: 231620

URL: http://llvm.org/viewvc/llvm-project?rev=231620&view=rev
Log:
[clang-tidy] Fix assertion when a dependent expression is used in an assert.

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

Modified: clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp?rev=231620&r1=231619&r2=231620&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp Sun Mar  8 21:27:57 2015
@@ -69,7 +69,9 @@ void StaticAssertCheck::check(const Matc
   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.

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp?rev=231620&r1=231619&r2=231620&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp Sun Mar  8 21:27:57 2015
@@ -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() {





More information about the cfe-commits mailing list