[PATCH] D35180: Expose the Clang::QualType to llvm::Type conversion functions

Benoit Vey via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 9 15:59:59 PDT 2017


Praetonus updated this revision to Diff 105795.
Praetonus marked 3 inline comments as done.
Praetonus added a comment.

Patch updated. I've made the convertFreeFunctionType return null on failure.


https://reviews.llvm.org/D35180

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


Index: lib/CodeGen/CodeGenABITypes.cpp
===================================================================
--- lib/CodeGen/CodeGenABITypes.cpp
+++ lib/CodeGen/CodeGenABITypes.cpp
@@ -64,3 +64,19 @@
       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);
+}
Index: include/clang/CodeGen/CodeGenABITypes.h
===================================================================
--- include/clang/CodeGen/CodeGenABITypes.h
+++ include/clang/CodeGen/CodeGenABITypes.h
@@ -31,6 +31,7 @@
 namespace llvm {
   class DataLayout;
   class Module;
+  class Type;
 }
 
 namespace clang {
@@ -70,6 +71,12 @@
                                               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
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35180.105795.patch
Type: text/x-patch
Size: 1595 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170709/d34c3dcc/attachment-0001.bin>


More information about the cfe-commits mailing list