Praetonus created this revision.
This change exposes the various CodeGenTypes::ConvertType functions in the
public Clang API. This allows external tools using the Clang API to rely on it
to generate LLVM types from C types. The precise use case that motivated this
change is explained in an email
<https://lists.llvm.org/pipermail/cfe-dev/2017-July/054550.html> to the Clang
mailing list.
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,20 @@
returnType, /*IsInstanceMethod=*/false, /*IsChainCall=*/false, argTypes,
info, {}, args);
}
+
+llvm::Type *
+CodeGen::ConvertType(CodeGenModule &CGM, QualType T) {
+ return CGM.getTypes().ConvertType(T);
+}
+
+llvm::Type *
+CodeGen::ConvertFunctionType(CodeGenModule &CGM,
+ QualType FT,
+ const FunctionDecl *FD) {
+ return CGM.getTypes().ConvertFunctionType(FT, FD);
+}
+
+llvm::Type *
+CodeGen::ConvertTypeForMem(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,14 @@
FunctionType::ExtInfo info,
RequiredArgs args);
+llvm::Type *ConvertType(CodeGenModule &CGM, QualType T);
+
+llvm::Type *ConvertFunctionType(CodeGenModule &CGM,
+ QualType FT,
+ const FunctionDecl *FD = nullptr);
+
+llvm::Type *ConvertTypeForMem(CodeGenModule &CGM, QualType T);
+
} // end namespace CodeGen
} // end namespace clang
Index: lib/CodeGen/CodeGenABITypes.cpp
===================================================================
--- lib/CodeGen/CodeGenABITypes.cpp
+++ lib/CodeGen/CodeGenABITypes.cpp
@@ -64,3 +64,20 @@
returnType, /*IsInstanceMethod=*/false, /*IsChainCall=*/false, argTypes,
info, {}, args);
}
+
+llvm::Type *
+CodeGen::ConvertType(CodeGenModule &CGM, QualType T) {
+ return CGM.getTypes().ConvertType(T);
+}
+
+llvm::Type *
+CodeGen::ConvertFunctionType(CodeGenModule &CGM,
+ QualType FT,
+ const FunctionDecl *FD) {
+ return CGM.getTypes().ConvertFunctionType(FT, FD);
+}
+
+llvm::Type *
+CodeGen::ConvertTypeForMem(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,14 @@
FunctionType::ExtInfo info,
RequiredArgs args);
+llvm::Type *ConvertType(CodeGenModule &CGM, QualType T);
+
+llvm::Type *ConvertFunctionType(CodeGenModule &CGM,
+ QualType FT,
+ const FunctionDecl *FD = nullptr);
+
+llvm::Type *ConvertTypeForMem(CodeGenModule &CGM, QualType T);
+
} // end namespace CodeGen
} // end namespace clang
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits