Reverted last commit. I pushed it by mistake.
This commit is contained in:
parent
5e1ccfaf90
commit
5051837c1a
|
@ -1995,6 +1995,8 @@ bool Tokenizer::tokenize(std::istream &code,
|
||||||
|
|
||||||
removeRedundantSemicolons();
|
removeRedundantSemicolons();
|
||||||
|
|
||||||
|
simplifyReservedWordNullptr();
|
||||||
|
|
||||||
simplifyParameterVoid();
|
simplifyParameterVoid();
|
||||||
|
|
||||||
simplifyRedundantConsecutiveBraces();
|
simplifyRedundantConsecutiveBraces();
|
||||||
|
@ -2104,14 +2106,6 @@ void Tokenizer::simplifyNull()
|
||||||
tok->str("0");
|
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()
|
void Tokenizer::concatenateNegativeNumber()
|
||||||
|
@ -2204,6 +2198,16 @@ 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()
|
void Tokenizer::simplifyRedundantConsecutiveBraces()
|
||||||
{
|
{
|
||||||
// Remove redundant consecutive braces, i.e. '.. { { .. } } ..' -> '.. { .. } ..'.
|
// Remove redundant consecutive braces, i.e. '.. { { .. } } ..' -> '.. { .. } ..'.
|
||||||
|
|
|
@ -463,6 +463,8 @@ public:
|
||||||
|
|
||||||
bool hasComplicatedSyntaxErrorsInTemplates();
|
bool hasComplicatedSyntaxErrorsInTemplates();
|
||||||
|
|
||||||
|
void simplifyReservedWordNullptr();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simplify e.g. 'atol("0")' into '0'
|
* Simplify e.g. 'atol("0")' into '0'
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -4646,7 +4646,6 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void simplify_null() {
|
void simplify_null() {
|
||||||
{
|
|
||||||
const char code[] =
|
const char code[] =
|
||||||
"int * p = NULL;\n"
|
"int * p = NULL;\n"
|
||||||
"int * q = __null;\n";
|
"int * q = __null;\n";
|
||||||
|
@ -4655,10 +4654,6 @@ private:
|
||||||
ASSERT_EQUALS(expected, tokenizeAndStringify(code,true));
|
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() {
|
void simplifyMulAndParens() {
|
||||||
// (error) Resource leak
|
// (error) Resource leak
|
||||||
const char code[] = "void f() {"
|
const char code[] = "void f() {"
|
||||||
|
|
Loading…
Reference in New Issue