Skip to content

Commit 9a1f898

Browse files
committed
Merge remote-tracking branch 'upstream/release/21.x' into rustc/21.1-2025-08-01
2 parents d35840a + 6096d35 commit 9a1f898

File tree

129 files changed

+3624
-2108
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+3624
-2108
lines changed

clang-tools-extra/clangd/ConfigFragment.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,15 @@ struct Fragment {
315315
/// AngledHeaders (i.e. a header matches a regex in both QuotedHeaders and
316316
/// AngledHeaders), system headers use <> and non-system headers use "".
317317
/// These can match any suffix of the header file in question.
318-
/// Matching is performed against the header text, not its absolute path
318+
/// Matching is performed against the absolute path of the header
319319
/// within the project.
320320
std::vector<Located<std::string>> QuotedHeaders;
321321
/// List of regexes for headers that should always be included with a
322322
/// <>-style include. By default, and in case of a conflict with
323323
/// AngledHeaders (i.e. a header matches a regex in both QuotedHeaders and
324324
/// AngledHeaders), system headers use <> and non-system headers use "".
325325
/// These can match any suffix of the header file in question.
326-
/// Matching is performed against the header text, not its absolute path
326+
/// Matching is performed against the absolute path of the header
327327
/// within the project.
328328
std::vector<Located<std::string>> AngledHeaders;
329329
};

