Skip to content

Commit 19f0a49

Browse files
committed
Merge remote-tracking branch 'upstream/release/21.x' into rustc/21.1-2025-08-01
2 parents 37d6f91 + 3623fe6 commit 19f0a49

File tree

185 files changed

+5978
-695
lines changed

Some content is hidden

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

185 files changed

+5978
-695
lines changed

clang/docs/PointerAuthentication.rst

Lines changed: 1163 additions & 32 deletions
Large diffs are not rendered by default.

clang/docs/ReleaseNotes.rst

Lines changed: 123 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ C++ Language Changes
123123
a perfect match (all conversion sequences are identity conversions) template candidates are not instantiated.
124124
Diagnostics that would have resulted from the instantiation of these template candidates are no longer
125125
produced. This aligns Clang closer to the behavior of GCC, and fixes (#GH62096), (#GH74581), and (#GH74581).
126+
- Implemented `P2719R5 Type-aware allocation and deallocation functions <https://wg21.link/P2719>`_
127+
as an extension in all C++ language modes.
126128

127129
C++2c Feature Support
128130
^^^^^^^^^^^^^^^^^^^^^
@@ -359,6 +361,12 @@ Non-comprehensive list of changes in this release
359361
ARC-managed pointers and other pointer types. The prior behavior was overly
360362
strict and inconsistent with the ARC specification.
361363

364+
- Use of ``__has_feature`` to detect the ``ptrauth_qualifier`` and ``ptrauth_intrinsics``
365+
features has been deprecated, and is restricted to the arm64e target only. The
366+
correct method to check for these features is to test for the ``__PTRAUTH__``
367+
macro.
368+
369+
362370
New Compiler Flags
363371
------------------
364372

@@ -378,6 +386,11 @@ New Compiler Flags
378386

379387
- New options ``-fthinlto-distributor=`` and ``-Xthinlto-distributor=`` added for Integrated Distributed ThinLTO (DTLTO). DTLTO enables the distribution of backend ThinLTO compilations via external distribution systems, such as Incredibuild, during the traditional link step. (#GH147265, `ThinLTODocs <https://clang.llvm.org/docs/ThinLTO.html#integrated-distributed-thinlto-dtlto>`_).
380388

389+
- A new flag - `-static-libclosure` was introduced to support statically linking
390+
the runtime for the Blocks extension on Windows. This flag currently only
391+
changes the code generation, and even then, only on Windows. This does not
392+
impact the linker behaviour like the other `-static-*` flags.
393+
381394
Deprecated Compiler Flags
382395
-------------------------
383396

@@ -676,7 +689,7 @@ Improvements to Clang's diagnostics
676689
#GH142457, #GH139913, #GH138850, #GH137867, #GH137860, #GH107840, #GH93308,
677690
#GH69470, #GH59391, #GH58172, #GH46215, #GH45915, #GH45891, #GH44490,
678691
#GH36703, #GH32903, #GH23312, #GH69874.
679-
692+
680693
- Clang no longer emits a spurious -Wdangling-gsl warning in C++23 when
681694
iterating over an element of a temporary container in a range-based
682695
for loop.(#GH109793, #GH145164)
@@ -997,6 +1010,19 @@ Miscellaneous Clang Crashes Fixed
9971010
OpenACC Specific Changes
9981011
------------------------
9991012

1013+
- OpenACC support, enabled via `-fopenacc` has reached a level of completeness
1014+
to finally be at least notionally usable. Currently, the OpenACC 3.4
1015+
specification has been completely implemented for Sema and AST creation, so
1016+
nodes will show up in the AST after having been properly checked. Lowering is
1017+
currently a work in progress, with compute, loop, and combined constructs
1018+
partially implemented, plus a handful of data and executable constructs
1019+
implemented. Lowering will only work in Clang-IR mode (so only with a compiler
1020+
built with Clang-IR enabled, and with `-fclangir` used on the command line).
1021+
However, note that the Clang-IR implementation status is also quite partial,
1022+
so frequent 'not yet implemented' diagnostics should be expected. Also, the
1023+
ACC MLIR dialect does not currently implement any lowering to LLVM-IR, so no
1024+
code generation is possible for OpenACC.
1025+
10001026
Target Specific Changes
10011027
-----------------------
10021028

@@ -1125,9 +1151,19 @@ CUDA/HIP Language Changes
11251151
CUDA Support
11261152
^^^^^^^^^^^^
11271153

1154+
PowerPC Support
1155+
^^^^^^^^^^^^^^^
1156+
1157+
* Add `__dmr1024` type for Dense Math Facility.
1158+
* Add prototype for Dense Math Facility integer calculation builtins.
1159+
11281160
AIX Support
11291161
^^^^^^^^^^^
11301162

1163+
* Fixed `-print-runtime-dir` to fallback to the target subdirectory (rather than OS subdirectory) if the runtime path is not found.
1164+
* Fixed `-print-runtime-dir` to find the correct runtime path if the triple has "unknown" as the environment component.
1165+
* Changed AIX targets to use the per-target runtime directories for compiler runtimes (i.e. `lib/clang/20/lib/aix` became `lib/clang/21/lib/powerpc-ibm-aix` and `clang/21/lib/powerpc64-ibm-aix`).
1166+
11311167
NetBSD Support
11321168
^^^^^^^^^^^^^^
11331169

@@ -1198,53 +1234,112 @@ Code Completion
11981234

11991235
Static Analyzer
12001236
---------------
1201-
- Fixed a crash when C++20 parenthesized initializer lists are used. This issue
1202-
was causing a crash in clang-tidy. (#GH136041)
12031237

12041238
New features
12051239
^^^^^^^^^^^^
12061240

1207-
- A new flag - `-static-libclosure` was introduced to support statically linking
1208-
the runtime for the Blocks extension on Windows. This flag currently only
1209-
changes the code generation, and even then, only on Windows. This does not
1210-
impact the linker behaviour like the other `-static-*` flags.
1211-
- OpenACC support, enabled via `-fopenacc` has reached a level of completeness
1212-
to finally be at least notionally usable. Currently, the OpenACC 3.4
1213-
specification has been completely implemented for Sema and AST creation, so
1214-
nodes will show up in the AST after having been properly checked. Lowering is
1215-
currently a work in progress, with compute, loop, and combined constructs
1216-
partially implemented, plus a handful of data and executable constructs
1217-
implemented. Lowering will only work in Clang-IR mode (so only with a compiler
1218-
built with Clang-IR enabled, and with `-fclangir` used on the command line).
1219-
However, note that the Clang-IR implementation status is also quite partial,
1220-
so frequent 'not yet implemented' diagnostics should be expected. Also, the
1221-
ACC MLIR dialect does not currently implement any lowering to LLVM-IR, so no
1222-
code generation is possible for OpenACC.
1223-
- Implemented `P2719R5 Type-aware allocation and deallocation functions <https://wg21.link/P2719>`_
1224-
as an extension in all C++ language modes.
1241+
- Added support for the ``[[clang::assume(cond)]]`` attribute, treating it as
1242+
``__builtin_assume(cond)`` for better static analysis. (#GH129234)
12251243

1244+
- Introduced per-entry-point statistics to provide more detailed analysis metrics.
1245+
Documentation: :doc:`analyzer/developer-docs/Statistics` (#GH131175)
1246+
1247+
- Added time-trace scopes for high-level analyzer steps to improve performance
1248+
debugging. Documentation: :doc:`analyzer/developer-docs/PerformanceInvestigation`
1249+
(#GH125508, #GH125884)
1250+
1251+
- Enhanced the ``check::BlockEntrance`` checker callback to provide more granular
1252+
control over block-level analysis.
1253+
`Documentation (check::BlockEntrance)
1254+
<https://clang.llvm.org/doxygen/CheckerDocumentation_8cpp_source.html>`_
1255+
(#GH140924)
1256+
1257+
- Added a new checker ``core.FixedAddressDereference`` to detect dereferences
1258+
of fixed addresses, which can be useful for finding hard-coded memory
1259+
accesses. (#GH127191, #GH132404)
12261260

12271261
Crash and bug fixes
12281262
^^^^^^^^^^^^^^^^^^^
12291263

1230-
- Fixed a crash in ``UnixAPIMisuseChecker`` and ``MallocChecker`` when analyzing
1264+
- Fixed a crash when C++20 parenthesized initializer lists are used.
1265+
This affected a crash of the well-known lambda overloaded pattern.
1266+
(#GH136041, #GH135665)
1267+
1268+
- Dropped an unjustified assertion, that was triggered in ``BugReporterVisitors.cpp``
1269+
for variable initialization detection. (#GH125044)
1270+
1271+
- Fixed a crash in ``unix.API`` and ``unix.Malloc`` when analyzing
12311272
code with non-standard ``getline`` or ``getdelim`` function signatures. (#GH144884)
12321273

1274+
- Fixed crashes involving ``__builtin_bit_cast``. (#GH139188)
1275+
1276+
- ``__datasizeof`` (C++) and ``_Countof`` (C) no longer cause a failed assertion
1277+
when given an operand of VLA type. (#GH151711)
1278+
1279+
- Fixed a crash in ``alpha.core.CastSize``. (#GH134387)
1280+
1281+
- Some ``cplusplus.PlacementNew`` false positives were fixed. (#GH150161)
1282+
12331283
Improvements
12341284
^^^^^^^^^^^^
12351285

1286+
- Added option to assume at least one iteration in loops to reduce false positives.
1287+
(#GH125494)
1288+
12361289
- The checker option ``optin.cplusplus.VirtualCall:PureOnly`` was removed,
1237-
because it had been deprecated since 2019 and it is completely useless (it
1238-
was kept only for compatibility with pre-2019 versions, setting it to true is
1239-
equivalent to completely disabling the checker).
1290+
because it had been deprecated since 2019. (#GH131823)
1291+
1292+
- Enhanced the ``core.StackAddressEscape`` to detect more cases of stack address
1293+
escapes, including return values for child stack frames. (#GH126620, #GH126986)
1294+
1295+
- Improved the ``unix.BlockInCriticalSection`` to recognize ``O_NONBLOCK``
1296+
streams and suppress reports in those cases. (#GH127049)
1297+
1298+
- Better support for lambda-converted function pointers in analysis. (#GH144906)
1299+
1300+
- Improved modeling of ``getcwd`` function in ``unix.StdCLibraryFunctions`` checker.
1301+
(#GH141076)
1302+
1303+
- Enhanced the ``optin.core.EnumCastOutOfRange`` checker to ignore ``[[clang::flag_enum]]``
1304+
enums. (#GH141232)
1305+
1306+
- Improved handling of structured bindings captured by lambdas. (#GH132579, #GH91835)
1307+
1308+
- Fixed unnamed bitfield handling in ``optin.cplusplus.UninitializedObject``. (#GH132427, #GH132001)
1309+
1310+
- Enhanced iterator checker modeling for ``insert`` operations. (#GH132596)
1311+
1312+
- Improved ``format`` attribute handling in ``optin.taint.GenericTaint``. (#GH132765)
1313+
1314+
- Added support for ``consteval`` in ``ConditionBRVisitor::VisitTerminator``.
1315+
(#GH146859, #GH139130)
1316+
1317+
- C standard streams are no longer invalidated by all C library function calls.
1318+
(#GH147766)
1319+
1320+
- Enhanced store management with region-store-binding-limit to improve performance.
1321+
See `region-store-max-binding-fanout
1322+
<https://clang.llvm.org/docs/analyzer/user-docs/Options.html#region-store-max-binding-fanout>`_
1323+
config option. Overriding these options are discouraged, unless you know what you do.
1324+
(#GH127602)
1325+
1326+
- Updated undefined assignment checker (``core.uninitialized.Assign``) diagnostics
1327+
to avoid using the term ``garbage``. (#GH126596)
1328+
1329+
- Fixed false memory leak reports involving placement new. (#GH144341)
1330+
1331+
- Avoided unnecessary super region invalidation in ``unix.cstring.*`` checkers.
1332+
(#GH146212, #GH143807)
1333+
1334+
- Enhanced handling of tainted division-by-zero error paths in the
1335+
``optin.taint.TaintedDiv`` checker. (#GH144491)
12401336

12411337
Moved checkers
12421338
^^^^^^^^^^^^^^
12431339

1244-
- After lots of improvements, the checker ``alpha.security.ArrayBoundV2`` is
1340+
- After lots of improvements, the checker ``alpha.security.ArrayBoundV2`` was
12451341
renamed to ``security.ArrayBound``. As this checker is stable now, the old
1246-
checker ``alpha.security.ArrayBound`` (which was searching for the same kind
1247-
of bugs with an different, simpler and less accurate algorithm) is removed.
1342+
checker ``alpha.security.ArrayBound`` was removed.
12481343

12491344
.. _release-notes-sanitizers:
12501345

clang/include/clang/AST/APValue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class APValue {
143143
AddrLabelDiff
144144
};
145145

146-
class LValueBase {
146+
class alignas(uint64_t) LValueBase {
147147
typedef llvm::PointerUnion<const ValueDecl *, const Expr *, TypeInfoLValue,
148148
DynamicAllocLValue>
149149
PtrTy;

clang/include/clang/Basic/Features.def

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,17 @@ FEATURE(type_sanitizer, LangOpts.Sanitize.has(SanitizerKind::Type))
147147
FEATURE(thread_sanitizer, LangOpts.Sanitize.has(SanitizerKind::Thread))
148148
FEATURE(dataflow_sanitizer, LangOpts.Sanitize.has(SanitizerKind::DataFlow))
149149
FEATURE(scudo, LangOpts.Sanitize.hasOneOf(SanitizerKind::Scudo))
150-
FEATURE(ptrauth_intrinsics, LangOpts.PointerAuthIntrinsics)
151-
EXTENSION(ptrauth_qualifier, LangOpts.PointerAuthIntrinsics)
150+
FEATURE(ptrauth_intrinsics, LangOpts.PointerAuthIntrinsics &&
151+
PP.getTargetInfo().getTriple().isOSDarwin())
152+
FEATURE(ptrauth_qualifier, LangOpts.PointerAuthIntrinsics &&
153+
PP.getTargetInfo().getTriple().isOSDarwin())
152154
FEATURE(ptrauth_calls, LangOpts.PointerAuthCalls)
153155
FEATURE(ptrauth_returns, LangOpts.PointerAuthReturns)
154156
FEATURE(ptrauth_vtable_pointer_address_discrimination, LangOpts.PointerAuthVTPtrAddressDiscrimination)
155157
FEATURE(ptrauth_vtable_pointer_type_discrimination, LangOpts.PointerAuthVTPtrTypeDiscrimination)
156158
FEATURE(ptrauth_type_info_vtable_pointer_discrimination, LangOpts.PointerAuthTypeInfoVTPtrDiscrimination)
157159
FEATURE(ptrauth_member_function_pointer_type_discrimination, LangOpts.PointerAuthCalls)
160+
FEATURE(ptrauth_signed_block_descriptors, LangOpts.PointerAuthBlockDescriptorPointers)
158161
FEATURE(ptrauth_function_pointer_type_discrimination, LangOpts.PointerAuthFunctionTypeDiscrimination)
159162
FEATURE(ptrauth_indirect_gotos, LangOpts.PointerAuthIndirectGotos)
160163
FEATURE(ptrauth_init_fini, LangOpts.PointerAuthInitFini)
@@ -163,7 +166,7 @@ FEATURE(ptrauth_elf_got, LangOpts.PointerAuthELFGOT)
163166

164167
FEATURE(ptrauth_objc_isa, LangOpts.PointerAuthObjcIsa)
165168
FEATURE(ptrauth_objc_interface_sel, LangOpts.PointerAuthObjcInterfaceSel)
166-
FEATURE(ptrauth_objc_signable_class, true)
169+
FEATURE(ptrauth_objc_signable_class, LangOpts.PointerAuthIntrinsics)
167170
FEATURE(ptrauth_objc_method_list_pointer, LangOpts.PointerAuthCalls)
168171

169172
EXTENSION(swiftcc,

clang/include/clang/Basic/LangOptions.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ LANGOPT(PointerAuthObjcInterfaceSel, 1, 0, NotCompatible, "authentication of SEL
138138
LANGOPT(PointerAuthObjcInterfaceSelKey, 16, 0, NotCompatible, "authentication key for SEL fields of ObjC interfaces")
139139
LANGOPT(PointerAuthObjcClassROPointers, 1, 0, Benign, "class_ro_t pointer authentication")
140140

141+
LANGOPT(PointerAuthBlockDescriptorPointers, 1, 0, NotCompatible, "enable signed block descriptors")
142+
141143
LANGOPT(DoubleSquareBracketAttributes, 1, 0, NotCompatible, "'[[]]' attributes extension for all language standard modes")
142144
LANGOPT(ExperimentalLateParseAttributes, 1, 0, NotCompatible, "experimental late parsing of attributes")
143145

clang/include/clang/Basic/PointerAuthOptions.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323

2424
namespace clang {
2525

26+
/// Constant discriminator to be used with block descriptor pointers. The value
27+
/// is ptrauth_string_discriminator("block_descriptor")
28+
constexpr uint16_t BlockDescriptorConstantDiscriminator = 0xC0BB;
29+
2630
/// Constant discriminator to be used with function pointers in .init_array and
2731
/// .fini_array. The value is ptrauth_string_discriminator("init_fini")
2832
constexpr uint16_t InitFiniPointerConstantDiscriminator = 0xD9D4;
@@ -223,6 +227,18 @@ struct PointerAuthOptions {
223227
/// The ABI for function addresses in .init_array and .fini_array
224228
PointerAuthSchema InitFiniPointers;
225229

230+
/// The ABI for block invocation function pointers.
231+
PointerAuthSchema BlockInvocationFunctionPointers;
232+
233+
/// The ABI for block object copy/destroy function pointers.
234+
PointerAuthSchema BlockHelperFunctionPointers;
235+
236+
/// The ABI for __block variable copy/destroy function pointers.
237+
PointerAuthSchema BlockByrefHelperFunctionPointers;
238+
239+
/// The ABI for pointers to block descriptors.
240+
PointerAuthSchema BlockDescriptorPointers;
241+
226242
/// The ABI for Objective-C method lists.
227243
PointerAuthSchema ObjCMethodListFunctionPointers;
228244

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4527,6 +4527,7 @@ defm aarch64_jump_table_hardening: OptInCC1FFlag<"aarch64-jump-table-hardening",
45274527
defm ptrauth_objc_isa : OptInCC1FFlag<"ptrauth-objc-isa", "Enable signing and authentication of Objective-C object's 'isa' field">;
45284528
defm ptrauth_objc_interface_sel : OptInCC1FFlag<"ptrauth-objc-interface-sel", "Enable signing and authentication of Objective-C object's 'SEL' fields">;
45294529
defm ptrauth_objc_class_ro : OptInCC1FFlag<"ptrauth-objc-class-ro", "Enable signing and authentication for ObjC class_ro pointers">;
4530+
defm ptrauth_block_descriptor_pointers : OptInCC1FFlag<"ptrauth-block-descriptor-pointers", "Enable signing and authentication of block descriptors">;
45304531
}
45314532

45324533
def fenable_matrix : Flag<["-"], "fenable-matrix">, Group<f_Group>,

clang/include/clang/Lex/Lexer.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,6 @@ class Lexer : public PreprocessorLexer {
143143
/// True if this is the first time we're lexing the input file.
144144
bool IsFirstTimeLexingFile;
145145

146-
/// True if current lexing token is the first pp-token.
147-
bool IsFirstPPToken;
148-
149146
// NewLinePtr - A pointer to new line character '\n' being lexed. For '\r\n',
150147
// it also points to '\n.'
151148
const char *NewLinePtr;

0 commit comments

Comments
 (0)