Skip to content
Closed
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
14 changes: 7 additions & 7 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2367,6 +2367,12 @@ bool Tokenizer::tokenize(std::istream &code,
// remove Borland stuff..
simplifyBorland();

// Remove "volatile", "inline", "register", and "restrict"
simplifyKeyword();

// Remove __builtin_expect, likely and unlikely
simplifyBuiltinExpect();

// typedef..
simplifyTypedef();

Expand All @@ -2388,12 +2394,6 @@ bool Tokenizer::tokenize(std::istream &code,
}
}

// Remove "volatile", "inline", "register", and "restrict"
simplifyKeyword();

// Remove __builtin_expect, likely and unlikely
simplifyBuiltinExpect();

// collapse compound standard types into a single token
// unsigned long long int => long _isUnsigned=true,_isLong=true
simplifyStdType();
Expand Down Expand Up @@ -8820,7 +8820,7 @@ void Tokenizer::simplifyAttribute()
// Remove "volatile", "inline", "register", and "restrict"
void Tokenizer::simplifyKeyword()
{
const char pattern[] = "volatile|inline|__inline|__forceinline|register|restrict|__restrict__";
const char pattern[] = "volatile|inline|__inline|__forceinline|register|restrict|__restrict|__restrict__";
while (Token::Match(_tokens, pattern))
{
_tokens->deleteThis();
Expand Down
3 changes: 2 additions & 1 deletion test/testsimplifytokens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6273,12 +6273,13 @@ class TestSimplifyTokens : public TestFixture
ASSERT_EQUALS("int foo ( ) { }", tok("__forceinline int foo ( ) { }", true));
ASSERT_EQUALS("if ( a ) { }", tok("if ( likely ( a ) ) { }", true));
ASSERT_EQUALS("if ( a ) { }", tok("if ( unlikely ( a ) ) { }", true));
ASSERT_EQUALS("int * p ;", tok("int * __restrict__ p;", true));
ASSERT_EQUALS("int * p ;", tok("int * __restrict p;", true));
ASSERT_EQUALS("int * * p ;", tok("int * __restrict__ * p;", true));
ASSERT_EQUALS("void foo ( float * a , float * b ) ;", tok("void foo(float * __restrict__ a, float * __restrict__ b);", true));
ASSERT_EQUALS("int * p ;", tok("int * restrict p;", true));
ASSERT_EQUALS("int * * p ;", tok("int * restrict * p;", true));
ASSERT_EQUALS("void foo ( float * a , float * b ) ;", tok("void foo(float * restrict a, float * restrict b);", true));
ASSERT_EQUALS("; int * p ;", tok("typedef int * __restrict__ rint; rint p;", true));
}

void simplifyCallingConvention()
Expand Down