From: Ted Kremenek Date: Mon, 30 Mar 2009 19:53:37 +0000 (+0000) Subject: Simplify more code by using SVal::getAsSymbol(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=93e71455e932fb6436a154e2c805395558b7d54c;p=clang Simplify more code by using SVal::getAsSymbol(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68052 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp index cb6fcab380..28a5b98fc4 100644 --- a/lib/Analysis/BasicStore.cpp +++ b/lib/Analysis/BasicStore.cpp @@ -239,7 +239,7 @@ SVal BasicStoreManager::getLValueElement(const GRState* St, SVal Base, // FIXME: Should we have symbolic regions be typed or typeless? // Here we assume that these regions are typeless, even though the // symbol is typed. - SymbolRef Sym = cast(&BaseL)->getSymbol(); + SymbolRef Sym = BaseL.getAsSymbol(); // Create a region to represent this symbol. // FIXME: In the future we may just use symbolic regions instead of // SymbolVals to reason about symbolic memory chunks. diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp index a240062ef7..36515870b8 100644 --- a/lib/Analysis/BugReporter.cpp +++ b/lib/Analysis/BugReporter.cpp @@ -635,17 +635,12 @@ public: bool HandleBinding(StoreManager& SMgr, Store store, const MemRegion* R, SVal V) { - SymbolRef ScanSym = 0; - - if (loc::SymbolVal* SV = dyn_cast(&V)) - ScanSym = SV->getSymbol(); - else if (nonloc::SymbolVal* SV = dyn_cast(&V)) - ScanSym = SV->getSymbol(); - else + + SymbolRef ScanSym = V.getAsSymbol(); + + if (!ScanSym) return true; - assert (ScanSym); - if (!BR.isNotable(ScanSym)) return true; diff --git a/lib/Analysis/CheckNSError.cpp b/lib/Analysis/CheckNSError.cpp index a35497a6bf..ff9da0f659 100644 --- a/lib/Analysis/CheckNSError.cpp +++ b/lib/Analysis/CheckNSError.cpp @@ -194,11 +194,11 @@ void NSErrorCheck::CheckParamDeref(VarDecl* Param, GRStateRef rootState, assert (ParamR && "Parameters always have VarRegions."); SVal ParamSVal = rootState.GetSVal(ParamR); - // FIXME: For now assume that ParamSVal is symbolic. We need to generalize // this later. - loc::SymbolVal* SV = dyn_cast(&ParamSVal); - if (!SV) return; + SymbolRef ParamSym = ParamSVal.getAsLocSymbol(); + if (!ParamSym) + return; // Iterate over the implicit-null dereferences. for (GRExprEngine::null_deref_iterator I=Eng.implicit_null_derefs_begin(), @@ -206,13 +206,11 @@ void NSErrorCheck::CheckParamDeref(VarDecl* Param, GRStateRef rootState, GRStateRef state = GRStateRef((*I)->getState(), Eng.getStateManager()); const SVal* X = state.get(); - const loc::SymbolVal* SVX = dyn_cast_or_null(X); - if (!SVX || SVX->getSymbol() != SV->getSymbol()) continue; - - // Emit an error. - + if (!X || X->getAsSymbol() != ParamSym) + continue; + // Emit an error. std::string sbuf; llvm::raw_string_ostream os(sbuf); os << "Potential null dereference. According to coding standards ";