[clang-tools-extra] r236812 - [clang-tidy] Fix for llvm.org/PR23161
Szabolcs Sipos
szabolcs.sipos at ericsson.com
Fri May 8 00:56:24 PDT 2015
Author: eszasip
Date: Fri May 8 02:56:24 2015
New Revision: 236812
URL: http://llvm.org/viewvc/llvm-project?rev=236812&view=rev
Log:
[clang-tidy] Fix for llvm.org/PR23161
The misc-static-assert check will not warn on the followings:
assert(NULL == "shouldn't warn");
assert(__null == "shouldn't warn");
Where NULL is a macro defined as __null.
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=236812&r1=236811&r2=236812&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp Fri May 8 02:56:24 2015
@@ -29,7 +29,7 @@ StaticAssertCheck::StaticAssertCheck(Str
void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
auto IsAlwaysFalse = expr(ignoringParenImpCasts(
expr(anyOf(boolLiteral(equals(false)), integerLiteral(equals(0)),
- nullPtrLiteralExpr())).bind("isAlwaysFalse")));
+ nullPtrLiteralExpr(), gnuNullExpr())).bind("isAlwaysFalse")));
auto IsAlwaysFalseWithCast = ignoringParenImpCasts(anyOf(IsAlwaysFalse,
cStyleCastExpr(has(IsAlwaysFalse)).bind("castExpr")));
auto AssertExprRoot = anyOf(
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=236812&r1=236811&r2=236812&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 Fri May 8 02:56:24 2015
@@ -95,6 +95,12 @@ int main() {
assert(NULL && "Report me!");
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
// CHECK-FIXES: {{^ }}static_assert(NULL , "Report me!");
+
+#define NULL __null
+ assert(__null == "Don't report me!");
+ // CHECK-FIXES: {{^ }}assert(__null == "Don't report me!");
+ assert(NULL == "Don't report me!");
+ // CHECK-FIXES: {{^ }}assert(NULL == "Don't report me!");
#undef NULL
assert(ZERO_MACRO && "Report me!");
More information about the cfe-commits
mailing list