From b8e22b2e84edccdea13f4736e69f92e814dd93fd Mon Sep 17 00:00:00 2001 From: Szabolcs Sipos Date: Thu, 7 May 2015 14:24:22 +0000 Subject: [PATCH] Adding new AST matcher: gnuNullExpr It matches GNU __null expression. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236731 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/ASTMatchers/ASTMatchers.h | 5 +++++ unittests/ASTMatchers/ASTMatchersTest.cpp | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index 3280083b2b..94906d190b 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -1441,6 +1441,11 @@ const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNullPtrLiteralExpr> nullPtrLiteralExpr; +/// \brief Matches GNU __null expression. +const internal::VariadicDynCastAllOfMatcher< + Stmt, + GNUNullExpr> gnuNullExpr; + /// \brief Matches binary operator expressions. /// /// Example matches a || b diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp index 46ddb8d0fb..6f1cf3fe2c 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -2144,6 +2144,10 @@ TEST(Matcher, NullPtrLiteral) { EXPECT_TRUE(matches("int* i = nullptr;", nullPtrLiteralExpr())); } +TEST(Matcher, GNUNullExpr) { + EXPECT_TRUE(matches("int* i = __null;", gnuNullExpr())); +} + TEST(Matcher, AsmStatement) { EXPECT_TRUE(matches("void foo() { __asm(\"mov al, 2\"); }", asmStmt())); } -- 2.40.0