[PATCH] D21860: [ASTMatcher] Add a node matcher for EnumType.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 30 00:57:17 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274217: [ASTMatcher] Add a node matcher for EnumType. (authored by hokein).
Changed prior to commit:
http://reviews.llvm.org/D21860?vs=62277&id=62340#toc
Repository:
rL LLVM
http://reviews.llvm.org/D21860
Files:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===================================================================
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1299,6 +1299,13 @@
hasType(rValueReferenceType()))));
}
+TEST(TypeMatching, MatchesEnumTypes) {
+ EXPECT_TRUE(matches("enum Color { Green }; Color color;",
+ loc(enumType())));
+ EXPECT_TRUE(matches("enum class Color { Green }; Color color;",
+ loc(enumType())));
+}
+
TEST(TypeMatching, MatchesPointersToConstTypes) {
EXPECT_TRUE(matches("int b; int * const a = &b;",
loc(pointerType())));
Index: cfe/trunk/docs/LibASTMatchersReference.html
===================================================================
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -1448,6 +1448,21 @@
</pre></td></tr>
+<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('enumType0')"><a name="enumType0Anchor">enumType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>...</td></tr>
+<tr><td colspan="4" class="doc" id="enumType0"><pre>Matches enum types.
+
+Given
+ enum C { Green };
+ enum S { Red };
+
+ C c;
+ S s;
+
+enumType() matches the type of the variable declarations of both c and
+s.
+</pre></td></tr>
+
+
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('functionProtoType0')"><a name="functionProtoType0Anchor">functionProtoType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>>...</td></tr>
<tr><td colspan="4" class="doc" id="functionProtoType0"><pre>Matches FunctionProtoType nodes.
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===================================================================
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -4654,6 +4654,21 @@
/// matches "typedef int X"
AST_TYPE_MATCHER(TypedefType, typedefType);
+/// \brief Matches enum types.
+///
+/// Given
+/// \code
+/// enum C { Green };
+/// enum class S { Red };
+///
+/// C c;
+/// S s;
+/// \endcode
+//
+/// \c enumType() matches the type of the variable declarations of both \c c and
+/// \c s.
+AST_TYPE_MATCHER(EnumType, enumType);
+
/// \brief Matches template specialization types.
///
/// Given
Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===================================================================
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -171,6 +171,7 @@
REGISTER_MATCHER(elaboratedType);
REGISTER_MATCHER(enumConstantDecl);
REGISTER_MATCHER(enumDecl);
+ REGISTER_MATCHER(enumType);
REGISTER_MATCHER(equalsBoundNode);
REGISTER_MATCHER(equalsIntegralValue);
REGISTER_MATCHER(explicitCastExpr);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21860.62340.patch
Type: text/x-patch
Size: 3207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160630/ce85063d/attachment-0001.bin>
More information about the cfe-commits
mailing list