diff options
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/Analysis/PathDiagnostic.h | 2 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/BasicValueFactory.h | 6 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRCoreEngine.h | 22 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRExprEngine.h | 47 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h | 3 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/MemRegion.h | 2 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/ValueManager.h | 4 | ||||
-rw-r--r-- | include/clang/Analysis/ProgramPoint.h | 28 |
8 files changed, 71 insertions, 43 deletions
diff --git a/include/clang/Analysis/PathDiagnostic.h b/include/clang/Analysis/PathDiagnostic.h index 33adcc99ad..8d53cdb679 100644 --- a/include/clang/Analysis/PathDiagnostic.h +++ b/include/clang/Analysis/PathDiagnostic.h @@ -96,6 +96,8 @@ public: bool isValid() const { return SM != 0; } + + const SourceManager& getSourceManager() const { assert(isValid());return *SM;} FullSourceLoc asLocation() const; SourceRange asRange() const; diff --git a/include/clang/Analysis/PathSensitive/BasicValueFactory.h b/include/clang/Analysis/PathSensitive/BasicValueFactory.h index 553f8a31bc..b694e9b299 100644 --- a/include/clang/Analysis/PathSensitive/BasicValueFactory.h +++ b/include/clang/Analysis/PathSensitive/BasicValueFactory.h @@ -126,8 +126,12 @@ public: return getValue(0, Ctx.getTypeSize(Ctx.VoidPtrTy), isUnsigned); } + inline const llvm::APSInt& getTruthValue(bool b, QualType T) { + return getValue(b ? 1 : 0, Ctx.getTypeSize(T), false); + } + inline const llvm::APSInt& getTruthValue(bool b) { - return getValue(b ? 1 : 0, Ctx.getTypeSize(Ctx.IntTy), false); + return getTruthValue(b, Ctx.IntTy); } const CompoundValData* getCompoundValData(QualType T, diff --git a/include/clang/Analysis/PathSensitive/GRCoreEngine.h b/include/clang/Analysis/PathSensitive/GRCoreEngine.h index 5bd76a034b..fe8634edad 100644 --- a/include/clang/Analysis/PathSensitive/GRCoreEngine.h +++ b/include/clang/Analysis/PathSensitive/GRCoreEngine.h @@ -146,14 +146,23 @@ public: ExplodedNodeImpl* generateNodeImpl(Stmt* S, const void* State, ExplodedNodeImpl* Pred, - ProgramPoint::Kind K = ProgramPoint::PostStmtKind); + ProgramPoint::Kind K = ProgramPoint::PostStmtKind, + const void *tag = 0); ExplodedNodeImpl* generateNodeImpl(Stmt* S, const void* State, - ProgramPoint::Kind K = ProgramPoint::PostStmtKind) { + ProgramPoint::Kind K = ProgramPoint::PostStmtKind, + const void *tag = 0) { ExplodedNodeImpl* N = getLastNode(); assert (N && "Predecessor of new node is infeasible."); - return generateNodeImpl(S, State, N, K); + return generateNodeImpl(S, State, N, K, tag); + } + + ExplodedNodeImpl* + generateNodeImpl(Stmt* S, const void* State, const void *tag = 0) { + ExplodedNodeImpl* N = getLastNode(); + assert (N && "Predecessor of new node is infeasible."); + return generateNodeImpl(S, State, N, ProgramPoint::PostStmtKind, tag); } /// getStmt - Return the current block-level expression associated with @@ -183,7 +192,7 @@ public: GRStmtNodeBuilder(GRStmtNodeBuilderImpl& nb, StateManagerTy& mgr) : NB(nb), Mgr(mgr), Auditor(0), PurgingDeadSymbols(false), BuildSinks(false), HasGeneratedNode(false), - PointKind(ProgramPoint::PostStmtKind) { + PointKind(ProgramPoint::PostStmtKind), Tag(0) { CleanedState = getLastNode()->getState(); } @@ -204,7 +213,7 @@ public: ProgramPoint::Kind K) { HasGeneratedNode = true; if (PurgingDeadSymbols) K = ProgramPoint::PostPurgeDeadSymbolsKind; - return static_cast<NodeTy*>(NB.generateNodeImpl(S, St, Pred, K)); + return static_cast<NodeTy*>(NB.generateNodeImpl(S, St, Pred, K, Tag)); } NodeTy* generateNode(Stmt* S, const StateTy* St, NodeTy* Pred) { @@ -214,7 +223,7 @@ public: NodeTy* generateNode(Stmt* S, const StateTy* St, ProgramPoint::Kind K) { HasGeneratedNode = true; if (PurgingDeadSymbols) K = ProgramPoint::PostPurgeDeadSymbolsKind; - return static_cast<NodeTy*>(NB.generateNodeImpl(S, St, K)); + return static_cast<NodeTy*>(NB.generateNodeImpl(S, St, K, Tag)); } NodeTy* generateNode(Stmt* S, const StateTy* St) { @@ -286,6 +295,7 @@ public: bool BuildSinks; bool HasGeneratedNode; ProgramPoint::Kind PointKind; + const void *Tag; }; class GRBranchNodeBuilderImpl { diff --git a/include/clang/Analysis/PathSensitive/GRExprEngine.h b/include/clang/Analysis/PathSensitive/GRExprEngine.h index 29acc707da..bc036b6a19 100644 --- a/include/clang/Analysis/PathSensitive/GRExprEngine.h +++ b/include/clang/Analysis/PathSensitive/GRExprEngine.h @@ -538,11 +538,11 @@ protected: return StateMgr.AssumeInBound(St, Idx, UpperBound, Assumption, isFeasible); } +public: NodeTy* MakeNode(NodeSet& Dst, Stmt* S, NodeTy* Pred, const GRState* St, - ProgramPoint::Kind K = ProgramPoint::PostStmtKind) { - assert (Builder && "GRStmtNodeBuilder not present."); - return Builder->MakeNode(Dst, S, Pred, St, K); - } + ProgramPoint::Kind K = ProgramPoint::PostStmtKind, + const void *tag = 0); +protected: /// Visit - Transfer function logic for all statements. Dispatches to /// other functions that handle specific kinds of statements. @@ -673,6 +673,8 @@ protected: return X.isValid() ? getTF().EvalComplement(*this, cast<NonLoc>(X)) : X; } +public: + SVal EvalBinOp(BinaryOperator::Opcode Op, NonLoc L, NonLoc R, QualType T) { return R.isValid() ? getTF().DetermEvalBinOpNN(*this, Op, L, R, T) : R; @@ -692,40 +694,41 @@ protected: SVal EvalBinOp(BinaryOperator::Opcode Op, SVal L, SVal R, QualType T); - void EvalCall(NodeSet& Dst, CallExpr* CE, SVal L, NodeTy* Pred) { - assert (Builder && "GRStmtNodeBuilder must be defined."); - getTF().EvalCall(Dst, *this, *Builder, CE, L, Pred); - } +protected: + + void EvalCall(NodeSet& Dst, CallExpr* CE, SVal L, NodeTy* Pred); void EvalObjCMessageExpr(NodeSet& Dst, ObjCMessageExpr* ME, NodeTy* Pred) { assert (Builder && "GRStmtNodeBuilder must be defined."); getTF().EvalObjCMessageExpr(Dst, *this, *Builder, ME, Pred); } + + void EvalReturn(NodeSet& Dst, ReturnStmt* s, NodeTy* Pred); + + const GRState* MarkBranch(const GRState* St, Stmt* Terminator, + bool branchTaken); /// EvalBind - Handle the semantics of binding a value to a specific location. /// This method is used by EvalStore, VisitDeclStmt, and others. void EvalBind(NodeSet& Dst, Expr* Ex, NodeTy* Pred, const GRState* St, SVal location, SVal Val); - void EvalStore(NodeSet& Dst, Expr* E, NodeTy* Pred, const GRState* St, - SVal TargetLV, SVal Val); - - void EvalStore(NodeSet& Dst, Expr* E, Expr* StoreE, NodeTy* Pred, - const GRState* St, SVal TargetLV, SVal Val); - - // FIXME: The "CheckOnly" option exists only because Array and Field - // loads aren't fully implemented. Eventually this option will go away. - +public: void EvalLoad(NodeSet& Dst, Expr* Ex, NodeTy* Pred, - const GRState* St, SVal location); + const GRState* St, SVal location, const void *tag = 0); NodeTy* EvalLocation(Stmt* Ex, NodeTy* Pred, - const GRState* St, SVal location); + const GRState* St, SVal location, + const void *tag = 0); + - void EvalReturn(NodeSet& Dst, ReturnStmt* s, NodeTy* Pred); + void EvalStore(NodeSet& Dst, Expr* E, NodeTy* Pred, const GRState* St, + SVal TargetLV, SVal Val, const void *tag = 0); + + void EvalStore(NodeSet& Dst, Expr* E, Expr* StoreE, NodeTy* Pred, + const GRState* St, SVal TargetLV, SVal Val, + const void *tag = 0); - const GRState* MarkBranch(const GRState* St, Stmt* Terminator, - bool branchTaken); }; } // end clang namespace diff --git a/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h b/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h index 074fb2233d..6c23745de2 100644 --- a/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h +++ b/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h @@ -52,6 +52,7 @@ class GRStmtNodeBuilderRef { const unsigned OldSize; const bool AutoCreateNode; SaveAndRestore<bool> OldSink; + SaveAndRestore<const void*> OldTag; SaveOr OldHasGen; private: @@ -68,7 +69,7 @@ private: const Stmt* s, bool auto_create_node) : Dst(dst), B(builder), Eng(eng), Pred(pred), state(st), stmt(s), OldSize(Dst.size()), AutoCreateNode(auto_create_node), - OldSink(B.BuildSinks), OldHasGen(B.HasGeneratedNode) {} + OldSink(B.BuildSinks), OldTag(B.Tag), OldHasGen(B.HasGeneratedNode) {} public: diff --git a/include/clang/Analysis/PathSensitive/MemRegion.h b/include/clang/Analysis/PathSensitive/MemRegion.h index 4f720d2522..af63386136 100644 --- a/include/clang/Analysis/PathSensitive/MemRegion.h +++ b/include/clang/Analysis/PathSensitive/MemRegion.h @@ -320,6 +320,8 @@ public: static bool classof(const MemRegion* R) { return R->getKind() == TypedViewRegionKind; } + + const MemRegion *removeViews() const; }; diff --git a/include/clang/Analysis/PathSensitive/ValueManager.h b/include/clang/Analysis/PathSensitive/ValueManager.h index aeabec80de..9842983b2c 100644 --- a/include/clang/Analysis/PathSensitive/ValueManager.h +++ b/include/clang/Analysis/PathSensitive/ValueManager.h @@ -91,7 +91,9 @@ public: const llvm::APSInt& rhs, QualType T); NonLoc makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op, - const SymExpr *rhs, QualType T); + const SymExpr *rhs, QualType T); + + NonLoc makeTruthVal(bool b, QualType T); }; } // end clang namespace #endif diff --git a/include/clang/Analysis/ProgramPoint.h b/include/clang/Analysis/ProgramPoint.h index 7c73a1f25d..1587371961 100644 --- a/include/clang/Analysis/ProgramPoint.h +++ b/include/clang/Analysis/ProgramPoint.h @@ -57,9 +57,9 @@ protected: : Data(reinterpret_cast<uintptr_t>(P1) | TwoPointers, reinterpret_cast<uintptr_t>(P2)), Tag(tag) {} - ProgramPoint(const void* P1, const void* P2, bool) + ProgramPoint(const void* P1, const void* P2, bool, const void *tag = 0) : Data(reinterpret_cast<uintptr_t>(P1) | Custom, - reinterpret_cast<uintptr_t>(P2)), Tag(0) {} + reinterpret_cast<uintptr_t>(P2)), Tag(tag) {} protected: void* getData1NoMask() const { @@ -173,10 +173,13 @@ protected: PostStmt(const Stmt* S, Kind k,const void *tag = 0) : ProgramPoint(S, k, tag) {} - PostStmt(const Stmt* S, const void* data) : ProgramPoint(S, data, true) {} + PostStmt(const Stmt* S, const void* data, bool, const void *tag =0) + : ProgramPoint(S, data, true, tag) {} public: - PostStmt(const Stmt* S) : ProgramPoint(S, PostStmtKind) {} + PostStmt(const Stmt* S, const void *tag = 0) + : ProgramPoint(S, PostStmtKind, tag) {} + Stmt* getStmt() const { return (Stmt*) getData1(); } @@ -200,7 +203,7 @@ class PostStmtCustom : public PostStmt { public: PostStmtCustom(const Stmt* S, const std::pair<const void*, const void*>* TaggedData) - : PostStmt(S, TaggedData) { + : PostStmt(S, TaggedData, true) { assert(getKind() == PostStmtCustomKind); } @@ -219,8 +222,8 @@ public: class PostOutOfBoundsCheckFailed : public PostStmt { public: - PostOutOfBoundsCheckFailed(const Stmt* S) - : PostStmt(S, PostOutOfBoundsCheckFailedKind) {} + PostOutOfBoundsCheckFailed(const Stmt* S, const void *tag = 0) + : PostStmt(S, PostOutOfBoundsCheckFailedKind, tag) {} static bool classof(const ProgramPoint* Location) { return Location->getKind() == PostOutOfBoundsCheckFailedKind; @@ -229,8 +232,8 @@ public: class PostUndefLocationCheckFailed : public PostStmt { public: - PostUndefLocationCheckFailed(const Stmt* S) - : PostStmt(S, PostUndefLocationCheckFailedKind) {} + PostUndefLocationCheckFailed(const Stmt* S, const void *tag = 0) + : PostStmt(S, PostUndefLocationCheckFailedKind, tag) {} static bool classof(const ProgramPoint* Location) { return Location->getKind() == PostUndefLocationCheckFailedKind; @@ -239,8 +242,8 @@ public: class PostNullCheckFailed : public PostStmt { public: - PostNullCheckFailed(const Stmt* S) - : PostStmt(S, PostNullCheckFailedKind) {} + PostNullCheckFailed(const Stmt* S, const void *tag = 0) + : PostStmt(S, PostNullCheckFailedKind, tag) {} static bool classof(const ProgramPoint* Location) { return Location->getKind() == PostNullCheckFailedKind; @@ -269,7 +272,8 @@ public: class PostPurgeDeadSymbols : public PostStmt { public: - PostPurgeDeadSymbols(const Stmt* S) : PostStmt(S, PostPurgeDeadSymbolsKind) {} + PostPurgeDeadSymbols(const Stmt* S, const void *tag = 0) + : PostStmt(S, PostPurgeDeadSymbolsKind, tag) {} static bool classof(const ProgramPoint* Location) { return Location->getKind() == PostPurgeDeadSymbolsKind; |