Tokenizer: simplify restrict
This commit is contained in:
parent
beb2db82a2
commit
da998fec68
|
@ -2379,6 +2379,12 @@ bool Tokenizer::tokenize(std::istream &code,
|
||||||
// remove Borland stuff..
|
// remove Borland stuff..
|
||||||
simplifyBorland();
|
simplifyBorland();
|
||||||
|
|
||||||
|
// Remove "volatile", "inline", "register", and "restrict"
|
||||||
|
simplifyKeyword();
|
||||||
|
|
||||||
|
// Remove __builtin_expect, likely and unlikely
|
||||||
|
simplifyBuiltinExpect();
|
||||||
|
|
||||||
// typedef..
|
// typedef..
|
||||||
simplifyTypedef();
|
simplifyTypedef();
|
||||||
|
|
||||||
|
@ -2400,12 +2406,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
|
// collapse compound standard types into a single token
|
||||||
// unsigned long long int => long _isUnsigned=true,_isLong=true
|
// unsigned long long int => long _isUnsigned=true,_isLong=true
|
||||||
simplifyStdType();
|
simplifyStdType();
|
||||||
|
@ -8899,7 +8899,7 @@ void Tokenizer::simplifyAttribute()
|
||||||
// Remove "volatile", "inline", "register", and "restrict"
|
// Remove "volatile", "inline", "register", and "restrict"
|
||||||
void Tokenizer::simplifyKeyword()
|
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))
|
while (Token::Match(_tokens, pattern))
|
||||||
{
|
{
|
||||||
_tokens->deleteThis();
|
_tokens->deleteThis();
|
||||||
|
|
|
@ -6304,12 +6304,13 @@ private:
|
||||||
ASSERT_EQUALS("int foo ( ) { }", tok("__forceinline int foo ( ) { }", true));
|
ASSERT_EQUALS("int foo ( ) { }", tok("__forceinline int foo ( ) { }", true));
|
||||||
ASSERT_EQUALS("if ( a ) { }", tok("if ( likely ( a ) ) { }", true));
|
ASSERT_EQUALS("if ( a ) { }", tok("if ( likely ( a ) ) { }", true));
|
||||||
ASSERT_EQUALS("if ( a ) { }", tok("if ( unlikely ( 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("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("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("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("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()
|
void simplifyCallingConvention()
|
||||||
|
|
Loading…
Reference in New Issue