r223860 - Updated the AST importer to support importing

Nico Rieck nico.rieck at gmail.com
Wed Dec 10 07:09:00 PST 2014


On 10.12.2014 01:00, Sean Callanan wrote:
> +  LinkageSpecDecl *ToLinkageSpec = LinkageSpecDecl::Create(Importer.getToContext(),
> +                                                           DC,
> +                                                           ExternLoc,
> +                                                           LangLoc,
> +                                                           D->getLanguage(),
> +                                                           HasBraces);
> +
> +  if (HasBraces) {
> +    SourceLocation RBraceLoc = Importer.Import(D->getRBraceLoc());
> +    ToLinkageSpec->setRBraceLoc(RBraceLoc);
> +  }

This can result in braceless LinkageSpecDecls without child decl when a
redeclaration is imported:

  extern "C" void foo();
  extern "C" void foo();

The DeclContext of the second decl is imported before the ASTImporter
looks up and returns the first decl, leaving the DeclContext empty.

I'm not sure how bad such empty LinkageSpecDecls are, but I've found
parts in clang that assert against it, like decl-printing.

-Nico



More information about the cfe-commits mailing list