llvm::Type
2.9 and earlier used to have getDescription
method to retrieve a string representation of the type. This method does not exist anymore in llvm 3.0.
I'm not sure if this is deprecated in favor of Type::print(raw_ostream&)
, but in any case I'm curious of this API. What examples are there about how to use it? How can I dump to a string
or const char*
?
In particular, I want to pass the string to Boost::Format
which is a modern c++ sprintf
.
I suppose, you need to create an instance of llvm::raw_string_ostream
and pass your std::string into it's construtor. Now you can use it as llvm::raw_ostream
and when you are done just call .str()
to get your string.
Something like that:
std::string type_str;
llvm::raw_string_ostream rso(&type_str);
your_type->print(rso);
std::cout<<rso.str();
LLVM has changed its interface, so now the following will work:
std::string type_str;
llvm::raw_string_ostream rso(type_str);
your_type->print(rso);
std::cout<<rso.str();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With