Merge commit 'a31edf53d0580efe47f4e9ef89dccc4429c056e8' into import-as-member

This commit is contained in:
Michael Ilseman
2016-03-23 13:05:57 -07:00
6536 changed files with 81412 additions and 56907 deletions

View File

@@ -326,7 +326,10 @@ SILLinkage SILDeclRef::getLinkage(ForDefinition_t forDefinition) const {
// Currying and calling convention thunks have shared linkage.
if (isThunk())
return SILLinkage::Shared;
// If a function declares a @_cdecl name, its native-to-foreign thunk is
// exported with the visibility of the function.
if (!isNativeToForeignThunk() || !d->getAttrs().hasAttribute<CDeclAttr>())
return SILLinkage::Shared;
// Enum constructors are essentially the same as thunks, they are
// emitted by need and have shared linkage.
@@ -508,13 +511,20 @@ static std::string mangleConstant(SILDeclRef c, StringRef prefix) {
return mangler.finalize();
}
// As a special case, functions can have external asm names.
// Use the asm name only for the original non-thunked, non-curried entry
// As a special case, functions can have manually mangled names.
// Use the SILGen name only for the original non-thunked, non-curried entry
// point.
if (auto AsmA = c.getDecl()->getAttrs().getAttribute<SILGenNameAttr>())
if (auto NameA = c.getDecl()->getAttrs().getAttribute<SILGenNameAttr>())
if (!c.isForeignToNativeThunk() && !c.isNativeToForeignThunk()
&& !c.isCurried) {
mangler.append(AsmA->Name);
mangler.append(NameA->Name);
return mangler.finalize();
}
// Use a given cdecl name for native-to-foreign thunks.
if (auto CDeclA = c.getDecl()->getAttrs().getAttribute<CDeclAttr>())
if (c.isNativeToForeignThunk()) {
mangler.append(CDeclA->Name);
return mangler.finalize();
}