summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-07-02 01:37:40 +0000
committerJordan Rose <jordan_rose@apple.com>2013-07-02 01:37:40 +0000
commit686df3221650a69fb5acf6a3313cee1d554193bd (patch)
tree2555b7c9eb732aed5d49ae2a60eed8e490b81612 /clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
parent54d04f3bec34fe0e1472e65515d3ac72f789ad1b (diff)
downloadbcm5719-llvm-686df3221650a69fb5acf6a3313cee1d554193bd.tar.gz
bcm5719-llvm-686df3221650a69fb5acf6a3313cee1d554193bd.zip
[analyzer] Explicitly disallow mixed Loc-NonLoc comparisons.
The one bit of code that was using this is gone, and neither C nor C++ actually allows this. Add an assertion and remove dead code. Found by Matthew Dempsky! llvm-svn: 185401
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp25
1 files changed, 3 insertions, 22 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
index cb9e451b24a..57ec2820251 100644
--- a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -837,32 +837,13 @@ SVal SimpleSValBuilder::evalBinOpLL(ProgramStateRef state,
SVal SimpleSValBuilder::evalBinOpLN(ProgramStateRef state,
BinaryOperator::Opcode op,
Loc lhs, NonLoc rhs, QualType resultTy) {
-
+ assert(!BinaryOperator::isComparisonOp(op) &&
+ "arguments to comparison ops must be of the same type");
+
// Special case: rhs is a zero constant.
if (rhs.isZeroConstant())
return lhs;
- // Special case: 'rhs' is an integer that has the same width as a pointer and
- // we are using the integer location in a comparison. Normally this cannot be
- // triggered, but transfer functions like those for OSCompareAndSwapBarrier32
- // can generate comparisons that trigger this code.
- // FIXME: Are all locations guaranteed to have pointer width?
- if (BinaryOperator::isComparisonOp(op)) {
- if (Optional<nonloc::ConcreteInt> rhsInt =
- rhs.getAs<nonloc::ConcreteInt>()) {
- const llvm::APSInt *x = &rhsInt->getValue();
- ASTContext &ctx = Context;
- if (ctx.getTypeSize(ctx.VoidPtrTy) == x->getBitWidth()) {
- // Convert the signedness of the integer (if necessary).
- if (x->isSigned())
- x = &getBasicValueFactory().getValue(*x, true);
-
- return evalBinOpLL(state, op, lhs, loc::ConcreteInt(*x), resultTy);
- }
- }
- return UnknownVal();
- }
-
// We are dealing with pointer arithmetic.
// Handle pointer arithmetic on constant values.
OpenPOWER on IntegriCloud