[clang-tools-extra] [clang-tidy] Fix default abbreviations in readability-suspicious-call-argument (PR #228876)
Zeyi Xu via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 4 05:24:12 PDT 2026
https://github.com/zeyi2 created https://github.com/llvm/llvm-project/pull/228876
None
>From 8845fe0b30d074b807371c7306cae91f6026dea0 Mon Sep 17 00:00:00 2001
From: Zeyi Xu <mitchell.xu2 at gmail.com>
Date: Sun, 4 Oct 2026 20:23:54 +0800
Subject: [PATCH] [clang-tidy] Fix default abbreviations in
readability-suspicious-call-argument
---
.../clang-tidy/readability/SuspiciousCallArgumentCheck.cpp | 2 +-
clang-tools-extra/docs/ReleaseNotes.md | 4 ++++
.../checkers/readability/suspicious-call-argument.cpp | 6 ++++++
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp b/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
index 49c327ad77177..6816feb892704 100644
--- a/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
@@ -100,7 +100,7 @@ static constexpr StringRef DefaultAbbreviations = "addr=address;"
"col=column;"
"cpy=copy;"
"dest=destination;"
- "dist=distance"
+ "dist=distance;"
"dst=distance;"
"elem=element;"
"hght=height;"
diff --git a/clang-tools-extra/docs/ReleaseNotes.md b/clang-tools-extra/docs/ReleaseNotes.md
index 41aa783cabd24..09d616231ac88 100644
--- a/clang-tools-extra/docs/ReleaseNotes.md
+++ b/clang-tools-extra/docs/ReleaseNotes.md
@@ -326,6 +326,10 @@ infrastructure are described first, followed by tool-specific sections.
<clang-tidy/checks/readability/simplify-boolean-expr>` producing invalid
fixes when applying De Morgan's theorem to overloaded comparison operators.
+- Improved {doc}`readability-suspicious-call-argument
+ <clang-tidy/checks/readability/suspicious-call-argument>` check by fixing the
+ default `dist` and `dst` abbreviations of `distance` not being recognized.
+
- Improved {doc}`readability-trailing-comma
<clang-tidy/checks/readability/trailing-comma>` check:
diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/suspicious-call-argument.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/suspicious-call-argument.cpp
index 27c007ea278b2..612c387687e24 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/readability/suspicious-call-argument.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/readability/suspicious-call-argument.cpp
@@ -16,6 +16,8 @@ void foo_7(int aaaaaa, int bbbbbb, int cccccc, int ffffff = 7) {}
void foo_8(int frobble1, int frobble2) {}
+void foo_9(int distance, int bbbbbb) {}
+
// Test functions for convertible argument--parameter types.
void fun(const int &m);
void fun2() {
@@ -409,6 +411,10 @@ int main() {
foo_2(aaaaaa, src);
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'aaaaaa' (passed to 'source') looks like it might be swapped with the 2nd, 'src' (passed to 'aaaaaa')
+ int dst = 0;
+ foo_9(cccccc, dst);
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'cccccc' (passed to 'distance') looks like it might be swapped with the 2nd, 'dst' (passed to 'bbbbbb')
+
// Levenshtein test.
int aaaabb = 0;
foo_1(cccccc, aaaabb);
More information about the cfe-commits
mailing list