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
24using namespace clang;
25using namespace CodeGen;
26
27CodeGenABITypes::CodeGenABITypes(ASTContext &C,
28                                 llvm::Module &M,
29                                 const llvm::DataLayout &TD,
30                                 CoverageSourceInfo *CoverageInfo)
31  : CGO(new CodeGenOptions),
32    CGM(new CodeGen::CodeGenModule(C, *CGO, M, TD, C.getDiagnostics(),
33                                   CoverageInfo)) {
34}
35
36CodeGenABITypes::~CodeGenABITypes()
37{
38  delete CGO;
39  delete CGM;
40}
41
42const CGFunctionInfo &
43CodeGenABITypes::arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD,
44                                                 QualType receiverType) {
45  return CGM->getTypes().arrangeObjCMessageSendSignature(MD, receiverType);
46}
47
48const CGFunctionInfo &
49CodeGenABITypes::arrangeFreeFunctionType(CanQual<FunctionProtoType> Ty) {
50  return CGM->getTypes().arrangeFreeFunctionType(Ty);
51}
52
53const CGFunctionInfo &
54CodeGenABITypes::arrangeFreeFunctionType(CanQual<FunctionNoProtoType> Ty) {
55  return CGM->getTypes().arrangeFreeFunctionType(Ty);
56}
57
58const CGFunctionInfo &
59CodeGenABITypes::arrangeCXXMethodType(const CXXRecordDecl *RD,
60                                      const FunctionProtoType *FTP) {
61  return CGM->getTypes().arrangeCXXMethodType(RD, FTP);
62}
63
64const CGFunctionInfo &
65CodeGenABITypes::arrangeFreeFunctionCall(CanQualType returnType,
66                                         ArrayRef<CanQualType> argTypes,
67                                         FunctionType::ExtInfo info,
68                                         RequiredArgs args) {
69  return CGM->getTypes().arrangeLLVMFunctionInfo(
70      returnType, /*IsInstanceMethod=*/false, /*IsChainCall=*/false, argTypes,
71      info, args);
72}
73