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()))
|
||||
break;
|
||||
|
||||
// Stop if do is found
|
||||
if (tok3->str() == "do")
|
||||
// Stop if a loop is found
|
||||
if (pointeralias && Token::Match(tok3, "do|for|while"))
|
||||
break;
|
||||
|
||||
// Stop if unknown function call is seen
|
||||
|
|
|
@ -1643,6 +1643,10 @@ private:
|
|||
ASSERT_EQUALS(
|
||||
"void foo ( ) { int n ; n = 10 ; for ( int i = 0 ; i < 10 ; ++ i ) { } }",
|
||||
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() {
|
||||
|
|
Loading…
Reference in New Issue