[PATCH] D29918: Add StringRef::getAsDouble

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 13 17:35:06 PST 2017


zturner added inline comments.


================
Comment at: llvm/include/llvm/ADT/StringRef.h:567
     bool getAsInteger(unsigned Radix, APInt &Result) const;
 
     /// @}
----------------
mehdi_amini wrote:
> I'd insert the declaration here, after all the integer related ones.
> 
> Also shouldn't we have a `consumeDouble` for symmetry with the integer case?
Probably so, but it's a bit tricky.  Right now the API does not have any means to return parse error information back up to the caller, which is why I documented in the doc comment "string must be a well-formed double".  I'd like to fix that though, so that we can return false when the string contains invalid characters.

That kind of API change would be necessary before we can think about stopping at the first invalid character.


https://reviews.llvm.org/D29918





More information about the llvm-commits mailing list