106 lines · cpp
1// RUN: %check_clang_tidy %s bugprone-argument-comment %t -- \2// RUN: -config="{CheckOptions: { \3// RUN: bugprone-argument-comment.IgnoreSingleArgument: true, \4// RUN: bugprone-argument-comment.CommentBoolLiterals: true, \5// RUN: bugprone-argument-comment.CommentIntegerLiterals: true, \6// RUN: bugprone-argument-comment.CommentFloatLiterals: true, \7// RUN: bugprone-argument-comment.CommentUserDefinedLiterals: true, \8// RUN: bugprone-argument-comment.CommentStringLiterals: true, \9// RUN: bugprone-argument-comment.CommentNullPtrs: true, \10// RUN: bugprone-argument-comment.CommentCharacterLiterals: true}}" --11 12struct A {13 void foo(bool abc);14 void foo(bool abc, bool cde);15 void foo(const char *, bool abc);16 void foo(int iabc);17 void foo(float fabc);18 void foo(double dabc);19 void foo(const char *strabc);20 void fooW(const wchar_t *wstrabc);21 void fooPtr(A *ptrabc);22 void foo(char chabc);23};24 25#define FOO 126 27void g(int a);28void h(double b);29void i(const char *c);30 31double operator"" _km(long double);32 33void test() {34 A a;35 36 a.foo(true);37 38 a.foo(false);39 40 a.foo(true, false);41 // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]42 // CHECK-MESSAGES: [[@LINE-2]]:15: warning: argument comment missing for literal argument 'cde' [bugprone-argument-comment]43 // CHECK-FIXES: a.foo(/*abc=*/true, /*cde=*/false);44 45 a.foo(false, true);46 // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]47 // CHECK-MESSAGES: [[@LINE-2]]:16: warning: argument comment missing for literal argument 'cde' [bugprone-argument-comment]48 // CHECK-FIXES: a.foo(/*abc=*/false, /*cde=*/true);49 50 a.foo(/*abc=*/false, true);51 // CHECK-MESSAGES: [[@LINE-1]]:24: warning: argument comment missing for literal argument 'cde' [bugprone-argument-comment]52 // CHECK-FIXES: a.foo(/*abc=*/false, /*cde=*/true);53 54 a.foo(false, /*cde=*/true);55 // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]56 // CHECK-FIXES: a.foo(/*abc=*/false, /*cde=*/true);57 58 bool val1 = true;59 bool val2 = false;60 a.foo(val1, val2);61 62 a.foo("", true);63 // CHECK-MESSAGES: [[@LINE-1]]:13: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]64 // CHECK-FIXES: a.foo("", /*abc=*/true);65 66 a.foo(0);67 68 a.foo(1.0f);69 70 a.foo(1.0);71 72 int val3 = 10;73 a.foo(val3);74 75 float val4 = 10.0;76 a.foo(val4);77 78 double val5 = 10.0;79 a.foo(val5);80 81 a.foo("Hello World");82 83 a.fooW(L"Hello World");84 85 a.fooPtr(nullptr);86 87 a.foo(402.0_km);88 89 a.foo('A');90 91 g(FOO);92 93 h(1.0f);94 95 i(__FILE__);96 97 g((1));98}99 100void f(bool _with_underscores_);101void ignores_underscores() {102 f(false);103 104 f(true);105}106