aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/ADT/StringRef.h
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-02-28 09:55:58 +0000
committerJohn McCall <rjmccall@apple.com>2010-02-28 09:55:58 +0000
commit1e7ad3993d8700488895fa372ecad55443f53485 (patch)
tree559719ee3c95466fd921a748a0bddfb75670f6fd /include/llvm/ADT/StringRef.h
parent5b0a7741ad262315d6365250a2da2edb8ba37e69 (diff)
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
Diffstat (limited to 'include/llvm/ADT/StringRef.h')
-rw-r--r--include/llvm/ADT/StringRef.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h
index 61cb558946..925777000f 100644
--- a/include/llvm/ADT/StringRef.h
+++ b/include/llvm/ADT/StringRef.h
@@ -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
/// @{