From: Ted Kremenek Date: Mon, 10 Sep 2007 15:56:38 +0000 (+0000) Subject: Renaming of the LiveVariablesAuditor interface. Changed "Auditor" and X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b00c95eab9919ee1dd7805a0e6f2218129a9733e;p=clang Renaming of the LiveVariablesAuditor interface. Changed "Auditor" and "Audit" to "Observer" and "Observe" git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41794 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Analysis/DeadStores.cpp b/Analysis/DeadStores.cpp index f79aa6ae04..4073eccf60 100644 --- a/Analysis/DeadStores.cpp +++ b/Analysis/DeadStores.cpp @@ -23,13 +23,13 @@ using namespace clang; namespace { -class DeadStoreAuditor : public LiveVariablesAuditor { +class DeadStoreObserver : public LiveVariablesObserver { Preprocessor& PP; public: - DeadStoreAuditor(Preprocessor& pp) : PP(pp) {} - virtual ~DeadStoreAuditor() {} + DeadStoreObserver(Preprocessor& pp) : PP(pp) {} + virtual ~DeadStoreObserver() {} - virtual void AuditStmt(Stmt* S, LiveVariables& L, llvm::BitVector& Live) { + virtual void ObserveStmt(Stmt* S, LiveVariables& L, llvm::BitVector& Live) { if (BinaryOperator* B = dyn_cast(S)) { // Is this an assignment? if (!B->isAssignmentOp()) @@ -68,7 +68,7 @@ public: namespace clang { void CheckDeadStores(CFG& cfg, LiveVariables& L, Preprocessor& PP) { - DeadStoreAuditor A(PP); + DeadStoreObserver A(PP); for (CFG::iterator I = cfg.begin(), E = cfg.end(); I != E; ++I) L.runOnBlock(&(*I),&A); diff --git a/Analysis/LiveVariables.cpp b/Analysis/LiveVariables.cpp index bf4437470e..1d06c26af8 100644 --- a/Analysis/LiveVariables.cpp +++ b/Analysis/LiveVariables.cpp @@ -117,11 +117,11 @@ class LivenessTFuncs : public StmtVisitor { Stmt* CurrentStmt; const CFGBlock* CurrentBlock; bool blockPreviouslyProcessed; - LiveVariablesAuditor* Auditor; + LiveVariablesObserver* Observer; public: - LivenessTFuncs(LiveVariables& l, LiveVariablesAuditor* A = NULL) + LivenessTFuncs(LiveVariables& l, LiveVariablesObserver* A = NULL) : L(l), CurrentStmt(NULL), CurrentBlock(NULL), - blockPreviouslyProcessed(false), Auditor(A) + blockPreviouslyProcessed(false), Observer(A) { Live.resize(l.getNumDecls()); KilledAtLeastOnce.resize(l.getNumDecls()); @@ -148,8 +148,8 @@ public: }; void LivenessTFuncs::VisitStmt(Stmt* S) { - if (Auditor) - Auditor->AuditStmt(S,L,Live); + if (Observer) + Observer->ObserveStmt(S,L,Live); // Evaluate the transfer functions for all subexpressions. Note that // each invocation of "Visit" will have a side-effect: "Liveness" and "Kills" @@ -159,8 +159,8 @@ void LivenessTFuncs::VisitStmt(Stmt* S) { } void LivenessTFuncs::VisitDeclRefExpr(DeclRefExpr* DR) { - if (Auditor) - Auditor->AuditStmt(DR,L,Live); + if (Observer) + Observer->ObserveStmt(DR,L,Live); // Register a use of the variable. Live.set(getIdx(DR->getDecl())); @@ -240,8 +240,8 @@ LiveVariables::VarInfo& LivenessTFuncs::KillVar(Decl* D) { } void LivenessTFuncs::VisitAssign(BinaryOperator* B) { - if (Auditor) - Auditor->AuditStmt(B,L,Live); + if (Observer) + Observer->ObserveStmt(B,L,Live); // Check if we are assigning to a variable. Stmt* LHS = B->getLHS(); @@ -264,8 +264,8 @@ void LivenessTFuncs::VisitAssign(BinaryOperator* B) { } void LivenessTFuncs::VisitDeclStmt(DeclStmt* DS) { - if (Auditor) - Auditor->AuditStmt(DS,L,Live); + if (Observer) + Observer->ObserveStmt(DS,L,Live); // Declarations effectively "kill" a variable since they cannot possibly // be live before they are declared. Declarations, however, are not kills @@ -299,8 +299,8 @@ bool LivenessTFuncs::ProcessBlock(const CFGBlock* B) { if (llvm::BitVector* V = getBlockEntryLiveness(*I)) Live |= *V; - if (Auditor) - Auditor->AuditBlockExit(B,L,Live); + if (Observer) + Observer->ObserveBlockExit(B,L,Live); // Tentatively mark all variables alive at the end of the current block // as being alive during the whole block. We then cull these out as @@ -343,7 +343,7 @@ bool LivenessTFuncs::ProcessBlock(const CFGBlock* B) { // runOnCFG - Method to run the actual liveness computation. // -void LiveVariables::runOnCFG(const CFG& cfg, LiveVariablesAuditor* Auditor) { +void LiveVariables::runOnCFG(const CFG& cfg, LiveVariablesObserver* Observer) { // Scan a CFG for DeclRefStmts. For each one, create a VarInfo object. { RegisterDecls R(*this,cfg); @@ -355,7 +355,7 @@ void LiveVariables::runOnCFG(const CFG& cfg, LiveVariablesAuditor* Auditor) { WorkList.enqueue(&cfg.getExit()); // Create the state for transfer functions. - LivenessTFuncs TF(*this,Auditor); + LivenessTFuncs TF(*this,Observer); // Process the worklist until it is empty. @@ -374,9 +374,10 @@ void LiveVariables::runOnCFG(const CFG& cfg, LiveVariablesAuditor* Auditor) { } -void LiveVariables::runOnBlock(const CFGBlock* B, LiveVariablesAuditor* Auditor) +void LiveVariables::runOnBlock(const CFGBlock* B, + LiveVariablesObserver* Observer) { - LivenessTFuncs TF(*this,Auditor); + LivenessTFuncs TF(*this,Observer); TF.ProcessBlock(B); } @@ -423,13 +424,14 @@ const LiveVariables::VarInfo& LiveVariables::getVarInfo(const Decl* D) const { } //===----------------------------------------------------------------------===// -// Defaults for LiveVariablesAuditor +// Defaults for LiveVariablesObserver -void LiveVariablesAuditor::AuditStmt(Stmt* S, LiveVariables& L, - llvm::BitVector& V) {} +void LiveVariablesObserver::ObserveStmt(Stmt* S, LiveVariables& L, + llvm::BitVector& V) {} -void LiveVariablesAuditor::AuditBlockExit(const CFGBlock* B, LiveVariables& L, - llvm::BitVector& V) {} +void LiveVariablesObserver::ObserveBlockExit(const CFGBlock* B, + LiveVariables& L, + llvm::BitVector& V) {} //===----------------------------------------------------------------------===// // printing liveness state for debugging diff --git a/include/clang/Analysis/LiveVariables.h b/include/clang/Analysis/LiveVariables.h index c63dc7c0d2..18b6b18683 100644 --- a/include/clang/Analysis/LiveVariables.h +++ b/include/clang/Analysis/LiveVariables.h @@ -28,23 +28,23 @@ namespace clang { class SourceManager; class LiveVariables; -class LiveVariablesAuditor { +class LiveVariablesObserver { public: - virtual ~LiveVariablesAuditor() {} + virtual ~LiveVariablesObserver() {} - /// AuditStmt - A callback invoked right before invoking the liveness + /// ObserveStmt - A callback invoked right before invoking the liveness /// transfer function on the given statement. If the liveness information /// has been previously calculated by running LiveVariables::runOnCFG, /// then V contains the liveness information after the execution of /// the given statement. - virtual void AuditStmt(Stmt* S, LiveVariables& L, llvm::BitVector& V); + virtual void ObserveStmt(Stmt* S, LiveVariables& L, llvm::BitVector& V); - /// AuditBlockExit - A callback invoked right before invoking the liveness + /// ObserveBlockExit - A callback invoked right before invoking the liveness /// transfer function on the given block. If the liveness information /// has been previously calculated by running LiveVariables::runOnCFG, /// then V contains the liveness information after the execution of /// the given block. - virtual void AuditBlockExit(const CFGBlock* B, LiveVariables& L, + virtual void ObserveBlockExit(const CFGBlock* B, LiveVariables& L, llvm::BitVector& V); }; @@ -70,7 +70,7 @@ public: void AddKill(Stmt* S, DeclRefExpr* DR) { Kills.push_back(std::make_pair(const_cast(S), const_cast(DR))); - } + } }; struct VPair { @@ -86,13 +86,13 @@ public: LiveVariables() : NumDecls(0) {} /// runOnCFG - Computes live variable information for a given CFG. - void runOnCFG(const CFG& cfg, LiveVariablesAuditor* A = NULL); + void runOnCFG(const CFG& cfg, LiveVariablesObserver* A = NULL); /// runOnBlock - Computes live variable information for a given block. /// This should usually be invoked only after previously computing /// live variable information using runOnCFG, and is intended to /// only be used for auditing the liveness within a block. - void runOnBlock(const CFGBlock* B, LiveVariablesAuditor* A); + void runOnBlock(const CFGBlock* B, LiveVariablesObserver* A); /// KillsVar - Return true if the specified statement kills the /// specified variable. @@ -104,7 +104,7 @@ public: /// IsLive - Return true if a variable is live according to the provided /// livness bitvector. This is typically used by classes that subclass - /// LiveVariablesAuditor. + /// LiveVariablesObserver. bool isLive(llvm::BitVector& V, const Decl* D) const; /// getVarInfo - Return the liveness information associated with a given