Skip to content

Commit

Permalink
Use StringRef instead of char* (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-prantl committed Dec 15, 2021
1 parent 5a81a60 commit 8b62429
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 2 additions & 4 deletions lldb/include/lldb/Expression/UserExpression.h
Expand Up @@ -266,10 +266,8 @@ class UserExpression : public Expression {
0x1001; ///< ValueObject::GetError() returns this if there is no result
/// from the expression.

const char *GetFixedText() {
if (m_fixed_text.empty())
return nullptr;
return m_fixed_text.c_str();
llvm::StringRef GetFixedText() {
return m_fixed_text;
}

protected:
Expand Down
8 changes: 3 additions & 5 deletions lldb/source/Expression/UserExpression.cpp
Expand Up @@ -254,9 +254,7 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
if (fixed_expression == nullptr)
fixed_expression = &tmp_fixed_expression;

const char *fixed_text = user_expression_sp->GetFixedText();
if (fixed_text != nullptr)
fixed_expression->append(fixed_text);
*fixed_expression = user_expression_sp->GetFixedText().str();

// If there is a fixed expression, try to parse it:
if (!parse_success) {
Expand Down Expand Up @@ -285,8 +283,8 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
} else {
// The fixed expression also didn't parse. Let's check for any new
// Fix-Its we could try.
if (fixed_expression_sp->GetFixedText()) {
*fixed_expression = fixed_expression_sp->GetFixedText();
if (!fixed_expression_sp->GetFixedText().empty()) {
*fixed_expression = fixed_expression_sp->GetFixedText().str();
} else {
// Fixed expression didn't compile without a fixit, don't retry and
// don't tell the user about it.
Expand Down

0 comments on commit 8b62429

Please sign in to comment.