This is an archive of the discontinued LLVM Phabricator instance.

[clang][Syntax] Handle macro arguments in spelledForExpanded
ClosedPublic

Authored by kadircet on Mar 2 2020, 4:20 AM.

Diff Detail

Event Timeline

kadircet created this revision.Mar 2 2020, 4:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 2 2020, 4:20 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

I think per offline discussion, this was going to have some additional docs clarifying the contracts of this function, and maybe extra tests?

The conclusion IIRC was that this function is designed to find the text that you could replace in order to replace an AST node, so it's fairly conservative (but arg expansions are fair game assuming expanded once).

I think per offline discussion, this was going to have some additional docs clarifying the contracts of this function, and maybe extra tests?

The conclusion IIRC was that this function is designed to find the text that you could replace in order to replace an AST node, so it's fairly conservative (but arg expansions are fair game assuming expanded once).

Right, I just didn't get a chance to look at it again. Planning to do that once I've got some cycles.

kadircet updated this revision to Diff 253325.Mar 28 2020, 3:13 AM
  • Rebase, update comments for spelledForExpanded and add tests for multiple arguments.
  • Do not dive into macro bodies while looking for a common expansion.
sammccall accepted this revision.Mar 28 2020, 6:46 AM

Thanks!

clang/include/clang/Tooling/Syntax/Tokens.h
201

Can we add the motivating use case?
e.g. between the two sentences: "This is the text that should be replaced if a refactoring were to rewrite the node."

This revision is now accepted and ready to land.Mar 28 2020, 6:46 AM
This revision was automatically updated to reflect the committed changes.
kadircet marked an inline comment as done.