]> granicus.if.org Git - clang/commitdiff
If a name is injected into an imported inline namespace without reopening that
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 23 Mar 2014 20:41:56 +0000 (20:41 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 23 Mar 2014 20:41:56 +0000 (20:41 +0000)
namespace, we need to update both the visible names of that namespace and of
its enclosing namespace set.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204570 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTWriterDecl.cpp
test/Modules/Inputs/cxx-inline-namespace.h
test/Modules/Inputs/module.map
test/Modules/cxx-inline-namespace.cpp

index 4474328ec3b3dfb1754a555c5be9edfdf8bb26c3..f0b0312834672c6da349cbaab292288b7c74ce2c 100644 (file)
@@ -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();
+    }
   }
 }
 
index 2525ad3569c05a2bf79756dd946ba52d62321f7d..4feb8501801eb80dc87015100b7d73fed90474b4 100644 (file)
@@ -9,3 +9,9 @@ namespace std {
     typedef int size_t;
   }
 }
+
+namespace X {
+  inline namespace Y {
+    struct Z;
+  }
+}
index 9f0fc0a29dc23fb46d5a9f8315178d490b4e52fd..d6effcf0ad0f88c0f8e9408ef5c1f36384d82a56 100644 (file)
@@ -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"
 }
index 5b967901b3384baff583c7b9922a69ce05d7bee7..f67d43b6843a17bf14664f207925242e2b4d5e4c 100644 (file)
@@ -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;
+@import cxx_inline_namespace_b;
 
 T x; // expected-error {{unknown type name 'T'}}
+
+X::Elaborated *p;