[LLVMdev] string to value

Duncan Sands baldrick at free.fr
Tue May 17 23:18:48 PDT 2011


Hi George,

>    Is there a way to convert a const char * to a Value type?

there's this ConstantArray::get method:

   /// This method constructs a ConstantArray and initializes it with a text
   /// string. The default behavior (AddNull==true) causes a null terminator to
   /// be placed at the end of the array. This effectively increases the length
   /// of the array by one (you've been warned).  However, in some situations
   /// this is not desired so if AddNull==false then the string is copied without
   /// null termination.
   static Constant *get(LLVMContext &Context, StringRef Initializer,
                        bool AddNull = true);

Ciao, Duncan.



More information about the llvm-dev mailing list