]> granicus.if.org Git - clang/commitdiff
Make the loading of multiple records for the same identifier (from
authorDouglas Gregor <dgregor@apple.com>
Sat, 20 Aug 2011 05:09:43 +0000 (05:09 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sat, 20 Aug 2011 05:09:43 +0000 (05:09 +0000)
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

lib/Serialization/ASTReader.cpp
test/Modules/Inputs/diamond_left.h
test/Modules/Inputs/diamond_right.h
test/Modules/diamond.c

index 0b13d479705714e2d46e13720e0a01f3833a81b0..768d5db7e3f690b628d1505045dea525c0adece4 100644 (file)
@@ -698,7 +698,8 @@ public:
     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 @@ public:
     // 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;
index 3a97094c08f79194a37fa9c96349a9dedab65ec0..9758b85d974125976071efe8a6eea1856bb19b6a 100644 (file)
@@ -2,3 +2,6 @@ float left(float *);
 
 int top_left(char *c);
 
+int left_and_right(int*);
+
+
index bbed7ec8053791bc0c0b26e65c96dc25825ceacc..9adeb6a9a894e6598941ec86925b9caf37107aa9 100644 (file)
@@ -1 +1,5 @@
 double right(double *);
+
+struct left_and_right {
+  int left, right;
+};
index 220a27903800a36c1d5d9a7e585a81e1e396b014..f9b283a9d2407502b966869fc8b261716e68209e 100644 (file)
@@ -8,6 +8,10 @@ void test_diamond(int i, float f, double d, char c) {
 
   // 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