[PATCH] D42185: [ASTMatcher] Add isScoped matcher for enumDecl.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 18 01:43:00 PST 2018
hokein updated this revision to Diff 130370.
hokein added a comment.
- add the matcher to dynamic registry.
- add documentation.
- remove duplicated ";".
Repository:
rC Clang
https://reviews.llvm.org/D42185
Files:
docs/LibASTMatchersReference.html
include/clang/ASTMatchers/ASTMatchers.h
lib/ASTMatchers/Dynamic/Registry.cpp
unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===================================================================
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2107,5 +2107,10 @@
cxxRecordDecl(hasDefinition())));
}
+TEST(IsScopedEnum, MatchesScopedEnum) {
+ EXPECT_TRUE(matches("enum class X {};", enumDecl(isScoped())));
+ EXPECT_TRUE(notMatches("enum X {};", enumDecl(isScoped())));
+}
+
} // namespace ast_matchers
} // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===================================================================
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -361,6 +361,7 @@
REGISTER_MATCHER(isProtected);
REGISTER_MATCHER(isPublic);
REGISTER_MATCHER(isPure);
+ REGISTER_MATCHER(isScoped);
REGISTER_MATCHER(isSignedInteger);
REGISTER_MATCHER(isStaticStorageClass);
REGISTER_MATCHER(isStruct);
Index: include/clang/ASTMatchers/ASTMatchers.h
===================================================================
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5880,6 +5880,17 @@
return Node.hasDefinition();
}
+/// \brief Matches C++11 scoped enum declaration.
+///
+/// Example matches Y (matcher = enumDecl(isScoped()))
+/// \code
+/// enum X {};
+/// enum class Y {};
+/// \endcode
+AST_MATCHER(EnumDecl, isScoped) {
+ return Node.isScoped();
+}
+
} // namespace ast_matchers
} // namespace clang
Index: docs/LibASTMatchersReference.html
===================================================================
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2644,6 +2644,15 @@
</pre></td></tr>
+<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html">EnumDecl</a>></td><td class="name" onclick="toggle('isScoped0')"><a name="isScoped0Anchor">isScoped</a></td><td></td></tr>
+<tr><td colspan="4" class="doc" id="isScoped0"><pre>Matches C++11 scoped enum declaration.
+
+Example matches Y (matcher = enumDecl(isScoped()))
+enum X {};
+enum class Y {};
+</pre></td></tr>
+
+
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>></td><td class="name" onclick="toggle('hasBitWidth0')"><a name="hasBitWidth0Anchor">hasBitWidth</a></td><td>unsigned Width</td></tr>
<tr><td colspan="4" class="doc" id="hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified
bit width.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42185.130370.patch
Type: text/x-patch
Size: 2576 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180118/a1a65c08/attachment.bin>
More information about the cfe-commits
mailing list