summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReader.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-08-11 22:18:49 +0000
committerDouglas Gregor <dgregor@apple.com>2011-08-11 22:18:49 +0000
commitaa8a827f08971db127c1b0e06571c14365cc4056 (patch)
tree0d044959495f481cc4830de406bac508de46a9d1 /clang/lib/Serialization/ASTReader.cpp
parente25942154c3999f4d67a6a52d954913ac42a9d60 (diff)
downloadbcm5719-llvm-aa8a827f08971db127c1b0e06571c14365cc4056.tar.gz
bcm5719-llvm-aa8a827f08971db127c1b0e06571c14365cc4056.zip
When initializing a context from a particular AST file, check whether
either "special" type has already been initialized. Previously, we did this check based on just the first special type (__builtin_va_list), but now we have some NULL special type entries to content with. llvm-svn: 137373
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r--clang/lib/Serialization/ASTReader.cpp105
1 files changed, 71 insertions, 34 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index f3ce0e9b548..490e5f9da2a 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -2960,28 +2960,48 @@ void ASTReader::InitializeContext(ASTContext &Ctx) {
// Load the translation unit declaration
GetTranslationUnitDecl();
- // FIXME: Find a better way to deal with built-in types
+ // FIXME: Find a better way to deal with collisions between these
+ // built-in types. Right now, we just ignore the problem.
+
+ // Load the special types.
if (Context->getBuiltinVaListType().isNull()) {
- // Load the special types.
Context->setBuiltinVaListType(
GetType(SpecialTypes[SPECIAL_TYPE_BUILTIN_VA_LIST]));
- if (unsigned Id = SpecialTypes[SPECIAL_TYPE_OBJC_ID])
+ }
+
+ if (unsigned Id = SpecialTypes[SPECIAL_TYPE_OBJC_ID]) {
+ if (Context->ObjCIdTypedefType.isNull())
Context->ObjCIdTypedefType = GetType(Id);
- if (unsigned Sel = SpecialTypes[SPECIAL_TYPE_OBJC_SELECTOR])
+ }
+
+ if (unsigned Sel = SpecialTypes[SPECIAL_TYPE_OBJC_SELECTOR]) {
+ if (Context->ObjCSelTypedefType.isNull())
Context->ObjCSelTypedefType = GetType(Sel);
- if (unsigned Proto = SpecialTypes[SPECIAL_TYPE_OBJC_PROTOCOL])
+ }
+
+ if (unsigned Proto = SpecialTypes[SPECIAL_TYPE_OBJC_PROTOCOL]) {
+ if (Context->ObjCProtoType.isNull())
Context->ObjCProtoType = GetType(Proto);
- if (unsigned Class = SpecialTypes[SPECIAL_TYPE_OBJC_CLASS])
+ }
+
+ if (unsigned Class = SpecialTypes[SPECIAL_TYPE_OBJC_CLASS]) {
+ if (Context->ObjCClassTypedefType.isNull())
Context->ObjCClassTypedefType = GetType(Class);
+ }
- if (unsigned String = SpecialTypes[SPECIAL_TYPE_CF_CONSTANT_STRING])
+ if (unsigned String = SpecialTypes[SPECIAL_TYPE_CF_CONSTANT_STRING]) {
+ if (!Context->CFConstantStringTypeDecl)
Context->setCFConstantStringType(GetType(String));
- if (unsigned File = SpecialTypes[SPECIAL_TYPE_FILE]) {
- QualType FileType = GetType(File);
- if (FileType.isNull()) {
- Error("FILE type is NULL");
- return;
- }
+ }
+
+ if (unsigned File = SpecialTypes[SPECIAL_TYPE_FILE]) {
+ QualType FileType = GetType(File);
+ if (FileType.isNull()) {
+ Error("FILE type is NULL");
+ return;
+ }
+
+ if (!Context->FILEDecl) {
if (const TypedefType *Typedef = FileType->getAs<TypedefType>())
Context->setFILEDecl(Typedef->getDecl());
else {
@@ -2993,12 +3013,16 @@ void ASTReader::InitializeContext(ASTContext &Ctx) {
Context->setFILEDecl(Tag->getDecl());
}
}
- if (unsigned Jmp_buf = SpecialTypes[SPECIAL_TYPE_jmp_buf]) {
- QualType Jmp_bufType = GetType(Jmp_buf);
- if (Jmp_bufType.isNull()) {
- Error("jmp_buf type is NULL");
- return;
- }
+ }
+
+ if (unsigned Jmp_buf = SpecialTypes[SPECIAL_TYPE_jmp_buf]) {
+ QualType Jmp_bufType = GetType(Jmp_buf);
+ if (Jmp_bufType.isNull()) {
+ Error("jmp_buf type is NULL");
+ return;
+ }
+
+ if (!Context->jmp_bufDecl) {
if (const TypedefType *Typedef = Jmp_bufType->getAs<TypedefType>())
Context->setjmp_bufDecl(Typedef->getDecl());
else {
@@ -3010,12 +3034,16 @@ void ASTReader::InitializeContext(ASTContext &Ctx) {
Context->setjmp_bufDecl(Tag->getDecl());
}
}
- if (unsigned Sigjmp_buf = SpecialTypes[SPECIAL_TYPE_sigjmp_buf]) {
- QualType Sigjmp_bufType = GetType(Sigjmp_buf);
- if (Sigjmp_bufType.isNull()) {
- Error("sigjmp_buf type is NULL");
- return;
- }
+ }
+
+ if (unsigned Sigjmp_buf = SpecialTypes[SPECIAL_TYPE_sigjmp_buf]) {
+ QualType Sigjmp_bufType = GetType(Sigjmp_buf);
+ if (Sigjmp_bufType.isNull()) {
+ Error("sigjmp_buf type is NULL");
+ return;
+ }
+
+ if (!Context->sigjmp_bufDecl) {
if (const TypedefType *Typedef = Sigjmp_bufType->getAs<TypedefType>())
Context->setsigjmp_bufDecl(Typedef->getDecl());
else {
@@ -3024,20 +3052,29 @@ void ASTReader::InitializeContext(ASTContext &Ctx) {
Context->setsigjmp_bufDecl(Tag->getDecl());
}
}
- if (unsigned ObjCIdRedef
- = SpecialTypes[SPECIAL_TYPE_OBJC_ID_REDEFINITION])
+ }
+
+ if (unsigned ObjCIdRedef
+ = SpecialTypes[SPECIAL_TYPE_OBJC_ID_REDEFINITION]) {
+ if (Context->ObjCIdRedefinitionType.isNull())
Context->ObjCIdRedefinitionType = GetType(ObjCIdRedef);
- if (unsigned ObjCClassRedef
- = SpecialTypes[SPECIAL_TYPE_OBJC_CLASS_REDEFINITION])
+ }
+
+ if (unsigned ObjCClassRedef
+ = SpecialTypes[SPECIAL_TYPE_OBJC_CLASS_REDEFINITION]) {
+ if (Context->ObjCClassRedefinitionType.isNull())
Context->ObjCClassRedefinitionType = GetType(ObjCClassRedef);
- if (unsigned ObjCSelRedef
- = SpecialTypes[SPECIAL_TYPE_OBJC_SEL_REDEFINITION])
- Context->ObjCSelRedefinitionType = GetType(ObjCSelRedef);
+ }
- if (SpecialTypes[SPECIAL_TYPE_INT128_INSTALLED])
- Context->setInt128Installed();
+ if (unsigned ObjCSelRedef
+ = SpecialTypes[SPECIAL_TYPE_OBJC_SEL_REDEFINITION]) {
+ if (Context->ObjCSelRedefinitionType.isNull())
+ Context->ObjCSelRedefinitionType = GetType(ObjCSelRedef);
}
+ if (SpecialTypes[SPECIAL_TYPE_INT128_INSTALLED])
+ Context->setInt128Installed();
+
ReadPragmaDiagnosticMappings(Context->getDiagnostics());
// If there were any CUDA special declarations, deserialize them.
OpenPOWER on IntegriCloud