r228104 - [modules] If we already have a fake definition for one declaration of a class,
Richard Smith
richard-llvm at metafoo.co.uk
Tue Feb 3 17:23:46 PST 2015
Author: rsmith
Date: Tue Feb 3 19:23:46 2015
New Revision: 228104
URL: http://llvm.org/viewvc/llvm-project?rev=228104&view=rev
Log:
[modules] If we already have a fake definition for one declaration of a class,
don't think we're providing a new one in an update record adding a definition
to another declaration of the same class.
Added:
cfe/trunk/test/Modules/Inputs/merge-template-members/a1.h
- copied unchanged from r227939, cfe/trunk/test/Modules/Inputs/merge-template-members/a.h
cfe/trunk/test/Modules/Inputs/merge-template-members/a2.h
- copied unchanged from r227939, cfe/trunk/test/Modules/Inputs/merge-template-members/a.h
cfe/trunk/test/Modules/Inputs/merge-template-members/b1.h
- copied, changed from r227939, cfe/trunk/test/Modules/Inputs/merge-template-members/b.h
cfe/trunk/test/Modules/Inputs/merge-template-members/b2.h
- copied, changed from r227939, cfe/trunk/test/Modules/Inputs/merge-template-members/b.h
Removed:
cfe/trunk/test/Modules/Inputs/merge-template-members/a.h
cfe/trunk/test/Modules/Inputs/merge-template-members/b.h
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/test/Modules/Inputs/merge-template-members/c.h
cfe/trunk/test/Modules/Inputs/merge-template-members/module.modulemap
cfe/trunk/test/Modules/merge-template-members.cpp
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=228104&r1=228103&r2=228104&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue Feb 3 19:23:46 2015
@@ -3648,7 +3648,8 @@ void ASTDeclReader::UpdateDecl(Decl *D,
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.
Removed: cfe/trunk/test/Modules/Inputs/merge-template-members/a.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-template-members/a.h?rev=228103&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/merge-template-members/a.h (original)
+++ cfe/trunk/test/Modules/Inputs/merge-template-members/a.h (removed)
@@ -1,9 +0,0 @@
-namespace N {
- template <typename> struct A {
- int n;
- A() : n() {}
- };
-
- // Create declaration of A<int>.
- typedef A<int> AI;
-}
Removed: cfe/trunk/test/Modules/Inputs/merge-template-members/b.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-template-members/b.h?rev=228103&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/merge-template-members/b.h (original)
+++ cfe/trunk/test/Modules/Inputs/merge-template-members/b.h (removed)
@@ -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; }
Copied: cfe/trunk/test/Modules/Inputs/merge-template-members/b1.h (from r227939, cfe/trunk/test/Modules/Inputs/merge-template-members/b.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-template-members/b1.h?p2=cfe/trunk/test/Modules/Inputs/merge-template-members/b1.h&p1=cfe/trunk/test/Modules/Inputs/merge-template-members/b.h&r1=227939&r2=228104&rev=228104&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/merge-template-members/b.h (original)
+++ cfe/trunk/test/Modules/Inputs/merge-template-members/b1.h Tue Feb 3 19:23:46 2015
@@ -1,6 +1,6 @@
-#include "a.h"
+#include "a1.h"
// Add update record for definition of A<int> and constructors.
-// We need an eagerly-emitted function here to get the problematic
+// We need an eagerly-emitted use here to get the problematic
// deserialization ordering.
-void foobar() { N::A<int> x; }
+N::A<int> b1;
Copied: cfe/trunk/test/Modules/Inputs/merge-template-members/b2.h (from r227939, cfe/trunk/test/Modules/Inputs/merge-template-members/b.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-template-members/b2.h?p2=cfe/trunk/test/Modules/Inputs/merge-template-members/b2.h&p1=cfe/trunk/test/Modules/Inputs/merge-template-members/b.h&r1=227939&r2=228104&rev=228104&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/merge-template-members/b.h (original)
+++ cfe/trunk/test/Modules/Inputs/merge-template-members/b2.h Tue Feb 3 19:23:46 2015
@@ -1,6 +1,6 @@
-#include "a.h"
+#include "a2.h"
// Add update record for definition of A<int> and constructors.
-// We need an eagerly-emitted function here to get the problematic
+// We need an eagerly-emitted use here to get the problematic
// deserialization ordering.
-void foobar() { N::A<int> x; }
+N::A<int> b2;
Modified: cfe/trunk/test/Modules/Inputs/merge-template-members/c.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-template-members/c.h?rev=228104&r1=228103&r2=228104&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/merge-template-members/c.h (original)
+++ cfe/trunk/test/Modules/Inputs/merge-template-members/c.h Tue Feb 3 19:23:46 2015
@@ -11,4 +11,4 @@ namespace N {
}
// Merge in another declaration and update records.
-#include "b.h"
+#include "b1.h"
Modified: cfe/trunk/test/Modules/Inputs/merge-template-members/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-template-members/module.modulemap?rev=228104&r1=228103&r2=228104&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/merge-template-members/module.modulemap (original)
+++ cfe/trunk/test/Modules/Inputs/merge-template-members/module.modulemap Tue Feb 3 19:23:46 2015
@@ -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 * }
Modified: cfe/trunk/test/Modules/merge-template-members.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/merge-template-members.cpp?rev=228104&r1=228103&r2=228104&view=diff
==============================================================================
--- cfe/trunk/test/Modules/merge-template-members.cpp (original)
+++ cfe/trunk/test/Modules/merge-template-members.cpp Tue Feb 3 19:23:46 2015
@@ -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
More information about the cfe-commits
mailing list