[Lldb-commits] [PATCH] D124370: [lldb] Fix PR54761

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 25 02:52:48 PDT 2022


labath created this revision.
labath added reviewers: shafik, clayborg.
Herald added a project: All.
labath requested review of this revision.
Herald added a project: LLDB.

The issue is somewhat hard to describe (I recommend reading the bug),
but what roughly happens is that we have a type with no full definition
(-flimit-debug-info is active), but various compile units still contain
definitions of some methods of that type.

In this situation, we could run into a problem if we started to parse a
method of that type (this is for example needed to establish a
declaration context for any types defined inside that method), and the
class itself was already parsed in another compile unit. In this case,
we would hit a piece of code which would try to merge/copy the two sets
of methods.

The precise purpose of this code is not clear to me, but if it
definitely not doing the right thing in this case (and I'm having
trouble imagining a case where it would be doing the right thing). There
are several ways to to fix this problem, but the simplest one seems to
be to change the condition guarding the problematic code from:

  if (class_opaque_type.IsBeingDefined() || alternate_defn)

to plain:

  if (class_opaque_type.IsBeingDefined())

Since adding a method to a class that is not currently being defined
(i.e., we either having started defining it, or we've already completed
it) is not a good idea, any code path that has this condition false (as
ours did) is most likely erroneous.

This also ensures that the first method of such class is treated in the
same was as the second one -- the first method is not being added
either, although it ends up going through a completely different code
path.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124370

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/test/API/lang/cpp/incomplete-types/members/Makefile
  lldb/test/API/lang/cpp/incomplete-types/members/TestCppIncompleteTypeMembers.py
  lldb/test/API/lang/cpp/incomplete-types/members/a.h
  lldb/test/API/lang/cpp/incomplete-types/members/f.cpp
  lldb/test/API/lang/cpp/incomplete-types/members/g.cpp
  lldb/test/API/lang/cpp/incomplete-types/members/main.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124370.424851.patch
Type: text/x-patch
Size: 3946 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220425/4d538d52/attachment.bin>


More information about the lldb-commits mailing list