Tokenizer::simplifyKnownVariables: Added bailout when pointer alias is simplified and loop is encountered
This commit is contained in:
parent
e0d4720e19
commit
d4f2512421
|
@ -6471,8 +6471,8 @@ bool Tokenizer::simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsign
|
||||||
if (pointeralias && Token::Match(tok3, ("!!= " + value).c_str()))
|
if (pointeralias && Token::Match(tok3, ("!!= " + value).c_str()))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Stop if do is found
|
// Stop if a loop is found
|
||||||
if (tok3->str() == "do")
|
if (pointeralias && Token::Match(tok3, "do|for|while"))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Stop if unknown function call is seen
|
// Stop if unknown function call is seen
|
||||||
|
|
|
@ -1643,6 +1643,10 @@ private:
|
||||||
ASSERT_EQUALS(
|
ASSERT_EQUALS(
|
||||||
"void foo ( ) { int n ; n = 10 ; for ( int i = 0 ; i < 10 ; ++ i ) { } }",
|
"void foo ( ) { int n ; n = 10 ; for ( int i = 0 ; i < 10 ; ++ i ) { } }",
|
||||||
simplifyKnownVariables(code));
|
simplifyKnownVariables(code));
|
||||||
|
|
||||||
|
ASSERT_EQUALS(
|
||||||
|
"void foo ( int i ) { int n ; n = i ; for ( i = 0 ; i < n ; ++ i ) { } }",
|
||||||
|
simplifyKnownVariables("void foo(int i) { int n = i; for (i = 0; i < n; ++i) { } }"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void simplifyKnownVariables22() {
|
void simplifyKnownVariables22() {
|
||||||
|
|
Loading…
Reference in New Issue