aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Frontend/PCHReader.h3
-rw-r--r--lib/Frontend/PCHReader.cpp9
2 files changed, 11 insertions, 1 deletions
diff --git a/include/clang/Frontend/PCHReader.h b/include/clang/Frontend/PCHReader.h
index 9f91739106..3d29fccf8f 100644
--- a/include/clang/Frontend/PCHReader.h
+++ b/include/clang/Frontend/PCHReader.h
@@ -616,6 +616,9 @@ public:
TypeSourceInfo *GetTypeSourceInfo(const RecordData &Record,
unsigned &Idx);
+ /// \brief Resolve and return the translation unit declaration.
+ TranslationUnitDecl *GetTranslationUnitDecl();
+
/// \brief Resolve a type ID into a type, potentially building a new
/// type.
QualType GetType(pch::TypeID ID);
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index 568d9ce77e..6acfdb29e4 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -1702,7 +1702,7 @@ void PCHReader::InitializeContext(ASTContext &Ctx) {
PP->setExternalSource(this);
// Load the translation unit declaration
- ReadDeclRecord(DeclOffsets[0], 0);
+ GetTranslationUnitDecl();
// Load the special types.
Context->setBuiltinVaListType(
@@ -2590,6 +2590,13 @@ Decl *PCHReader::GetExternalDecl(uint32_t ID) {
return GetDecl(ID);
}
+TranslationUnitDecl *PCHReader::GetTranslationUnitDecl() {
+ if (!DeclsLoaded[0])
+ ReadDeclRecord(DeclOffsets[0], 0);
+
+ return cast<TranslationUnitDecl>(DeclsLoaded[0]);
+}
+
Decl *PCHReader::GetDecl(pch::DeclID ID) {
if (ID == 0)
return 0;