Skip to content

Commit bbf7626

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:9a9ca9850f3c6b278e052745f51a87296d9fedd2 into amd-gfx:f812ac9e8cf2
Local branch amd-gfx f812ac9 Merged main:5e990b0b7f4cf60e6b700ba4f7c76005c0d53086 into amd-gfx:e0cb32e22b9d Remote branch main 9a9ca98 [mlir][MemRef] Add more ops to narrow type support, strided metadata expansion (llvm#102228)
2 parents f812ac9 + 9a9ca98 commit bbf7626

File tree

262 files changed

+6675
-2569
lines changed

Some content is hidden

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

262 files changed

+6675
-2569
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/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: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,31 @@ 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

@@ -95,6 +120,9 @@ C++23 Feature Support
95120
C++2c Feature Support
96121
^^^^^^^^^^^^^^^^^^^^^
97122

123+
- Add ``__builtin_is_implicit_lifetime`` intrinsic, which supports
124+
`P2647R1 A trait for implicit lifetime types <https://wg21.link/p2674r1>`_
125+
98126
- Add ``__builtin_is_virtual_base_of`` intrinsic, which supports
99127
`P2985R0 A type trait for detecting virtual base classes <https://wg21.link/p2985r0>`_
100128

@@ -140,6 +168,11 @@ Modified Compiler Flags
140168
Removed Compiler Flags
141169
-------------------------
142170

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

@@ -217,8 +250,10 @@ Bug Fixes to C++ Support
217250
- Clang now preserves the unexpanded flag in a lambda transform used for pack expansion. (#GH56852), (#GH85667),
218251
(#GH99877).
219252
- 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
253+
- Fixed an assertion failure when selecting a function from an overload set that includes a
221254
specialization of a conversion function template.
255+
- Correctly diagnose attempts to use a concept name in its own definition;
256+
A concept name is introduced to its scope sooner to match the C++ standard. (#GH55875)
222257

223258
Bug Fixes to AST Handling
224259
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -357,6 +392,36 @@ Moved checkers
357392
Sanitizers
358393
----------
359394

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