11329 Commits

Author SHA1 Message Date
Baranov Victor
e326ff2a88
[clang-tidy] Fix FP on cppcoreguidelines-pro-type-member-init with forward decl (#190521)
Fixes https://github.com/llvm/llvm-project/issues/155416.
2026-04-06 08:42:24 +03:00
Zeyi Xu
0b7f01ad51
[clang-tidy] Add frames for bugprone-exception-escape options (#187971)
This patch adds frames emitting for
`bugprone-exception-escape.TreatFunctionsWithoutSpecificationAsThrowing`.

As of AI Usage: Gemini 3 is used for pre-commit reviewing.

Closes https://github.com/llvm/llvm-project/issues/184781
2026-04-05 22:07:20 +08:00
serge-sans-paille
df2de0a26d
[clang-tidy] Improve bugprone.use-after-move interaction with explicit destructor call. (#188866)
It is valid (although niche) to call an explicit destructor after moving
the object.
2026-04-05 10:06:46 +00:00
Paul Kirth
64987a9ccc
[clang-doc] Enforce arena allocated types are trivially destructible (#190049)
We can enforce at compile-time that the types we want to place in the
arenas are always safe to allocate there.
2026-04-03 21:28:18 +00:00
Paul Kirth
1deab59f6f
[clang-doc] Migrate Namespaces to arena allocation (#190048)
This patch allocates the NamespaceInfo types in the local arenas, and
adapts the merging logic for the new list type and its children.
Memory use and performance improve slightly. Micro-benchmarks show a
regression in merge operations due to the more complex list operations.

 ## Build Clang-Doc Documentation
| Metric | Baseline | Prev | This | Culm% | Seq% |
| :--- | :--- | :--- | :--- | :--- | :--- |
| Time | 920.5s | 1009.2s | 1002.4s | +8.9% | -0.7% |
| Memory | 86.0G | 43.2G | 43.9G | -49.0% | +1.6% |

 ## Microbenchmarks (Filtered for >1% Delta)
| Benchmark | Baseline | Prev | This | Culm% | Seq% |
| :--- | :--- | :--- | :--- | :--- | :--- |
| BM_BitcodeReader_Scale/10 | 67.9us | 69.7us | 69.3us | +1.9% | -0.7% |
| BM_BitcodeReader_Scale/10000 | 70.5ms | 22.3ms | 24.8ms | -64.8% |
+11.4% |
| BM_BitcodeReader_Scale/4096 | 23.2ms | 4.7ms | 4.4ms | -80.9% | -5.7%
|
| BM_BitcodeReader_Scale/512 | 509.4us | 558.7us | 540.2us | +6.0% |
-3.3% |
| BM_BitcodeReader_Scale/64 | 114.8us | 119.2us | 117.0us | +1.9% |
-1.8% |
| BM_EmitInfoFunction | 1.6us | 1.6us | 1.6us | -1.1% | +0.8% |
| BM_Index_Insertion/10 | 2.3us | 4.2us | 3.7us | +61.7% | -11.3% |
| BM_Index_Insertion/10000 | 3.1ms | 5.4ms | 4.9ms | +56.8% | -9.1% |
| BM_Index_Insertion/4096 | 1.3ms | 2.2ms | 2.0ms | +54.5% | -8.2% |
| BM_Index_Insertion/512 | 153.6us | 259.6us | 236.7us | +54.1% | -8.8%
|
| BM_Index_Insertion/64 | 18.1us | 30.7us | 27.9us | +54.5% | -9.0% |
| BM_JSONGenerator_Scale/10 | 36.8us | 37.6us | 36.6us | -0.7% | -2.7% |
| BM_JSONGenerator_Scale/4096 | 33.7ms | 34.3ms | 34.2ms | +1.4% | -0.3%
|
| BM_JSONGenerator_Scale/64 | 222.4us | 225.6us | 220.2us | -1.0% |
-2.4% |
| BM_Mapper_Scale/10 | 2.5ms | 2.5ms | 2.5ms | -1.4% | -1.7% |
| BM_Mapper_Scale/10000 | 104.3ms | 109.3ms | 105.9ms | +1.6% | -3.1% |
| BM_Mapper_Scale/4096 | 44.3ms | 43.9ms | 44.7ms | +0.8% | +1.8% |
| BM_Mapper_Scale/512 | 7.6ms | 7.6ms | 7.6ms | +0.8% | +1.2% |
| BM_MergeInfos_Scale/10000 | 12.2ms | 1.6ms | 2.0ms | -83.6% | +28.7% |
| BM_MergeInfos_Scale/2 | 1.9us | 1.7us | 1.7us | -8.1% | +0.9% |
| BM_MergeInfos_Scale/4096 | 2.8ms | 520.5us | 557.4us | -79.9% | +7.1%
|
| BM_MergeInfos_Scale/512 | 68.9us | 37.9us | 39.9us | -42.0% | +5.3% |
| BM_MergeInfos_Scale/64 | 10.3us | 6.3us | 6.5us | -36.7% | +2.7% |
| BM_MergeInfos_Scale/8 | 2.8us | 2.2us | 2.2us | -20.7% | +1.2% |
| BM_SerializeFunctionInfo | 25.5us | 25.8us | 26.1us | +2.1% | +1.1% |
2026-04-03 20:33:56 +00:00
Daniil Dudkin
418ae6c600
[include-cleaner][NFC] expose and test normalizePath helper (#189364)
Also fix a bug where the root `/` path would become an empty string.
2026-04-03 19:34:07 +00:00
Paul Kirth
4ad1844304
[clang-doc] Refactor FriendInfo parameters to use ArrayRef (#190047)
This also adapts readBlock for the new layouts.
2026-04-03 11:26:12 -07:00
Björn Svensson
6111520043
[clang-tidy] Fix readability-identifier-naming for C++17 structured bindings (#189500)
`BindingDecl` nodes, i.e. the individual names in a structured binding,
were not handled in `IdentifierNamingCheck::findStyleKind()`, causing
them to fall through to the Default style or be silently ignored.
This led to incorrect renames, e.g. applying member variable conventions
to local bindings.

---------

Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
2026-04-03 21:11:18 +03:00
Willem Kaufmann
e1f6dc4b23
[clang-tidy] Add AllowExplicitObjectParameters option to avoid-capturing-lambda-coroutines (#182916)
Add an off-by-default `AllowExplicitObjectParameters` option to the
existing `cppcoreguidelines-avoid-capturing-lambda-coroutines` check.

When enabled, lambda coroutines that use C++23 "deducing this" (explicit
object parameter) are not flagged, since captures are moved into the
coroutine frame ([1], [2], [3]). In C++23 mode, the check also provides
fix-it hints to add `this auto` as the first parameter for lambdas that
don't use it.

The option is off by default to match the current C++ Core Guidelines,
which do not yet recognize explicit object parameters as a solution
([4]). Once the guidelines adopt the proposal, the default can be
flipped.

[1]:
https://github.com/scylladb/seastar/blob/master/doc/lambda-coroutine-fiasco.md#solution-c23-and-up

[2]: https://www.scs.stanford.edu/~dm/blog/vexing-capture.html

[3]: https://lists.isocpp.org/std-proposals/2020/05/1391.php

[4]:
https://github.com/isocpp/CppCoreGuidelines/pull/2289#issuecomment-3756500251
2026-04-03 16:56:08 +03:00
Paul Kirth
a52a504e69
[clang-doc] Prepare Info types for Arena allocation (#190046)
To allocate Info structures directly in an Arena, they cannot have
members with nontrivial destructors, or we will leak memory. Before we
migrate them, we can replace growable vector types with intrusive lists.

This introduces some slight overhead as these types now have new pointer
members for use in ilists in later patches.

| Metric | Baseline | Prev | This | Culm% | Seq% |
| :--- | :--- | :--- | :--- | :--- | :--- |
| Time | 920.5s | 1005.7s | 1010.5s | +9.8% | +0.5% |
| Memory | 86.0G | 42.1G | 42.9G | -50.2% | +1.8% |

| Benchmark | Baseline | Prev | This | Culm% | Seq% |
| :--- | :--- | :--- | :--- | :--- | :--- |
| BM_BitcodeReader_Scale/10 | 67.9us | 68.6us | 69.2us | +1.9% | +0.9% |
| BM_BitcodeReader_Scale/10000 | 70.5ms | 21.3ms | 21.9ms | -68.9% |
+2.8% |
| BM_BitcodeReader_Scale/4096 | 23.2ms | 4.6ms | 4.6ms | -80.0% | +0.8%
|
| BM_BitcodeReader_Scale/512 | 509.4us | 546.3us | 541.8us | +6.4% |
-0.8% |
| BM_BitcodeReader_Scale/64 | 114.8us | 117.9us | 117.6us | +2.5% |
-0.2% |
| BM_EmitInfoFunction | 1.6us | 1.5us | 1.6us | -1.9% | +3.9% |
| BM_Index_Insertion/10 | 2.3us | 3.9us | 4.0us | +75.3% | +3.0% |
| BM_Index_Insertion/10000 | 3.1ms | 5.3ms | 5.4ms | +72.7% | +2.4% |
| BM_Index_Insertion/4096 | 1.3ms | 2.1ms | 2.1ms | +67.1% | +1.8% |
| BM_Index_Insertion/512 | 153.6us | 253.0us | 259.0us | +68.6% | +2.4%
|
| BM_Index_Insertion/64 | 18.1us | 30.1us | 30.3us | +67.8% | +0.5% |
| BM_JSONGenerator_Scale/10 | 36.8us | 37.0us | 38.2us | +3.6% | +3.2% |
| BM_JSONGenerator_Scale/10000 | 89.6ms | 91.7ms | 90.7ms | +1.2% |
-1.1% |
| BM_JSONGenerator_Scale/4096 | 33.7ms | 35.1ms | 34.7ms | +2.9% | -1.1%
|
| BM_JSONGenerator_Scale/512 | 1.9ms | 1.9ms | 2.0ms | +3.9% | +4.0% |
| BM_JSONGenerator_Scale/64 | 222.4us | 223.3us | 230.1us | +3.5% |
+3.1% |
| BM_Mapper_Scale/10000 | 104.3ms | 105.6ms | 100.9ms | -3.2% | -4.4% |
| BM_Mapper_Scale/4096 | 44.3ms | 44.8ms | 42.8ms | -3.5% | -4.4% |
| BM_Mapper_Scale/512 | 7.6ms | 7.6ms | 7.4ms | -2.6% | -3.2% |
| BM_Mapper_Scale/64 | 3.1ms | 3.0ms | 3.0ms | -2.0% | -1.3% |
| BM_MergeInfos_Scale/10000 | 12.2ms | 1.4ms | 1.6ms | -86.7% | +12.5% |
| BM_MergeInfos_Scale/2 | 1.9us | 1.7us | 1.7us | -10.2% | -1.9% |
| BM_MergeInfos_Scale/4096 | 2.8ms | 487.3us | 503.4us | -81.9% | +3.3%
|
| BM_MergeInfos_Scale/512 | 68.9us | 38.7us | 38.1us | -44.6% | -1.4% |
| BM_MergeInfos_Scale/64 | 10.3us | 6.4us | 6.4us | -37.6% | -0.4% |
| BM_MergeInfos_Scale/8 | 2.8us | 2.2us | 2.2us | -21.7% | -1.5% |
| BM_SerializeFunctionInfo | 25.5us | 25.9us | 26.0us | +1.9% | +0.4% |
2026-04-03 06:02:32 +00:00
Paul Kirth
4b2623d03c
[clang-doc] Introduce TransientArena for short lived allocations (#190045)
With strings interned, we can move the StringRefs in various Info
structs into a new short lived arena. This change migrates the remaining
SmallVectors in CommentInfo to use an ArrayRef backed by the new
transient arena.

This results in further minor reductions in overall memory usage, but no
significant effect on runtime performance.

| Metric | Baseline | Prev | This | Culm% | Seq% |
| :--- | :--- | :--- | :--- | :--- | :--- |
| Time | 920.5s | 1011.0s | 1005.7s | +9.2% | -0.5% |
| Memory | 86.0G | 44.9G | 42.1G | -51.0% | -6.2% |

| Benchmark | Baseline | Prev | This | Culm% | Seq% |
| :--- | :--- | :--- | :--- | :--- | :--- |
| BM_BitcodeReader_Scale/10 | 67.9us | 70.0us | 68.6us | +1.0% | -2.0% |
| BM_BitcodeReader_Scale/10000 | 70.5ms | 21.3ms | 21.3ms | -69.8% |
-0.0% |
| BM_BitcodeReader_Scale/4096 | 23.2ms | 4.5ms | 4.6ms | -80.2% | +2.8%
|
| BM_BitcodeReader_Scale/512 | 509.4us | 538.8us | 546.3us | +7.3% |
+1.4% |
| BM_BitcodeReader_Scale/64 | 114.8us | 118.0us | 117.9us | +2.7% |
-0.1% |
| BM_EmitInfoFunction | 1.6us | 1.6us | 1.5us | -5.5% | -6.2% |
| BM_Index_Insertion/10 | 2.3us | 4.0us | 3.9us | +70.3% | -0.7% |
| BM_Index_Insertion/10000 | 3.1ms | 5.0ms | 5.3ms | +68.6% | +5.0% |
| BM_Index_Insertion/4096 | 1.3ms | 2.0ms | 2.1ms | +64.2% | +4.5% |
| BM_Index_Insertion/512 | 153.6us | 245.0us | 253.0us | +64.8% | +3.2%
|
| BM_Index_Insertion/64 | 18.1us | 28.9us | 30.1us | +67.0% | +4.4% |
| BM_JSONGenerator_Scale/10 | 36.8us | 36.4us | 37.0us | +0.4% | +1.7% |
| BM_JSONGenerator_Scale/10000 | 89.6ms | 90.4ms | 91.7ms | +2.3% |
+1.5% |
| BM_JSONGenerator_Scale/4096 | 33.7ms | 34.0ms | 35.1ms | +4.0% | +3.0%
|
| BM_JSONGenerator_Scale/64 | 222.4us | 220.5us | 223.3us | +0.4% |
+1.3% |
| BM_Mapper_Scale/10000 | 104.3ms | 105.4ms | 105.6ms | +1.3% | +0.3% |
| BM_Mapper_Scale/4096 | 44.3ms | 44.7ms | 44.8ms | +1.0% | +0.1% |
| BM_Mapper_Scale/512 | 7.6ms | 7.7ms | 7.6ms | +0.7% | -1.2% |
| BM_MergeInfos_Scale/10000 | 12.2ms | 1.4ms | 1.4ms | -88.2% | +0.1% |
| BM_MergeInfos_Scale/2 | 1.9us | 1.7us | 1.7us | -8.5% | +2.1% |
| BM_MergeInfos_Scale/4096 | 2.8ms | 495.6us | 487.3us | -82.5% | -1.7%
|
| BM_MergeInfos_Scale/512 | 68.9us | 34.6us | 38.7us | -43.9% | +11.6% |
| BM_MergeInfos_Scale/64 | 10.3us | 6.0us | 6.4us | -37.4% | +7.2% |
| BM_MergeInfos_Scale/8 | 2.8us | 2.1us | 2.2us | -20.6% | +5.1% |
| BM_SerializeFunctionInfo | 25.5us | 26.8us | 25.9us | +1.4% | -3.3% |
2026-04-03 05:46:25 +00:00
Paul Kirth
2600533a66
[clang-doc] Switch to string internment (#190044)
This is the first step in migrating all the Info types to be POD. We
introduced a shared string saver that can be used safely across threads,
and updated the internal represntation of various data types to use
these over owned strings, like SmallString or std::string.

This also required changes to YAMLGenerator to keep the single quoted
string formatting and to update the YAML traits.

This change gives an almost 50% reduction in peak memory when building
documentation for clang, at about a 10% performance loss. Future patches
can mitigate the performance penalties, and further reduce memory use.

| Metric | Baseline | Prev | This | Culm% | Seq% |
| :--- | :--- | :--- | :--- | :--- | :--- |
| Time | 920.5s | 920.5s | 1011.0s | +9.8% | +9.8% |
| Memory | 86.0G | 86.0G | 44.9G | -47.8% | -47.8% |

| Benchmark | Baseline | Prev | This | Culm% | Seq% |
| :--- | :--- | :--- | :--- | :--- | :--- |
| BM_BitcodeReader_Scale/10 | 67.9us | 67.9us | 70.0us | +3.0% | +3.0% |
| BM_BitcodeReader_Scale/10000 | 70.5ms | 70.5ms | 21.3ms | -69.8% |
-69.8% |
| BM_BitcodeReader_Scale/4096 | 23.2ms | 23.2ms | 4.5ms | -80.7% |
-80.7% |
| BM_BitcodeReader_Scale/512 | 509.4us | 509.4us | 538.8us | +5.8% |
+5.8% |
| BM_BitcodeReader_Scale/64 | 114.8us | 114.8us | 118.0us | +2.8% |
+2.8% |
| BM_Index_Insertion/10 | 2.3us | 2.3us | 4.0us | +71.6% | +71.6% |
| BM_Index_Insertion/10000 | 3.1ms | 3.1ms | 5.0ms | +60.6% | +60.6% |
| BM_Index_Insertion/4096 | 1.3ms | 1.3ms | 2.0ms | +57.1% | +57.1% |
| BM_Index_Insertion/512 | 153.6us | 153.6us | 245.0us | +59.6% | +59.6%
|
| BM_Index_Insertion/64 | 18.1us | 18.1us | 28.9us | +60.0% | +60.0% |
| BM_JSONGenerator_Scale/10 | 36.8us | 36.8us | 36.4us | -1.3% | -1.3% |
| BM_Mapper_Scale/10000 | 104.3ms | 104.3ms | 105.4ms | +1.0% | +1.0% |
| BM_Mapper_Scale/512 | 7.6ms | 7.6ms | 7.7ms | +1.9% | +1.9% |
| BM_MergeInfos_Scale/10000 | 12.2ms | 12.2ms | 1.4ms | -88.2% | -88.2%
|
| BM_MergeInfos_Scale/2 | 1.9us | 1.9us | 1.7us | -10.3% | -10.3% |
| BM_MergeInfos_Scale/4096 | 2.8ms | 2.8ms | 495.6us | -82.2% | -82.2% |
| BM_MergeInfos_Scale/512 | 68.9us | 68.9us | 34.6us | -49.7% | -49.7% |
| BM_MergeInfos_Scale/64 | 10.3us | 10.3us | 6.0us | -41.6% | -41.6% |
| BM_MergeInfos_Scale/8 | 2.8us | 2.8us | 2.1us | -24.4% | -24.4% |
| BM_SerializeFunctionInfo | 25.5us | 25.5us | 26.8us | +4.9% | +4.9% |

note: I used an LLM to help generate the test code adjustments and the
YAML traits.
2026-04-02 23:25:21 +00:00
Victor Chernyakin
a413a40150
[clang-tidy][NFC] Remove another ad-hoc exclusion for system headers (#190094)
This is another ad-hoc approach made obsolete by #151035.
2026-04-02 20:52:47 +00:00
Paul Kirth
802d4631e0
[clang-doc] Update lookup routines for consistency (#190043)
When filtering is enabled, its possible an Info doesn't have a 
Parent USR. Use `find()` to safely handle that case.

Additionally, I noticed the comparison code for the index
poorly reimplemented the existing comparison from StringRef.
We can just use the one from ADT.
2026-04-01 23:17:42 -07:00
Thorsten Klein
2b87d02b03
[clang-tidy] Properly escape printed clang-tidy command in run-clang-tidy.py (#189974)
The `run-clang-tidy.py` script now uses `shlex.join()` to construct the
command string for printing.

This ensures that arguments containing shell metacharacters, such as the
asterisk in `--warnings-as-errors=*`, are correctly quoted. This allows
the command to be safely copied and pasted into any shell for manual
execution, fixing errors previously seen with shells like `fish` that
are strict about wildcard expansion.

Before:
```
[ 1/15][0.2s] /usr/bin/clang-tidy -p=/home/user/work/project/build --warnings-as-errors=* /home/user/work/project/src/main.cpp
```

Note: When running this command in fish shell you get some error like
`fish: No matches for wildcard '--warnings-as-errors=*'. See `help
wildcards-globbing``

After:
```
[ 1/15][0.2s] /usr/bin/clang-tidy -p=/home/user/work/project/build '--warnings-as-errors=*' /home/user/work/project/src/main.cpp
```
2026-04-01 23:35:40 +03:00
Victor Chernyakin
5d393aee10
[clang-tidy][NFC] Remove the ObjCModuleTest.cpp unit test (#185832)
These unit tests only duplicate the tests in
`clang-tools-extra/test/clang-tidy/checkers/objc/forbidden-subclassing.m`.
2026-04-01 07:19:42 -07:00
Baranov Victor
76f5c5d36c
[clang-tidy] Add AllowLogicalOperatorConversion option to implicit-bool-conversion (#189149)
Fixes https://github.com/llvm/llvm-project/issues/176889.
2026-03-30 21:18:16 +00:00
Erick Velez
cd3da41c01
[clang-doc] Integrate enum LIT tests (#187818)
Combine the two separate test files and have them feed from a common
source. This will be the way that tests are handled to prevent testing
divergence in the future.
2026-03-30 10:34:37 -07:00
Zeyi Xu
032f36bdbc
[clang-tidy] Rename performance-faster-string-find to performance-prefer-single-char-overloads (#186946)
Related discussion:
https://github.com/llvm/llvm-project/pull/182697#issuecomment-3986242476
Closes https://github.com/llvm/llvm-project/issues/186853

---------

Co-authored-by: Victor Chernyakin <chernyakin.victor.j@outlook.com>
2026-03-30 14:19:27 +08:00
Zeyi Xu
c963ce446c
[clang-tidy] Diagnose NULL macro expansions in implicit-bool-conversion (#188694)
The check can't find `NULL` from system headers, this is not the default
behaviour we want. This commit fixes the problem.

https://clang-tidy.godbolt.org/z/Exd4bzqaT

Related discussion in:
https://github.com/llvm/llvm-project/pull/188399#discussion_r2985381743
2026-03-30 12:14:39 +08:00
Baranov Victor
71263dc615
[clang-tidy] Fix bugprone-inc-dec-in-conditions FP with lambda condition (#189145)
Fixes https://github.com/llvm/llvm-project/issues/163913.
2026-03-29 09:11:28 +03:00
Victor Chernyakin
6ead6868e7
[clang-tidy][NFC] Run performance-faster-string-find over the codebase (#189202) 2026-03-28 18:41:48 -07:00
Baranov Victor
ad91a2f036
[clang-tidy] Fix rvalue-reference-param-not-moved FP on implicit functions (#189113)
Fixes https://github.com/llvm/llvm-project/issues/187716.
2026-03-28 10:44:46 +03:00
Zeyi Xu
93e475a475
[clang-tidy] Add missing #include insertion in macros for modernize-use-std-print (#188394)
Follow-up of: #188247

---------

Co-authored-by: Victor Chernyakin <chernyakin.victor.j@outlook.com>
2026-03-27 17:13:43 +08:00
Zeyi Xu
983b2023dd
[clang-tidy][NFC] Use mock header instead of #define NULL in tests (#188420)
Since stddef.h in the mock headers of clang-tidy tests now provides
`#define NULL 0L`, we can migrate manual `#define NULL` in these tests
to standard `#include`s.
2026-03-26 10:19:09 +08:00
Zeyi Xu
acbbe5c145
[clang-tidy][NFC] Remove hack in readability-implicit-bool-conversion testcases (#188399)
Another attempt after #184850
2026-03-25 14:21:00 +08:00
Zeyi Xu
dd9885c0f3
[clang-tidy] Add missing #include insertion in macros for modernize-use-std-format (#188247)
Added missing ``#include`` insertion when the format function call
appears as an argument to a macro.

Part of #175183

---------

Co-authored-by: Victor Chernyakin <chernyakin.victor.j@outlook.com>
2026-03-25 07:52:45 +08:00
earnol
4eedd518be
[clang-tidy] Do not provide diagnostics for cert-dcl58-cpp on implicit declarations (#188152)
Do not provide diagnostics for cert-dcl58-cpp for compiler generated
intrinsic as it will be a false positive.

In provided tests compiler generates align_val_t which ends up inside
std namespace, resulting in std::align_val_t symbol. This symbol is
compiler generated, having no location, causing compiler crash. Also
there is no point to notify user about violations which user has no
control of.

Resolution: Diagnostics suppressed.

Co-authored-by: Vladislav Aranov <vladislav.aranov@ericsson.com>
2026-03-24 12:40:49 -04:00
Justin Cady
c1ea10a854
[clangd] Add background index path remapping tool (#185482)
Introduce a standalone tool to remap paths inside clangd background
index files. This allows users to pay the cost of generating a full
background index once, then reuse the background index across multiple
clients. Each client rewrites the background index in place after
copying the original, specifying the path(s) to be remapped.

This is an alternative approach to the dynamic path remapping proposed
in #180285.

Fixes clangd/clangd#847

Assisted-by: claude
2026-03-24 11:21:06 -04:00
Aleksandr Platonov
a8b669ba6e
[clangd] Add ArcsinX as a maintainer (#187886)
To address clangd maintance problem, I'm nominating myself as a clangd
maintainer.
I'm currently actively reviewing PRs. I also participated in
clangd-related discourse discussions, subscribed to clangd issues and
PRs. For a while I plan to spend some time for PRs review in clangd.
2026-03-24 09:18:08 +03:00
LeeYoungJoon
d734ead132
[clang-tidy] Fix false positive in cert-ctr56-cpp (PointerArithmeticOnPolymorphicObjectCheck) (#187452)
## Summary
This change adds `unless(isInstantiationDependent())` to the
`ArraySubscript` matcher.

## Motivation
In template code, some array subscript expressions are not fully
resolved yet.
Because of this, the matcher may treat them incorrectly and produce
false positives.

## Change
This patch skips instantiation-dependent expressions in templates. 
It helps the matcher work only on resolved expressions.

Closes https://github.com/llvm/llvm-project/issues/187009.
2026-03-24 10:12:35 +09:00
Baranov Victor
2ab8924c53
[clang-tidy][NFC] Use universal containers mock (#186669)
Changes are quite big but most of them is just copypasting and creating
mocks.
2026-03-23 13:11:34 +03:00
Tom
bb86440c60
[clang-tidy] Correctly ignore function templates in derived-method-shadowing-base-method (#185741) (#185875)
This commit fixes a false positive in the
derived-method-shadowin-base-method clang-tidy check, as described in
[ticket 185741](https://github.com/llvm/llvm-project/issues/185741)

Fixes #185741

---------

Co-authored-by: Tom James <tom.james@siemens.com>
Co-authored-by: Zeyi Xu <mitchell.xu2@gmail.com>
2026-03-23 17:28:41 +08:00
Zeyi Xu
c911b84923
[clang-tidy][NFC] Remove guidelines in documentation of misc-multiple-inheritance (#186657)
Closes https://github.com/llvm/llvm-project/issues/186058
2026-03-23 11:56:47 +08:00
Chuanqi Xu
95c906a31c
[clangd] [C++ Modules] Fix handling of relative paths in prebuilt mod… (#187654)
…ule files

When compile_commands.json contains relative paths in -fmodule-file=
arguments (as generated by CMake), clangd failed to find the BMI files
because it was looking for them relative to the wrong working directory.

This patch fixes the issue by converting relative paths to absolute
paths based on the compilation directory (CompileCommand.Directory)
before checking if the module file exists and is up to date.

Added a unit test that verifies the fix works correctly.

AI Assisted
2026-03-23 03:48:41 +00:00
Chuanqi Xu
5ef593b750
[clangd] [C++ Modules] Enable content validation for module input files (#187653)
The IsModuleFileUpToDate function was not properly validating input
files for C++20 modules. By default, ASTReader skips input file
validation for StandardCXXModule files unless
ForceCheckCXX20ModulesInputFiles and ValidateASTInputFilesContent are
both set.

This change:
- Passes ValidateASTInputFilesContent=true to ASTReader constructor
- Uses ARR_OutOfDate flag for cleaner error handling
- Simplifies the validation logic (ReadAST already validates internally)
- Adds a test to verify header changes in module units are detected

Assised with AI.
2026-03-23 03:43:57 +00:00
Victor Chernyakin
5567572c44
[clang-tidy][NFC] Remove optimized container implementations in misc-no-recursion (#187630)
About half of this check's code is dedicated to implementing a pair of
set containers with optimizations for when the element count is small.
But the check only uses these containers while constructing the warning
message. That's not generally a hot path in any check. Just to confirm,
I ran the check over `clang/lib/Sema/Sema.cpp` and all its included
headers before and after, and saw no performance difference. So, these
containers seem like a false optimization.
2026-03-22 18:21:05 -07:00
Hippolyte Melica
98f84f9bf2
[clangd] Code completion for declaration of class method (#165916)
Code completion previously could not tell apart the declaration of
a method from a call to it, and provided call-like behaviour even
in declaration contexts. This included things like not offering 
completion for private methods, and inserting placeholders for
the parameters as though the user was going to fill in arguments.

This patch adds support to Parser and SemaCodeComplete to
detect and provide dedicated behaviour for declaration contexts.
In these contexts, the flag CodeCompletionResult::DeclaringEntity
is set, and createCodeCompletionString() is adjusted to handle this
flag, e.g. by inserting parameter declarations as text chunks rather
than placeholder chunks.

The DeclaringEntity flag is also available for consumers of
SemaCodeComplete, such as clangd, to customize their behaviour.

In addition, the patch tweaks the conditions under which the
existing CodeCompletionResult::FunctionCanBeCall flag is set to
be more accurate, excluding declaration contexts and cases where
the address of the function is likely being taken.

Fixes clangd/clangd#753
Fixes clangd/clangd#880
Fixes clangd/clangd#1752
2026-03-22 22:25:54 +00:00
juan.vazquez
2566961cef
[clang-tidy] use-after-move: Support null_after_move annotations (#186903)
Extend the bugprone-use-after-move check to recognize user defined
smart-pointer-like types that make guarantees on the state of a
moved-from object, leaving it in a valid and specified state that
matches the standard smart pointer's moved-from state (nullptr), where
it is safe to use but not dereference.

Following the RFC discussion:

* Use `[[clang::annotate]]` to mark the types.
* Use an schema for the `[[clang::annotate]]` annotation and arguments
to help avoid conflicts with other users of the attribute.
* The annotation will identify the tool ("clang-tidy") and the arguments
the plugin ("bugprone-use-after-move"), and the behavior of the type
("null_after_move"). E.g.:

`[[clang::annotate("clang-tidy", "bugprone-use-after-move",
"null_after_move")]]`

RFC:
https://discourse.llvm.org/t/rfc-add-a-class-attribute-clang-null-after-move-for-use-after-move-analysis/89760
2026-03-22 19:42:24 +03:00
Berkay Sahin
b4084bd213
[clang] Detect pointee mutations in placement new expressions (#187508)
Fixes #187012 which is a false positive on clang-tidy end.
2026-03-22 12:22:17 +01:00
Mir Immad
a5472086ce
[clang-tidy] False negatives readability-redundant-parantheses member of struct (#187054)
Fixes #186749
2026-03-22 17:26:31 +08:00
Victor Chernyakin
1087db5b1f
[clang-tidy] Speed up bugprone-suspicious-semicolon (#187558)
```txt
                   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
Status quo:        0.4743 (100.0%)   0.3802 (100.0%)   0.8546 (100.0%)   0.8567 (100.0%)  bugprone-suspicious-semicolon
With this change:  0.0103 (100.0%)   0.0027 (100.0%)   0.0130 (100.0%)   0.0133 (100.0%)  bugprone-suspicious-semicolon
```
Continuing the trend of registering one `anyOf` matcher being slower
than registering each of its matchers separately (see #178829 for a
previous example).

(This PR also changes the traversal mode, but I only saw a small speedup
from that. Most of it came from registering the matchers separately.)

This check wasn't super expensive to begin with, but the speedup is
still pretty nice.
2026-03-21 00:29:07 -05:00
Erick Velez
51c158b5d2
[clang-doc] Fix incorrectly rendered specialization args in HTML (#187761)
Function template specialization arguments were incorrectly rendered
without a comma. This was due to the "End" JSON property also being
used in the levels above. Mustache looks for missing properties in
parent contexts, see #174359.
2026-03-20 16:09:34 -07:00
Zeyi Xu
6d45f6dfb7
[clang-tidy] Generate valid JSON for characters that require escaping (#187454)
As of AI Usage: This PR is assisted by Claude
Closes #187201
2026-03-20 23:55:00 +08:00
Zeyi Xu
172c0bbfbd
[clang-tidy] Fix alphabetical order check for multiline doc entries and whitespace handling (#186950)
The `check_alphabetical_order.py` script previously only scanned the
first line of each bullet point in `ReleaseNotes.rst`, causing sorting
failures when a `:doc:` tag was split across multiple lines.

Also, when it is sorting the last entry of a section, the script will
insert an unnecessary whitespace.

This PR fixes these two problems.
2026-03-20 18:33:12 +08:00
Thomas Köppe
4376bf27c1
[clang-tidy] Fix "effective" -> "efficient". (#187536)
"Effective" is the wrong word: Both overloads are effective; they do
what they're supposed to do. But the character overload does less work.
2026-03-20 12:29:54 +03:00
Jan Svoboda
9ae3077ae9
[clang][modules] Remove Module::ASTFile (#185994)
This removes the assumption that a deserialized module is backed by a
`FileEntry`. The `OptionalFileEntryRef` member is replaced with
`ModuleFile{Name,Key}`.
2026-03-19 13:06:49 -07:00
Erick Velez
de9746cdfe
[clang-doc] Add individual target for unit tests (#185695) 2026-03-19 10:19:04 -07:00
Victor Chernyakin
555caa1876
[clang-tidy] Fix readability-else-after-return breaking code by deleting too many characters (#187437)
Fixes #57258.
2026-03-19 12:09:48 -05:00
Chuanqi Xu
621d40e182
Revert "[clang-tidy] [Modules] Skip checking decls in clang-tidy" (#187461)
Reverts llvm/llvm-project#145630

As requested in https://github.com/llvm/llvm-project/pull/145630
2026-03-19 09:51:54 +00:00