#include "clang/CodeGen/CodeGenABITypes.h"
#include "CGCXXABI.h"
#include "CGRecordLayout.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/CodeGen/CGFunctionInfo.h"
#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/Lex/PreprocessorOptions.h"
using namespace clang;
using namespace CodeGen;
void CodeGen::addDefaultFunctionDefinitionAttributes(CodeGenModule &CGM,
llvm::AttrBuilder &attrs) {
CGM.addDefaultFunctionDefinitionAttributes(attrs);
}
const CGFunctionInfo &
CodeGen::arrangeObjCMessageSendSignature(CodeGenModule &CGM,
const ObjCMethodDecl *MD,
QualType receiverType) {
return CGM.getTypes().arrangeObjCMessageSendSignature(MD, receiverType);
}
const CGFunctionInfo &
CodeGen::arrangeFreeFunctionType(CodeGenModule &CGM,
CanQual<FunctionProtoType> Ty) {
return CGM.getTypes().arrangeFreeFunctionType(Ty);
}
const CGFunctionInfo &
CodeGen::arrangeFreeFunctionType(CodeGenModule &CGM,
CanQual<FunctionNoProtoType> Ty) {
return CGM.getTypes().arrangeFreeFunctionType(Ty);
}
const CGFunctionInfo &
CodeGen::arrangeCXXMethodType(CodeGenModule &CGM,
const CXXRecordDecl *RD,
const FunctionProtoType *FTP,
const CXXMethodDecl *MD) {
return CGM.getTypes().arrangeCXXMethodType(RD, FTP, MD);
}
const CGFunctionInfo &
CodeGen::arrangeFreeFunctionCall(CodeGenModule &CGM,
CanQualType returnType,
ArrayRef<CanQualType> argTypes,
FunctionType::ExtInfo info,
RequiredArgs args) {
return CGM.getTypes().arrangeLLVMFunctionInfo(
returnType, false, false, argTypes,
info, {}, args);
}
ImplicitCXXConstructorArgs
CodeGen::getImplicitCXXConstructorArgs(CodeGenModule &CGM,
const CXXConstructorDecl *D) {
CodeGenFunction CGF(CGM, true);
CGCXXABI::AddedStructorArgs addedArgs =
CGM.getCXXABI().getImplicitConstructorArgs(CGF, D, Ctor_Complete,
false,
false);
ImplicitCXXConstructorArgs implicitArgs;
for (const auto &arg : addedArgs.Prefix) {
implicitArgs.Prefix.push_back(arg.Value);
}
for (const auto &arg : addedArgs.Suffix) {
implicitArgs.Suffix.push_back(arg.Value);
}
return implicitArgs;
}
llvm::FunctionType *
CodeGen::convertFreeFunctionType(CodeGenModule &CGM, const FunctionDecl *FD) {
assert(FD != nullptr && "Expected a non-null function declaration!");
llvm::Type *T = CGM.getTypes().ConvertType(FD->getType());
if (auto FT = dyn_cast<llvm::FunctionType>(T))
return FT;
return nullptr;
}
llvm::Type *
CodeGen::convertTypeForMemory(CodeGenModule &CGM, QualType T) {
return CGM.getTypes().ConvertTypeForMem(T);
}
unsigned CodeGen::getLLVMFieldNumber(CodeGenModule &CGM,
const RecordDecl *RD,
const FieldDecl *FD) {
return CGM.getTypes().getCGRecordLayout(RD).getLLVMFieldNo(FD);
}
llvm::Value *CodeGen::getCXXDestructorImplicitParam(
CodeGenModule &CGM, llvm::BasicBlock *InsertBlock,
llvm::BasicBlock::iterator InsertPoint, const CXXDestructorDecl *D,
CXXDtorType Type, bool ForVirtualBase, bool Delegating) {
CodeGenFunction CGF(CGM, true);
CGF.CurCodeDecl = D;
CGF.CurFuncDecl = D;
CGF.CurFn = InsertBlock->getParent();
CGF.Builder.SetInsertPoint(InsertBlock, InsertPoint);
return CGM.getCXXABI().getCXXDestructorImplicitParam(
CGF, D, Type, ForVirtualBase, Delegating);
}