1 //==--- CodeGenABITypes.cpp - Convert Clang types to LLVM types for ABI ----==// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // CodeGenABITypes is a simple interface for getting LLVM types for 11 // the parameters and the return value of a function given the Clang 12 // types. 13 // 14 // The class is implemented as a public wrapper around the private 15 // CodeGenTypes class in lib/CodeGen. 16 // 17 //===----------------------------------------------------------------------===// 18 19 #include "clang/CodeGen/CodeGenABITypes.h" 20 #include "CodeGenModule.h" 21 #include "clang/CodeGen/CGFunctionInfo.h" 22 #include "clang/Frontend/CodeGenOptions.h" 23 #include "clang/Lex/HeaderSearchOptions.h" 24 #include "clang/Lex/PreprocessorOptions.h" 25 26 using namespace clang; 27 using namespace CodeGen; 28 29 CodeGenABITypes::CodeGenABITypes(ASTContext &C, llvm::Module &M, 30 CoverageSourceInfo *CoverageInfo) 31 : CGO(new CodeGenOptions), HSO(new HeaderSearchOptions), 32 PPO(new PreprocessorOptions), 33 CGM(new CodeGen::CodeGenModule(C, *HSO, *PPO, *CGO, M, C.getDiagnostics(), 34 CoverageInfo)) {} 35 36 const CGFunctionInfo & 37 CodeGenABITypes::arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD, 38 QualType receiverType) { 39 return CGM->getTypes().arrangeObjCMessageSendSignature(MD, receiverType); 40 } 41 42 const CGFunctionInfo & 43 CodeGenABITypes::arrangeFreeFunctionType(CanQual<FunctionProtoType> Ty) { 44 return CGM->getTypes().arrangeFreeFunctionType(Ty); 45 } 46 47 const CGFunctionInfo & 48 CodeGenABITypes::arrangeFreeFunctionType(CanQual<FunctionNoProtoType> Ty) { 49 return CGM->getTypes().arrangeFreeFunctionType(Ty); 50 } 51 52 const CGFunctionInfo & 53 CodeGenABITypes::arrangeCXXMethodType(const CXXRecordDecl *RD, 54 const FunctionProtoType *FTP) { 55 return CGM->getTypes().arrangeCXXMethodType(RD, FTP); 56 } 57 58 const CGFunctionInfo & 59 CodeGenABITypes::arrangeFreeFunctionCall(CanQualType returnType, 60 ArrayRef<CanQualType> argTypes, 61 FunctionType::ExtInfo info, 62 RequiredArgs args) { 63 return CGM->getTypes().arrangeLLVMFunctionInfo( 64 returnType, /*IsInstanceMethod=*/false, /*IsChainCall=*/false, argTypes, 65 info, args); 66 } 67