Previously if the auto sense radix was specified as part of the string and you *also* explicitly specified the radix value to the function, we would fail. This patch allows the radix prefix to be properly consumed even in non-auto-sense mode. In doing so, I learned that there was zero test coverage for getAsInteger with an explicitly specified radix, so this patch also rectifies that since I needed to add tests to make sure this patch works.
Details
Details
- Reviewers
mehdi_amini chandlerc
Diff Detail
Diff Detail
Event Timeline
llvm/lib/Support/StringRef.cpp | ||
---|---|---|
442 | 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); |
llvm/lib/Support/StringRef.cpp | ||
---|---|---|
442 | int N; StringRef("012345").getAsInteger(10, N); should work, but auto-sense will detect this as base 8. |
You could avoid the duplication of the prefix logic by always calling GetAutoSenseRadix: