Provide ways to get back to the original Clang declaration from

a SILFunction or SILGLobalVariable.

This will be used as one step towards moving IRGen off of the
global external-definitions list.
This commit is contained in:
John McCall
2016-05-18 11:33:17 -07:00
parent ea1bf9c999
commit c2b8bb22ba
11 changed files with 105 additions and 37 deletions

View File

@@ -355,10 +355,12 @@ SILFunction *SILModule::getOrCreateFunction(SILLocation loc,
F->setGlobalInit(constant.isGlobal());
if (constant.hasDecl()) {
if (constant.isForeign && constant.isClangGenerated())
F->setForeignBody(HasForeignBody);
auto decl = constant.getDecl();
auto Attrs = constant.getDecl()->getAttrs();
if (constant.isForeign && decl->hasClangNode())
F->setClangNodeOwner(decl);
auto Attrs = decl->getAttrs();
for (auto *A : Attrs.getAttributes<SemanticsAttr, false /*AllowInvalid*/>())
F->addSemanticsAttr(cast<SemanticsAttr>(A)->Value);