Zhongxing Xu | c6238d2 | 2010-07-19 01:31:21 +0000 | [diff] [blame] | 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 | |
Argyrios Kyrtzidis | 98cabba | 2010-12-22 18:51:49 +0000 | [diff] [blame] | 10 | #include "clang/GR/PathSensitive/AnalysisManager.h" |
Zhongxing Xu | c6238d2 | 2010-07-19 01:31:21 +0000 | [diff] [blame] | 11 | #include "clang/Index/Entity.h" |
| 12 | #include "clang/Index/Indexer.h" |
| 13 | |
| 14 | using namespace clang; |
Argyrios Kyrtzidis | 5a4f98f | 2010-12-22 18:53:20 +0000 | [diff] [blame] | 15 | using namespace GR; |
Zhongxing Xu | c6238d2 | 2010-07-19 01:31:21 +0000 | [diff] [blame] | 16 | |
Zhongxing Xu | 19b78d9 | 2010-11-24 08:53:20 +0000 | [diff] [blame] | 17 | AnalysisContext * |
Zhongxing Xu | c6238d2 | 2010-07-19 01:31:21 +0000 | [diff] [blame] | 18 | AnalysisManager::getAnalysisContextInAnotherTU(const Decl *D) { |
| 19 | idx::Entity Ent = idx::Entity::get(const_cast<Decl *>(D), |
| 20 | Idxer->getProgram()); |
| 21 | FunctionDecl *FuncDef; |
| 22 | idx::TranslationUnit *TU; |
| 23 | llvm::tie(FuncDef, TU) = Idxer->getDefinitionFor(Ent); |
| 24 | |
| 25 | if (FuncDef == 0) |
| 26 | return 0; |
| 27 | |
| 28 | // This AnalysisContext wraps function definition in another translation unit. |
| 29 | // But it is still owned by the AnalysisManager associated with the current |
| 30 | // translation unit. |
| 31 | return AnaCtxMgr.getContext(FuncDef, TU); |
| 32 | } |