[Lldb-commits] [PATCH] D134011: [lldb] Fix parentheses placement in GetExpressionPath
Dave Lee via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Sep 15 20:32:12 PDT 2022
kastiglione created this revision.
kastiglione added a reviewer: jingham.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
Adjust the placement of parentheses around a pointer dereference in
`GetExpressionPath`.
The comment states:
> `*(a_ptr).memberName`, which is entirely fine
but the expression should be: `(*a_ptr).memberName`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D134011
Files:
lldb/source/Core/ValueObject.cpp
lldb/test/API/python_api/exprpath_synthetic/main.mm
Index: lldb/test/API/python_api/exprpath_synthetic/main.mm
===================================================================
--- lldb/test/API/python_api/exprpath_synthetic/main.mm
+++ lldb/test/API/python_api/exprpath_synthetic/main.mm
@@ -5,8 +5,11 @@
{
std::vector<int> v{1,2,3,4,5};
NSArray *a = @[@"Hello",@"World",@"From Me"];
+ int *p;
return 0; //% v = self.frame().FindVariable("v"); v0 = v.GetChildAtIndex(0); s = lldb.SBStream(); v0.GetExpressionPath(s);
//% self.runCmd("expr %s = 12" % s.GetData()); self.assertTrue(v0.GetValueAsUnsigned() == 12, "value change via expr failed")
//% a = self.frame().FindVariable("a"); a1 = a.GetChildAtIndex(1); s = lldb.SBStream(); a1.GetExpressionPath(s);
//% self.expect("po %s" % s.GetData(), substrs = ["World"])
+ //% p = self.frame().GetValueForVariablePath("*p")
+ //% self.assertEqual(p.path, "(*p)")
}
Index: lldb/source/Core/ValueObject.cpp
===================================================================
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -1929,11 +1929,11 @@
if (is_deref_of_parent &&
epformat == eGetExpressionPathFormatDereferencePointers) {
// this is the original format of GetExpressionPath() producing code like
- // *(a_ptr).memberName, which is entirely fine, until you put this into
+ // (*a_ptr).memberName, which is entirely fine, until you put this into
// StackFrame::GetValueForVariableExpressionPath() which prefers to see
// a_ptr->memberName. the eHonorPointers mode is meant to produce strings
// in this latter format
- s.PutCString("*(");
+ s.PutCString("(*");
}
ValueObject *parent = GetParent();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134011.460622.patch
Type: text/x-patch
Size: 1717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220916/e260a866/attachment-0001.bin>
More information about the lldb-commits
mailing list