Skip to content
Open
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
3 changes: 2 additions & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3862,7 +3862,8 @@ void Tokenizer::simplifyRedundantConsecutiveBraces()
for (Token *tok = list.front(); tok;) {
if (Token::simpleMatch(tok, "= {")) {
tok = tok->linkAt(1);
} else if (Token::simpleMatch(tok, "{ {") && Token::simpleMatch(tok->linkAt(1), "} }")) {
} else if (Token::simpleMatch(tok, "{ {") && Token::simpleMatch(tok->linkAt(1), "} }") &&
!Token::Match(tok->previous(), "%name%")) {
//remove internal parentheses
tok->linkAt(1)->deleteThis();
tok->deleteNext();
Expand Down
1 change: 1 addition & 0 deletions test/testsimplifytokens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,7 @@ class TestSimplifyTokens : public TestFixture {
ASSERT_EQUALS("void f ( ) { }", tok("void f(){{{}}}"));
ASSERT_EQUALS("void f ( ) { for ( ; ; ) { } }", tok("void f () { for(;;){} }"));
ASSERT_EQUALS("void f ( ) { { scope_lock lock ; foo ( ) ; } { scope_lock lock ; bar ( ) ; } }", tok("void f () { {scope_lock lock; foo();} {scope_lock lock; bar();} }"));
ASSERT_EQUALS("std :: map < int , int > m { { } } ;", tok("std::map<int, int> m{ {} };"));
}

void simplifyOverride() { // ticket #5069
Expand Down
Loading