We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e6e045f commit f47acb0Copy full SHA for f47acb0
lib/checkstring.cpp
@@ -318,6 +318,7 @@ void CheckString::checkIncorrectStringCompare()
318
}
319
320
} else if (Token::Match(tok, "%str%|%char%") &&
321
+ !Token::Match(tok->next(), "%name%") &&
322
isUsedAsBool(tok, *mSettings) &&
323
!isMacroUsage(tok))
324
incorrectStringBooleanError(tok, tok->str());
test/teststring.cpp
@@ -823,6 +823,13 @@ class TestString : public TestFixture {
823
" if (strequ(p, \"ALL\")) {}\n"
824
"}\n");
825
ASSERT_EQUALS("", errout_str());
826
+
827
+ check("void f(std::string_view);\n"
828
+ "void f(bool);\n"
829
+ "void g() {\n"
830
+ " f(\"\"sv);\n"
831
+ "}\n");
832
+ ASSERT_EQUALS("", errout_str());
833
834
835
void deadStrcmp() {
0 commit comments