From de5d3c717684f3821b8db58037bc7140acf134aa Mon Sep 17 00:00:00 2001 From: John McCall Date: Fri, 17 Feb 2012 03:33:10 +0000 Subject: Whether an argument is required (in contrast with being an optional argument passed through the variadic ellipsis) potentially affects how we need to lower it. Propagate this information down to the various getFunctionInfo(...) overloads on CodeGenTypes. Furthermore, rename those overloads to clarify their distinct purposes, and make sure we're calling the right one in the right place. This has a nice side-effect of making it easier to construct a function type, since the 'variadic' bit is no longer separable. This shouldn't really change anything for our existing platforms, with one minor exception --- we should now call variadic ObjC methods with the ... in the "right place" (see the test case), which I guess matters for anyone running GNUStep on MIPS. Mostly it's just a substantial clean-up. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150788 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenTypes.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'lib/CodeGen/CodeGenTypes.cpp') diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index 16ca7ec80d..03465199a0 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -15,6 +15,7 @@ #include "CGCall.h" #include "CGCXXABI.h" #include "CGRecordLayout.h" +#include "TargetInfo.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclCXX.h" @@ -26,11 +27,12 @@ using namespace clang; using namespace CodeGen; -CodeGenTypes::CodeGenTypes(ASTContext &Ctx, llvm::Module& M, - const llvm::TargetData &TD, const ABIInfo &Info, - CGCXXABI &CXXABI, const CodeGenOptions &CGO) - : Context(Ctx), Target(Ctx.getTargetInfo()), TheModule(M), TheTargetData(TD), - TheABIInfo(Info), TheCXXABI(CXXABI), CodeGenOpts(CGO) { +CodeGenTypes::CodeGenTypes(CodeGenModule &CGM) + : Context(CGM.getContext()), Target(Context.getTargetInfo()), + TheModule(CGM.getModule()), TheTargetData(CGM.getTargetData()), + TheABIInfo(CGM.getTargetCodeGenInfo().getABIInfo()), + TheCXXABI(CGM.getCXXABI()), + CodeGenOpts(CGM.getCodeGenOpts()), CGM(CGM) { SkippedLayout = false; } @@ -473,16 +475,13 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) { // The function type can be built; call the appropriate routines to // build it. const CGFunctionInfo *FI; - bool isVariadic; if (const FunctionProtoType *FPT = dyn_cast(FT)) { - FI = &getFunctionInfo( + FI = &arrangeFunctionType( CanQual::CreateUnsafe(QualType(FPT, 0))); - isVariadic = FPT->isVariadic(); } else { const FunctionNoProtoType *FNPT = cast(FT); - FI = &getFunctionInfo( + FI = &arrangeFunctionType( CanQual::CreateUnsafe(QualType(FNPT, 0))); - isVariadic = true; } // If there is something higher level prodding our CGFunctionInfo, then @@ -494,7 +493,7 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) { } else { // Otherwise, we're good to go, go ahead and convert it. - ResultType = GetFunctionType(*FI, isVariadic); + ResultType = GetFunctionType(*FI); } RecordsBeingLaidOut.erase(Ty); -- cgit v1.2.3