aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-01 17:14:15 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-01 17:14:15 +0000
commit62ba9f61af6177992d8cd2e3306257e1213b1bd3 (patch)
tree7988068b5dc366d40ca6c5c13e486b7051a0f30b
parent87ec9c257c99b4136af6c7f5be5a2d486906ba84 (diff)
Put a reference of the ASTReader in the ASTUnit.
This is intended for direct access of the ASTReader for uses that make little sense to try to shoehorn in the ExternalASTSource interface. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143465 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Frontend/ASTUnit.h1
-rw-r--r--lib/Frontend/ASTUnit.cpp7
2 files changed, 7 insertions, 1 deletions
diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h
index b0e7bb64bf..cbd293f72e 100644
--- a/include/clang/Frontend/ASTUnit.h
+++ b/include/clang/Frontend/ASTUnit.h
@@ -76,6 +76,7 @@ private:
llvm::IntrusiveRefCntPtr<TargetInfo> Target;
llvm::IntrusiveRefCntPtr<Preprocessor> PP;
llvm::IntrusiveRefCntPtr<ASTContext> Ctx;
+ ASTReader *Reader;
FileSystemOptions FileSystemOpts;
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index 7211ca6dce..0600203eae 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -211,7 +211,7 @@ const unsigned DefaultPreambleRebuildInterval = 5;
static llvm::sys::cas_flag ActiveASTUnitObjects;
ASTUnit::ASTUnit(bool _MainFileIsAST)
- : OnlyLocalDecls(false), CaptureDiagnostics(false),
+ : Reader(0), OnlyLocalDecls(false), CaptureDiagnostics(false),
MainFileIsAST(_MainFileIsAST),
TUKind(TU_Complete), WantTiming(getenv("LIBCLANG_TIMING")),
OwnsRemappedFileBuffers(true),
@@ -783,6 +783,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename,
AST->TheSema.reset(new Sema(PP, Context, *AST->Consumer));
AST->TheSema->Initialize();
ReaderPtr->InitializeSema(*AST->TheSema);
+ AST->Reader = ReaderPtr;
return AST.take();
}
@@ -1042,6 +1043,7 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) {
TheSema.reset();
Ctx = 0;
PP = 0;
+ Reader = 0;
// Clear out old caches and data.
TopLevelDecls.clear();
@@ -1117,6 +1119,7 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) {
Clang->setSourceManager(0);
Clang->setFileManager(0);
Target = &Clang->getTarget();
+ Reader = Clang->getModuleManager();
Act->EndSourceFile();
@@ -1709,6 +1712,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(CompilerInvocation *CI,
AST->TheSema.reset();
AST->Ctx = 0;
AST->PP = 0;
+ AST->Reader = 0;
// Create a file manager object to provide access to and cache the filesystem.
Clang->setFileManager(&AST->getFileManager());
@@ -1743,6 +1747,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(CompilerInvocation *CI,
Clang->setSourceManager(0);
Clang->setFileManager(0);
AST->Target = &Clang->getTarget();
+ AST->Reader = Clang->getModuleManager();
Act->EndSourceFile();