AnalysisManager.cpp revision 882998923889a2fcce9b49696506c499e22cf38f
1//===-- AnalysisManager.cpp -------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h" 11#include "clang/Index/Entity.h" 12#include "clang/Index/Indexer.h" 13 14using namespace clang; 15using namespace ento; 16 17AnalysisManager::AnalysisManager(ASTContext &ctx, Diagnostic &diags, 18 const LangOptions &lang, PathDiagnosticClient *pd, 19 StoreManagerCreator storemgr, 20 ConstraintManagerCreator constraintmgr, 21 CheckerManager *checkerMgr, 22 idx::Indexer *idxer, 23 unsigned maxnodes, unsigned maxvisit, 24 bool vizdot, bool vizubi, bool purge, 25 bool eager, bool trim, 26 bool inlinecall, bool useUnoptimizedCFG, 27 bool addImplicitDtors, bool addInitializers, 28 bool eagerlyTrimEGraph) 29 : AnaCtxMgr(useUnoptimizedCFG, addImplicitDtors, addInitializers), 30 Ctx(ctx), Diags(diags), LangInfo(lang), PD(pd), 31 CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr), 32 CheckerMgr(checkerMgr), Idxer(idxer), 33 AScope(ScopeDecl), MaxNodes(maxnodes), MaxVisit(maxvisit), 34 VisualizeEGDot(vizdot), VisualizeEGUbi(vizubi), PurgeDead(purge), 35 EagerlyAssume(eager), TrimGraph(trim), InlineCall(inlinecall), 36 EagerlyTrimEGraph(eagerlyTrimEGraph) 37{ 38 AnaCtxMgr.getCFGBuildOptions().setAllAlwaysAdd(); 39} 40 41AnalysisContext * 42AnalysisManager::getAnalysisContextInAnotherTU(const Decl *D) { 43 idx::Entity Ent = idx::Entity::get(const_cast<Decl *>(D), 44 Idxer->getProgram()); 45 FunctionDecl *FuncDef; 46 idx::TranslationUnit *TU; 47 llvm::tie(FuncDef, TU) = Idxer->getDefinitionFor(Ent); 48 49 if (FuncDef == 0) 50 return 0; 51 52 // This AnalysisContext wraps function definition in another translation unit. 53 // But it is still owned by the AnalysisManager associated with the current 54 // translation unit. 55 return AnaCtxMgr.getContext(FuncDef, TU); 56} 57