Fixed false positive in new stringLiteralWrite checker
This commit is contained in:
parent
6b80e61934
commit
e837bad01d
|
@ -35,7 +35,7 @@ namespace {
|
||||||
void CheckString::stringLiteralWrite()
|
void CheckString::stringLiteralWrite()
|
||||||
{
|
{
|
||||||
for (const Token* tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
for (const Token* tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||||
if (!tok->variable())
|
if (!tok->variable() || !tok->variable()->isPointer())
|
||||||
continue;
|
continue;
|
||||||
const Token *str = tok->getValueTokenMinStrSize();
|
const Token *str = tok->getValueTokenMinStrSize();
|
||||||
if (!str)
|
if (!str)
|
||||||
|
|
|
@ -111,8 +111,8 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (error) Modifying string literal directly or indirectly is undefined behaviour\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (error) Modifying string literal directly or indirectly is undefined behaviour\n", errout.str());
|
||||||
|
|
||||||
check("void f() {\n"
|
check("void f() {\n"
|
||||||
" char *abc = \"abc\";\n"
|
" QString abc = \"abc\";\n"
|
||||||
" if (*abc == 'a'){}\n"
|
" abc[0] = 'a';\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue