CodeGenABITypes.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. const CGFunctionInfo &
  33. CodeGenABITypes::arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD,
  34. QualType receiverType) {
  35. return CGM->getTypes().arrangeObjCMessageSendSignature(MD, receiverType);
  36. }
  37. const CGFunctionInfo &
  38. CodeGenABITypes::arrangeFreeFunctionType(CanQual<FunctionProtoType> Ty) {
  39. return CGM->getTypes().arrangeFreeFunctionType(Ty);
  40. }
  41. const CGFunctionInfo &
  42. CodeGenABITypes::arrangeFreeFunctionType(CanQual<FunctionNoProtoType> Ty) {
  43. return CGM->getTypes().arrangeFreeFunctionType(Ty);
  44. }
  45. const CGFunctionInfo &
  46. CodeGenABITypes::arrangeCXXMethodType(const CXXRecordDecl *RD,
  47. const FunctionProtoType *FTP) {
  48. return CGM->getTypes().arrangeCXXMethodType(RD, FTP);
  49. }
  50. const CGFunctionInfo &
  51. CodeGenABITypes::arrangeFreeFunctionCall(CanQualType returnType,
  52. ArrayRef<CanQualType> argTypes,
  53. FunctionType::ExtInfo info,
  54. RequiredArgs args) {
  55. return CGM->getTypes().arrangeLLVMFunctionInfo(
  56. returnType, /*IsInstanceMethod=*/false, /*IsChainCall=*/false, argTypes,
  57. info, args);
  58. }