Skip to content

Commit 7f35dc8

Browse files
committed
[AutoBump] Merge with 894d3ee (Aug 15)
2 parents 8e07459 + 894d3ee commit 7f35dc8

File tree

434 files changed

+12623
-6410
lines changed

Some content is hidden

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

434 files changed

+12623
-6410
lines changed

.git-blame-ignore-revs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,4 @@ b32931c5b32eb0d2cf37d688b34f8548c9674c19
9393
b6262880b34629e9d7a72b5a42f315a3c9ed8139
9494
39c7dc7207e76e72da21cf4fedda21b5311bf62d
9595
e80bc777749331e9519575f416c342f7626dd14d
96+
7e5cd8f1b6c5263ed5e2cc03d60c8779a8d3e9f7

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,15 +271,13 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {
271271
// specialized template. Implicit ones are filtered out by RAV.
272272
bool
273273
VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *CTSD) {
274-
// if (CTSD->isExplicitSpecialization())
275274
if (clang::isTemplateExplicitInstantiationOrSpecialization(
276275
CTSD->getTemplateSpecializationKind()))
277276
report(CTSD->getLocation(),
278277
CTSD->getSpecializedTemplate()->getTemplatedDecl());
279278
return true;
280279
}
281280
bool VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *VTSD) {
282-
// if (VTSD->isExplicitSpecialization())
283281
if (clang::isTemplateExplicitInstantiationOrSpecialization(
284282
VTSD->getTemplateSpecializationKind()))
285283
report(VTSD->getLocation(),

clang/docs/LanguageExtensions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,7 @@ The following type trait primitives are supported by Clang. Those traits marked
15471547
* ``__array_extent(type, dim)`` (Embarcadero):
15481548
The ``dim``'th array bound in the type ``type``, or ``0`` if
15491549
``dim >= __array_rank(type)``.
1550+
* ``__builtin_is_implicit_lifetime`` (C++, GNU, Microsoft)
15501551
* ``__builtin_is_virtual_base_of`` (C++, GNU, Microsoft)
15511552
* ``__can_pass_in_regs`` (C++)
15521553
Returns whether a class can be passed in registers under the current

clang/docs/ReleaseNotes.rst

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,36 @@ C++ Specific Potentially Breaking Changes
4949
few users and can be written as ``__is_same(__remove_cv(T), decltype(nullptr))``,
5050
which GCC supports as well.
5151

52+
- Clang will now correctly diagnose as ill-formed a constant expression where an
53+
enum without a fixed underlying type is set to a value outside the range of
54+
the enumeration's values.
55+
56+
.. code-block:: c++
57+
58+
enum E { Zero, One, Two, Three, Four };
59+
constexpr E Val1 = (E)3; // Ok
60+
constexpr E Val2 = (E)7; // Ok
61+
constexpr E Val3 = (E)8; // Now ill-formed, out of the range [0, 7]
62+
constexpr E Val4 = (E)-1; // Now ill-formed, out of the range [0, 7]
63+
64+
Since Clang 16, it has been possible to suppress the diagnostic via
65+
`-Wno-enum-constexpr-conversion`, to allow for a transition period for users.
66+
Now, in Clang 20, **it is no longer possible to suppress the diagnostic**.
67+
68+
- Extraneous template headers are now ill-formed by default.
69+
This error can be disable with ``-Wno-error=extraneous-template-head``.
70+
71+
.. code-block:: c++
72+
73+
template <> // error: extraneous template head
74+
template <typename T>
75+
void f();
76+
5277
ABI Changes in This Version
5378
---------------------------
5479

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+
5582
AST Dumping Potentially Breaking Changes
5683
----------------------------------------
5784

@@ -95,6 +122,9 @@ C++23 Feature Support
95122
C++2c Feature Support
96123
^^^^^^^^^^^^^^^^^^^^^
97124

125+
- Add ``__builtin_is_implicit_lifetime`` intrinsic, which supports
126+
`P2647R1 A trait for implicit lifetime types <https://wg21.link/p2674r1>`_
127+
98128
- Add ``__builtin_is_virtual_base_of`` intrinsic, which supports
99129
`P2985R0 A type trait for detecting virtual base classes <https://wg21.link/p2985r0>`_
100130

@@ -140,6 +170,11 @@ Modified Compiler Flags
140170
Removed Compiler Flags
141171
-------------------------
142172

173+
- The compiler flag `-Wenum-constexpr-conversion` (and the `Wno-`, `Wno-error-`
174+
derivatives) is now removed, since it's no longer possible to suppress the
175+
diagnostic (see above). Users can expect an `unknown warning` diagnostic if
176+
it's still in use.
177+
143178
Attribute Changes in Clang
144179
--------------------------
145180

@@ -217,8 +252,10 @@ Bug Fixes to C++ Support
217252
- Clang now preserves the unexpanded flag in a lambda transform used for pack expansion. (#GH56852), (#GH85667),
218253
(#GH99877).
219254
- Fixed a bug when diagnosing ambiguous explicit specializations of constrained member functions.
220-
- Fixed an assertion failure when selecting a function from an overload set that includes a
255+
- Fixed an assertion failure when selecting a function from an overload set that includes a
221256
specialization of a conversion function template.
257+
- Correctly diagnose attempts to use a concept name in its own definition;
258+
A concept name is introduced to its scope sooner to match the C++ standard. (#GH55875)
222259

223260
Bug Fixes to AST Handling
224261
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -347,11 +384,46 @@ Improvements
347384
Moved checkers
348385
^^^^^^^^^^^^^^
349386

387+
- The checker ``alpha.security.MallocOverflow`` was deleted because it was
388+
badly implemented and its agressive logic produced too many false positives.
389+
To detect too large arguments passed to malloc, consider using the checker
390+
``alpha.taint.TaintedAlloc``.
391+
350392
.. _release-notes-sanitizers:
351393

352394
Sanitizers
353395
----------
354396

397+
- Added the ``-fsanitize-overflow-pattern-exclusion=`` flag which can be used
398+
to disable specific overflow-dependent code patterns. The supported patterns
399+
are: ``add-overflow-test``, ``negated-unsigned-const``, and
400+
``post-decr-while``. The sanitizer instrumentation can be toggled off for all
401+
available patterns by specifying ``all``. Conversely, you can disable all
402+
exclusions with ``none``.
403+
404+
.. code-block:: c++
405+
406+
/// specified with ``-fsanitize-overflow-pattern-exclusion=add-overflow-test``
407+
int common_overflow_check_pattern(unsigned base, unsigned offset) {
408+
if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings, won't be instrumented
409+
}
410+
411+
/// specified with ``-fsanitize-overflow-pattern-exclusion=negated-unsigned-const``
412+
void negation_overflow() {
413+
unsigned long foo = -1UL; // No longer causes a negation overflow warning
414+
unsigned long bar = -2UL; // and so on...
415+
}
416+
417+
/// specified with ``-fsanitize-overflow-pattern-exclusion=post-decr-while``
418+
void while_post_decrement() {
419+
unsigned char count = 16;
420+
while (count--) { /* ... */} // No longer causes unsigned-integer-overflow sanitizer to trip
421+
}
422+
423+
Many existing projects have a large amount of these code patterns present.
424+
This new flag should allow those projects to enable integer sanitizers with
425+
less noise.
426+
355427
Python Binding Changes
356428
----------------------
357429
- Fixed an issue that led to crashes when calling ``Type.get_exception_specification_kind``.

clang/docs/UndefinedBehaviorSanitizer.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,48 @@ To silence reports from unsigned integer overflow, you can set
293293
``-fsanitize-recover=unsigned-integer-overflow``, is particularly useful for
294294
providing fuzzing signal without blowing up logs.
295295

296+
Disabling instrumentation for common overflow patterns
297+
------------------------------------------------------
298+
299+
There are certain overflow-dependent or overflow-prone code patterns which
300+
produce a lot of noise for integer overflow/truncation sanitizers. Negated
301+
unsigned constants, post-decrements in a while loop condition and simple
302+
overflow checks are accepted and pervasive code patterns. However, the signal
303+
received from sanitizers instrumenting these code patterns may be too noisy for
304+
some projects. To disable instrumentation for these common patterns one should
305+
use ``-fsanitize-overflow-pattern-exclusion=``.
306+
307+
Currently, this option supports three overflow-dependent code idioms:
308+
309+
``negated-unsigned-const``
310+
311+
.. code-block:: c++
312+
313+
/// -fsanitize-overflow-pattern-exclusion=negated-unsigned-const
314+
unsigned long foo = -1UL; // No longer causes a negation overflow warning
315+
unsigned long bar = -2UL; // and so on...
316+
317+
``post-decr-while``
318+
319+
.. code-block:: c++
320+
321+
/// -fsanitize-overflow-pattern-exclusion=post-decr-while
322+
unsigned char count = 16;
323+
while (count--) { /* ... */ } // No longer causes unsigned-integer-overflow sanitizer to trip
324+
325+
``add-overflow-test``
326+
327+
.. code-block:: c++
328+
329+
/// -fsanitize-overflow-pattern-exclusion=add-overflow-test
330+
if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings,
331+
// won't be instrumented (same for signed types)
332+
333+
You can enable all exclusions with
334+
``-fsanitize-overflow-pattern-exclusion=all`` or disable all exclusions with
335+
``-fsanitize-overflow-pattern-exclusion=none``. Specifying ``none`` has
336+
precedence over other values.
337+
296338
Issue Suppression
297339
=================
298340

clang/docs/analyzer/checkers.rst

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2951,49 +2951,6 @@ Warn about buffer overflows (newer checker).
29512951
char c = s[x]; // warn: index is tainted
29522952
}
29532953
2954-
.. _alpha-security-MallocOverflow:
2955-
2956-
alpha.security.MallocOverflow (C)
2957-
"""""""""""""""""""""""""""""""""
2958-
Check for overflows in the arguments to ``malloc()``.
2959-
It tries to catch ``malloc(n * c)`` patterns, where:
2960-
2961-
- ``n``: a variable or member access of an object
2962-
- ``c``: a constant foldable integral
2963-
2964-
This checker was designed for code audits, so expect false-positive reports.
2965-
One is supposed to silence this checker by ensuring proper bounds checking on
2966-
the variable in question using e.g. an ``assert()`` or a branch.
2967-
2968-
.. code-block:: c
2969-
2970-
void test(int n) {
2971-
void *p = malloc(n * sizeof(int)); // warn
2972-
}
2973-
2974-
void test2(int n) {
2975-
if (n > 100) // gives an upper-bound
2976-
return;
2977-
void *p = malloc(n * sizeof(int)); // no warning
2978-
}
2979-
2980-
void test3(int n) {
2981-
assert(n <= 100 && "Contract violated.");
2982-
void *p = malloc(n * sizeof(int)); // no warning
2983-
}
2984-
2985-
Limitations:
2986-
2987-
- The checker won't warn for variables involved in explicit casts,
2988-
since that might limit the variable's domain.
2989-
E.g.: ``(unsigned char)int x`` would limit the domain to ``[0,255]``.
2990-
The checker will miss the true-positive cases when the explicit cast would
2991-
not tighten the domain to prevent the overflow in the subsequent
2992-
multiplication operation.
2993-
2994-
- It is an AST-based checker, thus it does not make use of the
2995-
path-sensitive taint-analysis.
2996-
29972954
.. _alpha-security-MmapWriteExec:
29982955
29992956
alpha.security.MmapWriteExec (C)

clang/include/clang/AST/Decl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3206,6 +3206,10 @@ class FieldDecl : public DeclaratorDecl, public Mergeable<FieldDecl> {
32063206
/// Set the C++11 in-class initializer for this member.
32073207
void setInClassInitializer(Expr *NewInit);
32083208

3209+
/// Find the FieldDecl specified in a FAM's "counted_by" attribute. Returns
3210+
/// \p nullptr if either the attribute or the field doesn't exist.
3211+
const FieldDecl *findCountedByField() const;
3212+
32093213
private:
32103214
void setLazyInClassInitializer(LazyDeclStmtPtr NewInit);
32113215

clang/include/clang/AST/DeclTemplate.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3146,19 +3146,24 @@ class ConceptDecl : public TemplateDecl, public Mergeable<ConceptDecl> {
31463146
: TemplateDecl(Concept, DC, L, Name, Params),
31473147
ConstraintExpr(ConstraintExpr) {};
31483148
public:
3149-
static ConceptDecl *Create(ASTContext &C, DeclContext *DC,
3150-
SourceLocation L, DeclarationName Name,
3149+
static ConceptDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
3150+
DeclarationName Name,
31513151
TemplateParameterList *Params,
3152-
Expr *ConstraintExpr);
3152+
Expr *ConstraintExpr = nullptr);
31533153
static ConceptDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
31543154

31553155
Expr *getConstraintExpr() const {
31563156
return ConstraintExpr;
31573157
}
31583158

3159+
bool hasDefinition() const { return ConstraintExpr != nullptr; }
3160+
3161+
void setDefinition(Expr *E) { ConstraintExpr = E; }
3162+
31593163
SourceRange getSourceRange() const override LLVM_READONLY {
31603164
return SourceRange(getTemplateParameters()->getTemplateLoc(),
3161-
ConstraintExpr->getEndLoc());
3165+
ConstraintExpr ? ConstraintExpr->getEndLoc()
3166+
: SourceLocation());
31623167
}
31633168

31643169
bool isTypeConcept() const {

clang/include/clang/AST/Expr.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4043,6 +4043,15 @@ class BinaryOperator : public Expr {
40434043
void setHasStoredFPFeatures(bool B) { BinaryOperatorBits.HasFPFeatures = B; }
40444044
bool hasStoredFPFeatures() const { return BinaryOperatorBits.HasFPFeatures; }
40454045

4046+
/// Set and get the bit that informs arithmetic overflow sanitizers whether
4047+
/// or not they should exclude certain BinaryOperators from instrumentation
4048+
void setExcludedOverflowPattern(bool B) {
4049+
BinaryOperatorBits.ExcludedOverflowPattern = B;
4050+
}
4051+
bool hasExcludedOverflowPattern() const {
4052+
return BinaryOperatorBits.ExcludedOverflowPattern;
4053+
}
4054+
40464055
/// Get FPFeatures from trailing storage
40474056
FPOptionsOverride getStoredFPFeatures() const {
40484057
assert(hasStoredFPFeatures());

clang/include/clang/AST/Stmt.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,11 @@ class alignas(void *) Stmt {
650650
LLVM_PREFERRED_TYPE(bool)
651651
unsigned HasFPFeatures : 1;
652652

653+
/// Whether or not this BinaryOperator should be excluded from integer
654+
/// overflow sanitization.
655+
LLVM_PREFERRED_TYPE(bool)
656+
unsigned ExcludedOverflowPattern : 1;
657+
653658
SourceLocation OpLoc;
654659
};
655660

clang/include/clang/Basic/Attr.td

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4467,7 +4467,7 @@ def ReleaseHandle : InheritableParamAttr {
44674467

44684468
def UnsafeBufferUsage : InheritableAttr {
44694469
let Spellings = [Clang<"unsafe_buffer_usage">];
4470-
let Subjects = SubjectList<[Function]>;
4470+
let Subjects = SubjectList<[Function, Field]>;
44714471
let Documentation = [UnsafeBufferUsageDocs];
44724472
}
44734473

@@ -4599,12 +4599,18 @@ def HLSLResource : InheritableAttr {
45994599
"CBuffer", "Sampler", "TBuffer", "RTAccelerationStructure",
46004600
"FeedbackTexture2D", "FeedbackTexture2DArray"
46014601
],
4602-
/*opt=*/0, /*fake=*/0, /*isExternalType=*/1, /*isCovered=*/0>,
4603-
DefaultBoolArgument<"isROV", /*default=*/0>
4602+
/*opt=*/0, /*fake=*/0, /*isExternalType=*/1, /*isCovered=*/0>
46044603
];
46054604
let Documentation = [InternalOnly];
46064605
}
46074606

4607+
def HLSLROV : InheritableAttr {
4608+
let Spellings = [CXX11<"hlsl", "is_rov">];
4609+
let Subjects = SubjectList<[Struct]>;
4610+
let LangOpts = [HLSL];
4611+
let Documentation = [InternalOnly];
4612+
}
4613+
46084614
def HLSLResourceClass : InheritableAttr {
46094615
let Spellings = [CXX11<"hlsl", "resource_class">];
46104616
let Subjects = SubjectList<[Struct]>;

0 commit comments

Comments
 (0)