diff options
Diffstat (limited to 'lib/StaticAnalyzer/Core/SymbolManager.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/SymbolManager.cpp | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/lib/StaticAnalyzer/Core/SymbolManager.cpp b/lib/StaticAnalyzer/Core/SymbolManager.cpp index f2d5ee83f3cc7..ed197010ebb7e 100644 --- a/lib/StaticAnalyzer/Core/SymbolManager.cpp +++ b/lib/StaticAnalyzer/Core/SymbolManager.cpp @@ -1,4 +1,4 @@ -//== SymbolManager.h - Management of Symbolic Values ------------*- C++ -*--==// +//===- SymbolManager.h - Management of Symbolic Values --------------------===// // // The LLVM Compiler Infrastructure // @@ -13,15 +13,27 @@ //===----------------------------------------------------------------------===// #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h" +#include "clang/AST/ASTContext.h" +#include "clang/AST/Expr.h" #include "clang/Analysis/Analyses/LiveVariables.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Basic/LLVM.h" #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h" #include "clang/StaticAnalyzer/Core/PathSensitive/Store.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h" +#include "llvm/ADT/FoldingSet.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" +#include <cassert> using namespace clang; using namespace ento; -void SymExpr::anchor() { } +void SymExpr::anchor() {} LLVM_DUMP_METHOD void SymExpr::dump() const { dumpToStream(llvm::errs()); @@ -88,7 +100,7 @@ void SymbolMetadata::dumpToStream(raw_ostream &os) const { << getRegion() << ',' << T.getAsString() << '}'; } -void SymbolData::anchor() { } +void SymbolData::anchor() {} void SymbolRegionValue::dumpToStream(raw_ostream &os) const { os << "reg_$" << getSymbolID() @@ -138,7 +150,7 @@ void SymExpr::symbol_iterator::expand() { itr.push_back(cast<IntSymExpr>(SE)->getRHS()); return; case SymExpr::SymSymExprKind: { - const SymSymExpr *x = cast<SymSymExpr>(SE); + const auto *x = cast<SymSymExpr>(SE); itr.push_back(x->getLHS()); itr.push_back(x->getRHS()); return; @@ -147,13 +159,6 @@ void SymExpr::symbol_iterator::expand() { llvm_unreachable("unhandled expansion case"); } -unsigned SymExpr::computeComplexity() const { - unsigned R = 0; - for (symbol_iterator I = symbol_begin(), E = symbol_end(); I != E; ++I) - R++; - return R; -} - const SymbolRegionValue* SymbolManager::getRegionValueSymbol(const TypedValueRegion* R) { llvm::FoldingSetNodeID profile; @@ -192,7 +197,6 @@ const SymbolConjured* SymbolManager::conjureSymbol(const Stmt *E, const SymbolDerived* SymbolManager::getDerivedSymbol(SymbolRef parentSymbol, const TypedValueRegion *R) { - llvm::FoldingSetNodeID profile; SymbolDerived::Profile(profile, parentSymbol, R); void *InsertPos; @@ -227,7 +231,6 @@ const SymbolMetadata * SymbolManager::getMetadataSymbol(const MemRegion* R, const Stmt *S, QualType T, const LocationContext *LCtx, unsigned Count, const void *SymbolTag) { - llvm::FoldingSetNodeID profile; SymbolMetadata::Profile(profile, R, S, T, LCtx, Count, SymbolTag); void *InsertPos; @@ -382,11 +385,10 @@ void SymbolReaper::markDependentsLive(SymbolRef sym) { LI->second = HaveMarkedDependents; if (const SymbolRefSmallVectorTy *Deps = SymMgr.getDependentSymbols(sym)) { - for (SymbolRefSmallVectorTy::const_iterator I = Deps->begin(), - E = Deps->end(); I != E; ++I) { - if (TheLiving.find(*I) != TheLiving.end()) + for (const auto I : *Deps) { + if (TheLiving.find(I) != TheLiving.end()) continue; - markLive(*I); + markLive(I); } } } @@ -405,7 +407,7 @@ void SymbolReaper::markLive(const MemRegion *region) { void SymbolReaper::markElementIndicesLive(const MemRegion *region) { for (auto SR = dyn_cast<SubRegion>(region); SR; SR = dyn_cast<SubRegion>(SR->getSuperRegion())) { - if (auto ER = dyn_cast<ElementRegion>(SR)) { + if (const auto ER = dyn_cast<ElementRegion>(SR)) { SVal Idx = ER->getIndex(); for (auto SI = Idx.symbol_begin(), SE = Idx.symbol_end(); SI != SE; ++SI) markLive(*SI); @@ -432,10 +434,10 @@ bool SymbolReaper::isLiveRegion(const MemRegion *MR) { MR = MR->getBaseRegion(); - if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(MR)) + if (const auto *SR = dyn_cast<SymbolicRegion>(MR)) return isLive(SR->getSymbol()); - if (const VarRegion *VR = dyn_cast<VarRegion>(MR)) + if (const auto *VR = dyn_cast<VarRegion>(MR)) return isLive(VR, true); // FIXME: This is a gross over-approximation. What we really need is a way to @@ -533,7 +535,7 @@ bool SymbolReaper::isLive(const VarRegion *VR, bool includeStoreBindings) const{ if (!LCtx) return false; - const StackFrameContext *CurrentContext = LCtx->getCurrentStackFrame(); + const StackFrameContext *CurrentContext = LCtx->getStackFrame(); if (VarContext == CurrentContext) { // If no statement is provided, everything is live. @@ -547,7 +549,7 @@ bool SymbolReaper::isLive(const VarRegion *VR, bool includeStoreBindings) const{ return false; unsigned &cachedQuery = - const_cast<SymbolReaper*>(this)->includedRegionCache[VR]; + const_cast<SymbolReaper *>(this)->includedRegionCache[VR]; if (cachedQuery) { return cachedQuery == 1; |