This is an archive of the discontinued LLVM Phabricator instance.

ASTMatcher for Attr
ClosedPublic

Authored by jpienaar on Aug 20 2014, 6:36 PM.

Details

Summary

Add a matcher for decls that has a specific attribute.

Diff Detail

Event Timeline

jpienaar updated this revision to Diff 12728.Aug 20 2014, 6:36 PM
jpienaar retitled this revision from to ASTMatcher for Attr.
jpienaar updated this object.
jpienaar edited the test plan for this revision. (Show Details)
jpienaar added subscribers: Unknown Object (MLST), eliben.
klimek added inline comments.Aug 21 2014, 7:35 AM
include/clang/ASTMatchers/ASTMatchers.h
3669–3672

If we have this matcher, do the specialized ones still provide enough value? I was expecting us to either go for the specialized ones, or provide a generic one. Having both in the interface seems odd...

jpienaar updated this revision to Diff 12782.Aug 21 2014, 8:49 AM

Removed specialized attribute matchers in favor of retaining generic one.

include/clang/ASTMatchers/ASTMatchers.h
3669–3672

Agreed. I'll remove the specialized ones.

klimek added inline comments.
lib/ASTMatchers/Dynamic/Registry.cpp
185–187

And now that I see how this affects the dynamic matchers, I wonder how we're going to fix that up - that is, we'll need to teach the dynamic matchers to understand the possible clang attributes somehow.

jpienaar updated this revision to Diff 12785.Aug 21 2014, 10:13 AM

Re-implemented by having hasAttr take a parameter of type attr::Kind instead to avoid using templates and ease register dynamic matcher.

klimek added inline comments.Aug 21 2014, 10:16 AM
lib/ASTMatchers/Dynamic/Marshallers.h
79–88 ↗(On Diff #12785)

And that's enough to make the dynamic matchers work? Can you add an example to the dynamic matchers test? Thx!

jpienaar updated this revision to Diff 12793.Aug 21 2014, 12:24 PM

Interface to dynamic matcher using hasAttr now uses a string specification of the attribute instead of requiring the numerical enum value.

jpienaar updated this revision to Diff 12799.Aug 21 2014, 12:42 PM

Small cleanup.

+richard, since this is now touching lib/Basic...

Looks good to me, but I want Richard to take a look whether this makes sense or should be solved differently.

jpienaar updated this revision to Diff 12818.Aug 21 2014, 5:41 PM
jpienaar edited edge metadata.

Moved getAttrKind to a private method of ArgTypeTraints<attr::Kind>.

jpienaar updated this revision to Diff 12847.Aug 22 2014, 10:48 AM

Changed iterator type to const.

klimek accepted this revision.Aug 25 2014, 12:37 AM
klimek edited edge metadata.

Nice, LG. Let me know if you need me to submit.

This revision is now accepted and ready to land.Aug 25 2014, 12:37 AM

Thanks, I would need you to submit.

klimek closed this revision.Aug 25 2014, 4:34 AM

Thx! Committed as r216379.