Author: Adrian Prantl Date: 2021-12-15T14:48:39-08:00 New Revision: 8b624290635fea64dfa14587b650dbb5077879a2
URL: https://github.com/llvm/llvm-project/commit/8b624290635fea64dfa14587b650dbb5077879a2 DIFF: https://github.com/llvm/llvm-project/commit/8b624290635fea64dfa14587b650dbb5077879a2.diff LOG: Use StringRef instead of char* (NFC) Added: Modified: lldb/include/lldb/Expression/UserExpression.h lldb/source/Expression/UserExpression.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/Expression/UserExpression.h b/lldb/include/lldb/Expression/UserExpression.h index 8236c417f73a0..3874a60e06f09 100644 --- a/lldb/include/lldb/Expression/UserExpression.h +++ b/lldb/include/lldb/Expression/UserExpression.h @@ -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: diff --git a/lldb/source/Expression/UserExpression.cpp b/lldb/source/Expression/UserExpression.cpp index b61781c0b82bd..6c6fbda4ec180 100644 --- a/lldb/source/Expression/UserExpression.cpp +++ b/lldb/source/Expression/UserExpression.cpp @@ -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) { @@ -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. _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits