Skip to content

Commit b8ec0fb

Browse files
authored
Merge branch 'llvm:main' into main
2 parents b23f3ea + dff3c96 commit b8ec0fb

File tree

1,279 files changed

+54979
-17445
lines changed

Some content is hidden

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

1,279 files changed

+54979
-17445
lines changed

.mailmap

Lines changed: 1 addition & 1 deletion

bolt/test/X86/end-symbol.test

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# RUN: yaml2obj %p/Inputs/plt-sec.yaml &> %t.exe
22
# RUN: llvm-bolt %t.exe -o %t.out
3-
# RUN: (llvm-readelf --program-headers %t.out | grep LOAD | tail -n 1 ; llvm-nm %t.out) \
4-
# RUN: | FileCheck %s
3+
4+
# RUN: llvm-readelf --program-headers %t.out | grep LOAD | tail -n 1 > %t.load
5+
# RUN: llvm-nm %t.out >> %t.load
6+
# RUN: FileCheck %s < %t.load
57

68
## Check that llvm-bolt correctly updates _end symbol to match the end of the
79
## last loadable segment.

bolt/test/X86/instrumentation-eh_frame_hdr.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
// RUN: %clangxx %cxxflags -static -Wl,-q %s -o %t.exe -Wl,--entry=_start
77
// RUN: llvm-bolt %t.exe -o %t.instr -instrument \
88
// RUN: --instrumentation-file=%t.fdata -instrumentation-sleep-time=1
9-
// RUN: (llvm-readelf -SW %t.instr | grep -v bolt; llvm-readelf -lW %t.instr | \
10-
// RUN: grep LOAD | tail -n 1) | FileCheck %s
9+
// RUN: llvm-readelf -SW %t.instr | grep -v bolt > %t.sections
10+
// RUN: llvm-readelf -lW %t.instr | grep LOAD | tail -n 1 >> %t.sections
11+
// RUN: FileCheck %s < %t.sections
1112

1213
// CHECK: {{.*}} .eh_frame_hdr PROGBITS [[#%x, EH_ADDR:]]
1314
// CHECK: LOAD 0x[[#%x, LD_OFFSET:]] 0x[[#%x, LD_VADDR:]] 0x[[#%x, LD_FSIZE:]]

clang-tools-extra/clangd/TUScheduler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,7 @@ DebouncePolicy::compute(llvm::ArrayRef<clock::duration> History) const {
18381838
// Base the result on the median rebuild.
18391839
// nth_element needs a mutable array, take the chance to bound the data size.
18401840
History = History.take_back(15);
1841-
llvm::SmallVector<clock::duration, 15> Recent(History.begin(), History.end());
1841+
llvm::SmallVector<clock::duration, 15> Recent(History);
18421842
auto *Median = Recent.begin() + Recent.size() / 2;
18431843
std::nth_element(Recent.begin(), Median, Recent.end());
18441844

clang-tools-extra/include-cleaner/lib/WalkAST.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,11 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {
351351
}
352352

353353
bool VisitCXXNewExpr(CXXNewExpr *E) {
354-
report(E->getExprLoc(), E->getOperatorNew());
354+
report(E->getExprLoc(), E->getOperatorNew(), RefType::Ambiguous);
355355
return true;
356356
}
357357
bool VisitCXXDeleteExpr(CXXDeleteExpr *E) {
358-
report(E->getExprLoc(), E->getOperatorDelete());
358+
report(E->getExprLoc(), E->getOperatorDelete(), RefType::Ambiguous);
359359
return true;
360360
}
361361
};

clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,9 @@ TEST(WalkAST, FriendDecl) {
557557
}
558558

