Skip to content

Commit 7c4f2d2

Browse files
author
Jenkins
committed
merge main into amd-staging
Change-Id: I7c092554733c6f8e5580026a772d94fdbc00a6e3
2 parents 2d24083 + c7babfa commit 7c4f2d2

File tree

412 files changed

+16689
-2853
lines changed

Some content is hidden

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

412 files changed

+16689
-2853
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
# to receive an approval from a "code owner" in particular -- any LLVM project
88
# member can approve pull requests.
99
#
10-
# Note that GitHub's concept of "code owner" is independent from LLVM's own
11-
# "code owner" concept, they merely happen to share terminology. See
12-
# https://llvm.org/docs/DeveloperPolicy.html#code-owners, as well as the
13-
# CODE_OWNERS.txt files in the respective subproject directories.
10+
# This is independent of LLVM's own "maintainer" concept.
11+
# See https://llvm.org/docs/DeveloperPolicy.html#maintainers as well as the
12+
# Maintainers.* files in the the respective subproject directories.
1413

1514
/libcxx/ @llvm/reviewers-libcxx
1615
/libcxxabi/ @llvm/reviewers-libcxxabi

clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "ReturnConstRefFromParameterCheck.h"
10+
#include "clang/AST/Attrs.inc"
1011
#include "clang/AST/Expr.h"
1112
#include "clang/ASTMatchers/ASTMatchFinder.h"
1213
#include "clang/ASTMatchers/ASTMatchers.h"
@@ -15,14 +16,23 @@ using namespace clang::ast_matchers;
1516

