[llvm-dev] Few mistakes on TypeBuilder.h
Pierre Gagelin via llvm-dev
llvm-dev at lists.llvm.org
Wed Jun 22 06:14:33 PDT 2016
Hi,
I built my own type for some reason and it appears some minor mistakes are
present in the file (or I am getting wrong at some point and I am
interested to know where) TypeBuilder.h.
There is a little usecase presented at the beginning:
/// \code{.cpp}
///
/// struct MyType {
/// int32 a;
/// int32 *b;
/// void *array[1]; // Intended as a flexible array.
/// };
/// int8 AFunction(struct MyType *value);
int8, int32 are to be replaced with #include<stdint.h> and int8_t, int32_t
///
/// \endcode
///
/// You'll want to use
/// Function::Create(TypeBuilder<types::i<8>(MyType*), true>::get(), ...)
the call to get needs an LLVMContext argument.
/// to declare the function, but when you first try this, your compiler will
/// complain that TypeBuilder<MyType, true>::get() doesn't exist. To fix
this,
/// write:
///
/// \code{.cpp}
///
/// namespace llvm {
/// template<bool xcompile> class TypeBuilder<MyType, xcompile> {
/// public:
/// static StructType *get(LLVMContext &Context) {
/// // If you cache this result, be sure to cache it separately
/// // for each LLVMContext.
/// return StructType::get(
/// TypeBuilder<types::i<32>, xcompile>::get(Context),
/// TypeBuilder<types::i<32>*, xcompile>::get(Context),
/// TypeBuilder<types::i<8>*[], xcompile>::get(Context),
/// nullptr);
/// }
///
/// // You may find this a convenient place to put some constants
/// // to help with getelementptr. They don't have any effect on
/// // the operation of TypeBuilder.
/// enum Fields {
/// FIELD_A,
/// FIELD_B,
/// FIELD_ARRAY
/// };
/// }
/// } // namespace llvm
///
/// \endcode
Tell me if I'm wrong but it my case it worked only after those changes.
Thanks,
Pierre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160622/23650efb/attachment.html>
More information about the llvm-dev
mailing list