[PATCH] D34284: [StringRef] Make getAsInteger a tad more robust.

Adrian McCarthy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 16 12:34:32 PDT 2017


amccarth added inline comments.


================
Comment at: llvm/lib/Support/StringRef.cpp:442
+      Str = Str.drop_front(2);
+  }
   // Empty strings (after the radix autosense) are invalid.
----------------
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);




https://reviews.llvm.org/D34284





More information about the llvm-commits mailing list