This is an archive of the discontinued LLVM Phabricator instance.

[ASTMatchers] Add traversal-kind support to `DynTypedMatcher`
ClosedPublic

Authored by ymandel on May 27 2020, 7:19 PM.

Details

Summary

This patch exposes TraversalKind support in the DynTypedMatcher API. While
previously, the match method supported traversal logic, it was not possible to
set or get the traversal kind.

Diff Detail

Event Timeline

ymandel created this revision.May 27 2020, 7:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 27 2020, 7:19 PM
gribozavr2 accepted this revision.May 28 2020, 1:57 AM
gribozavr2 added a subscriber: gribozavr2.
gribozavr2 added inline comments.
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
234

It might read better as an instance method on DynTypedMatcher: DynTypedMatcher::withTraversalKind(). It is not unprecedented, see dynCastTo().

clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
183

Please use EXPECT_THAT(M.getTraversalKind(), llvm::ValueIs(TK_AsIs)); (also in tests below).

You'll need to include llvm/Testing/Support/SupportHelpers.h.

This revision is now accepted and ready to land.May 28 2020, 1:57 AM
ymandel updated this revision to Diff 266828.May 28 2020, 5:43 AM
ymandel marked 2 inline comments as done.

updated per comments

ymandel marked 2 inline comments as done.May 28 2020, 5:46 AM
ymandel added inline comments.
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
234

Agreed, thanks for the suggestion.

clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
183

Thanks! This cleaned up the tests quite nicely.

I also updated the CMake file. Please let me know if that looks right to you. Cargo-culted from other cmake files...

gribozavr2 accepted this revision.May 28 2020, 7:21 AM
This revision was automatically updated to reflect the committed changes.
ymandel marked an inline comment as done.