]> granicus.if.org Git - clang/commitdiff
[modules] If we already have a fake definition for one declaration of a class,
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 4 Feb 2015 01:23:46 +0000 (01:23 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 4 Feb 2015 01:23:46 +0000 (01:23 +0000)
don't think we're providing a new one in an update record adding a definition
to another declaration of the same class.

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

lib/Serialization/ASTReaderDecl.cpp
test/Modules/Inputs/merge-template-members/a1.h [moved from test/Modules/Inputs/merge-template-members/a.h with 100% similarity]
test/Modules/Inputs/merge-template-members/a2.h [new file with mode: 0644]
test/Modules/Inputs/merge-template-members/b.h [deleted file]
test/Modules/Inputs/merge-template-members/b1.h [new file with mode: 0644]
test/Modules/Inputs/merge-template-members/b2.h [new file with mode: 0644]
test/Modules/Inputs/merge-template-members/c.h
test/Modules/Inputs/merge-template-members/module.modulemap
test/Modules/merge-template-members.cpp

index 7f666a46077aad493fc0461bcf7ad288cce782a6..87b5296c94607dd5977f2511a108dc6c4247276f 100644 (file)
@@ -3648,7 +3648,8 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
       auto *RD = cast<CXXRecordDecl>(D);
       auto *OldDD = RD->DefinitionData.getNotUpdated();
       bool HadRealDefinition =
-          OldDD && !Reader.PendingFakeDefinitionData.count(OldDD);
+          OldDD && (OldDD->Definition != RD ||
+                    !Reader.PendingFakeDefinitionData.count(OldDD));
       ReadCXXRecordDefinition(RD, /*Update*/true);
 
       // Visible update is handled separately.
diff --git a/test/Modules/Inputs/merge-template-members/a2.h b/test/Modules/Inputs/merge-template-members/a2.h
new file mode 100644 (file)
index 0000000..9212a3f
--- /dev/null
@@ -0,0 +1,9 @@
+namespace N {
+  template <typename> struct A {
+    int n;
+    A() : n() {}
+  };
+
+  // Create declaration of A<int>.
+  typedef A<int> AI;
+}
diff --git a/test/Modules/Inputs/merge-template-members/b.h b/test/Modules/Inputs/merge-template-members/b.h
deleted file mode 100644 (file)
index df537b0..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "a.h"
-
-// Add update record for definition of A<int> and constructors.
-// We need an eagerly-emitted function here to get the problematic
-// deserialization ordering.
-void foobar() { N::A<int> x; }
diff --git a/test/Modules/Inputs/merge-template-members/b1.h b/test/Modules/Inputs/merge-template-members/b1.h
new file mode 100644 (file)
index 0000000..3828e26
--- /dev/null
@@ -0,0 +1,6 @@
+#include "a1.h"
+
+// Add update record for definition of A<int> and constructors.
+// We need an eagerly-emitted use here to get the problematic
+// deserialization ordering.
+N::A<int> b1;
diff --git a/test/Modules/Inputs/merge-template-members/b2.h b/test/Modules/Inputs/merge-template-members/b2.h
new file mode 100644 (file)
index 0000000..37357ac
--- /dev/null
@@ -0,0 +1,6 @@
+#include "a2.h"
+
+// Add update record for definition of A<int> and constructors.
+// We need an eagerly-emitted use here to get the problematic
+// deserialization ordering.
+N::A<int> b2;
index 54f34799c397e7eb01e7711e01f3a107c61473e3..92f20a0b132992ec8fb05cef1bfaf16d901efb4d 100644 (file)
@@ -11,4 +11,4 @@ namespace N {
 }
 
 // Merge in another declaration and update records.
-#include "b.h"
+#include "b1.h"
index 280667fcd79db89c5f9cf4547675cac280dd486b..0d72e58fbf1bbf1aa8160c5e5bc39744da02fad1 100644 (file)
@@ -1,6 +1,9 @@
 module def { header "def.h" export * }
 module update { header "update.h" export * }
 
-module a { header "a.h" export * }
-module b { header "b.h" export * }
+module a1 { header "a1.h" export * }
+module a2 { header "a2.h" export * }
+module b1 { header "b1.h" export * }
+module b2 { header "b2.h" export * }
+module merge { header "merge.h" export * }
 module c { header "c.h" export * }
index c0bfd2f22bb9bbe8a0aea2324e0b0edf1abcfe68..1fdaa9c29be2af2d91e0cc1a5e0fe0a8d1106a7a 100644 (file)
@@ -1,9 +1,10 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/merge-template-members -verify -emit-llvm-only %s
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/merge-template-members -verify -emit-llvm-only %s -DTEST=1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/merge-template-members -verify -emit-llvm-only %s -DTEST=2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/merge-template-members -verify -emit-llvm-only %s -DTEST=3
 // expected-no-diagnostics
 
-#include "c.h"
-N::A<int> ai;
+#if TEST == 1
 
 template<typename> struct A { int n; };
 template<typename> struct B { typedef A<void> C; };
@@ -11,3 +12,16 @@ template class B<int>;
 
 #include "update.h"
 B<int>::C use2;
+
+#elif TEST == 2
+
+#include "c.h"
+N::A<int> ai;
+
+#elif TEST == 3
+
+#include "merge.h"
+
+#else
+#error Unknown test
+#endif