]> granicus.if.org Git - clang/commitdiff
Expose some type-conversion functions as part of the IRGen ABI.
authorJohn McCall <rjmccall@apple.com>
Wed, 12 Jul 2017 07:44:17 +0000 (07:44 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 12 Jul 2017 07:44:17 +0000 (07:44 +0000)
Patch by Benoit Vey!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307760 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/CodeGen/CodeGenABITypes.h
lib/CodeGen/CodeGenABITypes.cpp

index 8ba769dfc3af33966d216b97b50b93ab80ca82af..615e55c8b69f8c35eb66b88382c7a3a32b69393e 100644 (file)
@@ -31,6 +31,8 @@
 namespace llvm {
   class DataLayout;
   class Module;
+  class FunctionType;
+  class Type;
 }
 
 namespace clang {
@@ -70,6 +72,12 @@ const CGFunctionInfo &arrangeFreeFunctionCall(CodeGenModule &CGM,
                                               FunctionType::ExtInfo info,
                                               RequiredArgs args);
 
+// Returns null if the function type is incomplete and can't be lowered.
+llvm::FunctionType *convertFreeFunctionType(CodeGenModule &CGM,
+                                            const FunctionDecl *FD);
+
+llvm::Type *convertTypeForMemory(CodeGenModule &CGM, QualType T);
+
 }  // end namespace CodeGen
 }  // end namespace clang
 
index 166f44f816f31183e03b40c03eeeed93eabd885f..0735a9c3dfbc1de91e67d7858c55aaab93e15eba 100644 (file)
@@ -64,3 +64,19 @@ CodeGen::arrangeFreeFunctionCall(CodeGenModule &CGM,
       returnType, /*IsInstanceMethod=*/false, /*IsChainCall=*/false, argTypes,
       info, {}, args);
 }
+
+llvm::FunctionType *
+CodeGen::convertFreeFunctionType(CodeGenModule &CGM, const FunctionDecl *FD) {
+  assert(FD != nullptr && "Expected a non-null function declaration!");
+  llvm::Type *T = CGM.getTypes().ConvertFunctionType(FD->getType(), FD);
+
+  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);
+}