<div dir="ltr"><div><div><div>Hi,<br><br></div>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.<br><br></div>There is a little usecase presented at the beginning:<br><br>/// \code{.cpp}<br>///<br>///   struct MyType {<br>///     int32 a;<br>///     int32 *b;<br>///     void *array[1];  // Intended as a flexible array.<br>///   };<br>///   int8 AFunction(struct MyType *value);<br><br></div>int8, int32 are to be replaced with #include<stdint.h> and int8_t, int32_t<br><div><br>///<br>/// \endcode<br>///<br>/// You'll want to use<br>///   Function::Create(TypeBuilder<types::i<8>(MyType*), true>::get(), ...)<br><br></div><div>the call to get needs an LLVMContext argument.<br></div><div><br>/// to declare the function, but when you first try this, your compiler will<br>/// complain that TypeBuilder<MyType, true>::get() doesn't exist. To fix this,<br>/// write:<br>///<br>/// \code{.cpp}<br>///<br>///   namespace llvm {<br>///   template<bool xcompile> class TypeBuilder<MyType, xcompile> {<br>///   public:<br>///     static StructType *get(LLVMContext &Context) {<br>///       // If you cache this result, be sure to cache it separately<br>///       // for each LLVMContext.<br>///       return StructType::get(<br>///         TypeBuilder<types::i<32>, xcompile>::get(Context),<br>///         TypeBuilder<types::i<32>*, xcompile>::get(Context),<br>///         TypeBuilder<types::i<8>*[], xcompile>::get(Context),<br>///         nullptr);<br>///     }<br>///<br>///     // You may find this a convenient place to put some constants<br>///     // to help with getelementptr.  They don't have any effect on<br>///     // the operation of TypeBuilder.<br>///     enum Fields {<br>///       FIELD_A,<br>///       FIELD_B,<br>///       FIELD_ARRAY<br>///     };<br>///   }<br>///   }  // namespace llvm<br>///<br>/// \endcode<br><br></div><div>Tell me if I'm wrong but it my case it worked only after those changes.<br><br></div><div>Thanks,<br></div><div>Pierre<br></div></div>