
Summary: Currently the breakpoint command is prompting the user to file a bug report if the provided regex is invalid: ``` (lldb) rbreak *foo error: Function name regular expression could not be compiled: "Inconvertible error value. An error has occurred that could not be converted to a known std::error_code. Please file a bug. repetition-operator operand invalid" ``` The reason is simply that we are using the wrong StringError constructor (the one with the error code as the first parameter is also printing the string version of the error code, and the inconvertible error code is just an invalid place holder code with that description). Switching the StringError constructor parameters will only print the error message we get from the regex engine when we convert the error into a string. I checked the rest of the code base and I couldn't find the same issue anywhere else. Fixes rdar://62233561 Reviewers: JDevlieghere Reviewed By: JDevlieghere Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D78808
42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
//===-- RegularExpression.cpp ---------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "lldb/Utility/RegularExpression.h"
|
|
|
|
#include <string>
|
|
|
|
using namespace lldb_private;
|
|
|
|
RegularExpression::RegularExpression(llvm::StringRef str)
|
|
: m_regex_text(std::string(str)),
|
|
// m_regex does not reference str anymore after it is constructed.
|
|
m_regex(llvm::Regex(str)) {}
|
|
|
|
RegularExpression::RegularExpression(const RegularExpression &rhs)
|
|
: RegularExpression(rhs.GetText()) {}
|
|
|
|
bool RegularExpression::Execute(
|
|
llvm::StringRef str,
|
|
llvm::SmallVectorImpl<llvm::StringRef> *matches) const {
|
|
if (!IsValid())
|
|
return false;
|
|
return m_regex.match(str, matches);
|
|
}
|
|
|
|
bool RegularExpression::IsValid() const { return m_regex.isValid(); }
|
|
|
|
llvm::StringRef RegularExpression::GetText() const { return m_regex_text; }
|
|
|
|
llvm::Error RegularExpression::GetError() const {
|
|
std::string error;
|
|
if (!m_regex.isValid(error))
|
|
return llvm::make_error<llvm::StringError>(error,
|
|
llvm::inconvertibleErrorCode());
|
|
return llvm::Error::success();
|
|
}
|