Skip to content

Commit

Permalink
[analyzer] pr38273: Legalize Loc<>NonLoc comparison symbols.
Browse files Browse the repository at this point in the history
Remove an assertion in RangeConstraintManager that expects such symbols to never
appear, while admitting that the constraint manager doesn't yet handle them.

Differential Revision: https://reviews.llvm.org/D49703

llvm-svn: 337769
  • Loading branch information
haoNoQ committed Jul 23, 2018
1 parent 54f10f8 commit 917111f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
Expand Up @@ -343,9 +343,11 @@ bool RangeConstraintManager::canReasonAbout(SVal X) const {
if (BinaryOperator::isEqualityOp(SSE->getOpcode()) ||
BinaryOperator::isRelationalOp(SSE->getOpcode())) {
// We handle Loc <> Loc comparisons, but not (yet) NonLoc <> NonLoc.
// We've recently started producing Loc <> NonLoc comparisons (that
// result from casts of one of the operands between eg. intptr_t and
// void *), but we can't reason about them yet.
if (Loc::isLocType(SSE->getLHS()->getType())) {
assert(Loc::isLocType(SSE->getRHS()->getType()));
return true;
return Loc::isLocType(SSE->getRHS()->getType());
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions clang/test/Analysis/casts.c
Expand Up @@ -171,3 +171,7 @@ void testCastVoidPtrToIntPtrThroughUIntTypedAssignment() {
(*((int *)(&x))) = (int)(unsigned *)getVoidPtr();
*x = 1; // no-crash
}

void testLocNonLocSymbolAssume(int a, int *b) {
if ((int)b < a) {}
}

0 comments on commit 917111f

Please sign in to comment.