Skip to content

Commit e7d7bac

Browse files
committed
Merge release/21.x into cheriot-clang21
2 parents 1ece9ce + 3623fe6 commit e7d7bac

File tree

30 files changed

+430
-191
lines changed

30 files changed

+430
-191
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 94 additions & 16 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
^^^^^^^^^^^^^^^^^^^^^
@@ -384,6 +386,11 @@ New Compiler Flags
384386

385387
- 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>`_).
386388

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+
387394
Deprecated Compiler Flags
388395
-------------------------
389396

@@ -682,7 +689,7 @@ Improvements to Clang's diagnostics
682689
#GH142457, #GH139913, #GH138850, #GH137867, #GH137860, #GH107840, #GH93308,
683690
#GH69470, #GH59391, #GH58172, #GH46215, #GH45915, #GH45891, #GH44490,
684691
#GH36703, #GH32903, #GH23312, #GH69874.
685-
692+
686693
- Clang no longer emits a spurious -Wdangling-gsl warning in C++23 when
687694
iterating over an element of a temporary container in a range-based
688695
for loop.(#GH109793, #GH145164)
@@ -1227,41 +1234,112 @@ Code Completion
12271234

12281235
Static Analyzer
12291236
---------------
1230-
- Fixed a crash when C++20 parenthesized initializer lists are used. This issue
1231-
was causing a crash in clang-tidy. (#GH136041)
12321237

12331238
New features
12341239
^^^^^^^^^^^^
12351240

1236-
- A new flag - `-static-libclosure` was introduced to support statically linking
1237-
the runtime for the Blocks extension on Windows. This flag currently only
1238-
changes the code generation, and even then, only on Windows. This does not
1239-
impact the linker behaviour like the other `-static-*` flags.
1240-
- Implemented `P2719R5 Type-aware allocation and deallocation functions <https://wg21.link/P2719>`_
1241-
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)
1243+
1244+
- Introduced per-entry-point statistics to provide more detailed analysis metrics.
1245+
Documentation: :doc:`analyzer/developer-docs/Statistics` (#GH131175)
12421246

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)
12431260

12441261
Crash and bug fixes
12451262
^^^^^^^^^^^^^^^^^^^
12461263

