This is an archive of the discontinued LLVM Phabricator instance.

[ASTMatchers] Add support for matching the type of a friend decl.
ClosedPublic

Authored by dlj on Jun 15 2018, 3:14 PM.

Details

Summary

This allows matchers like:

friendDecl(hasType(cxxRecordDecl(...)))
friendDecl(hasType(asString(...)))

It seems that hasType is probably the most reasonable narrowing matcher to
overload, since it is already used to narrow to other declaration kinds.

Diff Detail

Repository
rC Clang

Event Timeline

dlj created this revision.Jun 15 2018, 3:14 PM
klimek added inline comments.Jun 15 2018, 5:02 PM
include/clang/ASTMatchers/ASTMatchers.h
2904

In which cases can getUnderlyingType return a null type?

aaron.ballman accepted this revision.Jun 15 2018, 5:02 PM
aaron.ballman added a subscriber: aaron.ballman.

LGTM aside from some minor nits.

include/clang/ASTMatchers/ASTMatchers.h
2900–2904

I actually prefer the previous formatting, can you restore that?

include/clang/ASTMatchers/ASTMatchersInternal.h
128

tsi -> TSI

This revision is now accepted and ready to land.Jun 15 2018, 5:02 PM
dlj updated this revision to Diff 151593.Jun 15 2018, 5:20 PM
dlj marked 3 inline comments as done.
dlj added inline comments.
include/clang/ASTMatchers/ASTMatchers.h
2900–2904

Hmmm, it barely fits in 80 cols if I use the previous flow, but looks worse to me (it adds another line just for FriendDecl). I've updated to exactly what clang-format prefers, which happens to be fairly consistent with the other declaration of hasType.

2904

QT can be null for a FriendDecl that that doesn't name a type. That seems to DTRT here.

dlj added a comment.Jun 18 2018, 2:04 AM

Ping for Manuel...

klimek accepted this revision.Jun 18 2018, 2:12 AM

lg, thx

This revision was automatically updated to reflect the committed changes.