r204570 - If a name is injected into an imported inline namespace without reopening that
Richard Smith
richard-llvm at metafoo.co.uk
Sun Mar 23 13:41:56 PDT 2014
Author: rsmith
Date: Sun Mar 23 15:41:56 2014
New Revision: 204570
URL: http://llvm.org/viewvc/llvm-project?rev=204570&view=rev
Log:
If a name is injected into an imported inline namespace without reopening that
namespace, we need to update both the visible names of that namespace and of
its enclosing namespace set.
Modified:
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/Modules/Inputs/cxx-inline-namespace.h
cfe/trunk/test/Modules/Inputs/module.map
cfe/trunk/test/Modules/cxx-inline-namespace.cpp
Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=204570&r1=204569&r2=204570&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Sun Mar 23 15:41:56 2014
@@ -184,10 +184,15 @@ void ASTDeclWriter::VisitDecl(Decl *D) {
// This happens when we instantiate a class with a friend declaration or a
// function with a local extern declaration, for instance.
if (D->isOutOfLine()) {
- auto *NS = dyn_cast<NamespaceDecl>(D->getDeclContext()->getRedeclContext());
- // FIXME: Also update surrounding inline namespaces.
- if (NS && NS->isFromASTFile())
+ auto *DC = D->getDeclContext();
+ while (auto *NS = dyn_cast<NamespaceDecl>(DC->getRedeclContext())) {
+ if (!NS->isFromASTFile())
+ break;
Writer.AddUpdatedDeclContext(NS->getPrimaryContext());
+ if (!NS->isInlineNamespace())
+ break;
+ DC = NS->getParent();
+ }
}
}
Modified: cfe/trunk/test/Modules/Inputs/cxx-inline-namespace.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/cxx-inline-namespace.h?rev=204570&r1=204569&r2=204570&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/cxx-inline-namespace.h (original)
+++ cfe/trunk/test/Modules/Inputs/cxx-inline-namespace.h Sun Mar 23 15:41:56 2014
@@ -9,3 +9,9 @@ namespace std {
typedef int size_t;
}
}
+
+namespace X {
+ inline namespace Y {
+ struct Z;
+ }
+}
Modified: cfe/trunk/test/Modules/Inputs/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=204570&r1=204569&r2=204570&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/module.map (original)
+++ cfe/trunk/test/Modules/Inputs/module.map Sun Mar 23 15:41:56 2014
@@ -198,6 +198,10 @@ module cxx_inline_namespace {
header "cxx-inline-namespace.h"
}
+module cxx_inline_namespace_b {
+ header "cxx-inline-namespace-b.h"
+}
+
module cxx_linkage_cache {
header "cxx-linkage-cache.h"
}
Modified: cfe/trunk/test/Modules/cxx-inline-namespace.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/cxx-inline-namespace.cpp?rev=204570&r1=204569&r2=204570&view=diff
==============================================================================
--- cfe/trunk/test/Modules/cxx-inline-namespace.cpp (original)
+++ cfe/trunk/test/Modules/cxx-inline-namespace.cpp Sun Mar 23 15:41:56 2014
@@ -2,5 +2,8 @@
// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11
@import cxx_inline_namespace;
+ at import cxx_inline_namespace_b;
T x; // expected-error {{unknown type name 'T'}}
+
+X::Elaborated *p;
More information about the cfe-commits
mailing list