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

Joachim Priesner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 18 23:35:00 PDT 2022


jspam updated this revision to Diff 430586.
jspam added a comment.

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.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125885/new/

https://reviews.llvm.org/D125885

Files:
  clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp
@@ -29,7 +29,7 @@
 void i(const char *c);
 void j(int a, int b, int c);
 
-double operator"" _km(long double);
+double operator"" _km(long double value);
 
 void test() {
   A a;
@@ -171,6 +171,8 @@
   g((1));
   // FIXME But we should not add argument comments here.
   g(_Generic(0, int : 0));
+
+  402.0_km;
 }
 
 void f(bool _with_underscores_);
Index: clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -60,7 +60,7 @@
 
 void ArgumentCommentCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
-      callExpr(unless(cxxOperatorCallExpr()),
+      callExpr(unless(cxxOperatorCallExpr()), unless(userDefinedLiteral()),
                // NewCallback's arguments relate to the pointed function,
                // don't check them against NewCallback's parameter names.
                // FIXME: Make this configurable.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125885.430586.patch
Type: text/x-patch
Size: 1386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220519/5d485f31/attachment-0001.bin>


More information about the cfe-commits mailing list