This is an archive of the discontinued LLVM Phabricator instance.

[ASTMatchers] Re-order the internals to allow another use-case
ClosedPublic

Authored by steveire on Jan 16 2021, 6:53 AM.

Details

Summary

Add an operator overload to ArgumentAdaptingMatcherFunc to allow use of
mapAnyOf within hasAncestor, hasParent etc.

Diff Detail

Event Timeline

steveire requested review of this revision.Jan 16 2021, 6:53 AM
steveire created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 16 2021, 6:53 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
aaron.ballman accepted this revision.Jan 19 2021, 6:05 AM

LGTM, though it would have been a bit easier to review had the rearranging been done in a separate NFC patch.

clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
498–500

Can you also add a test like:

EXPECT_TRUE(notMatches(Code, floatLiteral(hasAncestor(mapAnyOf(ifStmt, forStmt)))));

to show that we can still search all of the nodes and fail.

This revision is now accepted and ready to land.Jan 19 2021, 6:05 AM