Skip to content

Commit 32ab7db

Browse files
authored
CheckOther: granulized some checks in checkComparePointers() to bail out early (danmar#7132)
1 parent 266cfda commit 32ab7db

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/checkother.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4072,12 +4072,16 @@ void CheckOther::checkComparePointers()
40724072
if (!Token::Match(tok, "<|>|<=|>=|-"))
40734073
continue;
40744074
const Token *tok1 = tok->astOperand1();
4075+
if (!astIsPointer(tok1))
4076+
continue;
40754077
const Token *tok2 = tok->astOperand2();
4076-
if (!astIsPointer(tok1) || !astIsPointer(tok2))
4078+
if (!astIsPointer(tok2))
40774079
continue;
40784080
ValueFlow::Value v1 = ValueFlow::getLifetimeObjValue(tok1);
4081+
if (!v1.isLocalLifetimeValue())
4082+
continue;
40794083
ValueFlow::Value v2 = ValueFlow::getLifetimeObjValue(tok2);
4080-
if (!v1.isLocalLifetimeValue() || !v2.isLocalLifetimeValue())
4084+
if (!v2.isLocalLifetimeValue())
40814085
continue;
40824086
const Variable *var1 = v1.tokvalue->variable();
40834087
const Variable *var2 = v2.tokvalue->variable();

0 commit comments

Comments
 (0)