[Lldb-commits] [PATCH] D71056: [lldb] Add a test for how we lazily create Clang AST nodes

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 5 05:00:39 PST 2019


teemperor created this revision.
teemperor added a reviewer: shafik.
Herald added subscribers: lldb-commits, JDevlieghere, abidh.
Herald added a project: LLDB.

One of the ways we try to make LLDB faster is by only creating the Clang declarations (and loading the associated types)
when we actually need them for something. For example an evaluated expression might need to load types to
type check and codegen the expression.

Currently this mechanism isn't really tested, so we currently have no way to know how many Clang nodes we load and
when we load them. In general there seems to be some confusion when and why certain Clang nodes are created.
As we are about to make some changes to the code which is creating Clang AST nodes we probably should have
a test that at least checks that the current behaviour doesn't change. It also serves as some kind of documentation
on the current behaviour.

The test in this patch is just evaluating some expressions and checks which Clang nodes are created due to this in the
module AST. The check happens by looking at the AST dump of the current module and then scanning it for the
declarations we are looking for.

I'm aware that there are things missing in this test (inheritance, template parameters, non-expression evaluation commands)
but I'll expand it in follow up patches.

Also this test found two potential bugs in LLDB which are documented near the respective asserts in the test:

1. LLDB seems to always load all types of local variables even when we don't reference them in the expression. We had patches

that tried to prevent this but it seems that didn't work as well as it should have (even though we don't complete these
types).

2. We always seem to complete the first field of any record we run into. This has the funny side effect that LLDB is faster when

all classes in a project have an arbitrary `char unused;` as their first member. We probably want to fix this.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D71056

Files:
  lldb/packages/Python/lldbsuite/test/functionalities/lazy-loading/Makefile
  lldb/packages/Python/lldbsuite/test/functionalities/lazy-loading/TestLazyLoading.py
  lldb/packages/Python/lldbsuite/test/functionalities/lazy-loading/main.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71056.232310.patch
Type: text/x-patch
Size: 12412 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191205/f82940f4/attachment-0001.bin>


More information about the lldb-commits mailing list