[PATCH] D95735: [ASTMatchers] Fix matching after generic top-level matcher
Stephen Kelly via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 30 05:46:00 PST 2021
steveire created this revision.
steveire added reviewers: aaron.ballman, alexfh.
steveire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
With a matcher like
expr(anyOf(integerLiteral(equals(42)), unless(expr())))
and code such as
struct B {
B(int);
};
B func1() { return 42; }
the top-level expr() would match each of the nodes which are not spelled
in the source and then ignore-traverse to match the integerLiteral node.
This would result in multiple results reported for the integerLiteral.
Fix that by only running matching logic on nodes which are not skipped
with the top-level matcher.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D95735
Files:
clang/lib/ASTMatchers/ASTMatchFinder.cpp
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95735.320295.patch
Type: text/x-patch
Size: 4086 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210130/af081e76/attachment.bin>
More information about the cfe-commits
mailing list