llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-tools-extra Author: mitchell (zeyi2) <details> <summary>Changes</summary> Closes #<!-- -->180346 --- Full diff: https://github.com/llvm/llvm-project/pull/180351.diff 4 Files Affected: - (modified) clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp (+5-1) - (modified) clang-tools-extra/docs/ReleaseNotes.rst (+5-1) - (added) clang-tools-extra/test/clang-tidy/checkers/readability/suspicious-call-argument-option.cpp (+7) - (modified) clang-tools-extra/test/clang-tidy/checkers/readability/suspicious-call-argument.cpp (+1-1) ``````````diff 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..6b1e417a6f149 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 malformed `Abbreviations` configuration. + 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) {} `````````` </details> https://github.com/llvm/llvm-project/pull/180351 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
