From: Ted Kremenek Date: Thu, 7 May 2009 18:27:16 +0000 (+0000) Subject: analyzer: Add ProgramPoint 'PostLValue' just to distinguish (for X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7090d5465de7ca620da16211cf886edf1edc1f1f;p=clang analyzer: Add ProgramPoint 'PostLValue' just to distinguish (for analysis introspection) when we computed an lvalue. This shouldn't effect the current analysis results in any way. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71169 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Analysis/ProgramPoint.h b/include/clang/Analysis/ProgramPoint.h index 1587371961..074a262038 100644 --- a/include/clang/Analysis/ProgramPoint.h +++ b/include/clang/Analysis/ProgramPoint.h @@ -39,8 +39,9 @@ public: PostStoreKind = 0x9, PostPurgeDeadSymbolsKind = 0x10, PostStmtCustomKind = 0x11, + PostLValueKind = 0x12, MinPostStmtKind = PostStmtKind, - MaxPostStmtKind = PostStmtCustomKind }; + MaxPostStmtKind = PostLValueKind }; private: enum { TwoPointers = 0x1, Custom = 0x2, Mask = 0x3 }; @@ -269,6 +270,16 @@ public: return Location->getKind() == PostStoreKind; } }; + +class PostLValue : public PostStmt { +public: + PostLValue(const Stmt* S, const void *tag = 0) + : PostStmt(S, PostLValueKind, tag) {} + + static bool classof(const ProgramPoint* Location) { + return Location->getKind() == PostLValueKind; + } +}; class PostPurgeDeadSymbols : public PostStmt { public: diff --git a/lib/Analysis/GRCoreEngine.cpp b/lib/Analysis/GRCoreEngine.cpp index 46a2173c96..8bbf71e90a 100644 --- a/lib/Analysis/GRCoreEngine.cpp +++ b/lib/Analysis/GRCoreEngine.cpp @@ -417,6 +417,9 @@ static inline PostStmt GetPostLoc(Stmt* S, ProgramPoint::Kind K, case ProgramPoint::PostStoreKind: return PostStore(S, tag); + case ProgramPoint::PostLValueKind: + return PostLValue(S, tag); + case ProgramPoint::PostPurgeDeadSymbolsKind: return PostPurgeDeadSymbols(S, tag); } diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index 0fabd35b0b..7054f3c0bb 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -963,7 +963,8 @@ void GRExprEngine::VisitDeclRefExpr(DeclRefExpr* Ex, NodeTy* Pred, NodeSet& Dst, SVal V = StateMgr.GetLValue(state, VD); if (asLValue) - MakeNode(Dst, Ex, Pred, BindExpr(state, Ex, V)); + MakeNode(Dst, Ex, Pred, BindExpr(state, Ex, V), + ProgramPoint::PostLValueKind); else EvalLoad(Dst, Ex, Pred, state, V); return; @@ -979,7 +980,8 @@ void GRExprEngine::VisitDeclRefExpr(DeclRefExpr* Ex, NodeTy* Pred, NodeSet& Dst, } else if (const FunctionDecl* FD = dyn_cast(D)) { assert(asLValue); SVal V = ValMgr.getFunctionPointer(FD); - MakeNode(Dst, Ex, Pred, BindExpr(state, Ex, V)); + MakeNode(Dst, Ex, Pred, BindExpr(state, Ex, V), + ProgramPoint::PostLValueKind); return; } @@ -1016,7 +1018,8 @@ void GRExprEngine::VisitArraySubscriptExpr(ArraySubscriptExpr* A, NodeTy* Pred, GetSVal(state, Idx)); if (asLValue) - MakeNode(Dst, A, *I2, BindExpr(state, A, V)); + MakeNode(Dst, A, *I2, BindExpr(state, A, V), + ProgramPoint::PostLValueKind); else EvalLoad(Dst, A, *I2, state, V); } @@ -1047,7 +1050,8 @@ void GRExprEngine::VisitMemberExpr(MemberExpr* M, NodeTy* Pred, SVal L = StateMgr.GetLValue(state, GetSVal(state, Base), Field); if (asLValue) - MakeNode(Dst, M, *I, BindExpr(state, M, L)); + MakeNode(Dst, M, *I, BindExpr(state, M, L), + ProgramPoint::PostLValueKind); else EvalLoad(Dst, M, *I, state, L); } @@ -2464,7 +2468,8 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred, SVal location = GetSVal(state, Ex); if (asLValue) - MakeNode(Dst, U, *I, BindExpr(state, U, location)); + MakeNode(Dst, U, *I, BindExpr(state, U, location), + ProgramPoint::PostLValueKind); else EvalLoad(Dst, U, *I, state, location); } @@ -3241,6 +3246,17 @@ struct VISIBILITY_HIDDEN DOTGraphTraits : << "\\l"; } + if (isa(Loc)) + Out << "\\lPostLoad\\l;"; + else if (isa(Loc)) + Out << "\\lPostStore\\l"; + else if (isa(Loc)) + Out << "\\lPostLValue\\l"; + else if (isa(Loc)) + Out << "\\lPostLocationChecksSucceed\\l"; + else if (isa(Loc)) + Out << "\\lPostNullCheckFailed\\l"; + if (GraphPrintCheckerState->isImplicitNullDeref(N)) Out << "\\|Implicit-Null Dereference.\\l"; else if (GraphPrintCheckerState->isExplicitNullDeref(N))