summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/RegionStore.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/RegionStore.cpp83
1 files changed, 2 insertions, 81 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
index 0d403bc190c..41783245435 100644
--- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -710,7 +710,8 @@ public:
}
bool AddToWorkList(const MemRegion *R) {
- return static_cast<DERIVED*>(this)->AddToWorkList(R);
+ const MemRegion *BaseR = R->getBaseRegion();
+ return AddToWorkList(WorkListElement(BaseR), getCluster(BaseR));
}
void RunWorkList() {
@@ -955,20 +956,9 @@ public:
void VisitCluster(const MemRegion *baseR, const ClusterBindings *C);
void VisitBinding(SVal V);
-
- using ClusterAnalysis::AddToWorkList;
-
- bool AddToWorkList(const MemRegion *R);
};
}
-bool invalidateRegionsWorker::AddToWorkList(const MemRegion *R) {
- bool doNotInvalidateSuperRegion = ITraits.hasTrait(
- R, RegionAndSymbolInvalidationTraits::TK_DoNotInvalidateSuperRegion);
- const MemRegion *BaseR = doNotInvalidateSuperRegion ? R : R->getBaseRegion();
- return AddToWorkList(WorkListElement(BaseR), getCluster(BaseR));
-}
-
void invalidateRegionsWorker::VisitBinding(SVal V) {
// A symbol? Mark it touched by the invalidation.
if (SymbolRef Sym = V.getAsSymbol())
@@ -1081,66 +1071,6 @@ void invalidateRegionsWorker::VisitCluster(const MemRegion *baseR,
}
if (const ArrayType *AT = Ctx.getAsArrayType(T)) {
- bool doNotInvalidateSuperRegion = ITraits.hasTrait(
- baseR,
- RegionAndSymbolInvalidationTraits::TK_DoNotInvalidateSuperRegion);
-
- if (doNotInvalidateSuperRegion) {
- // We are not doing blank invalidation of the whole array region so we
- // have to manually invalidate each elements.
- Optional<uint64_t> NumElements;
-
- // Compute lower and upper offsets for region within array.
- if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(AT))
- NumElements = CAT->getSize().getZExtValue();
- if (!NumElements) // We are not dealing with a constant size array
- goto conjure_default;
- QualType ElementTy = AT->getElementType();
- uint64_t ElemSize = Ctx.getTypeSize(ElementTy);
- const RegionOffset &RO = baseR->getAsOffset();
- const MemRegion *SuperR = baseR->getBaseRegion();
- if (RO.hasSymbolicOffset()) {
- // If base region has a symbolic offset,
- // we revert to invalidating the super region.
- if (SuperR)
- AddToWorkList(SuperR);
- goto conjure_default;
- }
- assert(RO.getOffset() >= 0 && "Offset should not be negative");
- uint64_t LowerOffset = RO.getOffset();
- uint64_t UpperOffset = LowerOffset + *NumElements * ElemSize;
-
- // Invalidate regions which are within array boundaries,
- // or have a symbolic offset.
- if (!SuperR)
- goto conjure_default;
-
- const ClusterBindings *C = B.lookup(SuperR);
- if (!C)
- goto conjure_default;
-
- for (ClusterBindings::iterator I = C->begin(), E = C->end(); I != E;
- ++I) {
- const BindingKey &BK = I.getKey();
- Optional<uint64_t> ROffset =
- BK.hasSymbolicOffset() ? Optional<uint64_t>() : BK.getOffset();
- // Check offset is not symbolic and within array's boundaries.
- // Handles arrays of 0 elements and of 0-sized elements as well.
- if (!ROffset ||
- (ROffset &&
- ((*ROffset >= LowerOffset && *ROffset < UpperOffset) ||
- (LowerOffset == UpperOffset && *ROffset == LowerOffset)))) {
- B = B.removeBinding(I.getKey());
- // Bound symbolic regions need to be invalidated for dead symbol
- // detection.
- SVal V = I.getData();
- const MemRegion *R = V.getAsRegion();
- if (R && isa<SymbolicRegion>(R))
- VisitBinding(V);
- }
- }
- }
- conjure_default:
// Set the default value of the array to conjured symbol.
DefinedOrUnknownSVal V =
svalBuilder.conjureSymbolVal(baseR, Ex, LCtx,
@@ -2257,20 +2187,11 @@ public:
void VisitCluster(const MemRegion *baseR, const ClusterBindings *C);
using ClusterAnalysis<removeDeadBindingsWorker>::VisitCluster;
- using ClusterAnalysis::AddToWorkList;
-
- bool AddToWorkList(const MemRegion *R);
-
bool UpdatePostponed();
void VisitBinding(SVal V);
};
}
-bool removeDeadBindingsWorker::AddToWorkList(const MemRegion *R) {
- const MemRegion *BaseR = R->getBaseRegion();
- return AddToWorkList(WorkListElement(BaseR), getCluster(BaseR));
-}
-
void removeDeadBindingsWorker::VisitAddedToCluster(const MemRegion *baseR,
const ClusterBindings &C) {
OpenPOWER on IntegriCloud