This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] bugprone-argument-comment: Ignore calls to user-defined literals
ClosedPublic

Authored by jspam on May 18 2022, 6:40 AM.

Details

Summary

Without this change, code such as "f(/*param=*/1_op)" will check the
comment twice, once for the parameter of f (correct) and once for
the parameter of operator""_op (likely incorrect). The change removes
only the second check.

Diff Detail

Event Timeline

jspam created this revision.May 18 2022, 6:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 18 2022, 6:40 AM
jspam requested review of this revision.May 18 2022, 6:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 18 2022, 6:40 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Eugene.Zelenko retitled this revision from bugprone-argument-comment: Ignore calls to user-defined literals to [clang-tidy] bugprone-argument-comment: Ignore calls to user-defined literals.May 18 2022, 7:10 AM
jspam updated this revision to Diff 430375.May 18 2022, 7:30 AM

Fix test

This revision is now accepted and ready to land.May 18 2022, 8:27 AM

These tests aren't that great.
I'd advise adding a test that just checks using the userDefinedLiteral in bugprone-argument-comment-literals.cpp, That check file will add comments to parameters that don't have them.
That way you aren't testing against distinguishing between the actual parameter comment and the literal comment.
This simple edit without your fix results in this diff in the output, with your fix that diff wont exist.

[build]  int operator""_op(unsigned long long Value);
[build]  
[build]  void test() {
[build] -  1_op;
[build] +  /*Value=*/1_op;
jspam updated this revision to Diff 430586.May 18 2022, 11:34 PM

Update test as suggested by njames93.

bugprone-argument-comment-literals.cpp also contains some instances of a UDL used as an argument which didn't lead to problems before because the argument didn't have a name. So that case is covered as well.

njames93 accepted this revision.May 18 2022, 11:48 PM

Would someone be able to commit this for me, as I do not have the necessary rights? Thanks

Would someone be able to commit this for me, as I do not have the necessary rights? Thanks

I can for you, what name and email address should I use?

jspam added a comment.Jun 20 2022, 1:42 AM

Thanks. Please use Joachim Priesner <llvm-project-704996@jspam.de>