Author: aaronballman
Date: Mon Oct  5 14:44:42 2015
New Revision: 249341

URL: http://llvm.org/viewvc/llvm-project?rev=249341&view=rev
Log:
Adding an AST node matcher for NonTypeTemplateParmDecl objects.

Modified:
    cfe/trunk/docs/LibASTMatchersReference.html
    cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
    cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=249341&r1=249340&r2=249341&view=diff
==============================================================================
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Oct  5 14:44:42 2015
@@ -316,6 +316,16 @@ namespaceDecl()
 </pre></td></tr>
 
 
+<tr><td>Matcher&lt<a 
href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html";>Decl</a>&gt;</td><td
 class="name" onclick="toggle('nonTypeTemplateParmDecl0')"><a 
name="nonTypeTemplateParmDecl0Anchor">nonTypeTemplateParmDecl</a></td><td>Matcher&lt<a
 
href="http://clang.llvm.org/doxygen/classclang_1_1NonTypeTemplateParmDecl.html";>NonTypeTemplateParmDecl</a>&gt;...</td></tr>
+<tr><td colspan="4" class="doc" id="nonTypeTemplateParmDecl0"><pre>Matches 
non-type template parameter declarations.
+
+Given
+  template &lt;typename T, int N&gt; struct C {};
+templateArgument()
+  matches 'N', but not 'T'.
+</pre></td></tr>
+
+
 <tr><td>Matcher&lt<a 
href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html";>Decl</a>&gt;</td><td
 class="name" onclick="toggle('objcInterfaceDecl0')"><a 
name="objcInterfaceDecl0Anchor">objcInterfaceDecl</a></td><td>Matcher&lt<a 
href="http://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html";>ObjCInterfaceDecl</a>&gt;...</td></tr>
 <tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches 
Objective-C interface declarations.
 
@@ -2213,7 +2223,7 @@ Usable as: Matcher&lt<a href="http://cla
 <tr><td>Matcher&lt<a 
href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html";>FunctionDecl</a>&gt;</td><td
 class="name" onclick="toggle('isVariadic0')"><a 
name="isVariadic0Anchor">isVariadic</a></td><td></td></tr>
 <tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function 
declaration is variadic.
 
-Example matches f, but not g or h. The function i will not match, event when
+Example matches f, but not g or h. The function i will not match, even when
 compiled in C mode.
   void f(...);
   void g(int);

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=249341&r1=249340&r2=249341&view=diff
==============================================================================
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Oct  5 14:44:42 2015
@@ -412,6 +412,18 @@ const internal::VariadicAllOfMatcher<CXX
 ///   matches 'int' in C<int>.
 const internal::VariadicAllOfMatcher<TemplateArgument> templateArgument;
 
+/// \brief Matches non-type template parameter declarations.
+///
+/// Given
+/// \code
+///   template <typename T, int N> struct C {};
+/// \endcode
+/// templateArgument()
+///   matches 'N', but not 'T'.
+const internal::VariadicDynCastAllOfMatcher<
+  Decl,
+  NonTypeTemplateParmDecl> nonTypeTemplateParmDecl;
+
 /// \brief Matches public C++ declarations.
 ///
 /// Given

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=249341&r1=249340&r2=249341&view=diff
==============================================================================
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Oct  5 14:44:42 2015
@@ -1172,6 +1172,13 @@ TEST(Matcher, SubstNonTypeTemplateParm)
                       substNonTypeTemplateParmExpr()));
 }
 
+TEST(Matcher, NonTypeTemplateParmDecl) {
+  EXPECT_TRUE(matches("template <int N> void f();",
+                      nonTypeTemplateParmDecl(hasName("N"))));
+  EXPECT_TRUE(
+      notMatches("template <typename T> void f();", 
nonTypeTemplateParmDecl()));
+}
+
 TEST(Matcher, UserDefinedLiteral) {
   EXPECT_TRUE(matches("constexpr char operator \"\" _inc (const char i) {"
                       "  return i + 1;"


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to