236 Commits

Author SHA1 Message Date
Michael Buch
a07347f609
[lldb][test] Rename/remove duplicate methods in API tests (#180250)
Ran my python script from
https://github.com/llvm/llvm-project/pull/97043 over the repo again and
there were 2 duplicate test-cases that have been introduced since I last
did this.

Also one of the WASM classes had a duplicate method which I just
removed.
2026-02-09 09:47:14 +00:00
Sergei Druzhkov
8092c997bc
[lldb] Add MSVC STL std::*_ordering summary providers (#175070)
Added summary providers for std::*_ordering from MSVC STL
2026-01-26 22:42:13 +03:00
Sergei Druzhkov
e4dc7034f8
[lldb] Add libcxx std::*_ordering summary providers (#174227)
Added libcxx std::*_ordering summary providers similar to #174195.
2026-01-26 21:20:47 +03:00
Michael Buch
ec28be3cca [lldb][test] TestDataFormatterLibcxxOptionalSimulator.py: skip on older Clang versions 2026-01-22 13:25:24 +00:00
Nerixyz
c061ddbd15
Reland [LLDB] Fix MS STL variant with non-trivial types and PDB (#176189)
Relands #171489 which was reverted due to a test failure on GreenDragon.

As suggested in
https://github.com/llvm/llvm-project/pull/171489#issuecomment-3754098800,
I'm checking for `std::string` on Darwin and `std::basic_string<char>`
otherwise, however I can't test that locally.
2026-01-15 23:13:04 +01:00
Jonas Devlieghere
a0b71b048b
Revert "[LLDB] Fix MS STL variant with non-trivial types" (#176059)
Reverts llvm/llvm-project#171489 because it causes
`TestDataFormatterStdVariant.py` to fail on Darwin.

Affected bots:

- https://ci.swift.org/view/all/job/llvm.org/view/LLDB/job/as-lldb-cmake/
- https://ci.swift.org/view/all/job/llvm.org/view/LLDB/job/lldb-cmake/
2026-01-14 23:29:33 +00:00
Nerixyz
9a632fd684
[LLDB] Fix MS STL variant with non-trivial types (#171489)
When using `std::variant` with non-trivial types, we need to go through
multiple bases to find the `_Which` member. The MSVC STL implements this
in `xsmf_control.h` which conditionally adds/deletes copy/move
constructors/operators.

We now go to `_Variant_base` (the holder of `_Which`). This inherits
from `_Variant_storage`, which is our entry point to finding the n-th
storage (going through `_Tail`).
2026-01-12 11:40:12 +01:00
Sergei Druzhkov
8ab6b38dab
[lldb] Add std::*_ordering summary providers (#174195)
I want to propose adding summary providers for `std::*_ordering` types
introduced in `C++20`. GDB already has pretty-printers for
[them](https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/python/libstdcxx/v6/printers.py#L1788),
so I think it will be useful.
2026-01-08 21:13:23 +03:00
Nerixyz
255f173139
[LLDB] Run MSVC STL deque tests with PDB (#172360)
Similar to the other PRs, this looks up the type from a member variable.
Here, we can use the type of `_Mapptr`. On its own, that's enough to
pass the test with clang-cl.
2026-01-08 17:19:54 +01:00
Nerixyz
c7c5259f01
[LLDB] Add MSVC STL span formatter (#173053)
`std::span` didn't have a formatter for MSVC's STL yet. The type is
quite useful in C++ 20, so this PR adds a formatter for it.

Since the formatter is new, I made it work with both DWARF and PDB from
the start.
2026-01-07 15:31:27 +01:00
Sergei Druzhkov
9937769cca
[lldb] Add libstdcpp string view summary provider (#171854)
This patch adds libstdcpp string view summary provider.
2026-01-06 22:16:43 +03:00
nerix
50001bb4de
[LLDB] Run MSVC STL unordered tests with PDB (#172731)
The unordered containers re-use the formatters for `std::list` which
were fixed for PDB with #166953.

This should be the last fix for PDB in MSVC STL tests. Unfortunately,
the type names here are very long, because the types of keys/values are
repeated in the template (for hash/eq/allocator).
2025-12-19 15:09:19 +01:00
nerix
d1e98939c8
[LLDB] Run MSVC STL vector tests with PDB (#172726) 2025-12-18 13:18:53 +01:00
nerix
eaf6d9a2ff
[LLDB] Run MSVC STL atomic tests with PDB (#172349)
Because PDB doesn't know about templates, we need to get to `T` of
`std::atomic<T>` differently. The type includes the `value_type`
typedef, which is always equal to `T`. The native PDB plugin includes
this since #169248.

Then we can run the `std::atomic` test with (native) PDB.
2025-12-16 18:26:27 +01:00
nerix
7fdf800a91
[LLDB] Run MSVC variant test with PDB (#171858)
Split off from #171489. This only adds the lookup of the active type for
a `std::variant` based on the head type (since PDB doesn't have template
info).
2025-12-11 18:03:42 +01:00
nerix
719826d33d
[LLDB] Run MSVC STL optional test with PDB (#171486)
Similar to the other PRs, this runs the `std::optional` test with PDB.
Since we don't know that variables use typedefs, we check for the full
name when testing PDB.
2025-12-09 19:52:02 +01:00
nerix
cd805a7373
[LLDB] Run MSVC STL (forward-)list test with PDB (#166953)
Since PDB doesn't have template information, we need to get the element
type from somewhere else. I'm using the type of `_Myval` in a list node,
which holds the element type.
2025-12-09 19:09:33 +01:00
nerix
9b12f8fcae
[LLDB] Run MSVC STL smart pointer tests with PDB (#166946)
Runs the `std::shared/unique_ptr` tests with PDB with two changes:

- PDB uses the "full" name, so `std::string` is `std::basic_string<char,
std::char_traits<char>, std::allocator<char>>`
- The type of the pointer inside the shared/unique_ptr isn't the
`element_type` typedef
2025-12-09 18:06:26 +01:00
Ebuka Ezike
e9bda498e6
[lldb] add libstdcpp span formatter (#168705) 2025-12-03 12:09:23 +00:00
Igor Kudrin
12d72050e1
[lldb][test] Correctly skip a test on a 32-bit target (#168631)
The test was added in #147252. On a 32-bit target, it fails with error:
```
  File "...\TestDataFormatterLibcxxInvalidString.py", line 23, in test
    self.skip()
    ^^^^^^^^^
AttributeError: 'LibcxxInvalidStringDataFormatterTestCase' object has no attribute 'skip'
```
2025-11-19 13:38:41 -08:00
Ebuka Ezike
94fb85646d
[lldb] Add libstdcpp initializer_list formatter (#167515)
Make the existing libc++ formatter generic
Add initializer_list summary provider.
Add test for `libstdcpp`
2025-11-13 14:57:23 +00:00
nerix
311d115ed8
[LLDB] Run MSVC STL string(-view) tests with PDB (#166833)
PDB doesn't include the typedefs for types, so all types use their full
name. For `std::string` and friends, this means they show up as
`std::basic_string<char, std::char_traits<char>, std::allocator<char>>`.

This PR updates the `std::{,w,u8,u16,u32}string(_view)` tests to account
for this and runs them with PDB.
2025-11-07 14:16:44 +01:00
nerix
de2a86e5f0
[LLDB] Run working STL data formatter tests with PDB (#166812)
This enables testing with PDB for all tests that don't require any
changes to pass. I ran the
`lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic`
tests locally and they passed.
2025-11-06 20:00:14 +01:00
Michael Buch
128f850af4 [lldb][test] Fix libc++ API tests on older Clang versions
Both of these fail on our Clang-19 macOS bots.
2025-10-30 15:08:08 +00:00
nerix
15cde999d4
[LLDB] Check type before creating std::atomic synthetic children (#163176)
From
https://github.com/llvm/llvm-project/pull/163077#issuecomment-3396435083:
Currently, `std::atomic<T>` will always use the MSVC STL synthetic
children and summary. When inspecting types from other STLs, the output
would not show any children.

This PR adds a check that `std::atomic` contains `_Storage` to be
classified as coming from MSVC's STL.
2025-10-13 19:25:26 +02:00
Michael Buch
86ba1986a2 [lldb][test] Un-XFAIL TestDataFormatterStdUnorderedMap.py for older Clang versions
Fixed in https://github.com/llvm/llvm-project/pull/156033
2025-10-02 13:30:43 +01:00
Ebuka Ezike
5e118eca93
[lldb][test] Fix unordered-map test. (#158286)
The build step is overidden so it uses `libstdc++` instead of `libc++`
on linux
2025-09-15 15:21:56 +01:00
Michael Buch
4b362f152e
[lldb][DataFormatter] Allow std::string formatters to match against custom allocators (#156050)
This came up in https://github.com/llvm/llvm-project/issues/155691.

For `std::basic_string` our formatter matching logic required the
allocator template parameter to be a `std::allocator`. There is no
compelling reason (that I know of) why this would be required for us to
apply the existing formatter to the string. We don't check the
`allocator` parameter for other STL containers either. This meant that
`std::string` that used custom allocators wouldn't be formatted. This
patch relaxes the regex for `basic_string`.
2025-09-05 09:24:50 +01:00
Jonas Devlieghere
820f440274
[lldb] Correct style of error messages (#156774)
The LLVM Style Guide says the following about error and warning messages
[1]:

> [T]o match error message styles commonly produced by other tools,
> start the first sentence with a lowercase letter, and finish the last
> sentence without a period, if it would end in one otherwise.

I often provide this feedback during code review, but we still have a
bunch of places where we have inconsistent error message, which bothers
me as a user. This PR identifies a handful of those places and updates
the messages to be consistent.

[1] https://llvm.org/docs/CodingStandards.html#error-and-warning-messages
2025-09-04 16:37:41 -07:00
Ebuka Ezike
7db1b2ad1e
[lldb][test] Run ranges::ref_vew test only for libc++ (#155813)
Remove redundant build step in std::ranges::ref_view test, this causes
it use `libstdc++` on linux instead of `libc++` .
2025-08-28 12:14:07 +01:00
Michael Buch
20dd053160
[lldb][DataFormatters] Support newer _LIBCPP_COMPRESSED_PAIR layout (#155153)
Starting with https://github.com/llvm/llvm-project/pull/154686 the
compressed_pair children are now wrapped in an anonymous structure.

This patch adjusts the LLDB data-formatters to support that.

Outstanding questions:
1. Should GetChildMemberWithName look through anonymous structures? That
will break users most likely. But maybe introducing a new API is worth
it? Then we wouldnt have to do this awkward passing around of
`anon_struct_index`
2. Do we support the layout without the anonymous structure? It's not
too much added complexity. And we did release that version of libc++, so
there is code out there compiled against it. But there is no great way
of testing it (some of our macOS matrix bots do test it i suppose, but
not in a targeted way). We have the layout "simulator" tests for some of
the STL types which I will adjust.
2025-08-25 09:17:55 -07:00
Matheus Izvekov
91cdd35008
[clang] Improve nested name specifier AST representation (#147835)
This is a major change on how we represent nested name qualifications in
the AST.

* The nested name specifier itself and how it's stored is changed. The
prefixes for types are handled within the type hierarchy, which makes
canonicalization for them super cheap, no memory allocation required.
Also translating a type into nested name specifier form becomes a no-op.
An identifier is stored as a DependentNameType. The nested name
specifier gains a lightweight handle class, to be used instead of
passing around pointers, which is similar to what is implemented for
TemplateName. There is still one free bit available, and this handle can
be used within a PointerUnion and PointerIntPair, which should keep
bit-packing aficionados happy.
* The ElaboratedType node is removed, all type nodes in which it could
previously apply to can now store the elaborated keyword and name
qualifier, tail allocating when present.
* TagTypes can now point to the exact declaration found when producing
these, as opposed to the previous situation of there only existing one
TagType per entity. This increases the amount of type sugar retained,
and can have several applications, for example in tracking module
ownership, and other tools which care about source file origins, such as
IWYU. These TagTypes are lazily allocated, in order to limit the
increase in AST size.

This patch offers a great performance benefit.

It greatly improves compilation time for
[stdexec](https://github.com/NVIDIA/stdexec). For one datapoint, for
`test_on2.cpp` in that project, which is the slowest compiling test,
this patch improves `-c` compilation time by about 7.2%, with the
`-fsyntax-only` improvement being at ~12%.

This has great results on compile-time-tracker as well:

![image](https://github.com/user-attachments/assets/700dce98-2cab-4aa8-97d1-b038c0bee831)

This patch also further enables other optimziations in the future, and
will reduce the performance impact of template specialization resugaring
when that lands.

It has some other miscelaneous drive-by fixes.

About the review: Yes the patch is huge, sorry about that. Part of the
reason is that I started by the nested name specifier part, before the
ElaboratedType part, but that had a huge performance downside, as
ElaboratedType is a big performance hog. I didn't have the steam to go
back and change the patch after the fact.

There is also a lot of internal API changes, and it made sense to remove
ElaboratedType in one go, versus removing it from one type at a time, as
that would present much more churn to the users. Also, the nested name
specifier having a different API avoids missing changes related to how
prefixes work now, which could make existing code compile but not work.

How to review: The important changes are all in
`clang/include/clang/AST` and `clang/lib/AST`, with also important
changes in `clang/lib/Sema/TreeTransform.h`.

The rest and bulk of the changes are mostly consequences of the changes
in API.

PS: TagType::getDecl is renamed to `getOriginalDecl` in this patch, just
for easier to rebasing. I plan to rename it back after this lands.

Fixes #136624
Fixes https://github.com/llvm/llvm-project/issues/43179
Fixes https://github.com/llvm/llvm-project/issues/68670
Fixes https://github.com/llvm/llvm-project/issues/92757
2025-08-09 05:06:53 -03:00
nerix
7b42e7c98e
[LLDB] Add formatters for MSVC STL std::string_view and friends (#150318)
Adds summaries for `std::{,w,u8,u16,u32}string_view`s from MSVC's STL. A
few functions from the string formatting can be reused.

Towards #24834.
2025-07-25 17:01:35 +01:00
nerix
d5c8303af8
[LLDB] Add formatters for MSVC STL std::deque (#150097)
This PR adds synthetic children for std::deque from MSVC's STL.

Similar to libstdc++ and libc++, the elements are in a `T**`, so we need
to "subscript" twice. The [NatVis for
deque](313964b78a/stl/debugger/STL.natvis (L1103-L1112))
uses `_EEN_DS` which contains the block size. We can't access this, but
we can access the [constexpr
`_Block_size`](313964b78a/stl/inc/deque (L641)).

Towards #24834.
2025-07-23 16:19:47 +01:00
nerix
cc380f6e9b
[LLDB] Add formatters for MSVC STL map-like types (#148385)
This PR adds formatters for `std::map`, `std::set`, `std::multimap`,
`std::multiset` as well as their iterators. It's done in one PR because
the types are essentially the same (a tree) except for their value type.
The iterators are required because of the tests.

`MsvcStlTreeIterSyntheticFrontEnd` is based on the libc++ equivalent. As
opposed to `std::list`, there aren't that many duplicates, so I didn't
create a generic type.

For reference, the tree is implemented in
313964b78a/stl/inc/xtree.

Towards #24834.
2025-07-23 12:37:04 +01:00
nerix
287b9447cc
[LLDB] Add formatters for MSVC STL unordered containers (#149519)
Adds formatters for MSVC STL's unordered containers. This one is
relatively simple, because it can reuse the `std::list` synthetic
children. The unordered containers (aka
[`_Hash`](313964b78a/stl/inc/xhash (L327)))
contain a
[`_List`](313964b78a/stl/inc/xhash (L2012))
which contains all elements (and is used for iterating through the
container).

Towards https://github.com/llvm/llvm-project/issues/24834.
2025-07-22 14:16:50 +01:00
nerix
f78c4ce55b
[LLDB] Add formatters for MSVC STL std::atomic (#149801)
Adds synthetic children and a summary provider for `std::atomic` on
MSVC's STL. This currently only supports DWARF because it relies on the
template argument. Once there are PDB tests, this will probably use the
return type of some method like `value()` because template types aren't
available there.

Towards #24834.
2025-07-22 12:34:26 +01:00
nerix
401b5ccf6b
[LLDB] Add formatters for MSVC STL std::variant (#148554)
Adds a summary and synthetic children for MSVC STL's `std::variant`.

This one is a bit complicated because of DWARF vs PDB differences. I put
the representations in comments. Being able to `GetChildMemberWithName`
a member in an anonymous union would make this a lot simpler
(`std::optional` will have something similar iirc).

Towards #24834.
2025-07-21 12:46:34 +01:00
nerix
f0a7462cf0
[LLDB] Add formatters for MSVC STL std::optional (#149545)
Adds synthetic children for `std::optional` from MSVC's STL. Most of the
machinery for `std::optional` is already there.

Towards #24834.
2025-07-21 10:20:47 +01:00
nerix
88a498c3b1
[LLDB] Add formatters for MSVC STL std::(forward_)list (#148285)
Adds synthetic providers for MSVC's `std::forward_list` and `std::list`.
It refactors `LibCxxList` to be generic over the STL type (currently
libc++ or MSVC STL). The libstdc++ synthetic providers use something
similar in Python
[here](3092b765ba/lldb/examples/synthetic/gnu_libstdcpp.py (L134)).
Eventually, this could be ported to C++ as well.

Towards #24834.
2025-07-16 14:00:18 +01:00
nerix
5ae4939395
[LLDB] Add formatters for MSVC STL std::vector (#147538)
This adds synthetic child providers for `std::vector<T>` and
`std::vector<bool>` for MSVC's STL.

The structure of a `std::vector<T>` is relatively similar to libc++'s
implementation that uses `__begin` and `__end`.
`std::vector<bool>` is different. It's a `std::vector<unsigned int>`
wrapper instead of `std::vector<uint8_t>`. This makes the calculation
slightly less simple. I put a comment in the `GetChildAtIndex` to make
this clear.

- [NatVis for
`std::vector<T>`](313964b78a/stl/debugger/STL.natvis (L1193-L1205))
- [NatVis for
`std::vector<bool>`](313964b78a/stl/debugger/STL.natvis (L1167-L1179))

Towards #24834.
2025-07-16 10:02:50 +01:00
nerix
eec98bef84
[LLDB] Add formatters for MSVC STL std::tuple (#148548)
Adds synthetic children for MSVC STL's
[`std::tuple`](313964b78a/stl/inc/tuple).
A `tuple` is a chain of base classes:
```cpp
template <>
class tuple<> {};

template <class _This, class... _Rest>
class tuple<_This, _Rest...> : private tuple<_Rest...> {
  _Tuple_val<_This> _Myfirst;
};
```

So the provider walks the base classes to the desired one.

The implementation makes it hard to detect if the empty tuple is from
this STL. Fortunately, libstdc++'s synthetic children provider works for
empty MSVC STL tuples as well.

Towards #24834.
2025-07-15 17:17:28 +01:00
nerix
da68e72b1b
[LLDB] Add formatters for MSVC STL std::unique_ptr (#148248)
This PR adds a summary and synthetic children for `std::unique_ptr` from
MSVC's STL
([NatVis](313964b78a/stl/debugger/STL.natvis (L285-L303))).

As with libc++, the deleter is only shown if it's non-empty.

Tested both the shared_ptr and unique_ptr tests on Windows.
Towards #24834.
2025-07-14 11:18:43 +01:00
nerix
def7bbbe17
[LLDB] Add formatters for MSVC STL std::shared_ptr (#147575)
This PR adds formatters for `std::shared_ptr` and `std::weak_ptr`. They
are similar to the ones from libc++ and libstdc++.
[Section from MSVC STL
NatVis](313964b78a/stl/debugger/STL.natvis (L512-L578)).

To support debugging with PDB debug info, I had to add an early exit in
`GetDesugaredSmartPointerValue`, because with PDB, LLDB doesn't know
about template types. This isn't an issue here, since the typedef type
is already resolved there, so no casting is needed.

The tests don't check for PDB - maybe this should be changed? I don't
know a good way to do this. PDB has the downside that it resolves
typedefs. Here in particular, the test for `element_type` would need to
be replaced with `User` and `std::string` with
`std::basic_string<char,std::char_traits<char>,std::allocator<char> >`.

Towards #24834.
2025-07-11 09:37:06 +01:00
Michael Buch
f1cee58789
[lldb][test] Combine libstdc++ and libc++ iterator tests into generic test (#147175)
This combines the libc++ and libstdc++ test cases. The libstdcpp tests
were a subset of the libc++ test, so this patch moves the libcxx test
into generic and removes the libstdcpp test entirely.

There are currently no formatters for libstdcpp
std::unorderd_map::iterator. So I removed those test-cases. We already
test them for libc++ in `libcxx/unordered_map-iterator`. And we test
`std::unordered_map` in `generic/unorderd`. So these test-cases would be
redundant.

Split out from https://github.com/llvm/llvm-project/pull/146740
2025-07-11 09:35:16 +01:00
Michael Buch
9d8058e3b8
[lldb][test] Move std::function from libcxx to generic directory (#147701)
This just moves the test from `libcxx` to `generic`. There are currently
no `std::function` formatters for libstdc++ so I didn't add a test-case
for it.

Split out from https://github.com/llvm/llvm-project/pull/146740
2025-07-09 22:16:59 +01:00
Michael Buch
e7c9f29fc5
[lldb][test] Move std::initializer_list from libcxx to generic directory (#147702)
This just moves the test from `libcxx` to `generic`. There are currently
no `std::initializer_list` formatters for libstdc++ so I didn't add a
test-case for it.

Split out from https://github.com/llvm/llvm-project/pull/146740
2025-07-09 16:40:23 +01:00
Michael Buch
cbb2ef3835 [lldb][test] Fix MSVC std::string formatter tests
These were mistakenly changed during https://github.com/llvm/llvm-project/pull/147525
2025-07-09 16:09:20 +01:00
Michael Buch
fa80a1a4d4
[lldb][test] Move std::ranges::ref_view from libcxx to generic directory (#147705)
This just moves the test from `libcxx` to `generic`. There are currently
no `std::ranges::ref_view` formatters for libstdc++ so I didn't add a
test-case for it.

Split out from https://github.com/llvm/llvm-project/pull/146740
2025-07-09 14:20:57 +01:00
Michael Buch
1e6dd8c1e4
[lldb][test] Merge MSVC STL std::(u8)string tests into generic directory (#147525)
Now that most STL formatter tests have been moved to `generic`. Do the
same for the MSVC tests (which are currently just for `std::string`).
The `std::string` test was mostly the same (MSVC just had 1 additional
check, which I moved over).

We also only tested `u8string` with MSVC. So i moved those into
`generic` as-is. I kept it separate from the existing std::string tests
since it requires c++20.

The tests are currently failing for libc++ and libstdc++ because MSVC
had a test case which checked that:
```
  std::string overwritten_zero("abc");
  const_cast<char *>(overwritten_zero.data())[3] = 'd';
```
prints as `"abc"`. But libc++ and libstdc++ print it as `"abcd"` (which
seems like the more correct thing to do?)
2025-07-09 14:20:44 +01:00