Author: dergachev Date: Mon Jul 23 16:09:44 2018 New Revision: 337769 URL: http://llvm.org/viewvc/llvm-project?rev=337769&view=rev Log: [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 Modified: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp cfe/trunk/test/Analysis/casts.c Modified: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp?rev=337769&r1=337768&r2=337769&view=diff ============================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp Mon Jul 23 16:09:44 2018 @@ -343,9 +343,11 @@ bool RangeConstraintManager::canReasonAb 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()); } } } Modified: cfe/trunk/test/Analysis/casts.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/casts.c?rev=337769&r1=337768&r2=337769&view=diff ============================================================================== --- cfe/trunk/test/Analysis/casts.c (original) +++ cfe/trunk/test/Analysis/casts.c Mon Jul 23 16:09:44 2018 @@ -171,3 +171,7 @@ void testCastVoidPtrToIntPtrThroughUIntT (*((int *)(&x))) = (int)(unsigned *)getVoidPtr(); *x = 1; // no-crash } + +void testLocNonLocSymbolAssume(int a, int *b) { + if ((int)b < a) {} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits