[cfe-commits] r68052 - in /cfe/trunk/lib/Analysis: BasicStore.cpp BugReporter.cpp CheckNSError.cpp
Ted Kremenek
kremenek at apple.com
Mon Mar 30 12:53:37 PDT 2009
Author: kremenek
Date: Mon Mar 30 14:53:37 2009
New Revision: 68052
URL: http://llvm.org/viewvc/llvm-project?rev=68052&view=rev
Log:
Simplify more code by using SVal::getAsSymbol().
Modified:
cfe/trunk/lib/Analysis/BasicStore.cpp
cfe/trunk/lib/Analysis/BugReporter.cpp
cfe/trunk/lib/Analysis/CheckNSError.cpp
Modified: cfe/trunk/lib/Analysis/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicStore.cpp?rev=68052&r1=68051&r2=68052&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicStore.cpp Mon Mar 30 14:53:37 2009
@@ -239,7 +239,7 @@
// 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<loc::SymbolVal>(&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.
Modified: cfe/trunk/lib/Analysis/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BugReporter.cpp?rev=68052&r1=68051&r2=68052&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Mon Mar 30 14:53:37 2009
@@ -635,17 +635,12 @@
bool HandleBinding(StoreManager& SMgr, Store store,
const MemRegion* R, SVal V) {
- SymbolRef ScanSym = 0;
-
- if (loc::SymbolVal* SV = dyn_cast<loc::SymbolVal>(&V))
- ScanSym = SV->getSymbol();
- else if (nonloc::SymbolVal* SV = dyn_cast<nonloc::SymbolVal>(&V))
- ScanSym = SV->getSymbol();
- else
+
+ SymbolRef ScanSym = V.getAsSymbol();
+
+ if (!ScanSym)
return true;
- assert (ScanSym);
-
if (!BR.isNotable(ScanSym))
return true;
Modified: cfe/trunk/lib/Analysis/CheckNSError.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckNSError.cpp?rev=68052&r1=68051&r2=68052&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CheckNSError.cpp (original)
+++ cfe/trunk/lib/Analysis/CheckNSError.cpp Mon Mar 30 14:53:37 2009
@@ -194,11 +194,11 @@
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<loc::SymbolVal>(&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 @@
GRStateRef state = GRStateRef((*I)->getState(), Eng.getStateManager());
const SVal* X = state.get<GRState::NullDerefTag>();
- const loc::SymbolVal* SVX = dyn_cast_or_null<loc::SymbolVal>(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 ";
More information about the cfe-commits
mailing list