]> granicus.if.org Git - clang/blobdiff - lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
[analyzer] A fix for substraction of an integer from a pointer.
[clang] / lib / StaticAnalyzer / Core / SimpleSValBuilder.cpp
index 6989526a561ff169803adbcd7ded5c5193f15596..a704ce224554fc4e1c78ee1c2b582167ce842c52 100644 (file)
@@ -911,8 +911,9 @@ SVal SimpleSValBuilder::evalBinOpLN(ProgramStateRef state,
       elementType = elemReg->getElementType();
     }
     else if (isa<SubRegion>(region)) {
+      assert(op == BO_Add || op == BO_Sub);
+      index = (op == BO_Add) ? rhs : evalMinus(rhs);
       superR = region;
-      index = rhs;
       if (resultTy->isAnyPointerType())
         elementType = resultTy->getPointeeType();
     }