559559
TEST(WalkAST, OperatorNewDelete) {
560-
testWalk("void* $explicit^operator new(decltype(sizeof(int)), void*);",
560+
testWalk("void* $ambiguous^operator new(decltype(sizeof(int)), void*);",
561561
"struct Bar { void foo() { Bar b; ^new (&b) Bar; } };");
562-
testWalk("struct A { static void $explicit^operator delete(void*); };",
562+
testWalk("struct A { static void $ambiguous^operator delete(void*); };",
563563
"void foo() { A a; ^delete &a; }");
564564
}
565565
} // namespace

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ the configuration (without a prefix: ``Auto``).
16171617
**AllowAllParametersOfDeclarationOnNextLine** (``Boolean``) :versionbadge:`clang-format 3.3` :ref:`<AllowAllParametersOfDeclarationOnNextLine>`
16181618
If the function declaration doesn't fit on a line,
16191619
allow putting all parameters of a function declaration onto
1620-
the next line even if ``BinPackParameters`` is ``false``.
1620+
the next line even if ``BinPackParameters`` is ``OnePerLine``.
16211621

16221622
.. code-block:: c++
16231623

@@ -2067,20 +2067,41 @@ the configuration (without a prefix: ``Auto``).
20672067

20682068
.. _BinPackParameters:
20692069

2070-
**BinPackParameters** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`<BinPackParameters>`
2071-
If ``false``, a function declaration's or function definition's
2072-
parameters will either all be on the same line or will have one line each.
2070+
**BinPackParameters** (``BinPackParametersStyle``) :versionbadge:`clang-format 3.7` :ref:`<BinPackParameters>`
2071+
The bin pack parameters style to use.
20732072

2074-
.. code-block:: c++
2073+
Possible values:
2074+
2075+
* ``BPPS_BinPack`` (in configuration: ``BinPack``)
2076+
Bin-pack parameters.
2077+
2078+
.. code-block:: c++
2079+
2080+
void f(int a, int bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
2081+
int ccccccccccccccccccccccccccccccccccccccccccc);
2082+
2083+
* ``BPPS_OnePerLine`` (in configuration: ``OnePerLine``)
2084+
Put all parameters on the current line if they fit.
2085+
Otherwise, put each one on its own line.
2086+
2087+
.. code-block:: c++
2088+
2089+
void f(int a, int b, int c);
2090+
2091+
void f(int a,
2092+
int b,
2093+
int ccccccccccccccccccccccccccccccccccccc);
2094+
2095+
* ``BPPS_AlwaysOnePerLine`` (in configuration: ``AlwaysOnePerLine``)
2096+
Always put each parameter on its own line.
2097+
2098+
.. code-block:: c++
2099+
2100+
void f(int a,
2101+
int b,
2102+
int c);
20752103

2076-
true:
2077-
void f(int aaaaaaaaaaaaaaaaaaaa, int aaaaaaaaaaaaaaaaaaaa,
2078-
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
20792104

2080-
false:
2081-
void f(int aaaaaaaaaaaaaaaaaaaa,
2082-
int aaaaaaaaaaaaaaaaaaaa,
2083-
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
20842105

20852106
.. _BitFieldColonSpacing:
20862107

@@ -4817,7 +4838,7 @@ the configuration (without a prefix: ``Auto``).
48174838
items into as few lines as possible when they go over ``ColumnLimit``.
48184839

48194840
If ``Auto`` (the default), delegates to the value in
4820-
``BinPackParameters``. If that is ``true``, bin-packs Objective-C
4841+
``BinPackParameters``. If that is ``BinPack``, bin-packs Objective-C
48214842
protocol conformance list items into as few lines as possible
48224843
whenever they go over ``ColumnLimit``.
48234844

@@ -4831,13 +4852,13 @@ the configuration (without a prefix: ``Auto``).
48314852

48324853
.. code-block:: objc
48334854
4834-
Always (or Auto, if BinPackParameters=true):
4855+
Always (or Auto, if BinPackParameters==BinPack):
48354856
@interface ccccccccccccc () <
48364857
ccccccccccccc, ccccccccccccc,
48374858
ccccccccccccc, ccccccccccccc> {
48384859
}
48394860
4840-
Never (or Auto, if BinPackParameters=false):
4861+
Never (or Auto, if BinPackParameters!=BinPack):
48414862
@interface ddddddddddddd () <
48424863
ddddddddddddd,
48434864
ddddddddddddd,

clang/docs/RealtimeSanitizer.rst

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
=================
2+
RealtimeSanitizer
3+
=================
4+
5+
.. contents::
6+
:local:
7+
8+
Introduction
9+
============
10+
RealtimeSanitizer (a.k.a. RTSan) is a real-time safety testing tool for C and C++
11+
projects. RTSan can be used to detect real-time violations, i.e. calls to methods
12+
that are not safe for use in functions with deterministic runtime requirements.
13+
RTSan considers any function marked with the ``[[clang::nonblocking]]`` attribute
14+
to be a real-time function. If RTSan detects a call to ``malloc``, ``free``,
15+
``pthread_mutex_lock``, or anything else that could have a non-deterministic
16+
execution time in a function marked ``[[clang::nonblocking]]``
17+
RTSan raises an error.
18+
19+
The runtime slowdown introduced by RealtimeSanitizer is negligible.
20+
21+
How to build
22+
============
23+
24+
Build LLVM/Clang with `CMake <https://llvm.org/docs/CMake.html>` and enable the
25+
``compiler-rt`` runtime. An example CMake configuration that will allow for the
26+
use/testing of RealtimeSanitizer:
27+
28+
.. code-block:: console
29+
30+
$ cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_RUNTIMES="compiler-rt" <path to source>/llvm
31+
32+
Usage
33+
=====
34+
35+
There are two requirements:
36+
37+
1. The code must be compiled with the ``-fsanitize=realtime`` flag.
38+
2. Functions that are subject to real-time constraints must be marked
39+
with the ``[[clang::nonblocking]]`` attribute.
40+
41+
Typically, these attributes should be added onto the functions that are entry
42+
points for threads with real-time priority. These threads are subject to a fixed
43+
callback time, such as audio callback threads or rendering loops in video game
44+
code.
45+
46+
.. code-block:: console
47+
48+
% cat example_realtime_violation.cpp
49+
#include <vector>
50+
51+
void violation() [[clang::nonblocking]]{
52+
std::vector<float> v;
53+
v.resize(100);
54+
}
55+
56+
int main() {
57+
violation();
58+
return 0;
59+
}
60+
# Compile and link
61+
% clang++ -fsanitize=realtime -g example_realtime_violation.cpp
62+
63+
If a real-time safety violation is detected in a ``[[clang::nonblocking]]``
64+
context, or any function invoked by that function, the program will exit with a
65+
non-zero exit code.
66+
67+
.. code-block:: console
68+
69+
% clang++ -fsanitize=realtime -g example_realtime_violation.cpp
70+
% ./a.out
71+
Real-time violation: intercepted call to real-time unsafe function `malloc` in real-time context! Stack trace:
72+
#0 0x000102893034 in __rtsan::PrintStackTrace() rtsan_stack.cpp:45
73+
#1 0x000102892e64 in __rtsan::Context::ExpectNotRealtime(char const*) rtsan_context.cpp:78
74+
#2 0x00010289397c in malloc rtsan_interceptors.cpp:286
75+
#3 0x000195bd7bd0 in operator new(unsigned long)+0x1c (libc++abi.dylib:arm64+0x16bd0)
76+
#4 0x5c7f00010230f07c (<unknown module>)
77+
#5 0x00010230f058 in std::__1::__libcpp_allocate[abi:ue170006](unsigned long, unsigned long) new:324
78+
#6 0x00010230effc in std::__1::allocator<float>::allocate[abi:ue170006](unsigned long) allocator.h:114
79+
... snip ...
80+
#10 0x00010230e4bc in std::__1::vector<float, std::__1::allocator<float>>::__append(unsigned long) vector:1162
81+
#11 0x00010230dcdc in std::__1::vector<float, std::__1::allocator<float>>::resize(unsigned long) vector:1981
82+
#12 0x00010230dc28 in violation() main.cpp:5
83+
#13 0x00010230dd64 in main main.cpp:9
84+
#14 0x0001958960dc (<unknown module>)
85+
#15 0x2f557ffffffffffc (<unknown module>)

clang/docs/ReleaseNotes.rst

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ C++ Specific Potentially Breaking Changes
7777
ABI Changes in This Version
7878
---------------------------
7979

80+
- Fixed Microsoft name mangling of placeholder, auto and decltype(auto), return types for MSVC 1920+. This change resolves incompatibilities with code compiled by MSVC 1920+ but will introduce incompatibilities with code compiled by earlier versions of Clang unless such code is built with the compiler option -fms-compatibility-version=19.14 to imitate the MSVC 1914 mangling behavior.
81+
8082
AST Dumping Potentially Breaking Changes
8183
----------------------------------------
8284

@@ -107,19 +109,6 @@ C++ Language Changes
107109
constant expression. Supports the `V.xyzw` syntax and other tidbits
108110
as seen in OpenCL. Selecting multiple elements is left as a future work.
109111

110-
C++17 Feature Support
111-
^^^^^^^^^^^^^^^^^^^^^
112-
113-
C++14 Feature Support
114-
^^^^^^^^^^^^^^^^^^^^^
115-
116-
C++20 Feature Support
117-
^^^^^^^^^^^^^^^^^^^^^
118-
119-
C++23 Feature Support
120-
^^^^^^^^^^^^^^^^^^^^^
121-
- Removed the restriction to literal types in constexpr functions in C++23 mode.
122-
123112
C++2c Feature Support
124113
^^^^^^^^^^^^^^^^^^^^^
125114

@@ -131,6 +120,16 @@ C++2c Feature Support
131120

132121
- Implemented `P2893R3 Variadic Friends <https://wg21.link/P2893>`_
133122

123+
- Implemented `P2747R2 constexpr placement new <https://wg21.link/P2747R2>`_.
124+
125+
C++23 Feature Support
126+
^^^^^^^^^^^^^^^^^^^^^
127+
- Removed the restriction to literal types in constexpr functions in C++23 mode.
128+
129+
C++20 Feature Support
130+
^^^^^^^^^^^^^^^^^^^^^
131+
132+
134133
Resolutions to C++ Defect Reports
135134
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
136135

@@ -177,11 +176,13 @@ New Compiler Flags
177176
Deprecated Compiler Flags
178177
-------------------------
179178

179+
- ``-fheinous-gnu-extensions`` is deprecated; it is now equivalent to
180+
specifying ``-Wno-error=invalid-gnu-asm-cast`` and may be removed in the
181+
future.
182+
180183
Modified Compiler Flags
181184
-----------------------
182185

183-
- The compiler flag `-fbracket-depth` default value is increased from 256 to 2048.
184-
185186
- The ``-ffp-model`` option has been updated to enable a more limited set of
186187
optimizations when the ``fast`` argument is used and to accept a new argument,
187188
``aggressive``. The behavior of ``-ffp-model=aggressive`` is equivalent
@@ -239,6 +240,20 @@ Improvements to Clang's diagnostics
239240

240241
- Clang now diagnoses when the result of a [[nodiscard]] function is discarded after being cast in C. Fixes #GH104391.
241242

243+
- Don't emit duplicated dangling diagnostics. (#GH93386).
244+
245+
- Improved diagnostic when trying to befriend a concept. (#GH45182).
246+
247+
- Added the ``-Winvalid-gnu-asm-cast`` diagnostic group to control warnings
248+
about use of "noop" casts for lvalues (a GNU extension). This diagnostic is
249+
a warning which defaults to being an error, is enabled by default, and is
250+
also controlled by the now-deprecated ``-fheinous-gnu-extensions`` flag.
251+
252+
- Added the ``-Wdecls-in-multiple-modules`` option to assist users to identify
253+
multiple declarations in different modules, which is the major reason of the slow
254+
compilation speed with modules. This warning is disabled by default and it needs
255+
to be explicitly enabled or by ``-Weverything``.
256+
242257
Improvements to Clang's time-trace
243258
----------------------------------
244259

@@ -292,6 +307,8 @@ Bug Fixes to C++ Support
292307
- Correctly check constraints of explicit instantiations of member functions. (#GH46029)
293308
- Fixed an assertion failure about a constraint of a friend function template references to a value with greater
294309
template depth than the friend function template. (#GH98258)
310+
- Clang now rebuilds the template parameters of out-of-line declarations and specializations in the context
311+
of the current instantiation in all cases.
295312

296313
Bug Fixes to AST Handling
297314
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -448,31 +465,42 @@ Moved checkers
448465

449466
Sanitizers
450467
----------
468+
- Introduced Realtime Sanitizer, activated by using the -fsanitize=realtime
469+
flag. This sanitizer detects unsafe system library calls, such as memory
470+
allocations and mutex locks. If any such function is called during invocation
471+
of a function marked with the ``[[clang::nonblocking]]`` attribute, an error
472+
is printed to the console and the process exits non-zero.
451473

452474
- Added the ``-fsanitize-undefined-ignore-overflow-pattern`` flag which can be
453475
used to disable specific overflow-dependent code patterns. The supported
454-
patterns are: ``add-overflow-test``, ``negated-unsigned-const``, and
455-
``post-decr-while``. The sanitizer instrumentation can be toggled off for all
456-
available patterns by specifying ``all``. Conversely, you can disable all
457-
exclusions with ``none``.
476+
patterns are: ``add-signed-overflow-test``, ``add-unsigned-overflow-test``,
477+
``negated-unsigned-const``, and ``unsigned-post-decr-while``. The sanitizer
478+
instrumentation can be toggled off for all available patterns by specifying
479+
``all``. Conversely, you may disable all exclusions with ``none`` which is
480+
the default.
458481

459482
.. code-block:: c++
460483

461-
/// specified with ``-fsanitize-undefined-ignore-overflow-pattern=add-overflow-test``
484+
/// specified with ``-fsanitize-undefined-ignore-overflow-pattern=add-unsigned-overflow-test``
462485
int common_overflow_check_pattern(unsigned base, unsigned offset) {
463486
if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings, won't be instrumented
464487
}
465488
489+
/// specified with ``-fsanitize-undefined-ignore-overflow-pattern=add-signed-overflow-test``
490+
int common_overflow_check_pattern_signed(signed int base, signed int offset) {
491+
if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings, won't be instrumented
492+
}
493+
466494
/// specified with ``-fsanitize-undefined-ignore-overflow-pattern=negated-unsigned-const``
467495
void negation_overflow() {
468496
unsigned long foo = -1UL; // No longer causes a negation overflow warning
469497
unsigned long bar = -2UL; // and so on...
470498
}
471499

472-
/// specified with ``-fsanitize-undefined-ignore-overflow-pattern=post-decr-while``
500+
/// specified with ``-fsanitize-undefined-ignore-overflow-pattern=unsigned-post-decr-while``
473501
void while_post_decrement() {
474502
unsigned char count = 16;
475-
while (count--) { /* ... */} // No longer causes unsigned-integer-overflow sanitizer to trip
503+
while (count--) { /* ... */ } // No longer causes unsigned-integer-overflow sanitizer to trip
476504
}
477505
478506
Many existing projects have a large amount of these code patterns present.

0 commit comments

Comments
 (0)