[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)
Pete Lawrence via lldb-commits
lldb-commits at lists.llvm.org
Tue Dec 19 11:30:32 PST 2023
================
@@ -1777,30 +1783,31 @@ static const char *SkipLeadingExpressionPathSeparators(const char *expression) {
ValueObjectSP
ValueObject::GetSyntheticExpressionPathChild(const char *expression,
bool can_create) {
- ValueObjectSP synthetic_child_sp;
ConstString name_const_string(expression);
// Check if we have already created a synthetic array member in this valid
// object. If we have we will re-use it.
- synthetic_child_sp = GetSyntheticChild(name_const_string);
- if (!synthetic_child_sp) {
- // We haven't made a synthetic array member for expression yet, so lets
- // make one and cache it for any future reference.
- synthetic_child_sp = GetValueForExpressionPath(
- expression, nullptr, nullptr,
- GetValueForExpressionPathOptions().SetSyntheticChildrenTraversal(
- GetValueForExpressionPathOptions::SyntheticChildrenTraversal::
- None));
-
- // Cache the value if we got one back...
- if (synthetic_child_sp.get()) {
- // FIXME: this causes a "real" child to end up with its name changed to
- // the contents of expression
- AddSyntheticChild(name_const_string, synthetic_child_sp.get());
- synthetic_child_sp->SetName(
- ConstString(SkipLeadingExpressionPathSeparators(expression)));
- }
- }
- return synthetic_child_sp;
+ if (auto existing_synthetic_child = GetSyntheticChild(name_const_string))
+ return existing_synthetic_child;
+
+ // We haven't made a synthetic array member for expression yet, so lets
+ // make one and cache it for any future reference.
+ auto path_options = GetValueForExpressionPathOptions();
+ auto traversal_none =
----------------
PortalPete wrote:
All great points that I'm going to add to my personal coding style guidelines going forward!
Back to inline for this little one, but I regret nothing in trying it multi-line way because I was hoping someone would provide:
* A preference against it (because most groups do) and …
* Reasoning behind it that I could use again here and elsewhere (which most groups don't)
Kudos for providing both! 🙂
https://github.com/llvm/llvm-project/pull/75865
More information about the lldb-commits
mailing list