[clang-tools-extra] 2463a0e - [clang-tidy][test] Add more bugprone-string-constructor tests (#70456)

via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 27 12:20:41 PDT 2023


Author: ツ
Date: 2023-10-27T21:20:37+02:00
New Revision: 2463a0ed70754524efb6e05b09d632dcacf9b51f

URL: https://github.com/llvm/llvm-project/commit/2463a0ed70754524efb6e05b09d632dcacf9b51f
DIFF: https://github.com/llvm/llvm-project/commit/2463a0ed70754524efb6e05b09d632dcacf9b51f.diff

LOG: [clang-tidy][test] Add more bugprone-string-constructor tests (#70456)

Test:

* string literal concatenation is accepted
* escaped embedded null char is accepted
* taking over the implicit null char is rejected

Added: 
    

Modified: 
    clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp
index 1ca4d14f85e29d3..a5b6b240ddc665a 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp
@@ -49,6 +49,8 @@ void Test() {
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter
   std::string q2("test", 200);
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger than string literal size
+  std::string t1("test", 5);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger than string literal size
   std::string q3(kText, 200);
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger than string literal size
   std::string q4(kText2, 200);
@@ -97,6 +99,8 @@ void Valid() {
   std::string s1("test", 4);
   std::string s2("test", 3);
   std::string s3("test");
+  std::string s4("test\000", 5);
+  std::string s6("te" "st", 4);
 
   std::string_view emptyv();
   std::string_view sv1("test", 4);


        


More information about the cfe-commits mailing list