kastiglione created this revision.
kastiglione added reviewers: aprantl, jingham.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
The `frame variable` command supports an implicit `this`/`self`, allowing a
user to run `v some_field` instead of `v this->some_field`. However, some
languages have non-pointer `this`/`self` types (for example, Swift).
With this change, support for non-pointer implicit `this`/`self` is supported.
This is done by consulting the type of the instance variable. If the type is
known to be non-pointer, then the dot operator `.` is used instead of the arrow
operator `->`.
The C language of families each have a pointer instance type, which makes
testing of this difficult. Tests for this feature will be done in the Swift
downstream fork, as Swift's `self` is a non-pointer (reference) type.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D127605
Files:
lldb/source/Target/StackFrame.cpp
Index: lldb/source/Target/StackFrame.cpp
===================================================================
--- lldb/source/Target/StackFrame.cpp
+++ lldb/source/Target/StackFrame.cpp
@@ -563,7 +563,12 @@
var_sp = variable_list->FindVariable(method_object_name);
if (var_sp) {
separator_idx = 0;
- var_expr_storage = "->";
+ if (auto var_type = var_sp->GetType())
+ if (!var_type->GetForwardCompilerType().IsPointerType())
+ var_expr_storage = ".";
+
+ if (var_expr_storage.empty())
+ var_expr_storage = "->";
var_expr_storage += var_expr;
var_expr = var_expr_storage;
synthetically_added_instance_object = true;
Index: lldb/source/Target/StackFrame.cpp
===================================================================
--- lldb/source/Target/StackFrame.cpp
+++ lldb/source/Target/StackFrame.cpp
@@ -563,7 +563,12 @@
var_sp = variable_list->FindVariable(method_object_name);
if (var_sp) {
separator_idx = 0;
- var_expr_storage = "->";
+ if (auto var_type = var_sp->GetType())
+ if (!var_type->GetForwardCompilerType().IsPointerType())
+ var_expr_storage = ".";
+
+ if (var_expr_storage.empty())
+ var_expr_storage = "->";
var_expr_storage += var_expr;
var_expr = var_expr_storage;
synthetically_added_instance_object = true;
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits