From: Artem Dergachev Date: Mon, 23 Jul 2018 23:09:44 +0000 (+0000) Subject: [analyzer] pr38273: Legalize Loc<>NonLoc comparison symbols. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6748c6fecb10eaebe06850aaf5d16f7075e92431;p=clang [analyzer] pr38273: Legalize Loc<>NonLoc comparison symbols. 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337769 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp b/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp index 1d2b94d6f7..e8c7bdbde3 100644 --- a/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ b/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp @@ -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()); } } } diff --git a/test/Analysis/casts.c b/test/Analysis/casts.c index 548b4223b6..49db822aa1 100644 --- a/test/Analysis/casts.c +++ b/test/Analysis/casts.c @@ -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) {} +}