Convert some Expression parser functions to StringRef.

llvm-svn: 286208
This commit is contained in:
Zachary Turner 2016-11-08 04:52:16 +00:00
parent 77c89b6958
commit c5d7df9035
23 changed files with 174 additions and 175 deletions

View File

@ -77,13 +77,14 @@ public:
return (m_matches.empty() ? nullptr : m_matches.data());
}
bool GetMatchAtIndex(const char *s, uint32_t idx,
bool GetMatchAtIndex(llvm::StringRef s, uint32_t idx,
std::string &match_str) const;
bool GetMatchAtIndex(const char *s, uint32_t idx,
bool GetMatchAtIndex(llvm::StringRef s, uint32_t idx,
llvm::StringRef &match_str) const;
bool GetMatchSpanningIndices(const char *s, uint32_t idx1, uint32_t idx2,
bool GetMatchSpanningIndices(llvm::StringRef s, uint32_t idx1,
uint32_t idx2,
llvm::StringRef &match_str) const;
protected:
@ -100,7 +101,6 @@ public:
RegularExpression();
explicit RegularExpression(llvm::StringRef string);
explicit RegularExpression(const char *) = delete;
//------------------------------------------------------------------
/// Destructor.

View File

@ -189,20 +189,17 @@ public:
return var_sp;
}
lldb::ExpressionVariableSP GetVariable(const char *name) {
lldb::ExpressionVariableSP var_sp;
if (name && name[0]) {
for (size_t index = 0, size = GetSize(); index < size; ++index) {
var_sp = GetVariableAtIndex(index);
const char *var_name_cstr = var_sp->GetName().GetCString();
if (!var_name_cstr || !name)
continue;
if (::strcmp(var_name_cstr, name) == 0)
return var_sp;
}
var_sp.reset();
lldb::ExpressionVariableSP GetVariable(llvm::StringRef name) {
if (name.empty())
return nullptr;
for (size_t index = 0, size = GetSize(); index < size; ++index) {
auto var_sp = GetVariableAtIndex(index);
llvm::StringRef var_name_str = var_sp->GetName().GetStringRef();
if (var_name_str == name)
return var_sp;
}
return var_sp;
return nullptr;
}
void RemoveVariable(lldb::ExpressionVariableSP var_sp) {

View File

@ -51,8 +51,8 @@ public:
std::shared_ptr<llvm::legacy::PassManager> LatePasses;
};
LLVMUserExpression(ExecutionContextScope &exe_scope, const char *expr,
const char *expr_prefix, lldb::LanguageType language,
LLVMUserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr,
llvm::StringRef prefix, lldb::LanguageType language,
ResultType desired_type,
const EvaluateExpressionOptions &options);
~LLVMUserExpression() override;

View File

@ -62,8 +62,8 @@ public:
/// If not eResultTypeAny, the type to use for the expression
/// result.
//------------------------------------------------------------------
UserExpression(ExecutionContextScope &exe_scope, const char *expr,
const char *expr_prefix, lldb::LanguageType language,
UserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr,
llvm::StringRef prefix, lldb::LanguageType language,
ResultType desired_type,
const EvaluateExpressionOptions &options);
@ -258,7 +258,7 @@ public:
//------------------------------------------------------------------
static lldb::ExpressionResults
Evaluate(ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options,
const char *expr_cstr, const char *expr_prefix,
llvm::StringRef expr_cstr, llvm::StringRef expr_prefix,
lldb::ValueObjectSP &result_valobj_sp, Error &error,
uint32_t line_offset = 0, std::string *fixed_expression = nullptr,
lldb::ModuleSP *jit_module_sp_ptr = nullptr);

View File

@ -358,10 +358,9 @@ public:
return min <= sval64 && sval64 <= max;
}
// TODO: Make this function take a StringRef
static lldb::addr_t StringToAddress(const ExecutionContext *exe_ctx,
const char *s, lldb::addr_t fail_value,
Error *error);
llvm::StringRef s,
lldb::addr_t fail_value, Error *error);
static bool StringToBoolean(llvm::StringRef s, bool fail_value,
bool *success_ptr);

View File

@ -1010,7 +1010,7 @@ public:
~ClangASTContextForExpressions() override = default;
UserExpression *
GetUserExpression(const char *expr, const char *expr_prefix,
GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix,
lldb::LanguageType language,
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options) override;

View File

@ -416,7 +416,7 @@ class GoASTContextForExpr : public GoASTContext {
public:
GoASTContextForExpr(lldb::TargetSP target) : m_target_wp(target) {}
UserExpression *
GetUserExpression(const char *expr, const char *expr_prefix,
GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix,
lldb::LanguageType language,
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options) override;

View File

@ -450,7 +450,7 @@ public:
}
virtual UserExpression *
GetUserExpression(const char *expr, const char *expr_prefix,
GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix,
lldb::LanguageType language,
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options) {

View File

@ -984,7 +984,7 @@ public:
// Returns a new-ed object which the caller owns.
UserExpression *GetUserExpressionForLanguage(
const char *expr, const char *expr_prefix, lldb::LanguageType language,
llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options, Error &error);
@ -1049,7 +1049,7 @@ public:
// If an expression is going to be run, then it should have a frame filled
// in in th execution context.
lldb::ExpressionResults EvaluateExpression(
const char *expression, ExecutionContextScope *exe_scope,
llvm::StringRef expression, ExecutionContextScope *exe_scope,
lldb::ValueObjectSP &result_valobj_sp,
const EvaluateExpressionOptions &options = EvaluateExpressionOptions(),
std::string *fixed_expression = nullptr);

View File

@ -224,7 +224,7 @@ bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx,
language = comp_unit->GetLanguage();
m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(
condition_text, nullptr, language, Expression::eResultTypeAny,
condition_text, llvm::StringRef(), language, Expression::eResultTypeAny,
EvaluateExpressionOptions(), error));
if (error.Fail()) {
if (log)

View File

@ -288,7 +288,7 @@ void Watchpoint::SetCondition(const char *condition) {
// Pass nullptr for expr_prefix (no translation-unit level definitions).
Error error;
m_condition_ap.reset(m_target.GetUserExpressionForLanguage(
condition, nullptr, lldb::eLanguageTypeUnknown,
condition, llvm::StringRef(), lldb::eLanguageTypeUnknown,
UserExpression::eResultTypeAny, EvaluateExpressionOptions(), error));
if (error.Fail()) {
// FIXME: Log something...

View File

@ -122,7 +122,7 @@ bool RegularExpression::Execute(llvm::StringRef str, Match *match) const {
return true;
}
bool RegularExpression::Match::GetMatchAtIndex(const char *s, uint32_t idx,
bool RegularExpression::Match::GetMatchAtIndex(llvm::StringRef s, uint32_t idx,
std::string &match_str) const {
llvm::StringRef match_str_ref;
if (GetMatchAtIndex(s, idx, match_str_ref)) {
@ -133,7 +133,7 @@ bool RegularExpression::Match::GetMatchAtIndex(const char *s, uint32_t idx,
}
bool RegularExpression::Match::GetMatchAtIndex(
const char *s, uint32_t idx, llvm::StringRef &match_str) const {
llvm::StringRef s, uint32_t idx, llvm::StringRef &match_str) const {
if (idx < m_matches.size()) {
if (m_matches[idx].rm_eo == -1 && m_matches[idx].rm_so == -1)
return false;
@ -143,8 +143,8 @@ bool RegularExpression::Match::GetMatchAtIndex(
match_str = llvm::StringRef();
return true;
} else if (m_matches[idx].rm_eo > m_matches[idx].rm_so) {
match_str = llvm::StringRef(s + m_matches[idx].rm_so,
m_matches[idx].rm_eo - m_matches[idx].rm_so);
match_str = s.substr(m_matches[idx].rm_so,
m_matches[idx].rm_eo - m_matches[idx].rm_so);
return true;
}
}
@ -152,7 +152,7 @@ bool RegularExpression::Match::GetMatchAtIndex(
}
bool RegularExpression::Match::GetMatchSpanningIndices(
const char *s, uint32_t idx1, uint32_t idx2,
llvm::StringRef s, uint32_t idx1, uint32_t idx2,
llvm::StringRef &match_str) const {
if (idx1 < m_matches.size() && idx2 < m_matches.size()) {
if (m_matches[idx1].rm_so == m_matches[idx2].rm_eo) {
@ -160,9 +160,8 @@ bool RegularExpression::Match::GetMatchSpanningIndices(
match_str = llvm::StringRef();
return true;
} else if (m_matches[idx1].rm_so < m_matches[idx2].rm_eo) {
match_str =
llvm::StringRef(s + m_matches[idx1].rm_so,
m_matches[idx2].rm_eo - m_matches[idx1].rm_so);
match_str = s.substr(m_matches[idx1].rm_so,
m_matches[idx2].rm_eo - m_matches[idx1].rm_so);
return true;
}
}

View File

@ -42,13 +42,12 @@
using namespace lldb_private;
LLVMUserExpression::LLVMUserExpression(ExecutionContextScope &exe_scope,
const char *expr,
const char *expr_prefix,
llvm::StringRef expr,
llvm::StringRef prefix,
lldb::LanguageType language,
ResultType desired_type,
const EvaluateExpressionOptions &options)
: UserExpression(exe_scope, expr, expr_prefix, language, desired_type,
options),
: UserExpression(exe_scope, expr, prefix, language, desired_type, options),
m_stack_frame_bottom(LLDB_INVALID_ADDRESS),
m_stack_frame_top(LLDB_INVALID_ADDRESS), m_transformed_text(),
m_execution_unit_sp(), m_materializer_ap(), m_jit_module_wp(),

View File

@ -47,13 +47,12 @@
using namespace lldb_private;
UserExpression::UserExpression(ExecutionContextScope &exe_scope,
const char *expr, const char *expr_prefix,
llvm::StringRef expr, llvm::StringRef prefix,
lldb::LanguageType language,
ResultType desired_type,
const EvaluateExpressionOptions &options)
: Expression(exe_scope), m_expr_text(expr),
m_expr_prefix(expr_prefix ? expr_prefix : ""), m_language(language),
m_desired_type(desired_type), m_options(options) {}
: Expression(exe_scope), m_expr_text(expr), m_expr_prefix(prefix),
m_language(language), m_desired_type(desired_type), m_options(options) {}
UserExpression::~UserExpression() {}
@ -140,7 +139,7 @@ lldb::addr_t UserExpression::GetObjectPointer(lldb::StackFrameSP frame_sp,
lldb::ExpressionResults UserExpression::Evaluate(
ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options,
const char *expr_cstr, const char *expr_prefix,
llvm::StringRef expr, llvm::StringRef prefix,
lldb::ValueObjectSP &result_valobj_sp, Error &error, uint32_t line_offset,
std::string *fixed_expression, lldb::ModuleSP *jit_module_sp_ptr) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS |
@ -187,16 +186,15 @@ lldb::ExpressionResults UserExpression::Evaluate(
ThreadList::ExpressionExecutionThreadPusher execution_thread_pusher(
thread_sp);
const char *full_prefix = NULL;
const char *option_prefix = options.GetPrefix();
llvm::StringRef full_prefix;
llvm::StringRef option_prefix(options.GetPrefix());
std::string full_prefix_storage;
if (expr_prefix && option_prefix) {
full_prefix_storage.assign(expr_prefix);
if (!prefix.empty() && !option_prefix.empty()) {
full_prefix_storage = prefix;
full_prefix_storage.append(option_prefix);
if (!full_prefix_storage.empty())
full_prefix = full_prefix_storage.c_str();
} else if (expr_prefix)
full_prefix = expr_prefix;
full_prefix = full_prefix_storage;
} else if (!prefix.empty())
full_prefix = prefix;
else
full_prefix = option_prefix;
@ -211,7 +209,7 @@ lldb::ExpressionResults UserExpression::Evaluate(
}
lldb::UserExpressionSP user_expression_sp(
target->GetUserExpressionForLanguage(expr_cstr, full_prefix, language,
target->GetUserExpressionForLanguage(expr, full_prefix, language,
desired_type, options, error));
if (error.Fail()) {
if (log)
@ -222,7 +220,7 @@ lldb::ExpressionResults UserExpression::Evaluate(
if (log)
log->Printf("== [UserExpression::Evaluate] Parsing expression %s ==",
expr_cstr);
expr.str().c_str());
const bool keep_expression_in_memory = true;
const bool generate_debug_info = options.GetGenerateDebugInfo();

View File

@ -550,106 +550,114 @@ void Args::Clear() {
}
lldb::addr_t Args::StringToAddress(const ExecutionContext *exe_ctx,
const char *s, lldb::addr_t fail_value,
llvm::StringRef s, lldb::addr_t fail_value,
Error *error_ptr) {
bool error_set = false;
if (s && s[0]) {
llvm::StringRef sref = s;
if (s.empty()) {
if (error_ptr)
error_ptr->SetErrorStringWithFormat("invalid address expression \"%s\"",
s.str().c_str());
return fail_value;
}
char *end = nullptr;
lldb::addr_t addr = ::strtoull(s, &end, 0);
if (*end == '\0') {
llvm::StringRef sref = s;
lldb::addr_t addr = LLDB_INVALID_ADDRESS;
if (!s.getAsInteger(0, addr)) {
if (error_ptr)
error_ptr->Clear();
return addr;
}
// Try base 16 with no prefix...
if (!s.getAsInteger(16, addr)) {
if (error_ptr)
error_ptr->Clear();
return addr;
}
Target *target = nullptr;
if (!exe_ctx || !(target = exe_ctx->GetTargetPtr())) {
if (error_ptr)
error_ptr->SetErrorStringWithFormat("invalid address expression \"%s\"",
s.str().c_str());
return fail_value;
}
lldb::ValueObjectSP valobj_sp;
EvaluateExpressionOptions options;
options.SetCoerceToId(false);
options.SetUnwindOnError(true);
options.SetKeepInMemory(false);
options.SetTryAllThreads(true);
ExpressionResults expr_result =
target->EvaluateExpression(s, exe_ctx->GetFramePtr(), valobj_sp, options);
bool success = false;
if (expr_result == eExpressionCompleted) {
if (valobj_sp)
valobj_sp = valobj_sp->GetQualifiedRepresentationIfAvailable(
valobj_sp->GetDynamicValueType(), true);
// Get the address to watch.
if (valobj_sp)
addr = valobj_sp->GetValueAsUnsigned(fail_value, &success);
if (success) {
if (error_ptr)
error_ptr->Clear();
return addr; // All characters were used, return the result
}
// Try base 16 with no prefix...
addr = ::strtoull(s, &end, 16);
if (*end == '\0') {
if (error_ptr)
error_ptr->Clear();
return addr; // All characters were used, return the result
return addr;
} else {
if (error_ptr) {
error_set = true;
error_ptr->SetErrorStringWithFormat(
"address expression \"%s\" resulted in a value whose type "
"can't be converted to an address: %s",
s, valobj_sp->GetTypeName().GetCString());
}
}
if (exe_ctx) {
Target *target = exe_ctx->GetTargetPtr();
if (target) {
lldb::ValueObjectSP valobj_sp;
EvaluateExpressionOptions options;
options.SetCoerceToId(false);
options.SetUnwindOnError(true);
options.SetKeepInMemory(false);
options.SetTryAllThreads(true);
} else {
// Since the compiler can't handle things like "main + 12" we should
// try to do this for now. The compiler doesn't like adding offsets
// to function pointer types.
static RegularExpression g_symbol_plus_offset_regex(
"^(.*)([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*$");
RegularExpression::Match regex_match(3);
if (g_symbol_plus_offset_regex.Execute(sref, &regex_match)) {
uint64_t offset = 0;
bool add = true;
std::string name;
std::string str;
if (regex_match.GetMatchAtIndex(s, 1, name)) {
if (regex_match.GetMatchAtIndex(s, 2, str)) {
add = str[0] == '+';
ExpressionResults expr_result = target->EvaluateExpression(
s, exe_ctx->GetFramePtr(), valobj_sp, options);
if (regex_match.GetMatchAtIndex(s, 3, str)) {
offset = StringConvert::ToUInt64(str.c_str(), 0, 0, &success);
bool success = false;
if (expr_result == eExpressionCompleted) {
if (valobj_sp)
valobj_sp = valobj_sp->GetQualifiedRepresentationIfAvailable(
valobj_sp->GetDynamicValueType(), true);
// Get the address to watch.
if (valobj_sp)
addr = valobj_sp->GetValueAsUnsigned(fail_value, &success);
if (success) {
if (error_ptr)
error_ptr->Clear();
return addr;
} else {
if (error_ptr) {
error_set = true;
error_ptr->SetErrorStringWithFormat(
"address expression \"%s\" resulted in a value whose type "
"can't be converted to an address: %s",
s, valobj_sp->GetTypeName().GetCString());
}
}
} else {
// Since the compiler can't handle things like "main + 12" we should
// try to do this for now. The compiler doesn't like adding offsets
// to function pointer types.
static RegularExpression g_symbol_plus_offset_regex(llvm::StringRef(
"^(.*)([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*$"));
RegularExpression::Match regex_match(3);
if (g_symbol_plus_offset_regex.Execute(sref, &regex_match)) {
uint64_t offset = 0;
bool add = true;
std::string name;
std::string str;
if (regex_match.GetMatchAtIndex(s, 1, name)) {
if (regex_match.GetMatchAtIndex(s, 2, str)) {
add = str[0] == '+';
if (regex_match.GetMatchAtIndex(s, 3, str)) {
offset = StringConvert::ToUInt64(str.c_str(), 0, 0, &success);
if (success) {
Error error;
addr = StringToAddress(exe_ctx, name.c_str(),
LLDB_INVALID_ADDRESS, &error);
if (addr != LLDB_INVALID_ADDRESS) {
if (add)
return addr + offset;
else
return addr - offset;
}
}
}
if (success) {
Error error;
addr = StringToAddress(exe_ctx, name.c_str(),
LLDB_INVALID_ADDRESS, &error);
if (addr != LLDB_INVALID_ADDRESS) {
if (add)
return addr + offset;
else
return addr - offset;
}
}
}
if (error_ptr) {
error_set = true;
error_ptr->SetErrorStringWithFormat(
"address expression \"%s\" evaluation failed", s);
}
}
}
}
if (error_ptr) {
error_set = true;
error_ptr->SetErrorStringWithFormat(
"address expression \"%s\" evaluation failed", s);
}
}
if (error_ptr) {
if (!error_set)
error_ptr->SetErrorStringWithFormat("invalid address expression \"%s\"",

View File

@ -58,10 +58,10 @@
using namespace lldb_private;
ClangUserExpression::ClangUserExpression(
ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
lldb::LanguageType language, ResultType desired_type,
const EvaluateExpressionOptions &options)
: LLVMUserExpression(exe_scope, expr, expr_prefix, language, desired_type,
ExecutionContextScope &exe_scope, llvm::StringRef expr,
llvm::StringRef prefix, lldb::LanguageType language,
ResultType desired_type, const EvaluateExpressionOptions &options)
: LLVMUserExpression(exe_scope, expr, prefix, language, desired_type,
options),
m_type_system_helper(*m_target_wp.lock().get(),
options.GetExecutionPolicy() ==

View File

@ -111,8 +111,8 @@ public:
/// If not eResultTypeAny, the type to use for the expression
/// result.
//------------------------------------------------------------------
ClangUserExpression(ExecutionContextScope &exe_scope, const char *expr,
const char *expr_prefix, lldb::LanguageType language,
ClangUserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr,
llvm::StringRef prefix, lldb::LanguageType language,
ResultType desired_type,
const EvaluateExpressionOptions &options);

View File

@ -198,12 +198,12 @@ CompilerType LookupType(TargetSP target, ConstString name) {
}
GoUserExpression::GoUserExpression(ExecutionContextScope &exe_scope,
const char *expr, const char *expr_prefix,
llvm::StringRef expr, llvm::StringRef prefix,
lldb::LanguageType language,
ResultType desired_type,
const EvaluateExpressionOptions &options)
: UserExpression(exe_scope, expr, expr_prefix, language, desired_type,
options) {}
: UserExpression(exe_scope, expr, prefix, language, desired_type, options) {
}
bool GoUserExpression::Parse(DiagnosticManager &diagnostic_manager,
ExecutionContext &exe_ctx,

View File

@ -57,8 +57,8 @@ private:
//----------------------------------------------------------------------
class GoUserExpression : public UserExpression {
public:
GoUserExpression(ExecutionContextScope &exe_scope, const char *expr,
const char *expr_prefix, lldb::LanguageType language,
GoUserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr,
llvm::StringRef prefix, lldb::LanguageType language,
ResultType desired_type,
const EvaluateExpressionOptions &options);

View File

@ -10050,14 +10050,14 @@ ClangASTContextForExpressions::ClangASTContextForExpressions(Target &target)
m_persistent_variables(new ClangPersistentVariables) {}
UserExpression *ClangASTContextForExpressions::GetUserExpression(
const char *expr, const char *expr_prefix, lldb::LanguageType language,
llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options) {
TargetSP target_sp = m_target_wp.lock();
if (!target_sp)
return nullptr;
return new ClangUserExpression(*target_sp.get(), expr, expr_prefix, language,
return new ClangUserExpression(*target_sp.get(), expr, prefix, language,
desired_type, options);
}

View File

@ -1435,12 +1435,12 @@ DWARFASTParser *GoASTContext::GetDWARFParser() {
}
UserExpression *GoASTContextForExpr::GetUserExpression(
const char *expr, const char *expr_prefix, lldb::LanguageType language,
llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options) {
TargetSP target = m_target_wp.lock();
if (target)
return new GoUserExpression(*target, expr, expr_prefix, language,
desired_type, options);
return new GoUserExpression(*target, expr, prefix, language, desired_type,
options);
return nullptr;
}

View File

@ -764,8 +764,8 @@ protected:
if (m_should_stop && wp_sp->GetConditionText() != nullptr) {
// We need to make sure the user sees any parse errors in their
// condition, so we'll hook the
// constructor errors up to the debugger's Async I/O.
// condition, so we'll hook the constructor errors up to the
// debugger's Async I/O.
ExpressionResults result_code;
EvaluateExpressionOptions expr_options;
expr_options.SetUnwindOnError(true);
@ -773,8 +773,8 @@ protected:
ValueObjectSP result_value_sp;
Error error;
result_code = UserExpression::Evaluate(
exe_ctx, expr_options, wp_sp->GetConditionText(), nullptr,
result_value_sp, error);
exe_ctx, expr_options, wp_sp->GetConditionText(),
llvm::StringRef(), result_value_sp, error);
if (result_code == eExpressionCompleted) {
if (result_value_sp) {
@ -784,8 +784,7 @@ protected:
// We have been vetoed. This takes precedence over querying
// the watchpoint whether it should stop (aka ignore count and
// friends). See also StopInfoWatchpoint::ShouldStop() as
// well
// as Process::ProcessEventData::DoOnRemoval().
// well as Process::ProcessEventData::DoOnRemoval().
m_should_stop = false;
} else
m_should_stop = true;

View File

@ -1961,7 +1961,7 @@ Target::GetPersistentExpressionStateForLanguage(lldb::LanguageType language) {
}
UserExpression *Target::GetUserExpressionForLanguage(
const char *expr, const char *expr_prefix, lldb::LanguageType language,
llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options, Error &error) {
Error type_system_error;
@ -1978,7 +1978,7 @@ UserExpression *Target::GetUserExpressionForLanguage(
return nullptr;
}
user_expr = type_system->GetUserExpression(expr, expr_prefix, language,
user_expr = type_system->GetUserExpression(expr, prefix, language,
desired_type, options);
if (!user_expr)
error.SetErrorStringWithFormat(
@ -2118,14 +2118,14 @@ Target *Target::GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr,
}
ExpressionResults Target::EvaluateExpression(
const char *expr_cstr, ExecutionContextScope *exe_scope,
llvm::StringRef expr, ExecutionContextScope *exe_scope,
lldb::ValueObjectSP &result_valobj_sp,
const EvaluateExpressionOptions &options, std::string *fixed_expression) {
result_valobj_sp.reset();
ExpressionResults execution_results = eExpressionSetupError;
if (expr_cstr == nullptr || expr_cstr[0] == '\0')
if (expr.empty())
return execution_results;
// We shouldn't run stop hooks in expressions.
@ -2147,10 +2147,10 @@ ExpressionResults Target::EvaluateExpression(
// variable (something like "$0")
lldb::ExpressionVariableSP persistent_var_sp;
// Only check for persistent variables the expression starts with a '$'
if (expr_cstr[0] == '$')
if (expr[0] == '$')
persistent_var_sp = GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC)
->GetPersistentExpressionState()
->GetVariable(expr_cstr);
->GetVariable(expr);
if (persistent_var_sp) {
result_valobj_sp = persistent_var_sp->GetValueObject();
@ -2158,10 +2158,10 @@ ExpressionResults Target::EvaluateExpression(
} else {
const char *prefix = GetExpressionPrefixContentsAsCString();
Error error;
execution_results = UserExpression::Evaluate(
exe_ctx, options, expr_cstr, prefix, result_valobj_sp, error,
0, // Line Number
fixed_expression);
execution_results = UserExpression::Evaluate(exe_ctx, options, expr, prefix,
result_valobj_sp, error,
0, // Line Number
fixed_expression);
}
m_suppress_stop_hooks = old_suppress_value;