[PATCH] D34284: [StringRef] Make getAsInteger a tad more robust.
Zachary Turner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 16 12:50:29 PDT 2017
zturner added inline comments.
================
Comment at: llvm/lib/Support/StringRef.cpp:442
+ Str = Str.drop_front(2);
+ }
// Empty strings (after the radix autosense) are invalid.
----------------
amccarth wrote:
> You could avoid the duplication of the prefix logic by always calling GetAutoSenseRadix:
>
> const auto SensedRadix = GetAutoSenseRadix(Str);
> if (Radix == 0)
> Radix = SensedRadix ;
> assert(Radix == SensedRadix);
>
>
```
int N;
StringRef("012345").getAsInteger(10, N);
```
should work, but auto-sense will detect this as base 8.
https://reviews.llvm.org/D34284
More information about the llvm-commits
mailing list