Add an override to StringRef::getAsInteger which parses into an APInt.

It gets its own implementation totally divorced from the (presumably
performance-sensitive) routines which parse into a uint64_t.

Add APInt::operator|=(uint64_t), which is situationally much better than
using a full APInt.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97381 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
John McCall
2010-02-28 09:55:58 +00:00
parent 5b0a7741ad
commit 1e7ad3993d
3 changed files with 132 additions and 12 deletions

View File

@@ -18,6 +18,7 @@
namespace llvm {
template<typename T>
class SmallVectorImpl;
class APInt;
/// StringRef - Represent a constant reference to a string, i.e. a character
/// array and a length, which need not be null terminated.
@@ -273,6 +274,19 @@ namespace llvm {
// TODO: Provide overloads for int/unsigned that check for overflow.
/// getAsInteger - Parse the current string as an integer of the
/// specified radix, or of an autosensed radix if the radix given
/// is 0. The current value in Result is discarded, and the
/// storage is changed to be wide enough to store the parsed
/// integer.
///
/// Returns true if the string does not solely consist of a valid
/// non-empty number in the appropriate base.
///
/// APInt::fromString is superficially similar but assumes the
/// string is well-formed in the given radix.
bool getAsInteger(unsigned Radix, APInt &Result) const;
/// @}
/// @name Substring Operations
/// @{