================ @@ -72,12 +74,39 @@ static std::optional<llvm::StringRef> IsWord(llvm::StringRef expr, static bool IsNumberBodyChar(char ch) { return IsDigit(ch) || IsLetter(ch); } -static std::optional<llvm::StringRef> IsNumber(llvm::StringRef expr, - llvm::StringRef &remainder) { - if (IsDigit(remainder[0])) { - llvm::StringRef number = remainder.take_while(IsNumberBodyChar); - remainder = remainder.drop_front(number.size()); - return number; +static std::optional<llvm::StringRef> IsNumber(llvm::StringRef &remainder, + bool &isFloat) { + llvm::StringRef::iterator cur_pos = remainder.begin(); + if (*cur_pos == '.') { + auto next_pos = cur_pos + 1; + if (next_pos == remainder.end() || !IsDigit(*next_pos)) + return std::nullopt; + } + if (IsDigit(*(cur_pos)) || *(cur_pos) == '.') { + while (IsNumberBodyChar(*cur_pos)) + cur_pos++; + + if (*cur_pos == '.') { + isFloat = true; + cur_pos++; + while (IsNumberBodyChar(*cur_pos)) + cur_pos++; ---------------- labath wrote:
How does anything in this function deal with running off the end of the String(Ref)? (This is kind of why I prefer using the StringRef methods (consume_front, drop_while, etc.) instead of working with iterators/indexes directly.) https://github.com/llvm/llvm-project/pull/152308 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits