clang-tidy: where does the comma get removed when removing an arg?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

clang-tidy: where does the comma get removed when removing an arg?

Nathan Ridge via cfe-dev
If I create a removal FixItHint in clang-tidy to remove a function argument (that is, the `CharSourceRange` in the cal to FixItHint::CreateRemoval() spans a function-call argument), the associated comma for that argument (if any) is removed as well.  

For example, when removing the second argument of `foo(3, 4)`, clang-tidy (correctly) removes the comma to produce `foo(3)`.

I'd like to understand *where* that happens in the code.   I've looked through much of the code involved and searched the codebase for `tok::comma`, but was completely unable to discover the source of this modification.

thanks,
yitzhak

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

smime.p7s (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: clang-tidy: where does the comma get removed when removing an arg?

Nathan Ridge via cfe-dev
I think the cleanup is done by cleanupAroundReplacements (clang-tidy formats the replacements before applying them).

On Mon, Jul 29, 2019 at 3:14 PM Yitzhak Mandelbaum via cfe-dev <[hidden email]> wrote:
If I create a removal FixItHint in clang-tidy to remove a function argument (that is, the `CharSourceRange` in the cal to FixItHint::CreateRemoval() spans a function-call argument), the associated comma for that argument (if any) is removed as well.  

For example, when removing the second argument of `foo(3, 4)`, clang-tidy (correctly) removes the comma to produce `foo(3)`.

I'd like to understand *where* that happens in the code.   I've looked through much of the code involved and searched the codebase for `tok::comma`, but was completely unable to discover the source of this modification.

thanks,
yitzhak
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang-tidy: where does the comma get removed when removing an arg?

Nathan Ridge via cfe-dev
thanks, that's quite helpful. For those curious, the code responsible is in clang/lib/Format/Format.cpp, in Cleaner::analyze().

On Mon, Jul 29, 2019 at 9:34 AM Haojian Wu <[hidden email]> wrote:
I think the cleanup is done by cleanupAroundReplacements (clang-tidy formats the replacements before applying them).

On Mon, Jul 29, 2019 at 3:14 PM Yitzhak Mandelbaum via cfe-dev <[hidden email]> wrote:
If I create a removal FixItHint in clang-tidy to remove a function argument (that is, the `CharSourceRange` in the cal to FixItHint::CreateRemoval() spans a function-call argument), the associated comma for that argument (if any) is removed as well.  

For example, when removing the second argument of `foo(3, 4)`, clang-tidy (correctly) removes the comma to produce `foo(3)`.

I'd like to understand *where* that happens in the code.   I've looked through much of the code involved and searched the codebase for `tok::comma`, but was completely unable to discover the source of this modification.

thanks,
yitzhak
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

smime.p7s (6K) Download Attachment