CodeGenABITypes.cpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. // Explicitly out-of-line because ~CodeGenModule() is private but
  33. // CodeGenABITypes.h is part of clang's API.
  34. CodeGenABITypes::~CodeGenABITypes() = default;
  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. const FunctionDecl *FD) {
  43. return CGM->getTypes().arrangeFreeFunctionType(Ty, FD);
  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. const CXXMethodDecl *MD) {
  53. return CGM->getTypes().arrangeCXXMethodType(RD, FTP, MD);
  54. }
  55. const CGFunctionInfo &CodeGenABITypes::arrangeFreeFunctionCall(
  56. CanQualType returnType, ArrayRef<CanQualType> argTypes,
  57. FunctionType::ExtInfo info, RequiredArgs args) {
  58. return CGM->getTypes().arrangeLLVMFunctionInfo(
  59. returnType, /*IsInstanceMethod=*/false, /*IsChainCall=*/false, argTypes,
  60. info, {}, args);
  61. }