[llvm-commits] [llvm] r78792 - in /llvm/trunk: include/llvm/ADT/Triple.h lib/Support/Triple.cpp
Daniel Dunbar
daniel at zuster.org
Wed Aug 12 19:53:38 PDT 2009
On Tue, Aug 11, 2009 at 11:19 PM, Chris Lattner<sabre at nondot.org> wrote:
> Author: lattner
> Date: Wed Aug 12 01:19:40 2009
> New Revision: 78792
>
> URL: http://llvm.org/viewvc/llvm-project?rev=78792&view=rev
> Log:
> add a couple of helpers to the Triple class for decoding
> the darwin version string. This should help consolidate
> the variety of weird functions we have scattered around the
> codebase that do stuff like this.
Thanks!
> Modified:
> llvm/trunk/include/llvm/ADT/Triple.h
> llvm/trunk/lib/Support/Triple.cpp
>
> Modified: llvm/trunk/include/llvm/ADT/Triple.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=78792&r1=78791&r2=78792&view=diff
>
> ==============================================================================
> +static unsigned EatNumber(StringRef &Str) {
> + assert(!Str.empty() && Str[0] >= '0' && Str[0] <= '9' && "Not a number");
> + unsigned Result = Str[0]-'0';
> +
> + // Eat the digit.
> + Str = Str.substr(1);
> +
> + // Handle "darwin11".
> + if (Result == 1 && !Str.empty() && Str[0] >= '0' && Str[0] <= '9') {
> + Result = Result*10 + (Str[0] - '0');
> + // Eat the digit.
> + Str = Str.substr(1);
> + }
> +
> + return Result;
> +}
Would it make more sense to just add a StringRef::toInt, and use that?
- Daniel
More information about the llvm-commits
mailing list