This is an archive of the discontinued LLVM Phabricator instance.

Adds AST Matcher for ObjCStringLiteral
ClosedPublic

Authored by t-rasmud on Jun 17 2022, 3:41 PM.

Diff Detail

Event Timeline

t-rasmud created this revision.Jun 17 2022, 3:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 17 2022, 3:41 PM
t-rasmud requested review of this revision.Jun 17 2022, 3:41 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 17 2022, 3:41 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
NoQ added a comment.Jun 17 2022, 4:47 PM

Matcher tests are written as unittests in unittests/ASTMatchers, I don't think you need to make an entire new check for that hmmm.

t-rasmud updated this revision to Diff 438852.Jun 21 2022, 3:25 PM
t-rasmud updated this revision to Diff 440359.Jun 27 2022, 1:01 PM
t-rasmud added a reviewer: ziqingluo-90.
t-rasmud updated this revision to Diff 440443.Jun 27 2022, 5:26 PM

Documentation edits and other fixes, thanks to suggestions from @ziqingluo-90

NoQ added a comment.Jun 27 2022, 5:33 PM

Looks great, thanks!

clang/docs/LibASTMatchersReference.html
2041

I think it's more appropriate for this documentation to mention the entire literal so that the reader didn't assume that @ is a different AST node that needs to be captured separately.

t-rasmud updated this revision to Diff 440450.Jun 27 2022, 5:56 PM
aaron.ballman added a subscriber: aaron.ballman.

We typically don't add AST matchers until we have a need for them to be used in-tree (ASTMatchers.h is already really expensive to parse; adding matchers for everything possible with AST nodes would be prohibitively expensive). However, this is a case that really seems like it doesn't need to wait for an in-tree use because of how foundational the matcher is, so I think it's fine to add as-is.

clang/docs/LibASTMatchersReference.html
2038

It looks like this documentation was added manually -- it should actually live in the ASTMatchers.h header file, and then you run clang/docs/tools/dump_ast_matchers.py to generate this HTML file automatically.

clang/include/clang/ASTMatchers/ASTMatchers.h
1518–1519

You should add your documentation comments above this declaration.

t-rasmud updated this revision to Diff 440766.Jun 28 2022, 2:08 PM

Removes manually added documentation and adds it in the header file.

NoQ added a comment.Jun 28 2022, 3:43 PM

Yes the use case is coming up in D126097; it's not used yet because hasDescendant(StringLiteral) is used to skip it but this matchert would be a more precise solution (yes there's an actual StringLiteral inside ObjCStringLiteral).

The only things left to do are: regenerate the documentation by running clang/docs/tools/dump_ast_matchers.py and add a release note for the new matcher, but otherwise this looks good to me.

Yes the use case is coming up in D126097; it's not used yet because hasDescendant(StringLiteral) is used to skip it but this matchert would be a more precise solution (yes there's an actual StringLiteral inside ObjCStringLiteral).

Ah, great to hear this will be used quickly in tree too!

t-rasmud updated this revision to Diff 441179.Jun 29 2022, 2:54 PM
aaron.ballman accepted this revision.Jun 30 2022, 6:22 AM

LGTM! Do you need me to commit on your behalf? If so, what name and email address would you like me to use for patch attribution?

This revision is now accepted and ready to land.Jun 30 2022, 6:22 AM

LGTM! Do you need me to commit on your behalf? If so, what name and email address would you like me to use for patch attribution?

Thank you @aaron.ballman. I believe I have the permissions to commit, so I can land the patch.

This revision was landed with ongoing or failed builds.Jun 30 2022, 3:23 PM
This revision was automatically updated to reflect the committed changes.