366 Commits

Author SHA1 Message Date
Dave Lee
7a5431eee3
[lldb][bytecode] Fix Update() and failing test (#187795)
Fixes a breakage from https://github.com/llvm/llvm-project/pull/182155
2026-03-20 15:27:34 -07:00
Nerixyz
58d34e2e02
[lldb] Include stdio.h in synthetic subscript test (#186847)
The [lldb-aarch64-windows](https://lab.llvm.org/buildbot/#/builders/141)
buildbot failed with:

```
lld-link: error: undefined symbol: printf
>>> referenced by main.o:(main)
```

I'm assuming that's because of the use of `__builtin_printf`. In other
tests, we use `printf` form `stdio.h` and these build fine, so I added
an include and used `printf`.
2026-03-16 18:54:44 +01:00
Dave Lee
a585f4566f
[lldb] Make date test handle host-target time difference (#185759)
It seems there may be a formatter bug when there's a time zone
difference between the target machine being debugged, and the host the
debugger is running on.
2026-03-10 14:36:30 -07:00
Adrian Prantl
70509b5e19
[LLDB] Allow one-line summaries in the presence of synthetic child providers (#184926)
This is driven by the Swift language. In Swift many data types such as
Int, and String are structs, and LLDB provides summary formatters and
synthetic child providers for them. For String, for example, a summary
formatter pulls out the string data from the implementation, while a
synthetic child provider hides the implementation details from users, so
strings don't expand their children.

rdar://171646109
2026-03-06 10:07:08 -08:00
Dave Lee
58c5252b28
[lldb] Automatic indexing for synthetic children of collections (#174885)
Synthetic providers for collection types use a child name format of
"[N]".

This `ValueObjectSynthetic` to automatically convert child names in this
convention to the index embedded in the subscript string. With this
change, synthetic formatters for collections will only need to implement
`GetIndexOfChildWithName` or `get_child_index` for non-indexed
collection children. Some examples of non-indexed children are
`$$dereference$$` support, or "hidden" children.

The automatic conversion applies to N values that are less than the
number of children reported by the synthetic provider.
2026-03-05 23:28:22 +00:00
Michael Buch
72e68fa73c [lldb][test] TestDataFormatterGenericOptional.py: remove obsolete skipIfs
Clang 7 and GCC 5 are pretty ancient. There's unlikely to be any bot configurations running this anymore. Lets remove it to reduce test noise.
2026-03-05 11:09:30 +00:00
Michael Buch
fcf6bb8f3c [lldb][test] Clean up USE_LIBSTDCPP/USE_LIBCPP usage
This patch makes the two tests consistent with the rest of the formatter API tests (and is in my opionion easier to follow).
2026-03-05 11:07:40 +00:00
Michael Buch
b9143faf46 [lldb][test] TestDataFormatterStdValarray: relax expected error message check
After https://github.com/llvm/llvm-project/pull/182297, we started generated `-gsimple-template-names` debug-info by default on macOS. The test was expecting template parameters in the error message. But with `simple-template-names` typenames would not contain template parameters (unless LLDB reconstructs them to do so). This formatter test was expecting template parameters, which would fail on macOS > 26.

Because the test is just concerned with checking that the `std::valarray` formatter works as expected (not that LLDB can retrieve typenames with/without template names), this patch relaxes the assertion.

In a follow-up we should fix up any type-name printing that would break with `simple-template-names`.
2026-02-23 16:26:30 +00:00
Omair Javaid
bca95d1e4d
Disable shared builds for tests failing on Windows (#182249)
PR #181720 introduced shared builds for LLDB API tests to improve test
efficiency. But several data formatter tests requiring PDB debug info
are failing on Windows x64 and AArch64 platforms.

This patch disables shared builds for these tests by setting
SHARED_BUILD_TESTCASE = False

The shared build optimization breaks these tests because they reuse
build artifacts between test methods
The test runs may could use multiple methods with different debug
formats or compiler flags. When a test runs first it builds with one set
of flags, but then it runs again but **make** sees the source unchanged
so it skips rebuilding and reuses the same old binary instead of
rebuilding with correct flags.
2026-02-19 17:17:53 +05:00
Dave Lee
e58d3250aa
[lldb] Disable shared build dir for TestDataFormatterStdMap.py (#182096)
Follow up to #181720. This test failed on builder lldb-x86_64-debian.
2026-02-18 10:57:04 -08:00
Dave Lee
b9225e8607
[lldb] Allow tests to share a single build (#181720)
This changes Python API tests to use a single build shared across all
test functions, instead of the previous default behavior of a separate
build dir for each test function.

This build behavior opt-out, tests can use the previous behavior of one
individual (unshared) build directory per test function, by setting
`SHARED_BUILD_TESTCASE` to False (in the test class).

The motivation is to make the test suite more efficient, by not
repeatedly building the same test source. When running tests on my macOS
machine, this reduces the time of `ninja check-lldb-api` by almost 60%
(sample numbers: from ~492s down to ~207s = 58%). Almost 5min time
saved.

Each test function still calls `self.build()`, but only the first call
will do a build, in the subsequent tests `make` will be a no-op because
the sources won't have changed.
2026-02-18 10:38:45 -08:00
Michael Buch
d49060a72d [lldb][test] TestCompactVectors.py: skip for older Clang
Was failing on the Clang 17 green dragon matrix bot:
```
/Applications/Xcode_26.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.2.sdk/System/Library/Frameworks/vecLib.framework/Headers/Sparse/SolveImplementationTyped.h:678:9: error: use of undeclared identifier '__builtin_verbose_trap'
07:28:37    678 |         __builtin_verbose_trap("unsupported", "LU factorization is not supported on this OS version");
07:28:37        |         ^
07:28:37  /Applications/Xcode_26.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.2.sdk/System/Library/Frameworks/vecLib.framework/Headers/Sparse/SolveImplementationTyped.h:888:95: error: unrecognized platform name visionOS
07:28:37    888 |       if(__builtin_available(macOS 15.5, macCatalyst 18.5, iOS 18.5, watchOS 11.5, tvOS 18.5, visionOS 2.5, *)) {
07:28:37        |
```
2026-02-12 09:45:40 +00:00
Dave Lee
52bcdc6ad1
[lldb] Implement bytecode based SyntheticChildren (#179832)
Initial implementation of a [bytecode][1] synthetic provider. This is a follow up to
https://github.com/llvm/llvm-project/pull/114333 which implemented the bytecode
interpreter, support for summary formatters, and more.

rdar://169727764

[1]: https://lldb.llvm.org/resources/formatterbytecode.html
2026-02-11 09:43:59 -08:00
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
Michael Buch
dca088023e
[lldb][Format] Unwrap references to C-strings when printing C-string summaries (#174398)
Depends on:
* https://github.com/llvm/llvm-project/pull/174385

(only last commit is relevant for this review)

The `${var%s}` format isn't capable of formatting references to
C-strings. So the summary for those becomes `<no value available>`. This
patch prevents the system C-string formatter from applying to
references, which means the summary for such types will be empty. This
prompts LLDB to instead print the child, which is the referenced
C-string.

Before:
```
(lldb) v ref
(const char *&) ref = 0x000000016fdfe960 <no value available>
```

After:
```
(lldb) v ref
(const char *&) ref = 0x000000016fdfec40 (&ref = "hi")
```

An alternative would be to support references in the `ValueObject` dump
methods. We assume C-string are pointers/arrays in a lot of places, so
such a fix would be a more intrusive undertaking, and I'm not sure we
would want to support references there in the first place. So for now I
went with the fallback logic in this PR.
2026-01-06 08:41:10 +00:00
Michael Buch
e982b4f411 [lldb][test] Add tests for printing references to C-strings
Printing references to C-strings doesn't work properly at the moment. This patch provides coverage for those cases and should fail once the underlying issue gets fixed (see https://github.com/llvm/llvm-project/pull/174398).
2026-01-05 15:08:23 +00:00
Michael Buch
3c32360c83
[lldb][test] Rewrite TestStringPrinter.py in a non-inline API test style (#174385)
Motivation here is that I'm planning to add more test cases to this and
it's easier to read/maintain as an API test.

Drive-by:
* I also removed the `std::string` checks since those belong in the STL
formatter tests.
2026-01-05 13:43:59 +00: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
Sirraide
9b95e10d5e
[LLDB] [Tests] Downgrade -Wincompatible-pointer-types to a warning in some tests (#158756)
These no longer compile because the warning now defaults to an error
after #157364, so downgrade the error to a warning for now; I’m not
familiar enough with either LLDB or MacOS to fix these warnings properly
(assuming they’re unintended).
2025-09-16 02:02:01 +02: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