2010-07-19 09:31:21 +08:00
|
|
|
//===-- AnalysisManager.cpp -------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-02-10 09:03:03 +08:00
|
|
|
#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
|
2010-07-19 09:31:21 +08:00
|
|
|
#include "clang/Index/Entity.h"
|
|
|
|
#include "clang/Index/Indexer.h"
|
|
|
|
|
|
|
|
using namespace clang;
|
2010-12-23 15:20:52 +08:00
|
|
|
using namespace ento;
|
2010-07-19 09:31:21 +08:00
|
|
|
|
2011-09-26 07:23:43 +08:00
|
|
|
AnalysisManager::AnalysisManager(ASTContext &ctx, DiagnosticsEngine &diags,
|
2011-07-21 13:22:52 +08:00
|
|
|
const LangOptions &lang, PathDiagnosticClient *pd,
|
|
|
|
StoreManagerCreator storemgr,
|
|
|
|
ConstraintManagerCreator constraintmgr,
|
|
|
|
CheckerManager *checkerMgr,
|
|
|
|
idx::Indexer *idxer,
|
|
|
|
unsigned maxnodes, unsigned maxvisit,
|
|
|
|
bool vizdot, bool vizubi, bool purge,
|
|
|
|
bool eager, bool trim,
|
|
|
|
bool inlinecall, bool useUnoptimizedCFG,
|
|
|
|
bool addImplicitDtors, bool addInitializers,
|
|
|
|
bool eagerlyTrimEGraph)
|
|
|
|
: AnaCtxMgr(useUnoptimizedCFG, addImplicitDtors, addInitializers),
|
|
|
|
Ctx(ctx), Diags(diags), LangInfo(lang), PD(pd),
|
|
|
|
CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr),
|
|
|
|
CheckerMgr(checkerMgr), Idxer(idxer),
|
|
|
|
AScope(ScopeDecl), MaxNodes(maxnodes), MaxVisit(maxvisit),
|
|
|
|
VisualizeEGDot(vizdot), VisualizeEGUbi(vizubi), PurgeDead(purge),
|
|
|
|
EagerlyAssume(eager), TrimGraph(trim), InlineCall(inlinecall),
|
|
|
|
EagerlyTrimEGraph(eagerlyTrimEGraph)
|
|
|
|
{
|
2011-07-29 07:07:59 +08:00
|
|
|
AnaCtxMgr.getCFGBuildOptions().setAllAlwaysAdd();
|
2011-07-21 13:22:52 +08:00
|
|
|
}
|
|
|
|
|
2010-11-24 16:53:20 +08:00
|
|
|
AnalysisContext *
|
2010-07-19 09:31:21 +08:00
|
|
|
AnalysisManager::getAnalysisContextInAnotherTU(const Decl *D) {
|
|
|
|
idx::Entity Ent = idx::Entity::get(const_cast<Decl *>(D),
|
|
|
|
Idxer->getProgram());
|
|
|
|
FunctionDecl *FuncDef;
|
|
|
|
idx::TranslationUnit *TU;
|
|
|
|
llvm::tie(FuncDef, TU) = Idxer->getDefinitionFor(Ent);
|
|
|
|
|
|
|
|
if (FuncDef == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// This AnalysisContext wraps function definition in another translation unit.
|
|
|
|
// But it is still owned by the AnalysisManager associated with the current
|
|
|
|
// translation unit.
|
|
|
|
return AnaCtxMgr.getContext(FuncDef, TU);
|
|
|
|
}
|