Author: d0k Date: Thu Aug 4 05:02:03 2016 New Revision: 277712 URL: http://llvm.org/viewvc/llvm-project?rev=277712&view=rev Log: Make isExternC work on VarDecls too.
Modified: cfe/trunk/docs/LibASTMatchersReference.html cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp Modified: cfe/trunk/docs/LibASTMatchersReference.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=277712&r1=277711&r2=277712&view=diff ============================================================================== --- cfe/trunk/docs/LibASTMatchersReference.html (original) +++ cfe/trunk/docs/LibASTMatchersReference.html Thu Aug 4 05:02:03 2016 @@ -3441,6 +3441,18 @@ Usable as: Matcher<<a href="http://cl </pre></td></tr> +<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isExternC1')"><a name="isExternC1Anchor">isExternC</a></td><td></td></tr> +<tr><td colspan="4" class="doc" id="isExternC1"><pre>Matches extern "C" function declarations. + +Given: + extern "C" void f() {} + extern "C" { void g() {} } + void h() {} +functionDecl(isExternC()) + matches the declaration of f and g, but not the declaration h +</pre></td></tr> + + <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isTemplateInstantiation1')"><a name="isTemplateInstantiation1Anchor">isTemplateInstantiation</a></td><td></td></tr> <tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static member variable template instantiations. Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=277712&r1=277711&r2=277712&view=diff ============================================================================== --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original) +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Thu Aug 4 05:02:03 2016 @@ -3342,7 +3342,8 @@ AST_MATCHER_P(FunctionDecl, returns, /// \endcode /// functionDecl(isExternC()) /// matches the declaration of f and g, but not the declaration h -AST_MATCHER(FunctionDecl, isExternC) { +AST_POLYMORPHIC_MATCHER(isExternC, AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, + VarDecl)) { return Node.isExternC(); } Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp?rev=277712&r1=277711&r2=277712&view=diff ============================================================================== --- cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp (original) +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp Thu Aug 4 05:02:03 2016 @@ -842,6 +842,12 @@ TEST(IsExternC, MatchesExternCFunctionDe EXPECT_TRUE(notMatches("void f() {}", functionDecl(isExternC()))); } +TEST(IsExternC, MatchesExternCVariableDeclarations) { + EXPECT_TRUE(matches("extern \"C\" int i;", varDecl(isExternC()))); + EXPECT_TRUE(matches("extern \"C\" { int i; }", varDecl(isExternC()))); + EXPECT_TRUE(notMatches("int i;", varDecl(isExternC()))); +} + TEST(IsDefaulted, MatchesDefaultedFunctionDeclarations) { EXPECT_TRUE(notMatches("class A { ~A(); };", functionDecl(hasName("~A"), isDefaulted()))); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits