1 //==--- CodeGenABITypes.cpp - Convert Clang types to LLVM types for ABI ----==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // CodeGenABITypes is a simple interface for getting LLVM types for
11 // the parameters and the return value of a function given the Clang
14 // The class is implemented as a public wrapper around the private
15 // CodeGenTypes class in lib/CodeGen.
17 //===----------------------------------------------------------------------===//
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"
26 using namespace clang;
27 using namespace CodeGen;
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(),
36 // Explicitly out-of-line because ~CodeGenModule() is private but
37 // CodeGenABITypes.h is part of clang's API.
38 CodeGenABITypes::~CodeGenABITypes() = default;
40 const CGFunctionInfo &
41 CodeGenABITypes::arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD,
42 QualType receiverType) {
43 return CGM->getTypes().arrangeObjCMessageSendSignature(MD, receiverType);
46 const CGFunctionInfo &
47 CodeGenABITypes::arrangeFreeFunctionType(CanQual<FunctionProtoType> Ty,
48 const FunctionDecl *FD) {
49 return CGM->getTypes().arrangeFreeFunctionType(Ty, FD);
52 const CGFunctionInfo &
53 CodeGenABITypes::arrangeFreeFunctionType(CanQual<FunctionNoProtoType> Ty) {
54 return CGM->getTypes().arrangeFreeFunctionType(Ty);
57 const CGFunctionInfo &
58 CodeGenABITypes::arrangeCXXMethodType(const CXXRecordDecl *RD,
59 const FunctionProtoType *FTP,
60 const CXXMethodDecl *MD) {
61 return CGM->getTypes().arrangeCXXMethodType(RD, FTP, MD);
64 const CGFunctionInfo &CodeGenABITypes::arrangeFreeFunctionCall(
65 CanQualType returnType, ArrayRef<CanQualType> argTypes,
66 FunctionType::ExtInfo info, RequiredArgs args) {
67 return CGM->getTypes().arrangeLLVMFunctionInfo(
68 returnType, /*IsInstanceMethod=*/false, /*IsChainCall=*/false, argTypes,