<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">It’s strange. It actually used to be called hasInnerType but I changed it either because of a review or because I thought that was the style. But searching
through ASTMatchers.h now I see most the other TRAVERSE_MATCHERs use hasSomething (except pointee(). I’m guessing it needs to change to?)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Manuel Klimek [mailto:klimek@google.com]
<br>
<b>Sent:</b> Tuesday, April 02, 2013 3:19 PM<br>
<b>To:</b> Vane, Edwin<br>
<b>Cc:</b> cfe-commits@cs.uiuc.edu<br>
<b>Subject:</b> Re: r178487 - Adding parenType() and innerType() AST Matchers<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Mon, Apr 1, 2013 at 8:33 PM, Edwin Vane <<a href="mailto:edwin.vane@intel.com" target="_blank">edwin.vane@intel.com</a>> wrote:<o:p></o:p></p>
<div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">Author: revane<br>
Date: Mon Apr 1 13:33:34 2013<br>
New Revision: 178487<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=178487&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=178487&view=rev</a><br>
Log:<br>
Adding parenType() and innerType() AST Matchers<br>
<br>
Updated docs and tests.<br>
<br>
<br>
Modified:<br>
cfe/trunk/docs/LibASTMatchersReference.html<br>
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h<br>
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp<br>
<br>
Modified: cfe/trunk/docs/LibASTMatchersReference.html<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=178487&r1=178486&r2=178487&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=178487&r1=178486&r2=178487&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/docs/LibASTMatchersReference.html (original)<br>
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Apr 1 13:33:34 2013<br>
@@ -1000,6 +1000,18 @@ memberPointerType()<br>
</pre></td></tr><br>
<br>
<br>
+<tr><td>Matcher<<a href="<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html</a>">TypeLoc</a>></td><td class="name" onclick="toggle('parenTypeLoc0')"><a name="parenTypeLoc0Anchor">parenTypeLoc</a></td><td>Matcher<<a
href="<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenTypeLoc.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1ParenTypeLoc.html</a>">ParenTypeLoc</a>>...</td></tr><br>
+<tr><td colspan="4" class="doc" id="parenTypeLoc0"><pre>Matches ParenType nodes.<br>
+<br>
+Given<br>
+ int (*ptr_to_array)[4];<br>
+ int *array_of_ptrs[4];<br>
+<br>
+varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not<br>
+array_of_ptrs.<br>
+</pre></td></tr><br>
+<br>
+<br>
<tr><td>Matcher<<a href="<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html</a>">TypeLoc</a>></td><td class="name" onclick="toggle('pointerTypeLoc0')"><a name="pointerTypeLoc0Anchor">pointerTypeLoc</a></td><td>Matcher<<a
href="<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html</a>">PointerTypeLoc</a>>...</td></tr><br>
<tr><td colspan="4" class="doc" id="pointerTypeLoc0"><pre>Matches pointer types.<br>
<br>
@@ -1267,6 +1279,18 @@ memberPointerType()<br>
</pre></td></tr><br>
<br>
<br>
+<tr><td>Matcher<<a href="<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1Type.html</a>">Type</a>></td><td class="name" onclick="toggle('parenType0')"><a name="parenType0Anchor">parenType</a></td><td>Matcher<<a
href="<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1ParenType.html</a>">ParenType</a>>...</td></tr><br>
+<tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes.<br>
+<br>
+Given<br>
+ int (*ptr_to_array)[4];<br>
+ int *array_of_ptrs[4];<br>
+<br>
+varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not<br>
+array_of_ptrs.<br>
+</pre></td></tr><br>
+<br>
+<br>
<tr><td>Matcher<<a href="<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1Type.html</a>">Type</a>></td><td class="name" onclick="toggle('pointerType0')"><a name="pointerType0Anchor">pointerType</a></td><td>Matcher<<a
href="<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1PointerType.html</a>">PointerType</a>>...</td></tr><br>
<tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types.<br>
<br>
@@ -2991,6 +3015,20 @@ nestedNameSpecifier(specifiesType(hasDec<br>
</pre></td></tr><br>
<br>
<br>
+<tr><td>Matcher<<a href="<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1ParenType.html</a>">ParenType</a>></td><td class="name" onclick="toggle('innerType0')"><a name="innerType0Anchor">innerType</a></td><td>Matcher<<a
href="<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1Type.html</a>">Type</a>></td></tr><br>
+<tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type.<br>
+<br>
+Given<br>
+ int (*ptr_to_array)[4];<br>
+ int (*ptr_to_func)(int);<br>
+<br>
+varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches<br>
+ptr_to_func but not ptr_to_array.<br>
+<br>
+Usable as: Matcher<<a href="<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1ParenType.html</a>">ParenType</a>><br>
+</pre></td></tr><br>
+<br>
+<br>
<tr><td>Matcher<<a href="<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html</a>">PointerTypeLoc</a>></td><td class="name" onclick="toggle('pointeeLoc1')"><a
name="pointeeLoc1Anchor">pointeeLoc</a></td><td>Matcher<<a href="<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html</a>">TypeLoc</a>></td></tr><br>
<tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the<br>
pointee matches a given matcher.<br>
<br>
Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=178487&r1=178486&r2=178487&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=178487&r1=178486&r2=178487&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)<br>
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Apr 1 13:33:34 2013<br>
@@ -2894,6 +2894,32 @@ AST_TYPE_TRAVERSE_MATCHER(hasDeducedType<br>
/// matches "int (*f)(int)" and the type of "g".<br>
AST_TYPE_MATCHER(FunctionType, functionType);<br>
<br>
+/// \brief Matches \c ParenType nodes.<br>
+///<br>
+/// Given<br>
+/// \code<br>
+/// int (*ptr_to_array)[4];<br>
+/// int *array_of_ptrs[4];<br>
+/// \endcode<br>
+///<br>
+/// \c varDecl(hasType(pointsTo(parenType()))) matches \c ptr_to_array but not<br>
+/// \c array_of_ptrs.<br>
+AST_TYPE_MATCHER(ParenType, parenType);<br>
+<br>
+/// \brief Matches \c ParenType nodes where the inner type is a specific type.<br>
+///<br>
+/// Given<br>
+/// \code<br>
+/// int (*ptr_to_array)[4];<br>
+/// int (*ptr_to_func)(int);<br>
+/// \endcode<br>
+///<br>
+/// \c varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches<br>
+/// \c ptr_to_func but not \c ptr_to_array.<br>
+///<br>
+/// Usable as: Matcher<ParenType><br>
+AST_TYPE_TRAVERSE_MATCHER(innerType, getInnerType);<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Sorry that I missed that in the precommit review, but I think we really want to call this hasInnerType. For a matcher called innerType I would expect an AST node InnerType (or CXXInnerType) to exist.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Cheers,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">/Manuel<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">+<br>
/// \brief Matches block pointer types, i.e. types syntactically represented as<br>
/// "void (^)(int)".<br>
///<br>
<br>
Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=178487&r1=178486&r2=178487&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=178487&r1=178486&r2=178487&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)<br>
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Apr 1 13:33:34 2013<br>
@@ -3387,6 +3387,19 @@ TEST(TypeMatching, MatchesFunctionTypes)<br>
EXPECT_TRUE(matches("void f(int i) {}", functionType()));<br>
}<br>
<br>
+TEST(TypeMatching, MatchesParenType) {<br>
+ EXPECT_TRUE(<br>
+ matches("int (*array)[4];", varDecl(hasType(pointsTo(parenType())))));<br>
+ EXPECT_TRUE(notMatches("int *array[4];", varDecl(hasType(parenType()))));<br>
+<br>
+ EXPECT_TRUE(matches(<br>
+ "int (*ptr_to_func)(int);",<br>
+ varDecl(hasType(pointsTo(parenType(innerType(functionType())))))));<br>
+ EXPECT_TRUE(notMatches(<br>
+ "int (*ptr_to_array)[4];",<br>
+ varDecl(hasType(pointsTo(parenType(innerType(functionType())))))));<br>
+}<br>
+<br>
TEST(TypeMatching, PointerTypes) {<br>
// FIXME: Reactive when these tests can be more specific (not matching<br>
// implicit code on certain platforms), likely when we have hasDescendant for<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>