Fixed #2103 (false positive when variable is checked to NULL and not freed)
This commit is contained in:
parent
68dd2f8378
commit
8b866178ff
|
@ -4604,7 +4604,9 @@ void Tokenizer::simplifyCasts()
|
|||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
while (Token::Match(tok->next(), "( %type% *| ) *|&| %var%") ||
|
||||
Token::Match(tok->next(), "( %type% %type% *| ) *|&| %var%"))
|
||||
Token::Match(tok->next(), "( %type% %type% *| ) *|&| %var%") ||
|
||||
(!tok->isName() && (Token::Match(tok->next(), "( %type% * ) (") ||
|
||||
Token::Match(tok->next(), "( %type% %type% * ) ("))))
|
||||
{
|
||||
if (tok->isName() && tok->str() != "return")
|
||||
break;
|
||||
|
|
|
@ -474,7 +474,7 @@ private:
|
|||
// dealloc;
|
||||
ASSERT_EQUALS(";;dealloc;", getcode("char *s; free(s);", "s"));
|
||||
ASSERT_EQUALS(";;dealloc;", getcode("char *s; free((void *)s);", "s"));
|
||||
TODO_ASSERT_EQUALS(";;dealloc;", getcode("char *s; free((void *)(s));", "s"));
|
||||
ASSERT_EQUALS(";;dealloc;", getcode("char *s; free((void *)(s));", "s"));
|
||||
ASSERT_EQUALS(";;dealloc;", getcode("char *s; free(reinterpret_cast<void *>(s));", "s"));
|
||||
ASSERT_EQUALS(";;dealloc;", getcode("char *s; delete s;", "s"));
|
||||
ASSERT_EQUALS(";;dealloc;", getcode("char *s; delete (s);", "s"));
|
||||
|
|
|
@ -62,6 +62,7 @@ private:
|
|||
TEST_CASE(removeCast3);
|
||||
TEST_CASE(removeCast4);
|
||||
TEST_CASE(removeCast5);
|
||||
TEST_CASE(removeCast6);
|
||||
|
||||
TEST_CASE(inlineasm);
|
||||
|
||||
|
@ -532,6 +533,12 @@ private:
|
|||
ASSERT_EQUALS("a . data = f ;", tokenizeAndStringify("a->data = reinterpret_cast<void*>(static_cast<intptr_t>(f));", true));
|
||||
}
|
||||
|
||||
void removeCast6()
|
||||
{
|
||||
// ticket #2103
|
||||
ASSERT_EQUALS("if ( ! x )", tokenizeAndStringify("if (x == (char *) ((void *)0))", true));
|
||||
}
|
||||
|
||||
void inlineasm()
|
||||
{
|
||||
ASSERT_EQUALS("; asm ( ) ;", tokenizeAndStringify(";asm { mov ax,bx };"));
|
||||
|
|
Loading…
Reference in New Issue