[all-commits] [llvm/llvm-project] e42edb: [lldb] Fix expressions that involve nested structs...

Greg Clayton via All-commits all-commits at lists.llvm.org
Fri Jan 5 09:27:08 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e42edb5547618c172abe25914000bb61f5278c4c
      https://github.com/llvm/llvm-project/commit/e42edb5547618c172abe25914000bb61f5278c4c
  Author: Greg Clayton <gclayton at fb.com>
  Date:   2024-01-05 (Fri, 05 Jan 2024)

  Changed paths:
    M lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
    M lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
    A lldb/test/API/commands/expression/nested/Makefile
    A lldb/test/API/commands/expression/nested/TestNestedExpressions.py
    A lldb/test/API/commands/expression/nested/main.cpp

  Log Message:
  -----------
  [lldb] Fix expressions that involve nested structs/classes/unions. (#77029)

The LLDB expression parser relies on using the external AST source
support in LLDB. This allows us to find a class at the root namespace
level, but it wouldn't allow us to find nested classes all of the time.
When LLDB finds a class via this mechanism, it would be able to complete
this class when needed, but during completion, we wouldn't populate
nested types within this class which would prevent us from finding
contained types when needed as clang would expect them to be present if
a class was completed. When we parse a type for a class, struct or
union, we make a forward declaration to the class which can be
completed. Now when the class is completed, we also add any contained
types to the class' declaration context which now allows these types to
be found. If we have a struct that contains a struct, we will add the
forward declaration of the contained structure which can be c ompleted
later. Having this forward declaration makes it possible for LLDB to
find everything it needs now.

This should fix an existing issue:
https://github.com/llvm/llvm-project/issues/53904

Previously, contained types could be parsed by accident and allow
expression to complete successfully. Other times we would have to run an
expression multiple times because our old type lookup from our
expressions would cau se a type to be parsed, but not used in the
current expression, but this would have parsed a type into the
containing decl context and the expression might succeed if it is run
again.




More information about the All-commits mailing list