From 0d6e8af229d33ca065bc6174f30f7466299f60a1 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 13 Jan 2011 04:36:46 +0000 Subject: [PATCH] Rename 'HasGeneratedNode' to 'hasGeneratedNode' and 'getBasePredecessor()' to 'getPredecessor()'. Also remove a unneeded save-and-restore of node builder's tag field. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123363 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../clang/StaticAnalyzer/PathSensitive/Checker.h | 2 +- .../StaticAnalyzer/PathSensitive/CoreEngine.h | 21 +++++++-------- .../PathSensitive/ExprEngineBuilders.h | 5 ++-- lib/StaticAnalyzer/Checker.cpp | 2 +- lib/StaticAnalyzer/Checkers/ExprEngine.cpp | 31 ++++++++++------------ lib/StaticAnalyzer/CoreEngine.cpp | 12 ++++----- 6 files changed, 34 insertions(+), 39 deletions(-) diff --git a/include/clang/StaticAnalyzer/PathSensitive/Checker.h b/include/clang/StaticAnalyzer/PathSensitive/Checker.h index 3b3952c20..f363fcc85 100644 --- a/include/clang/StaticAnalyzer/PathSensitive/Checker.h +++ b/include/clang/StaticAnalyzer/PathSensitive/Checker.h @@ -50,7 +50,7 @@ public: OldSink(B.BuildSinks), checkerTag(tag), OldPointKind(B.PointKind, K), - OldHasGen(B.HasGeneratedNode), + OldHasGen(B.hasGeneratedNode), ST(st), statement(stmt), size(Dst.size()), respondsToCallback(respondsToCB) {} diff --git a/include/clang/StaticAnalyzer/PathSensitive/CoreEngine.h b/include/clang/StaticAnalyzer/PathSensitive/CoreEngine.h index a59b7a236..133507700 100644 --- a/include/clang/StaticAnalyzer/PathSensitive/CoreEngine.h +++ b/include/clang/StaticAnalyzer/PathSensitive/CoreEngine.h @@ -145,7 +145,7 @@ class StmtNodeBuilder { public: bool PurgingDeadSymbols; bool BuildSinks; - bool HasGeneratedNode; + bool hasGeneratedNode; ProgramPoint::Kind PointKind; const void *Tag; @@ -163,7 +163,7 @@ public: ~StmtNodeBuilder(); - ExplodedNode* getBasePredecessor() const { return Pred; } + ExplodedNode* getPredecessor() const { return Pred; } // FIXME: This should not be exposed. WorkList *getWorkList() { return Eng.WList; } @@ -181,14 +181,14 @@ public: } ExplodedNode* generateNode(PostStmt PP,const GRState* St,ExplodedNode* Pred) { - HasGeneratedNode = true; + hasGeneratedNode = true; return generateNodeInternal(PP, St, Pred); } ExplodedNode* generateNode(const Stmt *S, const GRState *St, ExplodedNode *Pred, ProgramPoint::Kind K, const void *tag = 0) { - HasGeneratedNode = true; + hasGeneratedNode = true; if (PurgingDeadSymbols) K = ProgramPoint::PostPurgeDeadSymbolsKind; @@ -203,7 +203,7 @@ public: ExplodedNode *generateNode(const ProgramPoint &PP, const GRState* State, ExplodedNode* Pred) { - HasGeneratedNode = true; + hasGeneratedNode = true; return generateNodeInternal(PP, State, Pred); } @@ -233,7 +233,7 @@ public: unsigned getIndex() const { return Idx; } const GRState* GetState(ExplodedNode* Pred) const { - if (Pred == getBasePredecessor()) + if (Pred == getPredecessor()) return CleanedState; else return Pred->getState(); @@ -403,7 +403,6 @@ class GenericNodeBuilderImpl { protected: CoreEngine &engine; ExplodedNode *pred; - bool HasGeneratedNode; ProgramPoint pp; llvm::SmallVector sinksGenerated; @@ -411,10 +410,10 @@ protected: ProgramPoint programPoint, bool asSink); GenericNodeBuilderImpl(CoreEngine &eng, ExplodedNode *pr, ProgramPoint p) - : engine(eng), pred(pr), HasGeneratedNode(false), pp(p) {} + : engine(eng), pred(pr), pp(p), hasGeneratedNode(false) {} public: - bool hasGeneratedNode() const { return HasGeneratedNode; } + bool hasGeneratedNode; WorkList &getWorkList() { return *engine.WList; } @@ -450,11 +449,11 @@ class EndOfFunctionNodeBuilder { ExplodedNode* Pred; public: - bool HasGeneratedNode; + bool hasGeneratedNode; public: EndOfFunctionNodeBuilder(const CFGBlock* b, ExplodedNode* N, CoreEngine* e) - : Eng(*e), B(*b), Pred(N), HasGeneratedNode(false) {} + : Eng(*e), B(*b), Pred(N), hasGeneratedNode(false) {} ~EndOfFunctionNodeBuilder(); diff --git a/include/clang/StaticAnalyzer/PathSensitive/ExprEngineBuilders.h b/include/clang/StaticAnalyzer/PathSensitive/ExprEngineBuilders.h index 965ec3e1c..52b2f79c7 100644 --- a/include/clang/StaticAnalyzer/PathSensitive/ExprEngineBuilders.h +++ b/include/clang/StaticAnalyzer/PathSensitive/ExprEngineBuilders.h @@ -31,7 +31,6 @@ class StmtNodeBuilderRef { const unsigned OldSize; const bool AutoCreateNode; SaveAndRestore OldSink; - SaveAndRestore OldTag; SaveOr OldHasGen; private: @@ -48,14 +47,14 @@ 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), OldTag(B.Tag), OldHasGen(B.HasGeneratedNode) {} + OldSink(B.BuildSinks), OldHasGen(B.hasGeneratedNode) {} public: ~StmtNodeBuilderRef() { // Handle the case where no nodes where generated. Auto-generate that // contains the updated state if we aren't generating sinks. - if (!B.BuildSinks && Dst.size() == OldSize && !B.HasGeneratedNode) { + if (!B.BuildSinks && Dst.size() == OldSize && !B.hasGeneratedNode) { if (AutoCreateNode) B.MakeNode(Dst, const_cast(stmt), Pred, state); else diff --git a/lib/StaticAnalyzer/Checker.cpp b/lib/StaticAnalyzer/Checker.cpp index 2ee910f8d..c5112339c 100644 --- a/lib/StaticAnalyzer/Checker.cpp +++ b/lib/StaticAnalyzer/Checker.cpp @@ -24,7 +24,7 @@ CheckerContext::~CheckerContext() { // without actually generated a new node. We also shouldn't autotransition // if we are building sinks or we generated a node and decided to not // add it as a transition. - if (Dst.size() == size && !B.BuildSinks && !B.HasGeneratedNode) { + if (Dst.size() == size && !B.BuildSinks && !B.hasGeneratedNode) { if (ST && ST != B.GetState(Pred)) { static int autoTransitionTag = 0; addTransition(ST, &autoTransitionTag); diff --git a/lib/StaticAnalyzer/Checkers/ExprEngine.cpp b/lib/StaticAnalyzer/Checkers/ExprEngine.cpp index e912273e1..1577cbee3 100644 --- a/lib/StaticAnalyzer/Checkers/ExprEngine.cpp +++ b/lib/StaticAnalyzer/Checkers/ExprEngine.cpp @@ -541,7 +541,7 @@ void ExprEngine::ProcessStmt(const CFGStmt S, StmtNodeBuilder& builder) { "Error evaluating statement"); Builder = &builder; - EntryNode = builder.getBasePredecessor(); + EntryNode = builder.getPredecessor(); // Create the cleaned state. const LocationContext *LC = EntryNode->getLocationContext(); @@ -569,7 +569,7 @@ void ExprEngine::ProcessStmt(const CFGStmt S, StmtNodeBuilder& builder) { Tmp.Add(EntryNode); else { SaveAndRestore OldSink(Builder->BuildSinks); - SaveOr OldHasGen(Builder->HasGeneratedNode); + SaveOr OldHasGen(Builder->hasGeneratedNode); SaveAndRestore OldPurgeDeadSymbols(Builder->PurgingDeadSymbols); Builder->PurgingDeadSymbols = true; @@ -604,7 +604,7 @@ void ExprEngine::ProcessStmt(const CFGStmt S, StmtNodeBuilder& builder) { } } - if (!Builder->BuildSinks && !Builder->HasGeneratedNode) + if (!Builder->BuildSinks && !Builder->hasGeneratedNode) Tmp.Add(EntryNode); } @@ -623,7 +623,7 @@ void ExprEngine::ProcessStmt(const CFGStmt S, StmtNodeBuilder& builder) { // a node with a "cleaned" state; CoreEngine will actually handle // auto-transitions for other cases. if (Dst.size() == 1 && *Dst.begin() == EntryNode - && !Builder->HasGeneratedNode && !HasAutoGenerated) { + && !Builder->hasGeneratedNode && !HasAutoGenerated) { HasAutoGenerated = true; builder.generateNode(currentStmt, GetState(EntryNode), *I); } @@ -643,7 +643,7 @@ void ExprEngine::ProcessInitializer(const CFGInitializer Init, // We don't set EntryNode and currentStmt. And we don't clean up state. const CXXCtorInitializer *BMI = Init.getInitializer(); - ExplodedNode *Pred = builder.getBasePredecessor(); + ExplodedNode *Pred = builder.getPredecessor(); const LocationContext *LC = Pred->getLocationContext(); if (BMI->isAnyMemberInitializer()) { @@ -699,7 +699,7 @@ void ExprEngine::ProcessImplicitDtor(const CFGImplicitDtor D, void ExprEngine::ProcessAutomaticObjDtor(const CFGAutomaticObjDtor dtor, StmtNodeBuilder &builder) { - ExplodedNode *pred = builder.getBasePredecessor(); + ExplodedNode *pred = builder.getPredecessor(); const GRState *state = pred->getState(); const VarDecl *varDecl = dtor.getVarDecl(); @@ -1754,7 +1754,6 @@ void ExprEngine::evalStore(ExplodedNodeSet& Dst, const Expr *AssignE, SaveAndRestore OldSPointKind(Builder->PointKind, ProgramPoint::PostStoreKind); - SaveAndRestore OldTag(Builder->Tag, tag); // Proceed with the store. We use AssignE as the anchor for the PostStore // ProgramPoint if it is non-NULL, and LocationE otherwise. @@ -1811,7 +1810,6 @@ void ExprEngine::evalLoadCommon(ExplodedNodeSet& Dst, const Expr *Ex, assert(!location.isUndef()); SaveAndRestore OldSPointKind(Builder->PointKind); - SaveAndRestore OldTag(Builder->Tag); // Proceed with the load. for (ExplodedNodeSet::iterator NI=Tmp.begin(), NE=Tmp.end(); NI!=NE; ++NI) { @@ -1971,7 +1969,7 @@ void ExprEngine::VisitCall(const CallExpr* CE, ExplodedNode* Pred, // Dispatch to the plug-in transfer function. unsigned oldSize = DstTmp3.size(); - SaveOr OldHasGen(Builder->HasGeneratedNode); + SaveOr OldHasGen(Builder->hasGeneratedNode); Pred = *DI_Checker; // Dispatch to transfer function logic to handle the call itself. @@ -1982,7 +1980,7 @@ void ExprEngine::VisitCall(const CallExpr* CE, ExplodedNode* Pred, // Handle the case where no nodes where generated. Auto-generate that // contains the updated state if we aren't generating sinks. if (!Builder->BuildSinks && DstTmp3.size() == oldSize && - !Builder->HasGeneratedNode) + !Builder->hasGeneratedNode) MakeNode(DstTmp3, CE, Pred, state); } } @@ -2260,7 +2258,7 @@ void ExprEngine::VisitObjCMessageExpr(const ObjCMessageExpr* ME, bool RaisesException = false; unsigned oldSize = dstEval.size(); SaveAndRestore OldSink(Builder->BuildSinks); - SaveOr OldHasGen(Builder->HasGeneratedNode); + SaveOr OldHasGen(Builder->hasGeneratedNode); if (const Expr *Receiver = ME->getInstanceReceiver()) { const GRState *state = GetState(Pred); @@ -2344,7 +2342,7 @@ void ExprEngine::VisitObjCMessageExpr(const ObjCMessageExpr* ME, // Handle the case where no nodes where generated. Auto-generate that // contains the updated state if we aren't generating sinks. if (!Builder->BuildSinks && dstEval.size() == oldSize && - !Builder->HasGeneratedNode) + !Builder->hasGeneratedNode) MakeNode(dstEval, ME, Pred, GetState(Pred)); } @@ -3082,11 +3080,10 @@ void ExprEngine::VisitReturnStmt(const ReturnStmt *RS, ExplodedNode *Pred, // Record the returned expression in the state. It will be used in // processCallExit to bind the return value to the call expr. { - static int Tag = 0; - SaveAndRestore OldTag(Builder->Tag, &Tag); + static int tag = 0; const GRState *state = GetState(Pred); state = state->set(RetE); - Pred = Builder->generateNode(RetE, state, Pred); + Pred = Builder->generateNode(RetE, state, Pred, &tag); } // We may get a NULL Pred because we generated a cached node. if (Pred) @@ -3108,13 +3105,13 @@ void ExprEngine::VisitReturnStmt(const ReturnStmt *RS, ExplodedNode *Pred, unsigned size = Dst.size(); SaveAndRestore OldSink(Builder->BuildSinks); - SaveOr OldHasGen(Builder->HasGeneratedNode); + SaveOr OldHasGen(Builder->hasGeneratedNode); getTF().evalReturn(Dst, *this, *Builder, RS, Pred); // Handle the case where no nodes where generated. if (!Builder->BuildSinks && Dst.size() == size && - !Builder->HasGeneratedNode) + !Builder->hasGeneratedNode) MakeNode(Dst, RS, Pred, GetState(Pred)); } } diff --git a/lib/StaticAnalyzer/CoreEngine.cpp b/lib/StaticAnalyzer/CoreEngine.cpp index 9ccc4472f..13cca35aa 100644 --- a/lib/StaticAnalyzer/CoreEngine.cpp +++ b/lib/StaticAnalyzer/CoreEngine.cpp @@ -295,7 +295,7 @@ void CoreEngine::HandleBlockEdge(const BlockEdge& L, ExplodedNode* Pred) { SubEng.processCFGBlockEntrance(dstNodes, nodeBuilder); if (dstNodes.empty()) { - if (!nodeBuilder.hasGeneratedNode()) { + if (!nodeBuilder.hasGeneratedNode) { // Auto-generate a node and enqueue it to the worklist. generateNode(BE, Pred->State, Pred); } @@ -468,7 +468,7 @@ GenericNodeBuilderImpl::generateNodeImpl(const GRState *state, ProgramPoint programPoint, bool asSink) { - HasGeneratedNode = true; + hasGeneratedNode = true; bool isNew; ExplodedNode *node = engine.getGraph().getNode(programPoint, state, &isNew); if (pred) @@ -487,7 +487,7 @@ StmtNodeBuilder::StmtNodeBuilder(const CFGBlock* b, unsigned idx, ExplodedNode* N, CoreEngine* e, GRStateManager &mgr) : Eng(*e), B(*b), Idx(idx), Pred(N), Mgr(mgr), - PurgingDeadSymbols(false), BuildSinks(false), HasGeneratedNode(false), + PurgingDeadSymbols(false), BuildSinks(false), hasGeneratedNode(false), PointKind(ProgramPoint::PostStmtKind), Tag(0) { Deferred.insert(N); CleanedState = Pred->getState(); @@ -706,7 +706,7 @@ SwitchNodeBuilder::generateDefaultCaseNode(const GRState* St, bool isSink) { EndOfFunctionNodeBuilder::~EndOfFunctionNodeBuilder() { // Auto-generate an EOP node if one has not been generated. - if (!HasGeneratedNode) { + if (!hasGeneratedNode) { // If we are in an inlined call, generate CallExit node. if (Pred->getLocationContext()->getParent()) GenerateCallExitNode(Pred->State); @@ -718,7 +718,7 @@ EndOfFunctionNodeBuilder::~EndOfFunctionNodeBuilder() { ExplodedNode* EndOfFunctionNodeBuilder::generateNode(const GRState* State, const void *tag, ExplodedNode* P) { - HasGeneratedNode = true; + hasGeneratedNode = true; bool IsNew; ExplodedNode* Node = Eng.G->getNode(BlockEntrance(&B, @@ -735,7 +735,7 @@ EndOfFunctionNodeBuilder::generateNode(const GRState* State, const void *tag, } void EndOfFunctionNodeBuilder::GenerateCallExitNode(const GRState *state) { - HasGeneratedNode = true; + hasGeneratedNode = true; // Create a CallExit node and enqueue it. const StackFrameContext *LocCtx = cast(Pred->getLocationContext()); -- 2.11.4.GIT