From: Ted Kremenek Date: Wed, 20 Oct 2010 23:48:34 +0000 (+0000) Subject: Remove obsolete GRAuditor and GRSimpleAPICheck, which have been completely subsumed... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f093350f76320909a015c82de60a500fdcaf5b8f;p=clang Remove obsolete GRAuditor and GRSimpleAPICheck, which have been completely subsumed by the Checker interface. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116973 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Checker/PathSensitive/GRAuditor.h b/include/clang/Checker/PathSensitive/GRAuditor.h deleted file mode 100644 index 015c82e80b..0000000000 --- a/include/clang/Checker/PathSensitive/GRAuditor.h +++ /dev/null @@ -1,35 +0,0 @@ -//==- GRAuditor.h - Observers of the creation of ExplodedNodes------*- C++ -*-// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines GRAuditor and its primary subclasses, an interface -// to audit the creation of ExplodedNodes. This interface can be used -// to implement simple checkers that do not mutate analysis state but -// instead operate by perfoming simple logical checks at key monitoring -// locations (e.g., function calls). -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_ANALYSIS_GRAUDITOR -#define LLVM_CLANG_ANALYSIS_GRAUDITOR - -namespace clang { - -class ExplodedNode; -class GRStateManager; - -class GRAuditor { -public: - virtual ~GRAuditor() {} - virtual bool Audit(ExplodedNode* N, GRStateManager& M) = 0; -}; - - -} // end clang namespace - -#endif diff --git a/include/clang/Checker/PathSensitive/GRCoreEngine.h b/include/clang/Checker/PathSensitive/GRCoreEngine.h index 5a5b7f22de..a1062ac03e 100644 --- a/include/clang/Checker/PathSensitive/GRCoreEngine.h +++ b/include/clang/Checker/PathSensitive/GRCoreEngine.h @@ -19,7 +19,6 @@ #include "clang/Checker/PathSensitive/ExplodedGraph.h" #include "clang/Checker/PathSensitive/GRWorkList.h" #include "clang/Checker/PathSensitive/GRBlockCounter.h" -#include "clang/Checker/PathSensitive/GRAuditor.h" #include "clang/Checker/PathSensitive/GRSubEngine.h" #include "llvm/ADT/OwningPtr.h" @@ -182,7 +181,6 @@ class GRStmtNodeBuilder { const unsigned Idx; ExplodedNode* Pred; GRStateManager& Mgr; - GRAuditor* Auditor; public: bool PurgingDeadSymbols; @@ -273,8 +271,6 @@ public: unsigned getIndex() const { return Idx; } - void setAuditor(GRAuditor* A) { Auditor = A; } - const GRState* GetState(ExplodedNode* Pred) const { if (Pred == getBasePredecessor()) return CleanedState; diff --git a/include/clang/Checker/PathSensitive/GRExprEngine.h b/include/clang/Checker/PathSensitive/GRExprEngine.h index 1d40e9775d..193d49baf5 100644 --- a/include/clang/Checker/PathSensitive/GRExprEngine.h +++ b/include/clang/Checker/PathSensitive/GRExprEngine.h @@ -20,7 +20,6 @@ #include "clang/Checker/PathSensitive/GRSubEngine.h" #include "clang/Checker/PathSensitive/GRCoreEngine.h" #include "clang/Checker/PathSensitive/GRState.h" -#include "clang/Checker/PathSensitive/GRSimpleAPICheck.h" #include "clang/Checker/PathSensitive/GRTransferFuncs.h" #include "clang/Checker/BugReporter/BugReporter.h" #include "clang/AST/Type.h" @@ -74,8 +73,6 @@ class GRExprEngine : public GRSubEngine { Selector* NSExceptionInstanceRaiseSelectors; Selector RaiseSel; - llvm::OwningPtr BatchAuditor; - enum CallbackKind { PreVisitStmtCallback, PostVisitStmtCallback, @@ -178,9 +175,6 @@ public: return static_cast(lookupChecker(CHECKER::getTag())); } - void AddCheck(GRSimpleAPICheck* A, Stmt::StmtClass C); - void AddCheck(GRSimpleAPICheck* A); - /// ProcessStmt - Called by GRCoreEngine. Used to generate new successor /// nodes by processing the 'effects' of a block-level statement. void ProcessStmt(const CFGElement E, GRStmtNodeBuilder& builder); diff --git a/include/clang/Checker/PathSensitive/GRSimpleAPICheck.h b/include/clang/Checker/PathSensitive/GRSimpleAPICheck.h deleted file mode 100644 index 6d85e5fe6a..0000000000 --- a/include/clang/Checker/PathSensitive/GRSimpleAPICheck.h +++ /dev/null @@ -1,31 +0,0 @@ -// GRCheckAPI.h - Simple API checks based on GRAuditor ------------*- C++ -*--// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines the interface for building simple, path-sensitive checks -// that are stateless and only emit warnings at errors that occur at -// CallExpr or ObjCMessageExpr. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_ANALYSIS_GRAPICHECKS -#define LLVM_CLANG_ANALYSIS_GRAPICHECKS - -#include "clang/Checker/PathSensitive/GRAuditor.h" - -namespace clang { - -class GRSimpleAPICheck : public GRAuditor { -public: - GRSimpleAPICheck() {} - virtual ~GRSimpleAPICheck() {} -}; - -} // end namespace clang - -#endif diff --git a/lib/Checker/GRCoreEngine.cpp b/lib/Checker/GRCoreEngine.cpp index 4ade15fe75..536c9b33ba 100644 --- a/lib/Checker/GRCoreEngine.cpp +++ b/lib/Checker/GRCoreEngine.cpp @@ -417,7 +417,7 @@ void GRCoreEngine::GenerateNode(const ProgramPoint& Loc, GRStmtNodeBuilder::GRStmtNodeBuilder(const CFGBlock* b, unsigned idx, ExplodedNode* N, GRCoreEngine* e, GRStateManager &mgr) - : Eng(*e), B(*b), Idx(idx), Pred(N), Mgr(mgr), Auditor(0), + : Eng(*e), B(*b), Idx(idx), Pred(N), Mgr(mgr), PurgingDeadSymbols(false), BuildSinks(false), HasGeneratedNode(false), PointKind(ProgramPoint::PostStmtKind), Tag(0) { Deferred.insert(N); @@ -468,12 +468,8 @@ ExplodedNode* GRStmtNodeBuilder::MakeNode(ExplodedNodeSet& Dst, const Stmt* S, if (N) { if (BuildSinks) N->markAsSink(); - else { - if (Auditor && Auditor->Audit(N, Mgr)) - N->markAsSink(); - + else Dst.Add(N); - } } return N; diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp index babea205be..d542c2c293 100644 --- a/lib/Checker/GRExprEngine.cpp +++ b/lib/Checker/GRExprEngine.cpp @@ -98,73 +98,6 @@ static bool CalleeReturnsReferenceOrRecord(const CallExpr *CE) { } #endif -//===----------------------------------------------------------------------===// -// Batch auditor. DEPRECATED. -//===----------------------------------------------------------------------===// - -namespace { - -class MappedBatchAuditor : public GRSimpleAPICheck { - typedef llvm::ImmutableList Checks; - typedef llvm::DenseMap MapTy; - - MapTy M; - Checks::Factory F; - Checks AllStmts; - -public: - MappedBatchAuditor(llvm::BumpPtrAllocator& Alloc) : - F(Alloc), AllStmts(F.GetEmptyList()) {} - - virtual ~MappedBatchAuditor() { - llvm::DenseSet AlreadyVisited; - - for (MapTy::iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI) - for (Checks::iterator I=MI->second.begin(), E=MI->second.end(); I!=E;++I){ - - GRSimpleAPICheck* check = *I; - - if (AlreadyVisited.count(check)) - continue; - - AlreadyVisited.insert(check); - delete check; - } - } - - void AddCheck(GRSimpleAPICheck *A, Stmt::StmtClass C) { - assert (A && "Check cannot be null."); - void* key = reinterpret_cast((uintptr_t) C); - MapTy::iterator I = M.find(key); - M[key] = F.Concat(A, I == M.end() ? F.GetEmptyList() : I->second); - } - - void AddCheck(GRSimpleAPICheck *A) { - assert (A && "Check cannot be null."); - AllStmts = F.Concat(A, AllStmts); - } - - virtual bool Audit(ExplodedNode* N, GRStateManager& VMgr) { - // First handle the auditors that accept all statements. - bool isSink = false; - for (Checks::iterator I = AllStmts.begin(), E = AllStmts.end(); I!=E; ++I) - isSink |= (*I)->Audit(N, VMgr); - - // Next handle the auditors that accept only specific statements. - const Stmt* S = cast(N->getLocation()).getStmt(); - void* key = reinterpret_cast((uintptr_t) S->getStmtClass()); - MapTy::iterator MI = M.find(key); - if (MI != M.end()) { - for (Checks::iterator I=MI->second.begin(), E=MI->second.end(); I!=E; ++I) - isSink |= (*I)->Audit(N, VMgr); - } - - return isSink; - } -}; - -} // end anonymous namespace - //===----------------------------------------------------------------------===// // Checker worklist routines. //===----------------------------------------------------------------------===// @@ -423,20 +356,6 @@ GRExprEngine::~GRExprEngine() { // Utility methods. //===----------------------------------------------------------------------===// -void GRExprEngine::AddCheck(GRSimpleAPICheck* A, Stmt::StmtClass C) { - if (!BatchAuditor) - BatchAuditor.reset(new MappedBatchAuditor(getGraph().getAllocator())); - - ((MappedBatchAuditor*) BatchAuditor.get())->AddCheck(A, C); -} - -void GRExprEngine::AddCheck(GRSimpleAPICheck *A) { - if (!BatchAuditor) - BatchAuditor.reset(new MappedBatchAuditor(getGraph().getAllocator())); - - ((MappedBatchAuditor*) BatchAuditor.get())->AddCheck(A); -} - const GRState* GRExprEngine::getInitialState(const LocationContext *InitLoc) { const GRState *state = StateMgr.getInitialState(InitLoc); @@ -642,10 +561,6 @@ void GRExprEngine::ProcessStmt(const CFGElement CE,GRStmtNodeBuilder& builder) { Builder = &builder; EntryNode = builder.getBasePredecessor(); - // Set up our simple checks. - if (BatchAuditor) - Builder->setAuditor(BatchAuditor.get()); - // Create the cleaned state. const LocationContext *LC = EntryNode->getLocationContext(); SymbolReaper SymReaper(LC, CurrentStmt, SymMgr);