1247-
- 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
12481272
code with non-standard ``getline`` or ``getdelim`` function signatures. (#GH144884)
12491273

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+
12501283
Improvements
12511284
^^^^^^^^^^^^
12521285

1286+
- Added option to assume at least one iteration in loops to reduce false positives.
1287+
(#GH125494)
1288+
12531289
- The checker option ``optin.cplusplus.VirtualCall:PureOnly`` was removed,
1254-
because it had been deprecated since 2019 and it is completely useless (it
1255-
was kept only for compatibility with pre-2019 versions, setting it to true is
1256-
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)
12571336

12581337
Moved checkers
12591338
^^^^^^^^^^^^^^
12601339

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

12661344
.. _release-notes-sanitizers:
12671345

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/lib/CodeGen/CGExprConstant.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -873,8 +873,9 @@ bool ConstStructBuilder::Build(const APValue &Val, const RecordDecl *RD,
873873

874874
for (const BaseInfo &Base : Bases) {
875875
bool IsPrimaryBase = Layout.getPrimaryBase() == Base.Decl;
876-
Build(Val.getStructBase(Base.Index), Base.Decl, IsPrimaryBase,
877-
VTableClass, Offset + Base.Offset);
876+
if (!Build(Val.getStructBase(Base.Index), Base.Decl, IsPrimaryBase,
877+
VTableClass, Offset + Base.Offset))
878+
return false;
878879
}
879880
}
880881

@@ -1645,7 +1646,7 @@ llvm::Constant *ConstantEmitter::tryEmitConstantExpr(const ConstantExpr *CE) {
16451646
if (CE->isGLValue())
16461647
RetType = CGM.getContext().getLValueReferenceType(RetType);
16471648

1648-
return emitAbstract(CE->getBeginLoc(), CE->getAPValueResult(), RetType);
1649+
return tryEmitAbstract(CE->getAPValueResult(), RetType);
16491650
}
16501651

16511652
llvm::Constant *

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ class CodeGenFunction : public CodeGenTypeCache {
750750
};
751751

752752
/// Header for data within LifetimeExtendedCleanupStack.
753-
struct LifetimeExtendedCleanupHeader {
753+
struct alignas(uint64_t) LifetimeExtendedCleanupHeader {
754754
/// The size of the following cleanup object.
755755
unsigned Size;
756756
/// The kind of cleanup to push.
@@ -972,7 +972,8 @@ class CodeGenFunction : public CodeGenTypeCache {
972972
LifetimeExtendedCleanupStack.size() + sizeof(Header) + Header.Size +
973973
(Header.IsConditional ? sizeof(ActiveFlag) : 0));
974974

975-
static_assert(sizeof(Header) % alignof(T) == 0,
975+
static_assert((alignof(LifetimeExtendedCleanupHeader) == alignof(T)) &&
976+
(alignof(T) == alignof(RawAddress)),
976977
"Cleanup will be allocated on misaligned address");
977978
char *Buffer = &LifetimeExtendedCleanupStack[OldSize];
978979
new (Buffer) LifetimeExtendedCleanupHeader(Header);

clang/lib/CodeGen/EHScopeStack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class EHScopeStack {
143143
///
144144
/// Cleanup implementations should generally be declared in an
145145
/// anonymous namespace.
146-
class Cleanup {
146+
class alignas(uint64_t) Cleanup {
147147
// Anchor the construction vtable.
148148
virtual void anchor();
149149

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3274,14 +3274,8 @@ void tools::handleVectorizeSLPArgs(const ArgList &Args,
32743274

32753275
void tools::handleInterchangeLoopsArgs(const ArgList &Args,
32763276
ArgStringList &CmdArgs) {
3277-
// FIXME: instead of relying on shouldEnableVectorizerAtOLevel, we may want to
3278-
// implement a separate function to infer loop interchange from opt level.
3279-
// For now, enable loop-interchange at the same opt levels as loop-vectorize.
3280-
bool EnableInterchange = shouldEnableVectorizerAtOLevel(Args, false);
3281-
OptSpecifier InterchangeAliasOption =
3282-
EnableInterchange ? options::OPT_O_Group : options::OPT_floop_interchange;
3283-
if (Args.hasFlag(options::OPT_floop_interchange, InterchangeAliasOption,
3284-
options::OPT_fno_loop_interchange, EnableInterchange))
3277+
if (Args.hasFlag(options::OPT_floop_interchange,
3278+
options::OPT_fno_loop_interchange, false))
32853279
CmdArgs.push_back("-floop-interchange");
32863280
}
32873281

clang/lib/StaticAnalyzer/Checkers/AssumeModeling.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ void AssumeModelingChecker::checkPostStmt(const AttributedStmt *A,
4545
continue;
4646

4747
const auto *Assumption = AssumptionVal.getAsInteger();
48-
assert(Assumption && "We should know the exact outcome of an assume expr");
4948
if (Assumption && Assumption->isZero()) {
5049
C.addSink();
5150
}

clang/test/Analysis/cxx23-assume-attribute.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,9 @@ int assume_and_fallthrough_at_the_same_attrstmt(int a, int b) {
6969

7070
return 0;
7171
}
72+
73+
void assume_opaque_gh151854_no_crash() {
74+
extern bool opaque();
75+
[[assume(opaque())]]; // no-crash
76+
// expected-warning@-1 {{assumption is ignored because it contains (potential) side-effects}}
77+
}

clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \
1+
// RUN: %clang_cc1 %s -x c++ -std=c++20 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \
22
// RUN: -emit-llvm -o - | FileCheck --check-prefixes=CHECK,NODISC %s
33

4-
// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \
4+
// RUN: %clang_cc1 %s -x c++ -std=c++20 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \
55
// RUN: -fptrauth-vtable-pointer-type-discrimination \
66
// RUN: -emit-llvm -o - | FileCheck --check-prefixes=CHECK,TYPE %s
77

8-
// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \
8+
// RUN: %clang_cc1 %s -x c++ -std=c++20 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \
99
// RUN: -fptrauth-vtable-pointer-address-discrimination \
1010
// RUN: -emit-llvm -o - | FileCheck --check-prefixes=CHECK,ADDR %s
1111

12-
// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \
12+
// RUN: %clang_cc1 %s -x c++ -std=c++20 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics \
1313
// RUN: -fptrauth-vtable-pointer-type-discrimination \
1414
// RUN: -fptrauth-vtable-pointer-address-discrimination \
1515
// RUN: -emit-llvm -o - | FileCheck --check-prefixes=CHECK,BOTH %s
1616

17-
// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
17+
// RUN: %clang_cc1 %s -x c++ -std=c++20 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
1818
// RUN: -emit-llvm -o - | FileCheck --check-prefixes=CHECK,NODISC %s
1919

20-
// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
20+
// RUN: %clang_cc1 %s -x c++ -std=c++20 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
2121
// RUN: -fptrauth-vtable-pointer-type-discrimination \
2222
// RUN: -emit-llvm -o - | FileCheck --check-prefixes=CHECK,TYPE %s
2323

24-
// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
24+
// RUN: %clang_cc1 %s -x c++ -std=c++20 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
2525
// RUN: -fptrauth-vtable-pointer-address-discrimination \
2626
// RUN: -emit-llvm -o - | FileCheck --check-prefixes=CHECK,ADDR %s
2727

28-
// RUN: %clang_cc1 %s -x c++ -std=c++11 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
28+
// RUN: %clang_cc1 %s -x c++ -std=c++20 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
2929
// RUN: -fptrauth-vtable-pointer-type-discrimination \
3030
// RUN: -fptrauth-vtable-pointer-address-discrimination \
3131
// RUN: -emit-llvm -o - | FileCheck --check-prefixes=CHECK,BOTH %s
@@ -78,6 +78,27 @@ struct authenticated(default_key, default_address_discrimination, custom_discrim
7878
virtual void g();
7979
};
8080

81+
// CHECK: @_ZTVN5test19ConstEvalE = external unnamed_addr constant { [3 x ptr] }, align 8
82+
// CHECK: @_ZN5test12ceE = global %{{.*}} { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTVN5test19ConstEvalE, i32 0, i32 0, i32 2), i32 2, i64 0, ptr @_ZN5test12ceE) }, align 8
83+
// CHECK: @_ZTVN5test116ConstEvalDerivedE = linkonce_odr unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTIN5test116ConstEvalDerivedE, ptr ptrauth (ptr @_ZN5test19ConstEval1fEv, i32 0, i64 26259, ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTVN5test116ConstEvalDerivedE, i32 0, i32 0, i32 2))] },{{.*}}align 8
84+
// CHECK: @_ZN5test13cedE = global { ptr } { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTVN5test116ConstEvalDerivedE, i32 0, i32 0, i32 2), i32 2, i64 0, ptr @_ZN5test13cedE) }, align 8
85+
86+
struct authenticated(default_key, address_discrimination, no_extra_discrimination) ConstEval {
87+
consteval ConstEval() {}
88+
virtual void f();
89+
};
90+
91+
// clang used to bail out with error message "could not emit constant value abstractly".
92+
ConstEval ce;
93+
94+
struct ConstEvalDerived : public ConstEval {
95+
public:
96+
consteval ConstEvalDerived() {}
97+
};
98+
99+
// clang used to emit an undef initializer.
100+
ConstEvalDerived ced;
101+
81102
template <typename T>
82103
struct SubClass : T {
83104
virtual void g();

cmake/Modules/LLVMVersion.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ if(NOT DEFINED LLVM_VERSION_PATCH)
1010
set(LLVM_VERSION_PATCH 7)
1111
endif()
1212
if(NOT DEFINED LLVM_VERSION_SUFFIX)
13-
set(LLVM_VERSION_SUFFIX -rc3)
13+
set(LLVM_VERSION_SUFFIX)
1414
endif()
1515

0 commit comments

Comments
 (0)