diff options
Diffstat (limited to 'clang/lib/Serialization/ASTWriterDecl.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriterDecl.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index 4474328ec3b..f0b03128346 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -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(); + } } } |