[LLVMdev] Assert with getZExtValue()?
Krzysztof Parzyszek
kparzysz at codeaurora.org
Tue Dec 4 11:01:11 PST 2012
On 12/4/2012 12:56 PM, Ryan Taylor wrote:
> So is there a way to return the value as a string instead?
>
There are several ways:
include/llvm/ADT/APInt.h
/// toString - Converts an APInt to a string and append it to Str.
Str is
/// commonly a SmallString.
void toString(SmallVectorImpl<char> &Str, unsigned Radix, bool Signed,
bool formatAsCLiteral = false) const;
/// Considers the APInt to be unsigned and converts it into a string
in the
/// radix given. The radix can be 2, 8, 10 16, or 36.
void toStringUnsigned(SmallVectorImpl<char> &Str, unsigned Radix =
10) const {
toString(Str, Radix, false, false);
}
/// Considers the APInt to be signed and converts it into a string in the
/// radix given. The radix can be 2, 8, 10, 16, or 36.
void toStringSigned(SmallVectorImpl<char> &Str, unsigned Radix = 10)
const {
toString(Str, Radix, true, false);
}
/// toString - This returns the APInt as a std::string. Note that
this is an
/// inefficient method. It is better to pass in a
SmallVector/SmallString
/// to the methods above to avoid thrashing the heap for the string.
std::string toString(unsigned Radix, bool Signed) const;
-Krzysztof
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
More information about the llvm-dev
mailing list