mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-26 13:01:27 +03:00
Rollup merge of #155737 - Walnut356:getsyntheticvalue, r=jieyouxu
Account for `GetSyntheticValue` failures `GetSyntheticValue` returns an invalid `SBValue` if no synthetic is present. That wasn't a problem before when we were attaching synthetics to every type, but it won't be the case once github.com/rust-lang/rust/pull/155336 or similar lands. Additionally, codelldb subverts `lldb_commands` to apply similar behavior that doesn't attach synthetics to every type, so this fixes a regression there too. Additionally, I removed 1 useless instance of `GetSyntheticValue`, since pointers should always be `IndirectionSyntheticProvider`, not `DefaultSyntheticProvider`.
This commit is contained in:
+30
-23
@@ -108,8 +108,6 @@ class DefaultSyntheticProvider:
|
||||
return self.valobj.GetNumChildren()
|
||||
|
||||
def get_child_index(self, name: str) -> int:
|
||||
if self.is_ptr and name == "$$dereference$$":
|
||||
return self.valobj.Dereference().GetSyntheticValue()
|
||||
return self.valobj.GetIndexOfChildWithName(name)
|
||||
|
||||
def get_child_at_index(self, index: int) -> Optional[SBValue]:
|
||||
@@ -133,13 +131,17 @@ class IndirectionSyntheticProvider:
|
||||
return 1
|
||||
|
||||
def get_child_index(self, name: str) -> int:
|
||||
if self.is_ptr and name == "$$dereference$$":
|
||||
if name == "$$dereference$$":
|
||||
return 0
|
||||
return -1
|
||||
|
||||
def get_child_at_index(self, index: int) -> Optional[SBValue]:
|
||||
if index == 0:
|
||||
return self.valobj.Dereference().GetSyntheticValue()
|
||||
value = self.valobj.Dereference()
|
||||
if (synth := value.GetSyntheticValue()).IsValid():
|
||||
return synth
|
||||
else:
|
||||
return value
|
||||
return None
|
||||
|
||||
def update(self):
|
||||
@@ -569,7 +571,9 @@ class ClangEncodedEnumProvider:
|
||||
self.variant = all_variants.GetChildAtIndex(index)
|
||||
self.value = self.variant.GetChildMemberWithName(
|
||||
ClangEncodedEnumProvider.VALUE_MEMBER_NAME
|
||||
).GetSyntheticValue()
|
||||
)
|
||||
if (synth := self.value.GetSyntheticValue()).IsValid():
|
||||
self.value = synth
|
||||
|
||||
def _getCurrentVariantIndex(self, all_variants: SBValue) -> int:
|
||||
default_index = 0
|
||||
@@ -651,9 +655,10 @@ class MSVCEnumSyntheticProvider:
|
||||
).GetValueAsUnsigned()
|
||||
if tag == discr:
|
||||
self.variant = child
|
||||
self.value = child.GetChildMemberWithName(
|
||||
"value"
|
||||
).GetSyntheticValue()
|
||||
self.value = child.GetChildMemberWithName("value")
|
||||
if (synth := self.value.GetSyntheticValue()).IsValid():
|
||||
self.value = synth
|
||||
|
||||
return
|
||||
else: # if invalid, DISCR must be a range
|
||||
begin: int = (
|
||||
@@ -671,16 +676,18 @@ class MSVCEnumSyntheticProvider:
|
||||
if begin < end:
|
||||
if begin <= tag <= end:
|
||||
self.variant = child
|
||||
self.value = child.GetChildMemberWithName(
|
||||
"value"
|
||||
).GetSyntheticValue()
|
||||
self.value = child.GetChildMemberWithName("value")
|
||||
if (synth := self.value.GetSyntheticValue()).IsValid():
|
||||
self.value = synth
|
||||
|
||||
return
|
||||
else:
|
||||
if tag >= begin or tag <= end:
|
||||
self.variant = child
|
||||
self.value = child.GetChildMemberWithName(
|
||||
"value"
|
||||
).GetSyntheticValue()
|
||||
self.value = child.GetChildMemberWithName("value")
|
||||
if (synth := self.value.GetSyntheticValue()).IsValid():
|
||||
self.value = synth
|
||||
|
||||
return
|
||||
else: # if invalid, tag is a 128 bit value
|
||||
tag_lo: int = self.valobj.GetChildMemberWithName(
|
||||
@@ -714,9 +721,9 @@ class MSVCEnumSyntheticProvider:
|
||||
discr: int = (exact_hi << 64) | exact_lo
|
||||
if tag == discr:
|
||||
self.variant = child
|
||||
self.value = child.GetChildMemberWithName(
|
||||
"value"
|
||||
).GetSyntheticValue()
|
||||
self.value = child.GetChildMemberWithName("value")
|
||||
if (synth := self.value.GetSyntheticValue()).IsValid():
|
||||
self.value = synth
|
||||
return
|
||||
else: # if invalid, DISCR must be a range
|
||||
begin_lo: int = (
|
||||
@@ -748,16 +755,16 @@ class MSVCEnumSyntheticProvider:
|
||||
if begin < end:
|
||||
if begin <= tag <= end:
|
||||
self.variant = child
|
||||
self.value = child.GetChildMemberWithName(
|
||||
"value"
|
||||
).GetSyntheticValue()
|
||||
self.value = child.GetChildMemberWithName("value")
|
||||
if (synth := self.value.GetSyntheticValue()).IsValid():
|
||||
self.value = synth
|
||||
return
|
||||
else:
|
||||
if tag >= begin or tag <= end:
|
||||
self.variant = child
|
||||
self.value = child.GetChildMemberWithName(
|
||||
"value"
|
||||
).GetSyntheticValue()
|
||||
self.value = child.GetChildMemberWithName("value")
|
||||
if (synth := self.value.GetSyntheticValue()).IsValid():
|
||||
self.value = synth
|
||||
return
|
||||
|
||||
def num_children(self) -> int:
|
||||
|
||||
Reference in New Issue
Block a user