|
22 | 22 | #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" |
23 | 23 | #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicExtent.h" |
24 | 24 | #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h" |
| 25 | +#include "llvm/ADT/APSInt.h" |
25 | 26 | #include "llvm/ADT/SmallString.h" |
26 | 27 | #include "llvm/Support/FormatVariadic.h" |
27 | 28 | #include "llvm/Support/raw_ostream.h" |
@@ -241,26 +242,25 @@ computeOffset(ProgramStateRef State, SValBuilder &SVB, SVal Location) { |
241 | 242 | static std::pair<NonLoc, nonloc::ConcreteInt> |
242 | 243 | getSimplifiedOffsets(NonLoc offset, nonloc::ConcreteInt extent, |
243 | 244 | SValBuilder &svalBuilder) { |
| 245 | + const llvm::APSInt &extentVal = extent.getValue(); |
244 | 246 | std::optional<nonloc::SymbolVal> SymVal = offset.getAs<nonloc::SymbolVal>(); |
245 | 247 | if (SymVal && SymVal->isExpression()) { |
246 | 248 | if (const SymIntExpr *SIE = dyn_cast<SymIntExpr>(SymVal->getSymbol())) { |
247 | | - llvm::APSInt constant = |
248 | | - APSIntType(extent.getValue()).convert(SIE->getRHS()); |
| 249 | + llvm::APSInt constant = APSIntType(extentVal).convert(SIE->getRHS()); |
249 | 250 | switch (SIE->getOpcode()) { |
250 | 251 | case BO_Mul: |
251 | 252 | // The constant should never be 0 here, becasue multiplication by zero |
252 | 253 | // is simplified by the engine. |
253 | | - if ((extent.getValue() % constant) != 0) |
| 254 | + if ((extentVal % constant) != 0) |
254 | 255 | return std::pair<NonLoc, nonloc::ConcreteInt>(offset, extent); |
255 | 256 | else |
256 | 257 | return getSimplifiedOffsets( |
257 | 258 | nonloc::SymbolVal(SIE->getLHS()), |
258 | | - svalBuilder.makeIntVal(extent.getValue() / constant), |
259 | | - svalBuilder); |
| 259 | + svalBuilder.makeIntVal(extentVal / constant), svalBuilder); |
260 | 260 | case BO_Add: |
261 | 261 | return getSimplifiedOffsets( |
262 | 262 | nonloc::SymbolVal(SIE->getLHS()), |
263 | | - svalBuilder.makeIntVal(extent.getValue() - constant), svalBuilder); |
| 263 | + svalBuilder.makeIntVal(extentVal - constant), svalBuilder); |
264 | 264 | default: |
265 | 265 | break; |
266 | 266 | } |
@@ -363,7 +363,7 @@ static std::string getRegionName(const SubRegion *Region) { |
363 | 363 |
|
364 | 364 | static std::optional<int64_t> getConcreteValue(NonLoc SV) { |
365 | 365 | if (auto ConcreteVal = SV.getAs<nonloc::ConcreteInt>()) { |
366 | | - return ConcreteVal->getValue().tryExtValue(); |
| 366 | + return ConcreteVal->getValue()->tryExtValue(); |
367 | 367 | } |
368 | 368 | return std::nullopt; |
369 | 369 | } |
|
0 commit comments