r231950 - [modules] When merging the pattern of a class template definition into a prior
Richard Smith
richard-llvm at metafoo.co.uk
Wed Mar 11 11:21:03 PDT 2015
Author: rsmith
Date: Wed Mar 11 13:21:02 2015
New Revision: 231950
URL: http://llvm.org/viewvc/llvm-project?rev=231950&view=rev
Log:
[modules] When merging the pattern of a class template definition into a prior
definition, be sure to update the definition data on all declarations, not just
the canonical one, since the pattern might not be in the list of pending
definitions (if it used to be canonical itself).
One-line fix by me; reduced testcase by Daniel Jasper!
Added:
cfe/trunk/test/Modules/Inputs/merge-template-friend/
cfe/trunk/test/Modules/Inputs/merge-template-friend/def.h
cfe/trunk/test/Modules/Inputs/merge-template-friend/friend.h
cfe/trunk/test/Modules/Inputs/merge-template-friend/module.modulemap
cfe/trunk/test/Modules/merge-template-friend.cpp
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=231950&r1=231949&r2=231950&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Mar 11 13:21:02 2015
@@ -2158,6 +2158,7 @@ void ASTDeclReader::mergeTemplatePattern
DClass->IsCompleteDefinition = false;
} else {
ExistingClass->DefinitionData = DClass->DefinitionData;
+ Reader.PendingDefinitions.insert(DClass);
}
}
DClass->DefinitionData = ExistingClass->DefinitionData;
Added: cfe/trunk/test/Modules/Inputs/merge-template-friend/def.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-template-friend/def.h?rev=231950&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/merge-template-friend/def.h (added)
+++ cfe/trunk/test/Modules/Inputs/merge-template-friend/def.h Wed Mar 11 13:21:02 2015
@@ -0,0 +1,3 @@
+namespace ns {
+template <typename T> class C {};
+}
Added: cfe/trunk/test/Modules/Inputs/merge-template-friend/friend.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-template-friend/friend.h?rev=231950&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/merge-template-friend/friend.h (added)
+++ cfe/trunk/test/Modules/Inputs/merge-template-friend/friend.h Wed Mar 11 13:21:02 2015
@@ -0,0 +1,4 @@
+namespace ns { template <typename T> class C; };
+class A {
+ template <typename T> friend class ::ns::C;
+};
Added: cfe/trunk/test/Modules/Inputs/merge-template-friend/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-template-friend/module.modulemap?rev=231950&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/merge-template-friend/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/merge-template-friend/module.modulemap Wed Mar 11 13:21:02 2015
@@ -0,0 +1,3 @@
+module a { header "friend.h" export * }
+module b { header "def.h" export * }
+
Added: cfe/trunk/test/Modules/merge-template-friend.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/merge-template-friend.cpp?rev=231950&view=auto
==============================================================================
--- cfe/trunk/test/Modules/merge-template-friend.cpp (added)
+++ cfe/trunk/test/Modules/merge-template-friend.cpp Wed Mar 11 13:21:02 2015
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+//
+// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
+// RUN: -emit-module -fmodule-name=a -o %t/a.pcm \
+// RUN: %S/Inputs/merge-template-friend/module.modulemap
+//
+// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
+// RUN: -emit-module -fmodule-name=b -o %t/b.pcm \
+// RUN: %S/Inputs/merge-template-friend/module.modulemap
+//
+// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
+// RUN: -I%S/Inputs/merge-template-friend \
+// RUN: -fmodule-file=%t/a.pcm \
+// RUN: -fmodule-file=%t/b.pcm \
+// RUN: -verify %s
+
+#include "friend.h"
+#include "def.h"
+
+::ns::C<int> c;
+
+// expected-no-diagnostics
More information about the cfe-commits
mailing list