[all-commits] [llvm/llvm-project] 83bd2c: Prevent GetNumChildren from transitively walking p...

Raphael Isemann via All-commits all-commits at lists.llvm.org
Mon May 25 02:30:54 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 83bd2c4a06803fa9af7f92a474b1d37cb70397cc
      https://github.com/llvm/llvm-project/commit/83bd2c4a06803fa9af7f92a474b1d37cb70397cc
  Author: Jaroslav Sevcik <jarin at google.com>
  Date:   2020-05-25 (Mon, 25 May 2020)

  Changed paths:
    M lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
    A lldb/test/API/functionalities/pointer_num_children/Makefile
    A lldb/test/API/functionalities/pointer_num_children/TestPointerNumChildren.py
    A lldb/test/API/functionalities/pointer_num_children/main.cpp

  Log Message:
  -----------
  Prevent GetNumChildren from transitively walking pointer chains

Summary:

This is an attempt to fix https://bugs.llvm.org/show_bug.cgi?id=45988,
where SBValue::GetNumChildren returns 2, but SBValue::GetChildAtIndex(1) returns
an invalid value sentinel.

The root cause of this seems to be that GetNumChildren can return the number of
children of a wrong value. In particular, for pointers GetNumChildren just
recursively calls itself on the pointee type, so it effectively walks chains of
pointers. This is different from the logic of GetChildAtIndex, which only
recurses if pointee.IsAggregateType() returns true (IsAggregateType is false for
pointers and references), so it never follows chain of pointers.

This patch aims to make GetNumChildren (more) consistent with GetChildAtIndex by
only recursively calling GetNumChildren for aggregate types.

Ideally, GetNumChildren and GetChildAtIndex would share the code that decides
which pointers/references are followed, but that is a bit more invasive change.

Reviewers: teemperor, jingham, clayborg

Reviewed By: teemperor, clayborg

Subscribers: clayborg, labath, shafik, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D80254




More information about the All-commits mailing list