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
8 changes: 6 additions & 2 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8911,8 +8911,12 @@ Token* Tokenizer::getAttributeFuncTok(Token* tok, bool gccattr) const {
Token *prev = tok->previous();
while (Token::Match(prev, "%name%"))
prev = prev->previous();
if (Token::simpleMatch(prev, ")") && Token::Match(prev->link()->previous(), "%name% ("))
return prev->link()->previous();
if (Token::simpleMatch(prev, ")")) {
if (Token::Match(prev->link()->previous(), "%name% ("))
return prev->link()->previous();
if (Token::Match(prev->link()->tokAt(-2), "%name% ) ("))
return prev->link()->tokAt(-2);
}
if (Token::simpleMatch(prev, ")") && Token::Match(prev->link()->tokAt(-2), "operator %op% (") && isCPP())
return prev->link()->tokAt(-2);
if ((!prev || Token::Match(prev, "[;{}*]")) && Token::Match(tok->previous(), "%name%"))
Expand Down
1 change: 1 addition & 0 deletions test/testsimplifytokens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,7 @@ class TestSimplifyTokens : public TestFixture {
ASSERT_EQUALS("blah :: blah f ( ) ;", tok("__attribute__ ((visibility(\"default\"))) blah::blah f();"));
ASSERT_EQUALS("template < T > Result < T > f ( ) ;", tok("template<T> __attribute__ ((warn_unused_result)) Result<T> f();"));
ASSERT_EQUALS("template < T , U > Result < T , U > f ( ) ;", tok("template<T, U> __attribute__ ((warn_unused_result)) Result<T, U> f();"));
ASSERT_EQUALS("void ( * fp ) ( ) ; fp = nullptr ;", tok("typedef void (*fp_t)() __attribute__((noreturn)); fp_t fp = nullptr;")); // #12137
}

void simplifyFunctorCall() {
Expand Down