Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/checksizeof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ void CheckSizeof::sizeofCalculation()
if (tok->isExpandedMacro() && tok->previous()) {
const Token *cast_end = (tok->previous()->str() == "(") ? tok->previous() : tok;
if (Token::simpleMatch(cast_end->tokAt(-3), "( void )") ||
Token::simpleMatch(cast_end->previous(), "static_cast<void>")) {
Token::simpleMatch(cast_end->tokAt(-4), "static_cast < void >")) {
continue;
}
}
Expand Down Expand Up @@ -337,7 +337,7 @@ void CheckSizeof::sizeofFunction()
if (tok->isExpandedMacro() && tok->previous()) {
const Token *cast_end = (tok->previous()->str() == "(") ? tok->previous() : tok;
if (Token::simpleMatch(cast_end->tokAt(-3), "( void )") ||
Token::simpleMatch(cast_end->previous(), "static_cast<void>")) {
Token::simpleMatch(cast_end->tokAt(-4), "static_cast < void >")) {
continue;
}
}
Expand Down
52 changes: 0 additions & 52 deletions lib/templatesimplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,58 +245,6 @@ TemplateSimplifier::~TemplateSimplifier()
{
}

void TemplateSimplifier::cleanupAfterSimplify()
{
bool goback = false;
for (Token *tok = mTokenList.front(); tok; tok = tok->next()) {
if (goback) {
tok = tok->previous();
goback = false;
}
if (tok->str() == "(")
tok = tok->link();

else if (Token::Match(tok, "template < > %name%")) {
const Token *end = tok;
while (end) {
if (end->str() == ";")
break;
if (end->str() == "{") {
end = end->link()->next();
break;
}
if (!Token::Match(end, "%name%|::|<|>|,")) {
end = nullptr;
break;
}
end = end->next();
}
if (end) {
Token::eraseTokens(tok,end);
tok->deleteThis();
}
}

else if (Token::Match(tok, "%type% <") &&
(!tok->previous() || tok->previous()->str() == ";")) {
const Token *tok2 = tok->tokAt(2);
std::string type;
while (Token::Match(tok2, "%type%|%num% ,")) {
type += tok2->str() + ",";
tok2 = tok2->tokAt(2);
}
if (Token::Match(tok2, "%type%|%num% > (")) {
type += tok2->str();
tok->str(tok->str() + "<" + type + ">");
Token::eraseTokens(tok, tok2->tokAt(2));
if (tok == mTokenList.front())
goback = true;
}
}
}
}


void TemplateSimplifier::checkComplicatedSyntaxErrorsInTemplates()
{
// check for more complicated syntax errors when using templates..
Expand Down
7 changes: 0 additions & 7 deletions lib/templatesimplifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ class CPPCHECKLIB TemplateSimplifier {
explicit TemplateSimplifier(Tokenizer *tokenizer);
~TemplateSimplifier();

/**
* Used after simplifyTemplates to perform a little cleanup.
* Sometimes the simplifyTemplates isn't fully successful and then
* there are function calls etc with "wrong" syntax.
*/
void cleanupAfterSimplify();

/**
*/
void checkComplicatedSyntaxErrorsInTemplates();
Expand Down
4 changes: 0 additions & 4 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4747,11 +4747,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
if (Settings::terminated())
return false;

// sometimes the "simplifyTemplates" fail and then unsimplified
// function calls etc remain. These have the "wrong" syntax. So
// this function will just fix so that the syntax is corrected.
validate(); // #6847 - invalid code
mTemplateSimplifier->cleanupAfterSimplify();
}

// Simplify pointer to standard types (C only)
Expand Down
4 changes: 2 additions & 2 deletions test/testsimplifytemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -997,8 +997,8 @@ class TestSimplifyTemplate : public TestFixture {
}

void template_unhandled() {
// An unhandled template usage should be simplified..
ASSERT_EQUALS("x<int> ( ) ;", tok("x<int>();"));
// An unhandled template usage should not be simplified..
ASSERT_EQUALS("x < int > ( ) ;", tok("x<int>();"));
}

void template38() { // #4832 - Crash on C++11 right angle brackets
Expand Down
4 changes: 2 additions & 2 deletions test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4315,13 +4315,13 @@ class TestTokenizer : public TestFixture {
void unsigned3() {
{
const char code[] = "; foo<unsigned>();";
const char expected[] = "; foo<int> ( ) ;";
const char expected[] = "; foo < unsigned int > ( ) ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
}

{
const char code[] = "; foo<unsigned int>();";
const char expected[] = "; foo<int> ( ) ;";
const char expected[] = "; foo < unsigned int > ( ) ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
}
}
Expand Down