]> granicus.if.org Git - clang/commitdiff
Simplify more code by using SVal::getAsSymbol().
authorTed Kremenek <kremenek@apple.com>
Mon, 30 Mar 2009 19:53:37 +0000 (19:53 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 30 Mar 2009 19:53:37 +0000 (19:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68052 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/BasicStore.cpp
lib/Analysis/BugReporter.cpp
lib/Analysis/CheckNSError.cpp

index cb6fcab3805d193b6aafead30721d17417dbcee2..28a5b98fc4ed0bce62e2ca36e78ba2b2c6f0d730 100644 (file)
@@ -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<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.
index a240062ef7199a10676a5f354ef8976d2171028f..36515870b8eb028229928010297f159ed2523b60 100644 (file)
@@ -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<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;
   
index a35497a6bfd88fe657dbc1e7c529bb5d9c383d11..ff9da0f659c3687f70675741bed3b2ad1d4410f5 100644 (file)
@@ -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<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 @@ void NSErrorCheck::CheckParamDeref(VarDecl* Param, GRStateRef rootState,
     
     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 ";