Index: clang/include/clang/CodeGen/CodeGenABITypes.h =================================================================== --- clang/include/clang/CodeGen/CodeGenABITypes.h +++ clang/include/clang/CodeGen/CodeGenABITypes.h @@ -25,6 +25,7 @@ #include "clang/AST/CanonicalType.h" #include "clang/AST/Type.h" +#include "clang/Basic/ABI.h" #include "clang/CodeGen/CGFunctionInfo.h" namespace llvm { @@ -38,6 +39,7 @@ namespace clang { class ASTContext; +class CXXConstructorDecl; class CXXRecordDecl; class CXXMethodDecl; class CodeGenOptions; @@ -73,6 +75,20 @@ FunctionType::ExtInfo info, RequiredArgs args); +const CGFunctionInfo &arrangeCXXConstructorCall(CodeGenModule &CGM, + ArrayRef argTypes, + const CXXConstructorDecl *CD, + CXXCtorType CtorKind, + unsigned ExtraPrefixArgs, + unsigned ExtraSuffixArgs, + bool PassProtoArgs = true); + +const CGFunctionInfo &arrangeCXXMethodCall(CodeGenModule &CGM, + ArrayRef argTypes, + const FunctionProtoType *type, + RequiredArgs required, + unsigned numPrefixArgs); + /// Returns null if the function type is incomplete and can't be lowered. llvm::FunctionType *convertFreeFunctionType(CodeGenModule &CGM, const FunctionDecl *FD); Index: clang/lib/CodeGen/CGCall.cpp =================================================================== --- clang/lib/CodeGen/CGCall.cpp +++ clang/lib/CodeGen/CGCall.cpp @@ -399,6 +399,17 @@ for (const auto &Arg : args) ArgTypes.push_back(Context.getCanonicalParamType(Arg.Ty)); + return arrangeCXXConstructorCall(ArgTypes, D, CtorKind, ExtraPrefixArgs, + ExtraSuffixArgs, PassProtoArgs); +} + +const CGFunctionInfo & +CodeGenTypes::arrangeCXXConstructorCall(ArrayRef ArgTypes, + const CXXConstructorDecl *D, + CXXCtorType CtorKind, + unsigned ExtraPrefixArgs, + unsigned ExtraSuffixArgs, + bool PassProtoArgs) { // +1 for implicit this, which should always be args[0]. unsigned TotalPrefixArgs = 1 + ExtraPrefixArgs; @@ -677,15 +688,23 @@ const FunctionProtoType *proto, RequiredArgs required, unsigned numPrefixArgs) { - assert(numPrefixArgs + 1 <= args.size() && + // FIXME: Kill copy. + auto argTypes = getArgTypesForCall(Context, args); + + return arrangeCXXMethodCall(argTypes, proto, required, numPrefixArgs); +} + +const CGFunctionInfo & +CodeGenTypes::arrangeCXXMethodCall(ArrayRef argTypes, + const FunctionProtoType *proto, + RequiredArgs required, + unsigned numPrefixArgs) { + assert(numPrefixArgs + 1 <= argTypes.size() && "Emitting a call with less args than the required prefix?"); // Add one to account for `this`. It's a bit awkward here, but we don't count // `this` in similar places elsewhere. auto paramInfos = - getExtParameterInfosForCall(proto, numPrefixArgs + 1, args.size()); - - // FIXME: Kill copy. - auto argTypes = getArgTypesForCall(Context, args); + getExtParameterInfosForCall(proto, numPrefixArgs + 1, argTypes.size()); FunctionType::ExtInfo info = proto->getExtInfo(); return arrangeLLVMFunctionInfo( Index: clang/lib/CodeGen/CodeGenABITypes.cpp =================================================================== --- clang/lib/CodeGen/CodeGenABITypes.cpp +++ clang/lib/CodeGen/CodeGenABITypes.cpp @@ -63,6 +63,27 @@ info, {}, args); } +const CGFunctionInfo & +CodeGen::arrangeCXXConstructorCall(CodeGenModule &CGM, + ArrayRef argTypes, + const CXXConstructorDecl *CD, + CXXCtorType CtorKind, + unsigned ExtraPrefixArgs, + unsigned ExtraSuffixArgs, + bool PassProtoArgs) { + return CGM.getTypes().arrangeCXXConstructorCall( + argTypes, CD, CtorKind, ExtraPrefixArgs, ExtraSuffixArgs, PassProtoArgs); +} + +const CGFunctionInfo &arrangeCXXMethodCall(CodeGenModule &CGM, + ArrayRef argTypes, + const FunctionProtoType *type, + RequiredArgs required, + unsigned numPrefixArgs) { + return CGM.getTypes().arrangeCXXMethodCall(argTypes, type, required, + numPrefixArgs); +} + llvm::FunctionType * CodeGen::convertFreeFunctionType(CodeGenModule &CGM, const FunctionDecl *FD) { assert(FD != nullptr && "Expected a non-null function declaration!"); Index: clang/lib/CodeGen/CodeGenTypes.h =================================================================== --- clang/lib/CodeGen/CodeGenTypes.h +++ clang/lib/CodeGen/CodeGenTypes.h @@ -244,11 +244,22 @@ unsigned ExtraPrefixArgs, unsigned ExtraSuffixArgs, bool PassProtoArgs = true); + const CGFunctionInfo & + arrangeCXXConstructorCall(ArrayRef ArgTypes, + const CXXConstructorDecl *D, + CXXCtorType CtorKind, + unsigned ExtraPrefixArgs, + unsigned ExtraSuffixArgs, + bool PassProtoArgs = true); const CGFunctionInfo &arrangeCXXMethodCall(const CallArgList &args, const FunctionProtoType *type, RequiredArgs required, unsigned numPrefixArgs); + const CGFunctionInfo &arrangeCXXMethodCall(ArrayRef argTypes, + const FunctionProtoType *type, + RequiredArgs required, + unsigned numPrefixArgs); const CGFunctionInfo & arrangeUnprototypedMustTailThunk(const CXXMethodDecl *MD); const CGFunctionInfo &arrangeMSCtorClosure(const CXXConstructorDecl *CD,