[cfe-commits] r114874 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiate.cpp test/CodeGenCXX/template-inner-struct-visibility-hidden.cpp
Nico Weber
nicolasweber at gmx.de
Mon Sep 27 14:02:09 PDT 2010
Author: nico
Date: Mon Sep 27 16:02:09 2010
New Revision: 114874
URL: http://llvm.org/viewvc/llvm-project?rev=114874&view=rev
Log:
Correctly set "explicit template instantiation" kind on inner structs of templates whose explicit instantiation is first declared and then defined.
Fixes http://llvm.org/pr8207
Added:
cfe/trunk/test/CodeGenCXX/template-inner-struct-visibility-hidden.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=114874&r1=114873&r2=114874&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Mon Sep 27 16:02:09 2010
@@ -1447,7 +1447,7 @@
if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK,
Function,
MSInfo->getTemplateSpecializationKind(),
- MSInfo->getPointOfInstantiation(),
+ MSInfo->getPointOfInstantiation(),
SuppressNew) ||
SuppressNew)
continue;
@@ -1483,7 +1483,7 @@
if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK,
Var,
MSInfo->getTemplateSpecializationKind(),
- MSInfo->getPointOfInstantiation(),
+ MSInfo->getPointOfInstantiation(),
SuppressNew) ||
SuppressNew)
continue;
@@ -1518,11 +1518,11 @@
if (MSInfo->getTemplateSpecializationKind()
== TSK_ExplicitSpecialization)
continue;
-
+
if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK,
Record,
MSInfo->getTemplateSpecializationKind(),
- MSInfo->getPointOfInstantiation(),
+ MSInfo->getPointOfInstantiation(),
SuppressNew) ||
SuppressNew)
continue;
@@ -1549,6 +1549,13 @@
InstantiateClass(PointOfInstantiation, Record, Pattern,
TemplateArgs,
TSK);
+ } else {
+ if (TSK == TSK_ExplicitInstantiationDefinition &&
+ Record->getTemplateSpecializationKind() ==
+ TSK_ExplicitInstantiationDeclaration) {
+ Record->setTemplateSpecializationKind(TSK);
+ MarkVTableUsed(PointOfInstantiation, Record, true);
+ }
}
Pattern = cast_or_null<CXXRecordDecl>(Record->getDefinition());
Added: cfe/trunk/test/CodeGenCXX/template-inner-struct-visibility-hidden.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/template-inner-struct-visibility-hidden.cpp?rev=114874&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/template-inner-struct-visibility-hidden.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/template-inner-struct-visibility-hidden.cpp Mon Sep 27 16:02:09 2010
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fvisibility hidden -emit-llvm -o - %s | FileCheck %s
+
+// Verify that symbols are hidden.
+// CHECK: @_ZN1CIiE5Inner6Inner26StaticE = weak hidden global
+// CHECK: define weak_odr hidden void @_ZN1CIiE5Inner1fEv
+// CHECK: define weak_odr hidden void @_ZN1CIiE5Inner6Inner21gEv
+
+template<typename T>
+struct C {
+ struct Inner {
+ void f();
+ struct Inner2 {
+ void g();
+ static int Static;
+ };
+ };
+};
+
+template<typename T> void C<T>::Inner::f() { }
+template<typename T> void C<T>::Inner::Inner2::g() { }
+template<typename T> int C<T>::Inner::Inner2::Static;
+
+extern template struct C<int>;
+template struct C<int>;
More information about the cfe-commits
mailing list