CodeGenABITypes.cpp 2.6 KB

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