[PATCH] D91917: Update mode used in traverse() examples
Stephen Kelly via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 21 10:51:20 PST 2020
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
steveire requested review of this revision.
traverse() predates the IgnoreUnlessSpelledInSource mode. Update example
and test code to use the newer mode.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D91917
Files:
clang/docs/LibASTMatchersReference.html
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===================================================================
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1873,8 +1873,8 @@
auto Matcher = varDecl(hasInitializer(floatLiteral()));
EXPECT_TRUE(notMatches(VarDeclCode, traverse(TK_AsIs, Matcher)));
- EXPECT_TRUE(matches(VarDeclCode,
- traverse(TK_IgnoreImplicitCastsAndParentheses, Matcher)));
+ EXPECT_TRUE(
+ matches(VarDeclCode, traverse(TK_IgnoreUnlessSpelledInSource, Matcher)));
auto ParentMatcher = floatLiteral(hasParent(varDecl(hasName("i"))));
@@ -2715,14 +2715,14 @@
)cpp";
EXPECT_TRUE(
- matches(Code, traverse(TK_IgnoreImplicitCastsAndParentheses,
+ matches(Code, traverse(TK_IgnoreUnlessSpelledInSource,
callExpr(has(callExpr(traverse(
TK_AsIs, callExpr(has(implicitCastExpr(
has(floatLiteral())))))))))));
EXPECT_TRUE(matches(
Code,
- traverse(TK_IgnoreImplicitCastsAndParentheses,
+ traverse(TK_IgnoreUnlessSpelledInSource,
traverse(TK_AsIs, implicitCastExpr(has(floatLiteral()))))));
}
@@ -2738,8 +2738,7 @@
}
)cpp";
- auto Matcher =
- traverse(TK_IgnoreImplicitCastsAndParentheses, implicitCastExpr());
+ auto Matcher = traverse(TK_IgnoreUnlessSpelledInSource, implicitCastExpr());
// Verfiy that it does not segfault
EXPECT_FALSE(matches(Code, Matcher));
@@ -2766,7 +2765,7 @@
EXPECT_TRUE(matches(
Code,
functionDecl(anyOf(hasDescendant(Matcher),
- traverse(TK_IgnoreImplicitCastsAndParentheses,
+ traverse(TK_IgnoreUnlessSpelledInSource,
functionDecl(hasDescendant(Matcher)))))));
}
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===================================================================
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -782,7 +782,7 @@
/// \endcode
/// The matcher
/// \code
-/// traverse(TK_IgnoreImplicitCastsAndParentheses,
+/// traverse(TK_IgnoreUnlessSpelledInSource,
/// varDecl(hasInitializer(floatLiteral().bind("init")))
/// )
/// \endcode
Index: clang/docs/LibASTMatchersReference.html
===================================================================
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -5567,7 +5567,7 @@
int i = 3.0;
}
The matcher
- traverse(TK_IgnoreImplicitCastsAndParentheses,
+ traverse(TK_IgnoreUnlessSpelledInSource,
varDecl(hasInitializer(floatLiteral().bind("init")))
)
matches the variable declaration with "init" bound to the "3.0".
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91917.306857.patch
Type: text/x-patch
Size: 2894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201121/4a43bcbe/attachment.bin>
More information about the cfe-commits
mailing list