aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/PCHReader.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-07-08 17:13:02 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-07-08 17:13:02 +0000
commit8871a44ae61cf97ff6fff4c640fadce9ba4cf1b0 (patch)
treef6c689432e33df638fb7678e0d09af33f23cf463 /lib/Frontend/PCHReader.cpp
parentbfcc92c3476ada55ceeea49e43e6d2e083252830 (diff)
Introduce PCHReader::GetTranslationUnitDecl() and use it instead of ReadDeclRecord when initializing.
ReadDeclRecord would hit assertion if the translation unit declaration was already loaded during IdentifierInfo initialization. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107885 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PCHReader.cpp')
-rw-r--r--lib/Frontend/PCHReader.cpp9
1 files changed, 8 insertions, 1 deletions
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;