From 1e7ad3993d8700488895fa372ecad55443f53485 Mon Sep 17 00:00:00 2001 From: John McCall Date: Sun, 28 Feb 2010 09:55:58 +0000 Subject: 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 --- include/llvm/ADT/StringRef.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include/llvm/ADT/StringRef.h') 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 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 /// @{ -- cgit v1.2.3