You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[clang-tidy] Fix readability-suspicious-call-argument crash for arguments without name-like identifier
As originally reported by @steakhal in
http://github.com/llvm/llvm-project/issues/54074, the name extraction logic of
`readability-suspicious-call-argument` crashes if the argument passed to a
function was a function call to a non-trivially named entity (e.g. an operator).
Fixed this crash case by ignoring such constructs and considering them as having
no name.
Reviewed By: aaron.ballman, steakhal
Differential Revision: http://reviews.llvm.org/D120555
(Cherry-picked from commit 416e689)
Copy file name to clipboardExpand all lines: clang-tools-extra/test/clang-tidy/checkers/readability-suspicious-call-argument.cpp
+29Lines changed: 29 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -485,3 +485,32 @@ int main() {
485
485
486
486
return0;
487
487
}
488
+
489
+
namespaceIssue_54074 {
490
+
491
+
classT {};
492
+
using OperatorTy = int(const T &, const T &);
493
+
intoperator-(const T &, const T &);
494
+
495
+
template <typename U>
496
+
structWrap {
497
+
Wrap(U);
498
+
};
499
+
500
+
template <typename V>
501
+
voidwrapTaker(V, Wrap<OperatorTy>);
502
+
503
+
template <typename V>
504
+
voidwrapTaker(V aaaaa, V bbbbb, Wrap<OperatorTy>);
505
+
506
+
voidtest() {
507
+
wrapTaker(0, operator-);
508
+
// NO-WARN. No crash!
509
+
510
+
int aaaaa = 4, bbbbb = 8;
511
+
wrapTaker(bbbbb, aaaaa, operator-);
512
+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'bbbbb' (passed to 'aaaaa') looks like it might be swapped with the 2nd, 'aaaaa' (passed to 'bbbbb')
513
+
// CHECK-MESSAGES: :[[@LINE-9]]:6: note: in the call to 'wrapTaker<int>', declared here
0 commit comments