Make the loading of multiple records for the same identifier (from
different modules) more robust. It already handled (simple) merges of
the set of declarations attached to that identifier, so add a test
case that shows us getting two different declarations for the same
identifier (one struct, one function) from different modules, and are
able to use both of them.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138189 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index 0b13d47..768d5db 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -698,7 +698,8 @@
     assert(II->isExtensionToken() == ExtensionToken &&
            "Incorrect extension token flag");
     (void)ExtensionToken;
-    II->setIsPoisoned(Poisoned);
+    if (Poisoned)
+      II->setIsPoisoned(true);
     assert(II->isCPlusPlusOperatorKeyword() == CPlusPlusOperatorKeyword &&
            "Incorrect C++ operator keyword flag");
     (void)CPlusPlusOperatorKeyword;
@@ -706,6 +707,7 @@
     // If this identifier is a macro, deserialize the macro
     // definition.
     if (hasMacroDefinition) {
+      // FIXME: Check for conflicts?
       uint32_t Offset = ReadUnalignedLE32(d);
       Reader.SetIdentifierIsMacro(II, F, Offset);
       DataLen -= 4;
diff --git a/test/Modules/Inputs/diamond_left.h b/test/Modules/Inputs/diamond_left.h
index 3a97094..9758b85 100644
--- a/test/Modules/Inputs/diamond_left.h
+++ b/test/Modules/Inputs/diamond_left.h
@@ -2,3 +2,6 @@
 
 int top_left(char *c);
 
+int left_and_right(int*);
+
+
diff --git a/test/Modules/Inputs/diamond_right.h b/test/Modules/Inputs/diamond_right.h
index bbed7ec..9adeb6a 100644
--- a/test/Modules/Inputs/diamond_right.h
+++ b/test/Modules/Inputs/diamond_right.h
@@ -1 +1,5 @@
 double right(double *);
+
+struct left_and_right {
+  int left, right;
+};
diff --git a/test/Modules/diamond.c b/test/Modules/diamond.c
index 220a279..f9b283a 100644
--- a/test/Modules/diamond.c
+++ b/test/Modules/diamond.c
@@ -8,6 +8,10 @@
 
   // Names in multiple places in the diamond.
   top_left(&c);
+
+  left_and_right(&i);
+  struct left_and_right lr;
+  lr.left = 17;
 }
 
 // RUN: %clang_cc1 -emit-pch -o %t_top.h.pch %S/Inputs/diamond_top.h