Skip to content
Snippets Groups Projects
Commit 7c2d0241 authored by Rafael Espindola's avatar Rafael Espindola
Browse files

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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196712 91177308-0d34-0410-b5e6-96231b3b80d8
parent 24ba25c6
No related branches found
No related tags found
No related merge requests found
......@@ -976,7 +976,7 @@ getExplicitVisibilityAux(const NamedDecl *ND,
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);
......
......@@ -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
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment