Skip to content

Commit

Permalink
Merged main:9a9ca9850f3c6b278e052745f51a87296d9fedd2 into amd-gfx:f81…
Browse files Browse the repository at this point in the history
…2ac9e8cf2

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)
  • Loading branch information
SC llvm team authored and SC llvm team committed Aug 15, 2024
2 parents f812ac9 + 9a9ca98 commit bbf7626
Show file tree
Hide file tree
Showing 262 changed files with 6,675 additions and 2,569 deletions.
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,4 @@ b32931c5b32eb0d2cf37d688b34f8548c9674c19
b6262880b34629e9d7a72b5a42f315a3c9ed8139
39c7dc7207e76e72da21cf4fedda21b5311bf62d
e80bc777749331e9519575f416c342f7626dd14d
7e5cd8f1b6c5263ed5e2cc03d60c8779a8d3e9f7
1 change: 1 addition & 0 deletions clang/docs/LanguageExtensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,7 @@ The following type trait primitives are supported by Clang. Those traits marked
* ``__array_extent(type, dim)`` (Embarcadero):
The ``dim``'th array bound in the type ``type``, or ``0`` if
``dim >= __array_rank(type)``.
* ``__builtin_is_implicit_lifetime`` (C++, GNU, Microsoft)
* ``__builtin_is_virtual_base_of`` (C++, GNU, Microsoft)
* ``__can_pass_in_regs`` (C++)
Returns whether a class can be passed in registers under the current
Expand Down
67 changes: 66 additions & 1 deletion clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,31 @@ C++ Specific Potentially Breaking Changes
few users and can be written as ``__is_same(__remove_cv(T), decltype(nullptr))``,
which GCC supports as well.

- Clang will now correctly diagnose as ill-formed a constant expression where an
enum without a fixed underlying type is set to a value outside the range of
the enumeration's values.

.. code-block:: c++

enum E { Zero, One, Two, Three, Four };
constexpr E Val1 = (E)3; // Ok
constexpr E Val2 = (E)7; // Ok
constexpr E Val3 = (E)8; // Now ill-formed, out of the range [0, 7]
constexpr E Val4 = (E)-1; // Now ill-formed, out of the range [0, 7]

Since Clang 16, it has been possible to suppress the diagnostic via
`-Wno-enum-constexpr-conversion`, to allow for a transition period for users.
Now, in Clang 20, **it is no longer possible to suppress the diagnostic**.

- Extraneous template headers are now ill-formed by default.
This error can be disable with ``-Wno-error=extraneous-template-head``.

.. code-block:: c++

template <> // error: extraneous template head
template <typename T>
void f();

ABI Changes in This Version
---------------------------

Expand Down Expand Up @@ -95,6 +120,9 @@ C++23 Feature Support
C++2c Feature Support
^^^^^^^^^^^^^^^^^^^^^

- Add ``__builtin_is_implicit_lifetime`` intrinsic, which supports
`P2647R1 A trait for implicit lifetime types <https://wg21.link/p2674r1>`_

- Add ``__builtin_is_virtual_base_of`` intrinsic, which supports
`P2985R0 A type trait for detecting virtual base classes <https://wg21.link/p2985r0>`_

Expand Down Expand Up @@ -140,6 +168,11 @@ Modified Compiler Flags
Removed Compiler Flags
-------------------------

- The compiler flag `-Wenum-constexpr-conversion` (and the `Wno-`, `Wno-error-`
derivatives) is now removed, since it's no longer possible to suppress the
diagnostic (see above). Users can expect an `unknown warning` diagnostic if
it's still in use.

Attribute Changes in Clang
--------------------------

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

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -357,6 +392,36 @@ Moved checkers
Sanitizers
----------

- Added the ``-fsanitize-overflow-pattern-exclusion=`` flag which can be used
to disable specific overflow-dependent code patterns. The supported patterns
are: ``add-overflow-test``, ``negated-unsigned-const``, and
``post-decr-while``. The sanitizer instrumentation can be toggled off for all
available patterns by specifying ``all``. Conversely, you can disable all
exclusions with ``none``.

.. code-block:: c++

/// specified with ``-fsanitize-overflow-pattern-exclusion=add-overflow-test``
int common_overflow_check_pattern(unsigned base, unsigned offset) {
if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings, won't be instrumented
}
/// specified with ``-fsanitize-overflow-pattern-exclusion=negated-unsigned-const``
void negation_overflow() {
unsigned long foo = -1UL; // No longer causes a negation overflow warning
unsigned long bar = -2UL; // and so on...
}

/// specified with ``-fsanitize-overflow-pattern-exclusion=post-decr-while``
void while_post_decrement() {
unsigned char count = 16;
while (count--) { /* ... */} // No longer causes unsigned-integer-overflow sanitizer to trip
}
Many existing projects have a large amount of these code patterns present.
This new flag should allow those projects to enable integer sanitizers with
less noise.

Python Binding Changes
----------------------
- Fixed an issue that led to crashes when calling ``Type.get_exception_specification_kind``.
Expand Down
42 changes: 42 additions & 0 deletions clang/docs/UndefinedBehaviorSanitizer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,48 @@ To silence reports from unsigned integer overflow, you can set
``-fsanitize-recover=unsigned-integer-overflow``, is particularly useful for
providing fuzzing signal without blowing up logs.

Disabling instrumentation for common overflow patterns
------------------------------------------------------

There are certain overflow-dependent or overflow-prone code patterns which
produce a lot of noise for integer overflow/truncation sanitizers. Negated
unsigned constants, post-decrements in a while loop condition and simple
overflow checks are accepted and pervasive code patterns. However, the signal
received from sanitizers instrumenting these code patterns may be too noisy for
some projects. To disable instrumentation for these common patterns one should
use ``-fsanitize-overflow-pattern-exclusion=``.

Currently, this option supports three overflow-dependent code idioms:

``negated-unsigned-const``

.. code-block:: c++

/// -fsanitize-overflow-pattern-exclusion=negated-unsigned-const
unsigned long foo = -1UL; // No longer causes a negation overflow warning
unsigned long bar = -2UL; // and so on...

``post-decr-while``

.. code-block:: c++

/// -fsanitize-overflow-pattern-exclusion=post-decr-while
unsigned char count = 16;
while (count--) { /* ... */ } // No longer causes unsigned-integer-overflow sanitizer to trip
``add-overflow-test``

.. code-block:: c++

/// -fsanitize-overflow-pattern-exclusion=add-overflow-test
if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings,
// won't be instrumented (same for signed types)
You can enable all exclusions with
``-fsanitize-overflow-pattern-exclusion=all`` or disable all exclusions with
``-fsanitize-overflow-pattern-exclusion=none``. Specifying ``none`` has
precedence over other values.

Issue Suppression
=================

Expand Down
13 changes: 9 additions & 4 deletions clang/include/clang/AST/DeclTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -3146,19 +3146,24 @@ class ConceptDecl : public TemplateDecl, public Mergeable<ConceptDecl> {
: TemplateDecl(Concept, DC, L, Name, Params),
ConstraintExpr(ConstraintExpr) {};
public:
static ConceptDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, DeclarationName Name,
static ConceptDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
DeclarationName Name,
TemplateParameterList *Params,
Expr *ConstraintExpr);
Expr *ConstraintExpr = nullptr);
static ConceptDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);

Expr *getConstraintExpr() const {
return ConstraintExpr;
}

bool hasDefinition() const { return ConstraintExpr != nullptr; }

void setDefinition(Expr *E) { ConstraintExpr = E; }

SourceRange getSourceRange() const override LLVM_READONLY {
return SourceRange(getTemplateParameters()->getTemplateLoc(),
ConstraintExpr->getEndLoc());
ConstraintExpr ? ConstraintExpr->getEndLoc()
: SourceLocation());
}

bool isTypeConcept() const {
Expand Down
9 changes: 9 additions & 0 deletions clang/include/clang/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -4043,6 +4043,15 @@ class BinaryOperator : public Expr {
void setHasStoredFPFeatures(bool B) { BinaryOperatorBits.HasFPFeatures = B; }
bool hasStoredFPFeatures() const { return BinaryOperatorBits.HasFPFeatures; }

/// Set and get the bit that informs arithmetic overflow sanitizers whether
/// or not they should exclude certain BinaryOperators from instrumentation
void setExcludedOverflowPattern(bool B) {
BinaryOperatorBits.ExcludedOverflowPattern = B;
}
bool hasExcludedOverflowPattern() const {
return BinaryOperatorBits.ExcludedOverflowPattern;
}

/// Get FPFeatures from trailing storage
FPOptionsOverride getStoredFPFeatures() const {
assert(hasStoredFPFeatures());
Expand Down
5 changes: 5 additions & 0 deletions clang/include/clang/AST/Stmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,11 @@ class alignas(void *) Stmt {
LLVM_PREFERRED_TYPE(bool)
unsigned HasFPFeatures : 1;

/// Whether or not this BinaryOperator should be excluded from integer
/// overflow sanitization.
LLVM_PREFERRED_TYPE(bool)
unsigned ExcludedOverflowPattern : 1;

SourceLocation OpLoc;
};

Expand Down
12 changes: 9 additions & 3 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -4467,7 +4467,7 @@ def ReleaseHandle : InheritableParamAttr {

def UnsafeBufferUsage : InheritableAttr {
let Spellings = [Clang<"unsafe_buffer_usage">];
let Subjects = SubjectList<[Function]>;
let Subjects = SubjectList<[Function, Field]>;
let Documentation = [UnsafeBufferUsageDocs];
}

Expand Down Expand Up @@ -4599,12 +4599,18 @@ def HLSLResource : InheritableAttr {
"CBuffer", "Sampler", "TBuffer", "RTAccelerationStructure",
"FeedbackTexture2D", "FeedbackTexture2DArray"
],
/*opt=*/0, /*fake=*/0, /*isExternalType=*/1, /*isCovered=*/0>,
DefaultBoolArgument<"isROV", /*default=*/0>
/*opt=*/0, /*fake=*/0, /*isExternalType=*/1, /*isCovered=*/0>
];
let Documentation = [InternalOnly];
}

def HLSLROV : InheritableAttr {
let Spellings = [CXX11<"hlsl", "is_rov">];
let Subjects = SubjectList<[Struct]>;
let LangOpts = [HLSL];
let Documentation = [InternalOnly];
}

def HLSLResourceClass : InheritableAttr {
let Spellings = [CXX11<"hlsl", "resource_class">];
let Subjects = SubjectList<[Struct]>;
Expand Down
Loading

0 comments on commit bbf7626

Please sign in to comment.