aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/AnalysisConsumer.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-07-30 01:17:21 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-07-30 01:17:21 +0000
commit97ab3941effe1f508c7113d9aa0c2887774f6fa8 (patch)
treeec1800bdf281acc3761de17d7f16a2361a9f43f9 /lib/Frontend/AnalysisConsumer.cpp
parentd254a25bc1793a2387e37b96568285883fb12eff (diff)
This patch collects all analysis context data into a new class
AnalysisContext. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77563 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/AnalysisConsumer.cpp')
-rw-r--r--lib/Frontend/AnalysisConsumer.cpp48
1 files changed, 17 insertions, 31 deletions
diff --git a/lib/Frontend/AnalysisConsumer.cpp b/lib/Frontend/AnalysisConsumer.cpp
index 2031174cab..d631c69749 100644
--- a/lib/Frontend/AnalysisConsumer.cpp
+++ b/lib/Frontend/AnalysisConsumer.cpp
@@ -25,6 +25,7 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/FileManager.h"
#include "clang/AST/ParentMap.h"
+#include "clang/Analysis/PathSensitive/AnalysisContext.h"
#include "clang/Analysis/PathSensitive/BugReporter.h"
#include "clang/Analysis/Analyses/LiveVariables.h"
#include "clang/Analysis/LocalCheckers.h"
@@ -124,42 +125,39 @@ namespace {
class VISIBILITY_HIDDEN AnalysisManager : public BugReporterData {
- Decl* D; Stmt* Body;
+ AnalysisContextManager ContextMgr;
+ AnalysisContext *CurrentContext;
enum AnalysisScope { ScopeTU, ScopeDecl } AScope;
AnalysisConsumer& C;
bool DisplayedFunction;
- llvm::OwningPtr<CFG> cfg;
- llvm::OwningPtr<LiveVariables> liveness;
- llvm::OwningPtr<ParentMap> PM;
-
// Configurable components creators.
StoreManagerCreator CreateStoreMgr;
ConstraintManagerCreator CreateConstraintMgr;
public:
- AnalysisManager(AnalysisConsumer& c, Decl* d, Stmt* b, bool displayProgress)
- : D(d), Body(b), AScope(ScopeDecl), C(c),
- DisplayedFunction(!displayProgress) {
+ AnalysisManager(AnalysisConsumer& c, Decl* d, bool displayProgress)
+ : AScope(ScopeDecl), C(c), DisplayedFunction(!displayProgress) {
setManagerCreators();
+ CurrentContext = ContextMgr.getContext(d);
}
AnalysisManager(AnalysisConsumer& c, bool displayProgress)
- : D(0), Body(0), AScope(ScopeTU), C(c),
- DisplayedFunction(!displayProgress) {
+ : AScope(ScopeTU), C(c), DisplayedFunction(!displayProgress) {
setManagerCreators();
+ CurrentContext = 0;
}
Decl* getCodeDecl() const {
assert (AScope == ScopeDecl);
- return D;
+ return CurrentContext->getDecl();
}
Stmt* getBody() const {
assert (AScope == ScopeDecl);
- return Body;
+ return CurrentContext->getBody();
}
StoreManagerCreator getStoreManagerCreator() {
@@ -171,14 +169,15 @@ namespace {
}
virtual CFG* getCFG() {
- if (!cfg) cfg.reset(CFG::buildCFG(getBody(), &getContext()));
- return cfg.get();
+ return CurrentContext->getCFG();
}
virtual ParentMap& getParentMap() {
- if (!PM)
- PM.reset(new ParentMap(getBody()));
- return *PM.get();
+ return CurrentContext->getParentMap();
+ }
+
+ virtual LiveVariables* getLiveVariables() {
+ return CurrentContext->getLiveVariables();
}
virtual ASTContext& getContext() {
@@ -208,19 +207,6 @@ case PD_##NAME: C.PD.reset(CREATEFN(C.OutDir, C.PP, C.PPF)); break;
}
return C.PD.get();
}
-
- virtual LiveVariables* getLiveVariables() {
- if (!liveness) {
- CFG* c = getCFG();
- if (!c) return 0;
-
- liveness.reset(new LiveVariables(getContext(), *c));
- liveness->runOnCFG(*c);
- liveness->runOnAllBlocks(*c, 0, true);
- }
-
- return liveness.get();
- }
bool shouldVisualizeGraphviz() const { return C.Opts.VisualizeEGDot; }
@@ -381,7 +367,7 @@ void AnalysisConsumer::HandleCode(Decl* D, Stmt* Body, Actions& actions) {
// Create an AnalysisManager that will manage the state for analyzing
// this method/function.
- AnalysisManager mgr(*this, D, Body, Opts.AnalyzerDisplayProgress);
+ AnalysisManager mgr(*this, D, Opts.AnalyzerDisplayProgress);
// Dispatch on the actions.
for (Actions::iterator I = actions.begin(), E = actions.end(); I != E; ++I)