]> granicus.if.org Git - clang/commitdiff
Merge "special" types from different modules in the AST reader.
authorDouglas Gregor <dgregor@apple.com>
Fri, 1 Feb 2013 23:45:03 +0000 (23:45 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 1 Feb 2013 23:45:03 +0000 (23:45 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174234 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTReader.cpp
test/Modules/Inputs/module.map
test/Modules/Inputs/weird_objc.h [new file with mode: 0644]
test/Modules/objc_redef.m [new file with mode: 0644]

index 604b23143e9d4d3d1163582a27158f9adcb878d5..92dcc7d70327db2c062910d1966fea5a0b458ecd 100644 (file)
@@ -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:
index 5ec595c9e1b817946553b2b590f1a1559b08e051..55496fa35a22da842ecd908243d85081d03e055f 100644 (file)
@@ -155,3 +155,7 @@ module autolink {
     link framework "autolink_framework"
   }
 }
+
+module weird_objc {
+  header "weird_objc.h"
+}
diff --git a/test/Modules/Inputs/weird_objc.h b/test/Modules/Inputs/weird_objc.h
new file mode 100644 (file)
index 0000000..8acaf74
--- /dev/null
@@ -0,0 +1 @@
+typedef struct objc_object { void *super; int wibble; } *id;
diff --git a/test/Modules/objc_redef.m b/test/Modules/objc_redef.m
new file mode 100644 (file)
index 0000000..13a5b1d
--- /dev/null
@@ -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
+