From a729c62b81df17a1630de6b8f0709960bee9bc70 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. llvm-svn: 150788 --- clang/lib/CodeGen/CodeGenModule.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index dd613b4014f..c30fe22a674 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -66,7 +66,7 @@ CodeGenModule::CodeGenModule(ASTContext &C, const CodeGenOptions &CGO, : Context(C), Features(C.getLangOptions()), CodeGenOpts(CGO), TheModule(M), TheTargetData(TD), TheTargetCodeGenInfo(0), Diags(diags), ABI(createCXXABI(*this)), - Types(C, M, TD, getTargetCodeGenInfo().getABIInfo(), ABI, CGO), + Types(*this), TBAA(0), VTables(*this), ObjCRuntime(0), OpenCLRuntime(0), CUDARuntime(0), DebugInfo(0), ARCData(0), NoObjCARCExceptionsMetadata(0), @@ -580,7 +580,7 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, const FunctionDecl *FD = cast(GD.getDecl()); if (!IsIncompleteFunction) - SetLLVMFunctionAttributes(FD, getTypes().getFunctionInfo(GD), F); + SetLLVMFunctionAttributes(FD, getTypes().arrangeGlobalDeclaration(GD), F); // Only a few attributes are set on declarations; these may later be // overridden by a definition. @@ -1600,11 +1600,8 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD) { const FunctionDecl *D = cast(GD.getDecl()); // Compute the function info and LLVM type. - const CGFunctionInfo &FI = getTypes().getFunctionInfo(GD); - bool variadic = false; - if (const FunctionProtoType *fpt = D->getType()->getAs()) - variadic = fpt->isVariadic(); - llvm::FunctionType *Ty = getTypes().GetFunctionType(FI, variadic); + const CGFunctionInfo &FI = getTypes().arrangeGlobalDeclaration(GD); + llvm::FunctionType *Ty = getTypes().GetFunctionType(FI); // Get or create the prototype for the function. llvm::Constant *Entry = GetAddrOfFunction(GD, Ty); -- cgit v1.2.3