diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2016-03-31 02:45:46 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2016-03-31 02:45:46 +0000 |
commit | 8ed5cac97c1c7876fcde080bd58ee4969347a8a7 (patch) | |
tree | d2ab4f5c934c7c6512f5dd4ea82c4c08b2825401 /clang/lib/Driver/Driver.cpp | |
parent | 5e3ea4dd7931a010de30ebef7606215b667ab529 (diff) | |
download | bcm5719-llvm-8ed5cac97c1c7876fcde080bd58ee4969347a8a7.tar.gz bcm5719-llvm-8ed5cac97c1c7876fcde080bd58ee4969347a8a7.zip |
[DarwinDriver] Increase the number of valid digits for ld64 version string.
Previously only 3 digits were valid. Increase it to 5.
Differential Revision: http://reviews.llvm.org/D18304
rdar://problem/24843016
llvm-svn: 264987
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r-- | clang/lib/Driver/Driver.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index a5f9ebbdb15..64903de2945 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -2545,6 +2545,34 @@ bool Driver::GetReleaseVersion(const char *Str, unsigned &Major, return true; } +/// Parse digits from a string \p Str and fulfill \p Digits with +/// the parsed numbers. This method assumes that the max number of +/// digits to look for is equal to Digits.size(). +/// +/// \return True if the entire string was parsed and there are +/// no extra characters remaining at the end. +bool Driver::GetReleaseVersion(const char *Str, + MutableArrayRef<unsigned> Digits) { + if (*Str == '\0') + return false; + + char *End; + unsigned CurDigit = 0; + while (CurDigit < Digits.size()) { + unsigned Digit = (unsigned)strtol(Str, &End, 10); + Digits[CurDigit] = Digit; + if (*Str != '\0' && *End == '\0') + return true; + if (*End != '.' || Str == End) + return false; + Str = End + 1; + CurDigit++; + } + + // More digits than requested, bail out... + return false; +} + std::pair<unsigned, unsigned> Driver::getIncludeExcludeOptionFlagMasks() const { unsigned IncludedFlagsBitmask = 0; unsigned ExcludedFlagsBitmask = options::NoDriverOption; |