From 66b6f8183375ed545ef884192be4acef7500f7e9 Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Wed, 10 Dec 2014 00:00:37 +0000 Subject: [PATCH] Updated the AST importer to support importing LinkageSpecDecls. This is relevant when LLDB wants to import Decls from non-C++ modules, since many declarations are in extern "C" blocks. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223860 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ASTImporter.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 07b2a73ee8..88e5a41e60 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -151,6 +151,7 @@ namespace clang { Decl *VisitObjCMethodDecl(ObjCMethodDecl *D); Decl *VisitObjCCategoryDecl(ObjCCategoryDecl *D); Decl *VisitObjCProtocolDecl(ObjCProtocolDecl *D); + Decl *VisitLinkageSpecDecl(LinkageSpecDecl *D); Decl *VisitObjCInterfaceDecl(ObjCInterfaceDecl *D); Decl *VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D); Decl *VisitObjCImplementationDecl(ObjCImplementationDecl *D); @@ -3470,6 +3471,35 @@ Decl *ASTNodeImporter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) { return ToProto; } +Decl *ASTNodeImporter::VisitLinkageSpecDecl(LinkageSpecDecl *D) { + DeclContext *DC = Importer.ImportContext(D->getDeclContext()); + DeclContext *LexicalDC = Importer.ImportContext(D->getLexicalDeclContext()); + + SourceLocation ExternLoc = Importer.Import(D->getExternLoc()); + SourceLocation LangLoc = Importer.Import(D->getLocation()); + + bool HasBraces = D->hasBraces(); + + LinkageSpecDecl *ToLinkageSpec = LinkageSpecDecl::Create(Importer.getToContext(), + DC, + ExternLoc, + LangLoc, + D->getLanguage(), + HasBraces); + + if (HasBraces) { + SourceLocation RBraceLoc = Importer.Import(D->getRBraceLoc()); + ToLinkageSpec->setRBraceLoc(RBraceLoc); + } + + ToLinkageSpec->setLexicalDeclContext(LexicalDC); + LexicalDC->addDeclInternal(ToLinkageSpec); + + Importer.Imported(D, ToLinkageSpec); + + return ToLinkageSpec; +} + bool ASTNodeImporter::ImportDefinition(ObjCInterfaceDecl *From, ObjCInterfaceDecl *To, ImportDefinitionKind Kind) { -- 2.40.0