This is an archive of the discontinued LLVM Phabricator instance.

[ASTMatchers] Add matchers available through casting to derived
AcceptedPublic

Authored by steveire on Nov 11 2018, 2:40 PM.

Details

Reviewers
aaron.ballman

Diff Detail

Event Timeline

steveire created this revision.Nov 11 2018, 2:40 PM

These commits are available on github if it's convenient to see it all together there:

https://github.com/steveire/clang/commits/matcher-output

Here is context for the changes I'm making in case it is useful:

https://steveire.wordpress.com/2018/11/11/future-developments-in-clang-query/

Note that the commits pushed for review so far don't implement everything I wrote about there.

aaron.ballman added inline comments.Nov 12 2018, 3:21 PM
lib/ASTMatchers/Dynamic/Registry.cpp
647

Don't use auto here (and if you did. the const would go on the other side).

649–653

I think this can be replaced with llvm::find_if().

661

I'd prefer this to not be a default argument (the callers can pass it in). It might also be nice to use an enum here rather than a bool, but alternative to that, you should stick in comments in the callers that describe the parameter name. e.g. getMatchingMatchersImpl(yada, /*ExactOnly*/true);

711

Don't use auto.

716–718

Why do these need their own inner block scopes?

719

auto.

720–721

if (TypeForMatcherOpt && StaticType.isBaseOf(...)) {

722–723

auto, here and everywhere in this file.

756

Can remove whitespace around here.

768–773

It seems like getMatchingMatchersImpl() should just be renamed to getMatchingMatchers().

steveire updated this revision to Diff 179725.Dec 30 2018, 4:46 AM

Some updates

lebedev.ri retitled this revision from Add matchers available through casting to derived to [ASTMatchers] Add matchers available through casting to derived.Dec 30 2018, 5:44 AM
lebedev.ri added a subscriber: lebedev.ri.

Differential lacks description.

aaron.ballman added inline comments.Dec 31 2018, 8:11 AM
lib/ASTMatchers/Dynamic/Registry.cpp
644

targetCtor -> TargetCtor

646

it -> It

647

ctor -> Ctor

650–652

Elide braces

710

Can combine with the previous if statement, I believe.

716

Don't use auto here please.

719

Don't use auto here please.

732

Don't use auto here please.

738

item -> Item

Abpostelnicu added a subscriber: Abpostelnicu.EditedSep 5 2019, 6:51 AM

@aaron.ballman
I think the auto usage improves and simplifies the code, however, as I would really like to see this code landed, I would be ok to help Stephen to finish this work and replace auto by the "old" way. Do you think we can have this approved if we make the changes mentioned earlier?

Herald added a project: Restricted Project. · View Herald TranscriptSep 5 2019, 6:51 AM

@aaron.ballman
I think the auto usage improves and simplifies the code, however, as I would really like to see this code landed, I would be ok to help Stephen to finish this work and replace auto by the "old" way. Do you think we can have this approved if we make the changes mentioned earlier?

Nothing jumps out at me as blocking this, aside from completing the usual review activities. Have at it!

@aaron.ballman I think we agreed in Belfast in November (after the most recent comment) to get this in as it is and not be as draconian about auto. Is anything blocking this?

aaron.ballman accepted this revision.May 30 2020, 9:35 AM

@aaron.ballman I think we agreed in Belfast in November (after the most recent comment) to get this in as it is and not be as draconian about auto. Is anything blocking this?

Nothing is blocking this, but I think we may have slightly different understandings of what we agreed to. Reviewers asking for code to follow the coding guidelines is not draconian; it's expected for code to follow the coding guidelines and for patch authors to field requests for changes like these. I re-reviewed the things I was asking for changes on and have added a comment where I definitely insist on changes. LGTM with that nit fixed though.

lib/ASTMatchers/Dynamic/Registry.cpp
732

Please change this use of auto -- I have no idea what the type is for NestedResult without hunting for it and so I have no idea what the type is for Item and whether using a const reference is reasonable or not (after doing the hunting, it looks fine though).

This revision is now accepted and ready to land.May 30 2020, 9:35 AM