]> granicus.if.org Git - clang/commitdiff
[analyzer] Don't generate an explicit ExplodedNode for StringLiterals; have the SVal...
authorTed Kremenek <kremenek@apple.com>
Mon, 27 Feb 2012 23:34:19 +0000 (23:34 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 27 Feb 2012 23:34:19 +0000 (23:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151589 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
lib/StaticAnalyzer/Core/Environment.cpp
lib/StaticAnalyzer/Core/ExprEngine.cpp

index a868e05418f35efab4c695297c2501d0c250eb3f..45f5f1b0e140e48185529147c4ee7170b65e3f25 100644 (file)
@@ -230,9 +230,6 @@ public:
   /// Get the lvalue for a variable reference.
   Loc getLValue(const VarDecl *D, const LocationContext *LC) const;
 
-  /// Get the lvalue for a StringLiteral.
-  Loc getLValue(const StringLiteral *literal) const;
-
   Loc getLValue(const CompoundLiteralExpr *literal, 
                 const LocationContext *LC) const;
 
@@ -636,10 +633,6 @@ inline Loc ProgramState::getLValue(const VarDecl *VD,
   return getStateManager().StoreMgr->getLValueVar(VD, LC);
 }
 
-inline Loc ProgramState::getLValue(const StringLiteral *literal) const {
-  return getStateManager().StoreMgr->getLValueString(literal);
-}
-
 inline Loc ProgramState::getLValue(const CompoundLiteralExpr *literal,
                                const LocationContext *LC) const {
   return getStateManager().StoreMgr->getLValueCompoundLiteral(literal, LC);
index 2be7aa630468ec376bfb648f95b56a5d497bc13d..1c99f40eaf0a4046e8673ed3e8ebc5e8982f0638 100644 (file)
@@ -94,10 +94,6 @@ public:
     return svalBuilder.makeLoc(MRMgr.getVarRegion(VD, LC));
   }
 
-  virtual Loc getLValueString(const StringLiteral* S) {
-    return svalBuilder.makeLoc(MRMgr.getStringRegion(S));
-  }
-
   Loc getLValueCompoundLiteral(const CompoundLiteralExpr *CL,
                                const LocationContext *LC) {
     return loc::MemRegionVal(MRMgr.getCompoundLiteralRegion(CL, LC));
index 74f04ce5a5ae395143acdc50d8531deb691270f7..a44476e850c41dd279731cc91f1ce9b70c1c954d 100644 (file)
@@ -90,6 +90,11 @@ SVal Environment::getSVal(const EnvironmentEntry &Entry,
         continue;
       case Stmt::ObjCPropertyRefExprClass:
         return loc::ObjCPropRef(cast<ObjCPropertyRefExpr>(E));
+      case Stmt::StringLiteralClass: {
+        MemRegionManager &MRMgr = svalBuilder.getRegionManager();
+        const StringLiteral *SL = cast<StringLiteral>(E);
+        return svalBuilder.makeLoc(MRMgr.getStringRegion(SL));
+      }
       case Stmt::ReturnStmtClass: {
         const ReturnStmt *RS = cast<ReturnStmt>(E);
         if (const Expr *RE = RS->getRetValue()) {
index 3cf07feadb6c54cd94e413c80fad961146a1f7f7..77b71decc5240f63c9dd6c79d32c6ca02de6bb3c 100644 (file)
@@ -576,7 +576,6 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
     case Stmt::ObjCIsaExprClass:
     case Stmt::ObjCProtocolExprClass:
     case Stmt::ObjCSelectorExprClass:
-    case Stmt::ObjCStringLiteralClass:
     case Stmt::ParenListExprClass:
     case Stmt::PredefinedExprClass:
     case Stmt::ShuffleVectorExprClass:
@@ -595,6 +594,8 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
     case Stmt::CXXBoolLiteralExprClass:
     case Stmt::FloatingLiteralClass:
     case Stmt::SizeOfPackExprClass:
+    case Stmt::StringLiteralClass:
+    case Stmt::ObjCStringLiteralClass:
     case Stmt::CXXNullPtrLiteralExprClass: {
       Bldr.takeNodes(Pred);
       ExplodedNodeSet preVisit;
@@ -887,14 +888,6 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
       break;
     }
 
-    case Stmt::StringLiteralClass: {
-      ProgramStateRef state = Pred->getState();
-      SVal V = state->getLValue(cast<StringLiteral>(S));
-      Bldr.generateNode(S, Pred, state->BindExpr(S, Pred->getLocationContext(),
-                                                 V));
-      return;
-    }
-
     case Stmt::UnaryOperatorClass: {
       Bldr.takeNodes(Pred);
       const UnaryOperator *U = cast<UnaryOperator>(S);