break;
case TSK_ExplicitInstantiationDeclaration:
- return true; //FIXME: This looks wrong.
+ return false;
case TSK_ExplicitInstantiationDefinition:
// This is method of a explicit instantiation; mark all of the virtual
// Instantiate the members of this class template specialization.
Def = cast_or_null<ClassTemplateSpecializationDecl>(
Specialization->getDefinition());
- if (Def)
+ if (Def) {
+ TemplateSpecializationKind Old_TSK = Def->getTemplateSpecializationKind();
+
+ // Fix a TSK_ExplicitInstantiationDeclaration followed by a
+ // TSK_ExplicitInstantiationDefinition
+ if (Old_TSK == TSK_ExplicitInstantiationDeclaration &&
+ TSK == TSK_ExplicitInstantiationDefinition)
+ Def->setTemplateSpecializationKind(TSK);
+
InstantiateClassTemplateSpecializationMembers(TemplateNameLoc, Def, TSK);
+ }
return DeclPtrTy::make(Specialization);
}
--- /dev/null
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
+// CHECK: @_ZTVN5test018stdio_sync_filebufIwEE = constant
+
+namespace test0 {
+ struct basic_streambuf {
+ virtual ~basic_streambuf();
+ };
+ template<typename _CharT >
+ struct stdio_sync_filebuf : public basic_streambuf {
+ virtual void xsgetn();
+ };
+
+ // This specialization should cause the vtable to be emitted, even with
+ // the following extern template declaration.
+ template<> void stdio_sync_filebuf<wchar_t>::xsgetn() {
+ }
+ extern template class stdio_sync_filebuf<wchar_t>;
+}
+
+namespace test1 {
+ struct basic_streambuf {
+ virtual ~basic_streambuf();
+ };
+ template<typename _CharT >
+ struct stdio_sync_filebuf : public basic_streambuf {
+ virtual void xsgetn();
+ };
+
+ // Just a declaration should not force the vtable to be emitted.
+ template<> void stdio_sync_filebuf<wchar_t>::xsgetn();
+}