diff options
| author | Douglas Gregor <dgregor@apple.com> | 2013-02-01 23:45:03 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2013-02-01 23:45:03 +0000 |
| commit | 44180f8f6d5d55ba69764bb8eb9d89aee0c4d5eb (patch) | |
| tree | fb03a95d745f922b0b81f5fcedfae548ff71a185 | |
| parent | 6bade327dccc44ca8ab82ef5381441a390d97a9a (diff) | |
| download | bcm5719-llvm-44180f8f6d5d55ba69764bb8eb9d89aee0c4d5eb.tar.gz bcm5719-llvm-44180f8f6d5d55ba69764bb8eb9d89aee0c4d5eb.zip | |
Merge "special" types from different modules in the AST reader.
Different modules may have different views of the various "special"
types in the AST, such as the redefinition type for "id". Merge those
types rather than only considering the redefinition types for the
first AST file loaded.
llvm-svn: 174234
| -rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 20 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/module.map | 4 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/weird_objc.h | 1 | ||||
| -rw-r--r-- | clang/test/Modules/objc_redef.m | 13 |
4 files changed, 36 insertions, 2 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 604b23143e9..92dcc7d7032 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -2053,8 +2053,24 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) { break; case SPECIAL_TYPES: - for (unsigned I = 0, N = Record.size(); I != N; ++I) - SpecialTypes.push_back(getGlobalTypeID(F, Record[I])); + if (SpecialTypes.empty()) { + for (unsigned I = 0, N = Record.size(); I != N; ++I) + SpecialTypes.push_back(getGlobalTypeID(F, Record[I])); + break; + } + + if (SpecialTypes.size() != Record.size()) { + Error("invalid special-types record"); + return true; + } + + for (unsigned I = 0, N = Record.size(); I != N; ++I) { + serialization::TypeID ID = getGlobalTypeID(F, Record[I]); + if (!SpecialTypes[I]) + SpecialTypes[I] = ID; + // FIXME: If ID && SpecialTypes[I] != ID, do we need a separate + // merge step? + } break; case STATISTICS: diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map index 5ec595c9e1b..55496fa35a2 100644 --- a/clang/test/Modules/Inputs/module.map +++ b/clang/test/Modules/Inputs/module.map @@ -155,3 +155,7 @@ module autolink { link framework "autolink_framework" } } + +module weird_objc { + header "weird_objc.h" +} diff --git a/clang/test/Modules/Inputs/weird_objc.h b/clang/test/Modules/Inputs/weird_objc.h new file mode 100644 index 00000000000..8acaf746e85 --- /dev/null +++ b/clang/test/Modules/Inputs/weird_objc.h @@ -0,0 +1 @@ +typedef struct objc_object { void *super; int wibble; } *id; diff --git a/clang/test/Modules/objc_redef.m b/clang/test/Modules/objc_redef.m new file mode 100644 index 00000000000..13a5b1d9cc0 --- /dev/null +++ b/clang/test/Modules/objc_redef.m @@ -0,0 +1,13 @@ +@import redeclarations_left; +@import weird_objc; + +int test(id x) { + return x->wibble; +} + +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -emit-module -fmodule-name=redeclarations_left %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -emit-module -fmodule-name=weird_objc %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t %s -verify +// expected-no-diagnostics + |

