-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[lldb] unique_ptr-ify some GetUserExpression APIs. #106034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
These methods already returned a uniquely owned object, this just makes them self-documenting.
@llvm/pr-subscribers-lldb Author: Lang Hames (lhames) ChangesThese methods already returned a uniquely owned object, this just makes them self-documenting. Full diff: https://github.com/llvm/llvm-project/pull/106034.diff 7 Files Affected:
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h
index 7d48f9b316138c..b1ed5df3013a2b 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -495,7 +495,7 @@ class TypeSystem : public PluginInterface,
return IsPointerOrReferenceType(type, nullptr);
}
- virtual UserExpression *GetUserExpression(
+ virtual std::unique_ptr<UserExpression> GetUserExpression(
llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language,
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options, ValueObject *ctx_obj) {
diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h
index 7f4d607f5427df..95e3aaf02b19d5 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1174,7 +1174,7 @@ class Target : public std::enable_shared_from_this<Target>,
// parameters have the same meaning as for the UserExpression constructor.
// Returns a new-ed object which the caller owns.
- UserExpression *
+ std::unique_ptr<UserExpression>
GetUserExpressionForLanguage(llvm::StringRef expr, llvm::StringRef prefix,
SourceLanguage language,
Expression::ResultType desired_type,
diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp
index 41911fad41c648..8ef6b844230505 100644
--- a/lldb/source/Breakpoint/BreakpointLocation.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocation.cpp
@@ -251,9 +251,9 @@ bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx,
if (comp_unit)
language = comp_unit->GetLanguage();
- m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(
+ m_user_expression_sp = GetTarget().GetUserExpressionForLanguage(
condition_text, llvm::StringRef(), language, Expression::eResultTypeAny,
- EvaluateExpressionOptions(), nullptr, error));
+ EvaluateExpressionOptions(), nullptr, error);
if (error.Fail()) {
LLDB_LOGF(log, "Error getting condition expression: %s.",
error.AsCString());
diff --git a/lldb/source/Breakpoint/Watchpoint.cpp b/lldb/source/Breakpoint/Watchpoint.cpp
index 715e83c76697b2..577ee81d687dcb 100644
--- a/lldb/source/Breakpoint/Watchpoint.cpp
+++ b/lldb/source/Breakpoint/Watchpoint.cpp
@@ -463,9 +463,9 @@ void Watchpoint::SetCondition(const char *condition) {
} else {
// Pass nullptr for expr_prefix (no translation-unit level definitions).
Status error;
- m_condition_up.reset(m_target.GetUserExpressionForLanguage(
+ m_condition_up = m_target.GetUserExpressionForLanguage(
condition, {}, {}, UserExpression::eResultTypeAny,
- EvaluateExpressionOptions(), nullptr, error));
+ EvaluateExpressionOptions(), nullptr, error);
if (error.Fail()) {
// FIXME: Log something...
m_condition_up.reset();
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 695801da9da69a..2e2f4be6343791 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9741,7 +9741,7 @@ void ScratchTypeSystemClang::Dump(llvm::raw_ostream &output) {
}
}
-UserExpression *ScratchTypeSystemClang::GetUserExpression(
+std::unique_ptr<UserExpression> ScratchTypeSystemClang::GetUserExpression(
llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language,
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options, ValueObject *ctx_obj) {
@@ -9749,8 +9749,8 @@ UserExpression *ScratchTypeSystemClang::GetUserExpression(
if (!target_sp)
return nullptr;
- return new ClangUserExpression(*target_sp.get(), expr, prefix, language,
- desired_type, options, ctx_obj);
+ return std::make_unique<ClangUserExpression>(
+ *target_sp.get(), expr, prefix, language, desired_type, options, ctx_obj);
}
FunctionCaller *ScratchTypeSystemClang::GetFunctionCaller(
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index e39aedec7e3902..fc29a2e5eaefc7 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -1299,12 +1299,10 @@ class ScratchTypeSystemClang : public TypeSystemClang {
/// \see lldb_private::TypeSystem::Dump
void Dump(llvm::raw_ostream &output) override;
- UserExpression *GetUserExpression(llvm::StringRef expr,
- llvm::StringRef prefix,
- SourceLanguage language,
- Expression::ResultType desired_type,
- const EvaluateExpressionOptions &options,
- ValueObject *ctx_obj) override;
+ std::unique_ptr<UserExpression> GetUserExpression(
+ llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language,
+ Expression::ResultType desired_type,
+ const EvaluateExpressionOptions &options, ValueObject *ctx_obj) override;
FunctionCaller *GetFunctionCaller(const CompilerType &return_type,
const Address &function_address,
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 260974bddedf3a..f40fb1c10a5630 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -2511,7 +2511,7 @@ Target::GetPersistentExpressionStateForLanguage(lldb::LanguageType language) {
return nullptr;
}
-UserExpression *Target::GetUserExpressionForLanguage(
+std::unique_ptr<UserExpression> Target::GetUserExpressionForLanguage(
llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language,
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options, ValueObject *ctx_obj,
@@ -2534,8 +2534,8 @@ UserExpression *Target::GetUserExpressionForLanguage(
return nullptr;
}
- auto *user_expr = ts->GetUserExpression(expr, prefix, language, desired_type,
- options, ctx_obj);
+ auto user_expr = ts->GetUserExpression(expr, prefix, language, desired_type,
+ options, ctx_obj);
if (!user_expr)
error.SetErrorStringWithFormat(
"Could not create an expression for language %s",
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/163/builds/4286 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/181/builds/4140 Here is the relevant piece of the build log for the reference
|
This reverts commit 3c5ab5a while I investigate bot failures (e.g. https://lab.llvm.org/buildbot/#/builders/163/builds/4286).
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/45/builds/3265 Here is the relevant piece of the build log for the reference
|
…)" This reverts commit 3c5ab5a while I investigate bot failures (e.g. https://lab.llvm.org/buildbot/#/builders/163/builds/4286).
These methods already returned a uniquely owned object, this just makes them self-documenting.