CodeGenABITypes.cpp 2.4 KB

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