[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 13:27:02 PDT 2017


Praetonus updated this revision to Diff 105793.
Praetonus added a comment.

Patch updated based on @rjmccall's comments. I removed the wrapper for the ConvertType function, after giving it some thoughts I don't see any use case for it, I guess I added it by default. I left the convertFreeFunction function as returning an llvm::Type instead of an llvm::FunctionType as ConvertFunctionType represents incomplete function types as empty aggregate types.


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,14 @@
       returnType, /*IsInstanceMethod=*/false, /*IsChainCall=*/false, argTypes,
       info, {}, args);
 }
+
+llvm::Type *
+CodeGen::convertFreeFunctionType(CodeGenModule &CGM, const FunctionDecl *FD) {
+  assert(FD != nullptr && "Expected a non-null function declaration!");
+  return CGM.getTypes().ConvertFunctionType(FD->getType(), FD);
+}
+
+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,10 @@
                                               FunctionType::ExtInfo info,
                                               RequiredArgs args);
 
+llvm::Type *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.105793.patch
Type: text/x-patch
Size: 1363 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170709/0cdcb86e/attachment-0001.bin>


More information about the cfe-commits mailing list