diff options
| author | Artem Dergachev <artem.dergachev@gmail.com> | 2018-07-23 23:09:44 +0000 |
|---|---|---|
| committer | Artem Dergachev <artem.dergachev@gmail.com> | 2018-07-23 23:09:44 +0000 |
| commit | 917111f91ec136d6acab7da78eedd0fb41f169ae (patch) | |
| tree | 030211e76bddff63a45bed838f725d0f24b5b05b | |
| parent | 54f10f8e68012217c5a72bc68d98104303a3c0e0 (diff) | |
| download | bcm5719-llvm-917111f91ec136d6acab7da78eedd0fb41f169ae.tar.gz bcm5719-llvm-917111f91ec136d6acab7da78eedd0fb41f169ae.zip | |
[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
llvm-svn: 337769
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp | 6 | ||||
| -rw-r--r-- | clang/test/Analysis/casts.c | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp index 1d2b94d6f76..e8c7bdbde38 100644 --- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ b/clang/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/clang/test/Analysis/casts.c b/clang/test/Analysis/casts.c index 548b4223b6a..49db822aa13 100644 --- a/clang/test/Analysis/casts.c +++ b/clang/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) {} +} |

