Author: mitchell
Date: 2026-02-08T09:00:50+08:00
New Revision: 743538ccaba80592c519b58b217809006132d25e

URL: 
https://github.com/llvm/llvm-project/commit/743538ccaba80592c519b58b217809006132d25e
DIFF: 
https://github.com/llvm/llvm-project/commit/743538ccaba80592c519b58b217809006132d25e.diff

LOG: [clang-tidy] Fix crash in readability-suspicious-call-argument on invalid 
option (#180351)

Closes #180346

Added: 
    
clang-tools-extra/test/clang-tidy/checkers/readability/suspicious-call-argument-option.cpp

Modified: 
    clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
    clang-tools-extra/docs/ReleaseNotes.rst
    
clang-tools-extra/test/clang-tidy/checkers/readability/suspicious-call-argument.cpp

Removed: 
    


################################################################################
diff  --git 
a/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
index e1a73aa47919e..576603a978e3f 100644
--- a/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
@@ -528,7 +528,11 @@ SuspiciousCallArgumentCheck::SuspiciousCallArgumentCheck(
   for (const StringRef Abbreviation : optutils::parseStringList(
            Options.get("Abbreviations", DefaultAbbreviations))) {
     const auto [Key, Value] = Abbreviation.split("=");
-    assert(!Key.empty() && !Value.empty());
+    if (Key.empty() || Value.empty()) {
+      configurationDiag("Invalid abbreviation configuration '%0', ignoring.")
+          << Abbreviation;
+      continue;
+    }
     AbbreviationDictionary.try_emplace(Key, Value.str());
   }
 }

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 0ad69f5fdc5aa..84c1269658bb8 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -115,7 +115,7 @@ New checks
 
   Looks for functions returning ``std::[w|u8|u16|u32]string`` and suggests to
   change it to ``std::[...]string_view`` for performance reasons if possible.
-  
+
 - New :doc:`modernize-use-structured-binding
   <clang-tidy/checks/modernize/use-structured-binding>` check.
 
@@ -203,6 +203,10 @@ Changes in existing checks
   <clang-tidy/checks/readability/non-const-parameter>` check by avoiding false
   positives on parameters used in dependent expressions.
 
+- Improved :doc:`readability-suspicious-call-argument
+  <clang-tidy/checks/readability/suspicious-call-argument>` check by avoiding a
+  crash from invalid ``Abbreviations`` option.
+
 Removed checks
 ^^^^^^^^^^^^^^
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/suspicious-call-argument-option.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/suspicious-call-argument-option.cpp
new file mode 100644
index 0000000000000..7788feef8ce2c
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/suspicious-call-argument-option.cpp
@@ -0,0 +1,7 @@
+// RUN: %check_clang_tidy %s readability-suspicious-call-argument %t \
+// RUN: -config="{CheckOptions: 
{readability-suspicious-call-argument.Abbreviations: 'crash='}}" -- 
-std=c++11-or-later
+
+void f() {}
+// CHECK-MESSAGES: warning: Invalid abbreviation configuration 'crash=', 
ignoring.
+
+// TODO: Add testcases for other options

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 27db92be21f20..27c007ea278b2 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
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-suspicious-call-argument %t -- -- 
-std=c++11
+// RUN: %check_clang_tidy %s readability-suspicious-call-argument %t -- -- 
-std=c++11-or-later
 
 void foo_1(int aaaaaa, int bbbbbb) {}
 


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to