Generate method/property @encodings from the foreign

SILFunctionType of the method instead of its formal type.

Gives more accurate information to the @encoding, makes
foreign error conventions work implicitly, and allows
IRGen's Swift-to-Clang to avoid duplicating arbitrary
amounts of the bridging logic from SILGen.

Some finagling was required in order to avoid calling
getConstantFunctionType from within other kinds of
lowering, which might have re-entered a generic context.

Also required fixing a bug with the type lowering of
optional DynamicSelfTypes where we would end up with
a substituted type in the lowered type.

Also, for some reason, our @encoding for -dealloc
methods was pretending that there was a formal parameter.
There didn't seem to be any justification for this,
and it's not like Clang does that.  Fixed.

Swift SVN r29266
This commit is contained in:
John McCall
2015-06-03 02:33:38 +00:00
parent d4986aab50
commit ed68d261e7
16 changed files with 347 additions and 275 deletions

View File

@@ -247,8 +247,7 @@ private:
/// SIL functions that we need to emit lazily.
llvm::SmallVector<SILFunction*, 4> LazyFunctionDefinitions;
/// The order in which all the SIL function definitions should
/// appear in the translation unit.
llvm::DenseMap<SILFunction*, unsigned> FunctionOrder;
@@ -514,11 +513,15 @@ private:
};
llvm::DenseMap<ProtocolDecl*, ObjCProtocolPair> ObjCProtocols;
llvm::SmallVector<ProtocolDecl*, 4> LazyObjCProtocolDefinitions;
/// A mapping from order numbers to the LLVM functions which we
/// created for the SIL functions with those orders.
SuccessorMap<unsigned, llvm::Function*> EmittedFunctionsByOrder;
ObjCProtocolPair getObjCProtocolGlobalVars(ProtocolDecl *proto);
void emitLazyObjCProtocolDefinitions();
void emitLazyObjCProtocolDefinition(ProtocolDecl *proto);
llvm::Constant *emitProtocolConformances();
void emitGlobalLists();
@@ -651,6 +654,9 @@ public:
// if there is no generic context.
ArchetypeBuilder &getContextArchetypes();
private:
void emitLazyPrivateDefinitions();
//--- Global context emission --------------------------------------------------
public:
void emitRuntimeRegistration();