1617
namespace clang::tidy::bugprone {
1718

19+
namespace {
20+
21+
AST_MATCHER(ParmVarDecl, hasLifetimeBoundAttr) {
22+
return Node.hasAttr<LifetimeBoundAttr>();
23+
}
24+
25+
} // namespace
26+
1827
void ReturnConstRefFromParameterCheck::registerMatchers(MatchFinder *Finder) {
1928
const auto DRef = ignoringParens(
2029
declRefExpr(
2130
to(parmVarDecl(hasType(hasCanonicalType(
2231
qualType(lValueReferenceType(pointee(
2332
qualType(isConstQualified()))))
2433
.bind("type"))),
25-
hasDeclContext(functionDecl().bind("owner")))
34+
hasDeclContext(functionDecl().bind("owner")),
35+
unless(hasLifetimeBoundAttr()))
2636
.bind("param")))
2737
.bind("dref"));
2838
const auto Func =

clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ namespace clang::tidy::readability {
1818
/// a call to `empty()`.
1919
///
2020
/// The emptiness of a container should be checked using the `empty()` method
21-
/// instead of the `size()` method. It is not guaranteed that `size()` is a
22-
/// constant-time function, and it is generally more efficient and also shows
23-
/// clearer intent to use `empty()`. Furthermore some containers may implement
24-
/// the `empty()` method but not implement the `size()` method. Using `empty()`
25-
/// whenever possible makes it easier to switch to another container in the
26-
/// future.
21+
/// instead of the `size()` method. It shows clearer intent to use `empty()`.
22+
/// Furthermore some containers may implement the `empty()` method but not
23+
/// implement the `size()` method. Using `empty()` whenever possible makes it
24+
/// easier to switch to another container in the future.
2725
class ContainerSizeEmptyCheck : public ClangTidyCheck {
2826
public:
2927
ContainerSizeEmptyCheck(StringRef Name, ClangTidyContext *Context);

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ Changes in existing checks
184184
<clang-tidy/checks/bugprone/return-const-ref-from-parameter>` check to
185185
diagnose potential dangling references when returning a ``const &`` parameter
186186
by using the conditional operator ``cond ? var1 : var2`` and no longer giving
187-
false positives for functions which contain lambda.
187+
false positives for functions which contain lambda and ignore parameters
188+
with ``[[clang::lifetimebound]]`` attribute.
188189

189190
- Improved :doc:`bugprone-sizeof-expression
190191
<clang-tidy/checks/bugprone/sizeof-expression>` check to find suspicious

clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ after the call. When the function returns such a parameter also as constant refe
1212
then the returned reference can be used after the object it refers to has been
1313
destroyed.
1414

15-
This issue can be resolved by declaring an overload of the problematic function
16-
where the ``const &`` parameter is instead declared as ``&&``. The developer has
17-
to ensure that the implementation of that function does not produce a
18-
use-after-free, the exact error that this check is warning against.
19-
Marking such an ``&&`` overload as ``deleted``, will silence the warning as
20-
well. In the case of different ``const &`` parameters being returned depending
21-
on the control flow of the function, an overload where all problematic
22-
``const &`` parameters have been declared as ``&&`` will resolve the issue.
23-
2415
Example
2516
-------
2617

@@ -38,3 +29,23 @@ Example
3829

3930
const S& s = fn(S{1});
4031
s.v; // use after free
32+
33+
34+
This issue can be resolved by declaring an overload of the problematic function
35+
where the ``const &`` parameter is instead declared as ``&&``. The developer has
36+
to ensure that the implementation of that function does not produce a
37+
use-after-free, the exact error that this check is warning against.
38+
Marking such an ``&&`` overload as ``deleted``, will silence the warning as
39+
well. In the case of different ``const &`` parameters being returned depending
40+
on the control flow of the function, an overload where all problematic
41+
``const &`` parameters have been declared as ``&&`` will resolve the issue.
42+
43+
This issue can also be resolved by adding ``[[clang::lifetimebound]]``. Clang
44+
enable ``-Wdangling`` warning by default which can detect mis-uses of the
45+
annotated function. See `lifetimebound attribute <https://clang.llvm.org/docs/AttributeReference.html#id11>`_
46+
for details.
47+
48+
.. code-block:: c++
49+
50+
const int &f(const int &a [[clang::lifetimebound]]) { return a; } // no warning
51+
const int &v = f(1); // warning: temporary bound to local reference 'v' will be destroyed at the end of the full-expression [-Wdangling]

clang-tools-extra/docs/clang-tidy/checks/readability/container-size-empty.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ Checks whether a call to the ``size()``/``length()`` method can be replaced
88
with a call to ``empty()``.
99

1010
The emptiness of a container should be checked using the ``empty()`` method
11-
instead of the ``size()``/``length()`` method. It is not guaranteed that
12-
``size()``/``length()`` is a constant-time function, and it is generally more
13-
efficient and also shows clearer intent to use ``empty()``. Furthermore some
14-
containers may implement the ``empty()`` method but not implement the ``size()``
15-
or ``length()`` method. Using ``empty()`` whenever possible makes it easier to
16-
switch to another container in the future.
11+
instead of the ``size()``/``length()`` method. It shows clearer intent to use
12+
``empty()``. Furthermore some containers may implement the ``empty()`` method
13+
but not implement the ``size()`` or ``length()`` method. Using ``empty()``
14+
whenever possible makes it easier to switch to another container in the future.
1715

1816
The check issues warning if a container has ``empty()`` and ``size()`` or
1917
``length()`` methods matching following signatures:

clang-tools-extra/test/clang-tidy/checkers/bugprone/return-const-ref-from-parameter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,9 @@ int const &overload_params_difference3(int p1, int const &a, int p2) { return a;
197197
int const &overload_params_difference3(int p1, long &&a, int p2);
198198

199199
} // namespace overload
200+
201+
namespace gh117696 {
202+
namespace use_lifetime_bound_attr {
203+
int const &f(int const &a [[clang::lifetimebound]]) { return a; }
204+
} // namespace use_lifetime_bound_attr
205+
} // namespace gh117696

clang/docs/LanguageExtensions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ elementwise to the input.
648648
Unless specified otherwise operation(±0) = ±0 and operation(±infinity) = ±infinity
649649

650650
The integer elementwise intrinsics, including ``__builtin_elementwise_popcount``,
651-
can be called in a ``constexpr`` context.
651+
``__builtin_elementwise_bitreverse``, can be called in a ``constexpr`` context.
652652

653653
============================================== ====================================================================== =========================================
654654
Name Operation Supported element types

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ Resolutions to C++ Defect Reports
318318
by default.
319319
(`CWG2521: User-defined literals and reserved identifiers <https://cplusplus.github.io/CWG/issues/2521.html>`_).
320320

321+
- Fix name lookup for a dependent base class that is the current instantiation.
322+
(`CWG591: When a dependent base class is the current instantiation <https://cplusplus.github.io/CWG/issues/591.html>`_).
323+
321324
C Language Changes
322325
------------------
323326

@@ -412,6 +415,7 @@ Non-comprehensive list of changes in this release
412415
- ``__builtin_reduce_and`` function can now be used in constant expressions.
413416
- ``__builtin_reduce_or`` and ``__builtin_reduce_xor`` functions can now be used in constant expressions.
414417
- ``__builtin_elementwise_popcount`` function can now be used in constant expressions.
418+
- ``__builtin_elementwise_bitreverse`` function can now be used in constant expressions.
415419

416420
New Compiler Flags
417421
------------------
@@ -795,6 +799,8 @@ Bug Fixes to C++ Support
795799
- Fixed an assertion failure caused by using ``consteval`` in condition in consumed analyses. (#GH117385)
796800
- Fix a crash caused by incorrect argument position in merging deduced template arguments. (#GH113659)
797801
- Fixed an assertion failure caused by mangled names with invalid identifiers. (#GH112205)
802+
- Fixed an incorrect lambda scope of generic lambdas that caused Clang to crash when computing potential lambda
803+
captures at the end of a full expression. (#GH115931)
798804

799805
Bug Fixes to AST Handling
800806
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Basic/Builtins.td

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,7 @@ def ElementwiseATan2 : Builtin {
12701270

12711271
def ElementwiseBitreverse : Builtin {
12721272
let Spellings = ["__builtin_elementwise_bitreverse"];
1273-
let Attributes = [NoThrow, Const, CustomTypeChecking];
1273+
let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
12741274
let Prototype = "void(...)";
12751275
}
12761276

@@ -4738,6 +4738,12 @@ def GetDeviceSideMangledName : LangBuiltin<"CUDA_LANG"> {
47384738
}
47394739

47404740
// HLSL
4741+
def HLSLResourceGetPointer : LangBuiltin<"HLSL_LANG"> {
4742+
let Spellings = ["__builtin_hlsl_resource_getpointer"];
4743+
let Attributes = [NoThrow];
4744+
let Prototype = "void(...)";
4745+
}
4746+
47414747
def HLSLAll : LangBuiltin<"HLSL_LANG"> {
47424748
let Spellings = ["__builtin_hlsl_all"];
47434749
let Attributes = [NoThrow, Const];
@@ -4924,6 +4930,12 @@ def HLSLClip: LangBuiltin<"HLSL_LANG"> {
49244930
let Prototype = "void(...)";
49254931
}
49264932

4933+
def HLSLGroupMemoryBarrierWithGroupSync: LangBuiltin<"HLSL_LANG"> {
4934+
let Spellings = ["__builtin_hlsl_group_memory_barrier_with_group_sync"];
4935+
let Attributes = [NoThrow, Const];
4936+
let Prototype = "void()";
4937+
}
4938+
49274939
// Builtins for XRay.
49284940
def XRayCustomEvent : Builtin {
49294941
let Spellings = ["__xray_customevent"];

0 commit comments

Comments
 (0)