clang-tools-extra/clangd/Headers.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,17 @@ IncludeInserter::calculateIncludePath(const HeaderFile &InsertedHeader,
304304
// FIXME: should we allow (some limited number of) "../header.h"?
305305
if (llvm::sys::path::is_absolute(Suggested))
306306
return std::nullopt;
307+
auto HeaderPath = llvm::sys::path::convert_to_slash(InsertedHeader.File);
307308
bool IsAngled = false;
308309
for (auto &Filter : AngledHeaders) {
309-
if (Filter(Suggested)) {
310+
if (Filter(HeaderPath)) {
310311
IsAngled = true;
311312
break;
312313
}
313314
}
314315
bool IsQuoted = false;
315316
for (auto &Filter : QuotedHeaders) {
316-
if (Filter(Suggested)) {
317+
if (Filter(HeaderPath)) {
317318
IsQuoted = true;
318319
break;
319320
}
@@ -324,7 +325,7 @@ IncludeInserter::calculateIncludePath(const HeaderFile &InsertedHeader,
324325
if (IsAngled && IsQuoted) {
325326
elog("Header '{0}' matches both quoted and angled regexes, default will "
326327
"be used.",
327-
Suggested);
328+
HeaderPath);
328329
}
329330
IsAngled = IsAngledByDefault;
330331
}

clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ TEST(CompletionTest, IncludeInsertionRespectsQuotedAngledConfig) {
938938
{
939939
Config C;
940940
C.Style.AngledHeaders.push_back(
941-
[](auto header) { return header == "bar.h"; });
941+
[](auto header) { return header.contains("bar.h"); });
942942
WithContextValue WithCfg(Config::Key, std::move(C));
943943
Results = completions(TU, Test.point(), {Sym});
944944
EXPECT_THAT(Results.Completions,
@@ -947,7 +947,7 @@ TEST(CompletionTest, IncludeInsertionRespectsQuotedAngledConfig) {
947947
{
948948
Config C;
949949
C.Style.QuotedHeaders.push_back(
950-
[](auto header) { return header == "bar.h"; });
950+
[](auto header) { return header.contains("bar.h"); });
951951
WithContextValue WithCfg(Config::Key, std::move(C));
952952
Results = completions(TU, Test.point(), {Sym});
953953
EXPECT_THAT(Results.Completions,

clang-tools-extra/clangd/unittests/HeadersTests.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,17 @@ TEST_F(HeadersTest, ShortenIncludesInSearchPathBracketed) {
344344
EXPECT_EQ(calculate(BarHeader), "<sub/bar.h>");
345345
}
346346

347+
TEST_F(HeadersTest, ShortenIncludesInSearchPathBracketedFilterByFullPath) {
348+
// The filter receives the full path of the header, so it is able to filter by
349+
// the parent directory, even if it is part of the include search path
350+
AngledHeaders.push_back([](auto Path) {
351+
llvm::Regex Pattern("sub/.*");
352+
return Pattern.match(Path);
353+
});
354+
std::string BarHeader = testPath("sub/bar.h");
355+
EXPECT_EQ(calculate(BarHeader), "<bar.h>");
356+
}
357+
347358
TEST_F(HeadersTest, ShortenedIncludeNotInSearchPath) {
348359
std::string BarHeader =
349360
llvm::sys::path::convert_to_slash(testPath("sub-2/bar.h"));

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,18 @@ Major New Features
4646
Improvements to clangd
4747
----------------------
4848

49-
Inlay hints
50-
^^^^^^^^^^^
49+
Language feature support
50+
^^^^^^^^^^^^^^^^^^^^^^^^
5151

52-
Diagnostics
53-
^^^^^^^^^^^
52+
- Performance improvements and bugfixes to C++20 Modules support
53+
- Improved support for C++23 "deducing this"
54+
- Improvements to objective-c++ support
5455

55-
Semantic Highlighting
56-
^^^^^^^^^^^^^^^^^^^^^
56+
New Language Server Protocol features
57+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58+
59+
- Added support for `textDocument/rangesFormatting`
60+
- Added support for `positionEncoding`
5761

5862
Compile flags
5963
^^^^^^^^^^^^^
@@ -64,24 +68,58 @@ Compile flags
6468
Hover
6569
^^^^^
6670

71+
- Fixed a bug that would sometimes prevent documentation comments of standard library functions
72+
from being shown
73+
6774
Code completion
6875
^^^^^^^^^^^^^^^
6976

70-
Code actions
71-
^^^^^^^^^^^^
72-
73-
Signature help
74-
^^^^^^^^^^^^^^
77+
- Added `HeaderInsertion` config option to control whether code completion inserts a missing
78+
header needed for the symbol being completed. This is equivalent to the `--header-insertion`
79+
command-line option.
80+
- Added a `CodePatterns` config option to control whether code completion should offer code
81+
patterns as completions in addition to symbols.
7582

7683
Cross-references
7784
^^^^^^^^^^^^^^^^
7885

79-
Objective-C
86+
- References to symbols are now collected in array designators
87+
- Find-references now works for operators new and delete
88+
- Improvements to code navigation in templated code
89+
90+
Call hierarchy
91+
^^^^^^^^^^^^^^
92+
93+
- Call hierarchy now works with the remote index
94+
- Fixed a bug where call hierarchy could sometimes return bogus results
95+
96+
Inlay hints
8097
^^^^^^^^^^^
8198

99+
- Parameter hint forwarding now works for variadic forwarding functions declared in header files
100+
- Improved presentation of block-end hints
101+
102+
Code actions
103+
^^^^^^^^^^^^
104+
105+
- Improved the rename refactor's name collision checking logic
106+
107+
Clang-tidy integration
108+
^^^^^^^^^^^^^^^^^^^^^^
109+
110+
- Disabled the cppcoreguidelines-macro-to-enum checker which is incompatible with clangd
111+
112+
Include-cleaner integration
113+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
114+
115+
- Clangd now respects the `AngledHeaders` and `QuotedHeaders` config options for headers
116+
inserted to resolve include-cleaner diagnostics
117+
82118
Miscellaneous
83119
^^^^^^^^^^^^^
84120

121+
- Various crash fixes and other stability improvements
122+
85123
Improvements to clang-doc
86124
-------------------------
87125

clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ struct Header {
136136
}
137137
StringRef verbatim() const { return std::get<Verbatim>(Storage); }
138138

139-
/// For phiscal files, either absolute path or path relative to the execution
139+
/// For physical files, either absolute path or path relative to the execution
140140
/// root. Otherwise just the spelling without surrounding quotes/brackets.
141141
llvm::StringRef resolvedPath() const;
142142

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ C/C++ Language Potentially Breaking Changes
5555
case for old-style offsetof idioms like ``((int)(&(((struct S *)0)->field)))``, to
5656
ensure they are not caught by these optimizations. It is also possible to use
5757
``-fwrapv-pointer`` or ``-fno-delete-null-pointer-checks`` to make pointer arithmetic
58-
on null pointers well-defined. (#GH130734, #GH130742, #GH130952)
58+
on null pointers well-defined. (#GH130734, #GH130952)
5959

6060
C++ Specific Potentially Breaking Changes
6161
-----------------------------------------
@@ -953,7 +953,6 @@ Bug Fixes to C++ Support
953953
- Fixed an access checking bug when initializing non-aggregates in default arguments (#GH62444), (#GH83608)
954954
- Fixed a pack substitution bug in deducing class template partial specializations. (#GH53609)
955955
- Fixed a crash when constant evaluating some explicit object member assignment operators. (#GH142835)
956-
- Fixed an access checking bug when substituting into concepts (#GH115838)
957956
- Fix a bug where private access specifier of overloaded function not respected. (#GH107629)
958957
- Correctly handles calling an explicit object member function template overload set
959958
through its address (``(&Foo::bar<baz>)()``).

clang/docs/ThinLTO.rst

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ during the traditional link step.
249249

250250
The implementation is documented here: https://llvm.org/docs/DTLTO.html.
251251

252+
Command-Line Options
253+
^^^^^^^^^^^^^^^^^^^^
254+
252255
DTLTO requires the LLD linker (``-fuse-ld=lld``).
253256

254257
``-fthinlto-distributor=<path>``
@@ -260,17 +263,29 @@ DTLTO requires the LLD linker (``-fuse-ld=lld``).
260263
- Can be specified multiple times to pass multiple options.
261264
- Multiple options can also be specified by separating them with commas.
262265

263-
Examples:
264-
- ``clang -flto=thin -fthinlto-distributor=incredibuild.exe -Xthinlto-distributor=--verbose,--j10 -fuse-ld=lld``
265-
- ``clang -flto=thin -fthinlto-distributor=$(which python) -Xthinlto-distributor=incredibuild.py -fuse-ld=lld``
266-
267266
If ``-fthinlto-distributor=`` is specified, Clang supplies the path to a
268267
compiler to be executed remotely to perform the ThinLTO backend
269268
compilations. Currently, this is Clang itself.
270269

270+
Usage
271+
^^^^^
272+
273+
Compilation is unchanged from ThinLTO. DTLTO options need to supplied for the link step:
274+
275+
.. code-block:: console
276+
277+
% clang -flto=thin -fthinlto-distributor=distribute.sh -Xthinlto-distributor=--verbose,--j10 -fuse-ld=lld file1.o file2.o
278+
% clang -flto=thin -fthinlto-distributor=$(which python) -Xthinlto-distributor=distribute.py -fuse-ld=lld file1.o file2.o
279+
280+
When using lld-link:
281+
282+
.. code-block:: console
283+
284+
% lld-link /out:a.exe file1.obj file2.obj /thinlto-distributor:distribute.exe /thinlto-remote-compiler:${LLVM}\bin\clang.exe /thinlto-distributor-arg:--verbose
285+
271286
Note that currently, DTLTO is only supported in some LLD flavors. Support can
272287
be added to other LLD flavours in the future.
273-
See `DTLTO <https://lld.llvm.org/dtlto.html>`_ for more information.
288+
See `DTLTO <https://lld.llvm.org/DTLTO.html>`_ for more information.
274289

275290
More Information
276291
================

clang/include/clang/Basic/DiagnosticASTKinds.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,14 @@ def note_odr_number_of_bases : Note<
507507
"class has %0 base %plural{1:class|:classes}0">;
508508
def note_odr_enumerator : Note<"enumerator %0 with value %1 here">;
509509
def note_odr_missing_enumerator : Note<"no corresponding enumerator here">;
510+
def note_odr_incompatible_fixed_underlying_type : Note<
511+
"enumeration %0 declared with incompatible fixed underlying types (%1 vs. "
512+
"%2)">;
513+
def note_odr_fixed_underlying_type : Note<
514+
"enumeration %0 has fixed underlying type here">;
515+
def note_odr_missing_fixed_underlying_type : Note<
516+
"enumeration %0 missing fixed underlying type here">;
517+
510518
def err_odr_field_type_inconsistent : Error<
511519
"field %0 declared with incompatible types in different "
512520
"translation units (%1 vs. %2)">;

clang/include/clang/Basic/LangOptions.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,8 @@ LANGOPT(CheckConstexprFunctionBodies, 1, 1, Benign,
496496

497497
LANGOPT(BoundsSafety, 1, 0, NotCompatible, "Bounds safety extension for C")
498498

499+
LANGOPT(EnableLifetimeSafety, 1, 0, NotCompatible, "Experimental lifetime safety analysis for C++")
500+
499501
LANGOPT(PreserveVec3Type, 1, 0, NotCompatible, "Preserve 3-component vector type")
500502

501503
#undef LANGOPT

0 commit comments

Comments
 (0)