llvm-project/lldb
Raphael Isemann b8567559cf [lldb] Make the ClassTemplateDecl merging logic in TypeSystemClang respect template parameters
DWARF doesn't describe templates itself but only actual template instantiations.
Because of that LLDB has to infer the parameters of the class template
declarations from the actual instantiations when creating the internal Clang AST
from debug info

Because there is no dedicated DIE for the class template, LLDB also creates the
`ClassTemplateDecl` implicitly when parsing a template instantiation. To avoid
creating one ClassTemplateDecls for every instantiation,
`TypeSystemClang::CreateClassTemplateDecl` will check if there is already a
`ClassTemplateDecl` in the requested `DeclContext` and will reuse a found
fitting declaration.

The logic that checks if a found class template fits to an instantiation is
currently just comparing the name of the template. So right now we map
`template<typename T> struct S;` to an instantiation with the values `S<1, 2,
3>` even though they clearly don't belong together.

This causes crashes later on when for example the Itanium mangler's
`TemplateArgManglingInfo::needExactType` method tries to find fitting the class
template parameter that fits to an instantiation value. In the example above it
will try to find the parameter for the value `2` but will just trigger a
boundary check when retrieving the parameter with index 1 from the class
template.

There are two ways we can end up with an instantiation that doesn't fit to a
class template with the same name:

1. We have two TUs with two templates that have the same name and internal
   linkage.
2. A forward declared template instantiation is emitted by GCC and Clang
   without an empty list of parameter values.

This patch makes the check for whether a class template declaration can be
reused more sophisticated by also comparing whether the parameter values can fit
to the found class template. If we can't find a fitting class template we
justcreate a second class template with the fitting parameters.

Fixes rdar://76592821

Reviewed By: kastiglione

Differential Revision: https://reviews.llvm.org/D100662
2021-06-15 19:25:07 +02:00
..
bindings [lldb][docs] Document SBType 2021-06-14 13:19:19 +02:00
cmake [lldb] add LLDB_SKIP_DSYM option 2021-05-26 09:32:59 -07:00
docs [lldb][docs] Add the missing rst anchors to the Python enum docs 2021-06-14 16:31:28 +02:00
examples [LLDB][NFC] Remove parameter names from forward declarations from hand written expressions used in heap.py 2021-06-08 14:27:02 -07:00
include/lldb Work around MSVC compiler intricacies. 2021-06-15 08:17:56 -07:00
lldb/test/Shell/Breakpoint [lldb] Don't print script output twice in HandleCommand 2021-06-08 13:57:39 -07:00
packages/Python [lldb] Introduce createTestTarget for creating a valid target in API tests 2021-05-24 16:18:44 +02:00
resources [lldb] Remove stale LLDB-Info.plist 2021-01-08 10:12:16 -08:00
scripts Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk 2021-02-25 11:32:27 +01:00
source [lldb] Make the ClassTemplateDecl merging logic in TypeSystemClang respect template parameters 2021-06-15 19:25:07 +02:00
test [lldb] Make the ClassTemplateDecl merging logic in TypeSystemClang respect template parameters 2021-06-15 19:25:07 +02:00
third_party/Python/module Revert "[lldb] temporary commit to see why a test is failing only on lldb-aarch64-ubuntu" 2020-08-05 11:55:02 +02:00
tools [lldb-vscode] Synchronize calls to SendTerminatedEvent 2021-06-11 21:37:19 +05:30
unittests [lldb] Make the ClassTemplateDecl merging logic in TypeSystemClang respect template parameters 2021-06-15 19:25:07 +02:00
utils [lldb] Match test dependencies name to other LLVM projects. 2021-05-21 00:10:27 -07:00
.clang-format
.clang-tidy [lldb] Use C++11 default member initializers 2021-06-09 09:43:13 -07:00
.gitignore
CMakeLists.txt [LLDB] Don't use the local python to set a default for LLDB_PYTHON_RELATIVE_PATH when cross compiling. 2021-05-11 14:04:41 +03:00
CODE_OWNERS.txt
LICENSE.TXT
use_lldb_suite_root.py