Skip to content

Commit 2463a0e

Browse files
authored
[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
1 parent acc6f3e commit 2463a0e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ void Test() {
4949
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter
5050
std::string q2("test", 200);
5151
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger than string literal size
52+
std::string t1("test", 5);
53+
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger than string literal size
5254
std::string q3(kText, 200);
5355
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger than string literal size
5456
std::string q4(kText2, 200);
@@ -97,6 +99,8 @@ void Valid() {
9799
std::string s1("test", 4);
98100
std::string s2("test", 3);
99101
std::string s3("test");
102+
std::string s4("test\000", 5);
103+
std::string s6("te" "st", 4);
100104

101105
std::string_view emptyv();
102106
std::string_view sv1("test", 4);

0 commit comments

Comments
 (0)