This is an archive of the discontinued LLVM Phabricator instance.

[ASTMatchers] Add hasInClassInitializer traversal matcher for FieldDecl.
ClosedPublic

Authored by malcolm.parsons on Dec 21 2016, 3:03 PM.

Details

Summary

I needed to know whether a FieldDecl had an in-class
initializer for D26453. I used a narrowing matcher there, but a
traversal matcher might be generally useful.

VarDecl has a hasInitializer traversal matcher.
ForStmt has a withLoopInit traversal matcher.
CXXCtorInitializer has a withInitializer traversal matcher.
EnumConstantDecl doesn't have a traversal matcher for its initializer.
IfStmt doesn't have a traversal matcher for its initializer.

Diff Detail

Repository
rL LLVM

Event Timeline

malcolm.parsons retitled this revision from to [ASTMatchers] Add hasInClassInitializer traversal matcher for FieldDecl..
malcolm.parsons updated this object.
malcolm.parsons added reviewers: sbenza, bkramer, klimek.
malcolm.parsons added a subscriber: cfe-commits.
Prazek added a subscriber: Prazek.Dec 22 2016, 1:13 AM
Prazek added inline comments.
docs/LibASTMatchersReference.html
2442 ↗(On Diff #82278)

Fix not connected to patch?

4763 ↗(On Diff #82278)

It would be good to add int c; without initializer and show that fieldDecl(hasInClassInitializer(anything())) will match to a and b

include/clang/ASTMatchers/ASTMatchers.h
547 ↗(On Diff #82278)

Samw

docs/LibASTMatchersReference.html
2442 ↗(On Diff #82278)

Yes. The documentation is generated from the comments.

include/clang/ASTMatchers/ASTMatchers.h
547 ↗(On Diff #82278)

Yes.

aaron.ballman accepted this revision.Dec 22 2016, 7:09 AM
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a subscriber: aaron.ballman.

LGTM, modulo the unrelated documentation changes.

This revision is now accepted and ready to land.Dec 22 2016, 7:09 AM
malcolm.parsons edited edge metadata.

Improve doc.

This revision was automatically updated to reflect the committed changes.