r269916 - [ASTMatcher] Add a node matcher for UnresolvedLookupExpr.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed May 18 05:53:59 PDT 2016
Author: hokein
Date: Wed May 18 07:53:59 2016
New Revision: 269916
URL: http://llvm.org/viewvc/llvm-project?rev=269916&view=rev
Log:
[ASTMatcher] Add a node matcher for UnresolvedLookupExpr.
Reviewers: alexfh, aaron.ballman
Subscribers: aaron.ballman, klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D20360
Modified:
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
Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=269916&r1=269915&r2=269916&view=diff
==============================================================================
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Wed May 18 07:53:59 2016
@@ -1275,6 +1275,21 @@ Example matches !a
</pre></td></tr>
+<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('unresolvedLookupExpr0')"><a name="unresolvedLookupExpr0Anchor">unresolvedLookupExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedLookupExpr.html">UnresolvedLookupExpr</a>>...</td></tr>
+<tr><td colspan="4" class="doc" id="unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing
+but could not be resolved to a specific declaration.
+
+Given
+ template<typename T>
+ T foo() { T a; return a; }
+ template<typename T>
+ void bar() {
+ foo<T>();
+ }
+unresolvedLookupExpr()
+ matches foo<T>() </pre></td></tr>
+
+
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('userDefinedLiteral0')"><a name="userDefinedLiteral0Anchor">userDefinedLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UserDefinedLiteral.html">UserDefinedLiteral</a>>...</td></tr>
<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call.
Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=269916&r1=269915&r2=269916&view=diff
==============================================================================
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Wed May 18 07:53:59 2016
@@ -1086,6 +1086,24 @@ const internal::VariadicDynCastAllOfMatc
Decl,
UsingDirectiveDecl> usingDirectiveDecl;
+/// \brief Matches reference to a name that can be looked up during parsing
+/// but could not be resolved to a specific declaration.
+///
+/// Given
+/// \code
+/// template<typename T>
+/// T foo() { T a; return a; }
+/// template<typename T>
+/// void bar() {
+/// foo<T>();
+/// }
+/// \endcode
+/// unresolvedLookupExpr()
+/// matches \code foo<T>() \endcode
+const internal::VariadicDynCastAllOfMatcher<
+ Stmt,
+ UnresolvedLookupExpr> unresolvedLookupExpr;
+
/// \brief Matches unresolved using value declarations.
///
/// Given
Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=269916&r1=269915&r2=269916&view=diff
==============================================================================
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Wed May 18 07:53:59 2016
@@ -399,6 +399,7 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(unaryOperator);
REGISTER_MATCHER(unaryTransformType);
REGISTER_MATCHER(unless);
+ REGISTER_MATCHER(unresolvedLookupExpr);
REGISTER_MATCHER(unresolvedUsingTypenameDecl);
REGISTER_MATCHER(unresolvedUsingValueDecl);
REGISTER_MATCHER(userDefinedLiteral);
Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp?rev=269916&r1=269915&r2=269916&view=diff
==============================================================================
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp Wed May 18 07:53:59 2016
@@ -177,6 +177,15 @@ TEST(EnumConstant, Matches) {
EXPECT_TRUE(notMatches("enum X {};", Matcher));
}
+TEST(Matcher, UnresolvedLookupExpr) {
+ EXPECT_TRUE(matches("template<typename T>"
+ "T foo() { T a; return a; }"
+ "template<typename T>"
+ "void bar() {"
+ " foo<T>();"
+ "}",
+ unresolvedLookupExpr()));
+}
TEST(Matcher, Call) {
// FIXME: Do we want to overload Call() to directly take
More information about the cfe-commits
mailing list