[cfe-commits] r161070 - in /cfe/trunk: lib/AST/Decl.cpp test/CodeGenCXX/visibility.cpp
Rafael Espindola
rafael.espindola at gmail.com
Tue Jul 31 12:02:03 PDT 2012
Author: rafael
Date: Tue Jul 31 14:02:02 2012
New Revision: 161070
URL: http://llvm.org/viewvc/llvm-project?rev=161070&view=rev
Log:
Consider the visibility of template template arguments. GCC doesn't, but it also
fails to consider the linkage, which we were already considering.
Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/test/CodeGenCXX/visibility.cpp
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=161070&r1=161069&r2=161070&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Jul 31 14:02:02 2012
@@ -710,6 +710,10 @@
if (llvm::Optional<Visibility> V = getVisibilityOf(this))
return V;
+ // The visibility of a template is stored in the templated decl.
+ if (const TemplateDecl *TD = dyn_cast<TemplateDecl>(this))
+ return getVisibilityOf(TD->getTemplatedDecl());
+
// If there wasn't explicit visibility there, and this is a
// specialization of a class template, check for visibility
// on the pattern.
Modified: cfe/trunk/test/CodeGenCXX/visibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/visibility.cpp?rev=161070&r1=161069&r2=161070&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/visibility.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/visibility.cpp Tue Jul 31 14:02:02 2012
@@ -1094,3 +1094,21 @@
// CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test594testIXadL_ZNS_1fEvEEXadL_ZNS_1gEvEEEEvv
}
}
+
+namespace test60 {
+ template<int i>
+ class __attribute__((visibility("hidden"))) a {};
+ template<int i>
+ class __attribute__((visibility("default"))) b {};
+ template<template<int> class x, template<int> class y>
+ void test() {}
+ void use() {
+ test<a, b>();
+ // CHECK: define linkonce_odr hidden void @_ZN6test604testINS_1aENS_1bEEEvv
+ // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test604testINS_1aENS_1bEEEvv
+
+ test<b, a>();
+ // CHECK: define linkonce_odr hidden void @_ZN6test604testINS_1bENS_1aEEEvv
+ // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test604testINS_1bENS_1aEEEvv
+ }
+}
More information about the cfe-commits
mailing list