r174234 - Merge "special" types from different modules in the AST reader.
Douglas Gregor
dgregor at apple.com
Fri Feb 1 15:45:04 PST 2013
Author: dgregor
Date: Fri Feb 1 17:45:03 2013
New Revision: 174234
URL: http://llvm.org/viewvc/llvm-project?rev=174234&view=rev
Log:
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.
Added:
cfe/trunk/test/Modules/Inputs/weird_objc.h
cfe/trunk/test/Modules/objc_redef.m
Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/Inputs/module.map
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=174234&r1=174233&r2=174234&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Feb 1 17:45:03 2013
@@ -2053,8 +2053,24 @@ bool ASTReader::ReadASTBlock(ModuleFile
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:
Modified: cfe/trunk/test/Modules/Inputs/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=174234&r1=174233&r2=174234&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/module.map (original)
+++ cfe/trunk/test/Modules/Inputs/module.map Fri Feb 1 17:45:03 2013
@@ -155,3 +155,7 @@ module autolink {
link framework "autolink_framework"
}
}
+
+module weird_objc {
+ header "weird_objc.h"
+}
Added: cfe/trunk/test/Modules/Inputs/weird_objc.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/weird_objc.h?rev=174234&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/weird_objc.h (added)
+++ cfe/trunk/test/Modules/Inputs/weird_objc.h Fri Feb 1 17:45:03 2013
@@ -0,0 +1 @@
+typedef struct objc_object { void *super; int wibble; } *id;
Added: cfe/trunk/test/Modules/objc_redef.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/objc_redef.m?rev=174234&view=auto
==============================================================================
--- cfe/trunk/test/Modules/objc_redef.m (added)
+++ cfe/trunk/test/Modules/objc_redef.m Fri Feb 1 17:45:03 2013
@@ -0,0 +1,13 @@
+ at import redeclarations_left;
+ at 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
+
More information about the cfe-commits
mailing list