r196712 - Fix pr18174.
Rafael Espindola
rafael.espindola at gmail.com
Sat Dec 7 17:13:22 PST 2013
Author: rafael
Date: Sat Dec 7 19:13:22 2013
New Revision: 196712
URL: http://llvm.org/viewvc/llvm-project?rev=196712&view=rev
Log:
Fix pr18174.
Clang outputs LLVM one top level decl at a time. This combined with the
visibility computation code looking for the newest NamespaceDecl would cause
it to produce different results for nested namespaces.
The two options for producing consistent results are
* Delay codegen of anything inside a namespace until the end of the file.
* Don't look for the newest NamespaceDecl.
This patch implements the second option.
This matches the gcc behavior too.
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=196712&r1=196711&r2=196712&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Sat Dec 7 19:13:22 2013
@@ -976,7 +976,7 @@ getExplicitVisibilityAux(const NamedDecl
kind);
// Use the most recent declaration.
- if (!IsMostRecent) {
+ if (!IsMostRecent && !isa<NamespaceDecl>(ND)) {
const NamedDecl *MostRecent = ND->getMostRecentDecl();
if (MostRecent != ND)
return getExplicitVisibilityAux(MostRecent, kind, true);
Modified: cfe/trunk/test/CodeGenCXX/visibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/visibility.cpp?rev=196712&r1=196711&r2=196712&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/visibility.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/visibility.cpp Sat Dec 7 19:13:22 2013
@@ -1295,3 +1295,17 @@ namespace test68 {
}
// Check lines at top of file.
}
+
+namespace test69 {
+ // PR18174
+ namespace foo {
+ void f();
+ }
+ namespace foo {
+ void f() {};
+ }
+ namespace foo __attribute__((visibility("hidden"))) {
+ }
+ // CHECK-LABEL: define void @_ZN6test693foo1fEv
+ // CHECK-HIDDEN-LABEL: define hidden void @_ZN6test693foo1fEv
+}
More information about the cfe-commits
mailing list