[cfe-commits] r160057 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/CodeGenCXX/visibility.cpp
Rafael Espindola
rafael.espindola at gmail.com
Wed Jul 11 11:14:10 PDT 2012
Author: rafael
Date: Wed Jul 11 13:14:09 2012
New Revision: 160057
URL: http://llvm.org/viewvc/llvm-project?rev=160057&view=rev
Log:
Handle #pragma visibility in explicit specializations and enums.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGenCXX/visibility.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=160057&r1=160056&r2=160057&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jul 11 13:14:09 2012
@@ -8931,6 +8931,10 @@
if (isa<CXXRecordDecl>(Tag))
FieldCollector->FinishClass();
+ // If there's a #pragma GCC visibility in scope, and this isn't a subclass,
+ // set the visibility of this record.
+ AddPushedVisibilityAttribute(Tag);
+
// Exit this scope of this tag's definition.
PopDeclContext();
@@ -10059,12 +10063,6 @@
if (Attr)
ProcessDeclAttributeList(S, Record, Attr);
-
- // If there's a #pragma GCC visibility in scope, and this isn't a subclass,
- // set the visibility of this record.
- if (Record && !Record->getDeclContext()->isRecord() &&
- !isa<ClassTemplateSpecializationDecl>(Record))
- AddPushedVisibilityAttribute(Record);
}
/// \brief Determine whether the given integral value is representable within
Modified: cfe/trunk/test/CodeGenCXX/visibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/visibility.cpp?rev=160057&r1=160056&r2=160057&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/visibility.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/visibility.cpp Wed Jul 11 13:14:09 2012
@@ -980,10 +980,24 @@
static void _M_fill_insert();
};
#pragma GCC visibility push(hidden)
+ // GCC doesn't seem to use the visibility of enums at all, we do.
+ enum zed {v1};
+
+ // GCC fails to mark this specialization hidden, we mark it.
+ template<>
+ struct vector<int> {
+ static void _M_fill_insert();
+ };
void foo() {
vector<unsigned>::_M_fill_insert();
+ vector<int>::_M_fill_insert();
+ vector<zed>::_M_fill_insert();
}
#pragma GCC visibility pop
// CHECK: declare void @_ZN6test536vectorIjE14_M_fill_insertEv
// CHECK-HIDDEN: declare void @_ZN6test536vectorIjE14_M_fill_insertEv
+ // CHECK: declare hidden void @_ZN6test536vectorIiE14_M_fill_insertEv
+ // CHECK-HIDDEN: declare hidden void @_ZN6test536vectorIiE14_M_fill_insertEv
+ // CHECK: declare hidden void @_ZN6test536vectorINS_3zedEE14_M_fill_insertEv
+ // CHECK-HIDDEN: declare hidden void @_ZN6test536vectorINS_3zedEE14_M_fill_insertEv
}
More information about the cfe-commits
mailing list