Fixed #4035 (False positive: Memory leak: pTempFile)

This commit is contained in:
Daniel Marjamäki 2012-08-25 10:55:20 +02:00
parent 808c3468c9
commit 5e1ccfaf90
3 changed files with 19 additions and 20 deletions

View File

@ -1995,8 +1995,6 @@ bool Tokenizer::tokenize(std::istream &code,
removeRedundantSemicolons();
simplifyReservedWordNullptr();
simplifyParameterVoid();
simplifyRedundantConsecutiveBraces();
@ -2106,6 +2104,14 @@ void Tokenizer::simplifyNull()
tok->str("0");
}
}
// nullptr..
if (isCPP()) {
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (tok->str() == "nullptr")
tok->str("0");
}
}
}
void Tokenizer::concatenateNegativeNumber()
@ -2198,16 +2204,6 @@ void Tokenizer::simplifyParameterVoid()
}
}
void Tokenizer::simplifyReservedWordNullptr()
{
if (_settings->standards.cpp11) {
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (tok->str() == "nullptr")
tok->str("0");
}
}
}
void Tokenizer::simplifyRedundantConsecutiveBraces()
{
// Remove redundant consecutive braces, i.e. '.. { { .. } } ..' -> '.. { .. } ..'.

View File

@ -463,8 +463,6 @@ public:
bool hasComplicatedSyntaxErrorsInTemplates();
void simplifyReservedWordNullptr();
/**
* Simplify e.g. 'atol("0")' into '0'
*/

View File

@ -4646,12 +4646,17 @@ private:
}
void simplify_null() {
const char code[] =
"int * p = NULL;\n"
"int * q = __null;\n";
const char expected[] =
"int * p ; p = 0 ;\nint * q ; q = 0 ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code,true));
{
const char code[] =
"int * p = NULL;\n"
"int * q = __null;\n";
const char expected[] =
"int * p ; p = 0 ;\nint * q ; q = 0 ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code,true));
}
ASSERT_EQUALS("( a == nullptr )", tokenizeAndStringify("(a==nullptr)", false, false, Settings::Unspecified, "test.c"));
ASSERT_EQUALS("( ! a )", tokenizeAndStringify("(a==nullptr)", false, false, Settings::Unspecified, "test.cpp"));
}
void simplifyMulAndParens() {