From: Anna Zaks Date: Fri, 7 Oct 2011 21:01:38 +0000 (+0000) Subject: ProgramPoint cleanup after the previous commit r141408 (remove the copy constructor... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=63d3201619fdac284adfd3b9328562fa20a01c40;p=clang ProgramPoint cleanup after the previous commit r141408 (remove the copy constructor, mark withTag const). Move getProgramPoint() utility from CoreEngine.cpp into ProgramPoint. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141414 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Analysis/ProgramPoint.h b/include/clang/Analysis/ProgramPoint.h index e35c479add..7ec4ecd41b 100644 --- a/include/clang/Analysis/ProgramPoint.h +++ b/include/clang/Analysis/ProgramPoint.h @@ -78,12 +78,9 @@ protected: const void *getData2() const { return Data.second; } public: - ProgramPoint(const ProgramPoint &P) - : Data(P.Data), K(P.K), L(P.L), Tag(P.Tag) {} - /// Create a new ProgramPoint object that is the same as the original /// except for using the specified tag value. - ProgramPoint withTag(const ProgramPointTag *tag) { + ProgramPoint withTag(const ProgramPointTag *tag) const { return ProgramPoint(Data.first, Data.second, K, L, tag); } @@ -117,6 +114,11 @@ public: ID.AddPointer(L); ID.AddPointer(Tag); } + + static ProgramPoint getProgramPoint(const Stmt *S, ProgramPoint::Kind K, + const LocationContext *LC, + const ProgramPointTag *tag); + }; class BlockEntrance : public ProgramPoint { diff --git a/lib/Analysis/ProgramPoint.cpp b/lib/Analysis/ProgramPoint.cpp index 9b7df2c042..3a0bbd5640 100644 --- a/lib/Analysis/ProgramPoint.cpp +++ b/lib/Analysis/ProgramPoint.cpp @@ -18,6 +18,31 @@ using namespace clang; ProgramPointTag::~ProgramPointTag() {} +ProgramPoint ProgramPoint::getProgramPoint(const Stmt *S, ProgramPoint::Kind K, + const LocationContext *LC, + const ProgramPointTag *tag){ + switch (K) { + default: + llvm_unreachable("Unhandled ProgramPoint kind"); + case ProgramPoint::PreStmtKind: + return PreStmt(S, LC, tag); + case ProgramPoint::PostStmtKind: + return PostStmt(S, LC, tag); + case ProgramPoint::PreLoadKind: + return PreLoad(S, LC, tag); + case ProgramPoint::PostLoadKind: + return PostLoad(S, LC, tag); + case ProgramPoint::PreStoreKind: + return PreStore(S, LC, tag); + case ProgramPoint::PostStoreKind: + return PostStore(S, LC, tag); + case ProgramPoint::PostLValueKind: + return PostLValue(S, LC, tag); + case ProgramPoint::PostPurgeDeadSymbolsKind: + return PostPurgeDeadSymbols(S, LC, tag); + } +} + SimpleProgramPointTag::SimpleProgramPointTag(StringRef description) : desc(description) {} diff --git a/lib/StaticAnalyzer/Core/CoreEngine.cpp b/lib/StaticAnalyzer/Core/CoreEngine.cpp index 2511ca778d..c675f608b5 100644 --- a/lib/StaticAnalyzer/Core/CoreEngine.cpp +++ b/lib/StaticAnalyzer/Core/CoreEngine.cpp @@ -541,31 +541,6 @@ ExplodedNode *StmtNodeBuilder::MakeNode(ExplodedNodeSet &Dst, return N; } -static ProgramPoint GetProgramPoint(const Stmt *S, ProgramPoint::Kind K, - const LocationContext *LC, - const ProgramPointTag *tag){ - switch (K) { - default: - llvm_unreachable("Unhandled ProgramPoint kind"); - case ProgramPoint::PreStmtKind: - return PreStmt(S, LC, tag); - case ProgramPoint::PostStmtKind: - return PostStmt(S, LC, tag); - case ProgramPoint::PreLoadKind: - return PreLoad(S, LC, tag); - case ProgramPoint::PostLoadKind: - return PostLoad(S, LC, tag); - case ProgramPoint::PreStoreKind: - return PreStore(S, LC, tag); - case ProgramPoint::PostStoreKind: - return PostStore(S, LC, tag); - case ProgramPoint::PostLValueKind: - return PostLValue(S, LC, tag); - case ProgramPoint::PostPurgeDeadSymbolsKind: - return PostPurgeDeadSymbols(S, LC, tag); - } -} - ExplodedNode* StmtNodeBuilder::generateNodeInternal(const Stmt *S, const ProgramState *state, @@ -573,8 +548,8 @@ StmtNodeBuilder::generateNodeInternal(const Stmt *S, ProgramPoint::Kind K, const ProgramPointTag *tag) { - const ProgramPoint &L = GetProgramPoint(S, K, Pred->getLocationContext(), - tag); + const ProgramPoint &L = ProgramPoint::getProgramPoint(S, K, + Pred->getLocationContext(), tag); return generateNodeInternal(L, state, Pred); }