Skip to content

Commit 10e40cf

Browse files
committed
Merge "merge main into amd-staging" into amd-staging
2 parents 480e136 + d6df583 commit 10e40cf

File tree

281 files changed

+3951
-1421
lines changed

Some content is hidden

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

281 files changed

+3951
-1421
lines changed

clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ static bool canAdvanceAssignment(AssignedLevel Level) {
6767
static void updateAssignmentLevel(
6868
const FieldDecl *Field, const Expr *Init, const CXXConstructorDecl *Ctor,
6969
llvm::DenseMap<const FieldDecl *, AssignedLevel> &AssignedFields) {
70-
auto It = AssignedFields.find(Field);
71-
if (It == AssignedFields.end())
72-
It = AssignedFields.insert({Field, AssignedLevel::None}).first;
70+
auto It = AssignedFields.try_emplace(Field, AssignedLevel::None).first;
7371

7472
if (!canAdvanceAssignment(It->second))
7573
// fast path for already decided field.

clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ This check implements detection of local variables which could be declared as
77
``const`` but are not. Declaring variables as ``const`` is required or recommended by many
88
coding guidelines, such as:
99
`ES.25 <https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es25-declare-an-object-const-or-constexpr-unless-you-want-to-modify-its-value-later-on>`_
10-
from the C++ Core Guidelines and `AUTOSAR C++14 Rule A7-1-1 (6.7.1 Specifiers)
11-
<https://www.autosar.org/fileadmin/standards/R22-11/AP/AUTOSAR_RS_CPP14Guidelines.pdf>`_.
10+
from the C++ Core Guidelines.
1211

1312
Please note that this check's analysis is type-based only. Variables that are not modified
1413
but used to create a non-const handle that might escape the scope are not diagnosed

clang-tools-extra/docs/clang-tidy/checks/misc/unconventional-assign-operator.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,3 @@ types and definitions with good return type but wrong ``return`` statements.
1313
type (e.g. ``int``).
1414
* Private and deleted operators are ignored.
1515
* The operator must always return ``*this``.
16-
17-
This check implements `AUTOSAR C++14 Rule A13-2-1
18-
<https://www.autosar.org/fileadmin/standards/R22-11/AP/AUTOSAR_RS_CPP14Guidelines.pdf>`_.

clang-tools-extra/docs/clang-tidy/checks/readability/avoid-nested-conditional-operator.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,3 @@ Examples:
1616
int NestInConditional = (condition1 ? true1 : false1) ? true2 : false2;
1717
int NestInTrue = condition1 ? (condition2 ? true1 : false1) : false2;
1818
int NestInFalse = condition1 ? true1 : condition2 ? true2 : false1;
19-
20-
This check implements part of `AUTOSAR C++14 Rule A5-16-1
21-
<https://www.autosar.org/fileadmin/standards/R22-11/AP/AUTOSAR_RS_CPP14Guidelines.pdf>`_.

clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define LLVM_CLANG_ANALYSIS_ANALYSES_UNSAFEBUFFERUSAGE_H
1616

1717
#include "clang/AST/Decl.h"
18+
#include "clang/AST/Expr.h"
1819
#include "clang/AST/Stmt.h"
1920
#include "clang/Basic/SourceLocation.h"
2021
#include "llvm/Support/Debug.h"
@@ -106,6 +107,20 @@ class UnsafeBufferUsageHandler {
106107
virtual void handleUnsafeOperation(const Stmt *Operation,
107108
bool IsRelatedToDecl, ASTContext &Ctx) = 0;
108109

110+
/// Invoked when a call to an unsafe libc function is found.
111+
/// \param PrintfInfo
112+
/// is 0 if the callee function is not a member of the printf family;
113+
/// is 1 if the callee is `sprintf`;
114+
/// is 2 if arguments of the call have `__size_by` relation but are not in a
115+
/// safe pattern;
116+
/// is 3 if string arguments do not guarantee null-termination
117+
/// is 4 if the callee takes va_list
118+
/// \param UnsafeArg one of the actual arguments that is unsafe, non-null
119+
/// only when `2 <= PrintfInfo <= 3`
120+
virtual void handleUnsafeLibcCall(const CallExpr *Call, unsigned PrintfInfo,
121+
ASTContext &Ctx,
122+
const Expr *UnsafeArg = nullptr) = 0;
123+
109124
/// Invoked when an unsafe operation with a std container is found.
110125
virtual void handleUnsafeOperationInContainer(const Stmt *Operation,
111126
bool IsRelatedToDecl,
@@ -151,6 +166,10 @@ class UnsafeBufferUsageHandler {
151166
virtual bool
152167
ignoreUnsafeBufferInContainer(const SourceLocation &Loc) const = 0;
153168

169+
/// \return true iff unsafe libc call should NOT be reported at `Loc`
170+
virtual bool
171+
ignoreUnsafeBufferInLibcCall(const SourceLocation &Loc) const = 0;
172+
154173
virtual std::string
155174
getUnsafeBufferUsageAttributeTextAt(SourceLocation Loc,
156175
StringRef WSSuffix = "") const = 0;

clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
#define WARNING_GADGET(name) GADGET(name)
1919
#endif
2020

21-
/// A `WARNING_GADGET` subset, where the code pattern of each gadget
22-
/// corresponds uses of a (possibly hardened) contatiner (e.g., `std::span`).
23-
#ifndef WARNING_CONTAINER_GADGET
24-
#define WARNING_CONTAINER_GADGET(name) WARNING_GADGET(name)
21+
/// A `WARNING_GADGET` subset, each of which may be enable/disable separately
22+
/// with different flags
23+
#ifndef WARNING_OPTIONAL_GADGET
24+
#define WARNING_OPTIONAL_GADGET(name) WARNING_GADGET(name)
2525
#endif
2626

2727
/// Safe gadgets correspond to code patterns that aren't unsafe but need to be
@@ -38,7 +38,8 @@ WARNING_GADGET(PointerArithmetic)
3838
WARNING_GADGET(UnsafeBufferUsageAttr)
3939
WARNING_GADGET(UnsafeBufferUsageCtorAttr)
4040
WARNING_GADGET(DataInvocation)
41-
WARNING_CONTAINER_GADGET(SpanTwoParamConstructor) // Uses of `std::span(arg0, arg1)`
41+
WARNING_OPTIONAL_GADGET(UnsafeLibcFunctionCall)
42+
WARNING_OPTIONAL_GADGET(SpanTwoParamConstructor) // Uses of `std::span(arg0, arg1)`
4243
FIXABLE_GADGET(ULCArraySubscript) // `DRE[any]` in an Unspecified Lvalue Context
4344
FIXABLE_GADGET(DerefSimplePtrArithFixable)
4445
FIXABLE_GADGET(PointerDereference)
@@ -52,5 +53,5 @@ FIXABLE_GADGET(PointerInit)
5253

5354
#undef FIXABLE_GADGET
5455
#undef WARNING_GADGET
55-
#undef WARNING_CONTAINER_GADGET
56+
#undef WARNING_OPTIONAL_GADGET
5657
#undef GADGET

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ TARGET_BUILTIN(__builtin_amdgcn_s_barrier_join, "vi", "n", "gfx12-insts")
448448
TARGET_BUILTIN(__builtin_amdgcn_s_wakeup_barrier, "vi", "n", "gfx12-insts")
449449
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_leave, "b", "n", "gfx12-insts")
450450
TARGET_BUILTIN(__builtin_amdgcn_s_get_barrier_state, "Uii", "n", "gfx12-insts")
451+
TARGET_BUILTIN(__builtin_amdgcn_s_prefetch_data, "vvC*Ui", "nc", "gfx12-insts")
451452

452453
TARGET_BUILTIN(__builtin_amdgcn_global_load_tr_b64_v2i32, "V2iV2i*1", "nc", "gfx12-insts,wavefrontsize32")
453454
TARGET_BUILTIN(__builtin_amdgcn_global_load_tr_b128_v8i16, "V8sV8s*1", "nc", "gfx12-insts,wavefrontsize32")

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,8 @@ def ReadOnlyPlacementChecks : DiagGroup<"read-only-types">;
15541554

15551555
// Warnings and fixes to support the "safe buffers" programming model.
15561556
def UnsafeBufferUsageInContainer : DiagGroup<"unsafe-buffer-usage-in-container">;
1557-
def UnsafeBufferUsage : DiagGroup<"unsafe-buffer-usage", [UnsafeBufferUsageInContainer]>;
1557+
def UnsafeBufferUsageInLibcCall : DiagGroup<"unsafe-buffer-usage-in-libc-call">;
1558+
def UnsafeBufferUsage : DiagGroup<"unsafe-buffer-usage", [UnsafeBufferUsageInContainer, UnsafeBufferUsageInLibcCall]>;
15581559

15591560
// Warnings and notes related to the function effects system underlying
15601561
// the nonblocking and nonallocating attributes.

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12417,6 +12417,13 @@ def warn_unsafe_buffer_operation : Warning<
1241712417
"unsafe buffer access|function introduces unsafe buffer manipulation|unsafe invocation of span::data|"
1241812418
"field %1 prone to unsafe buffer manipulation}0">,
1241912419
InGroup<UnsafeBufferUsage>, DefaultIgnore;
12420+
def warn_unsafe_buffer_libc_call : Warning<
12421+
"function %0 is unsafe">,
12422+
InGroup<UnsafeBufferUsageInLibcCall>, DefaultIgnore;
12423+
def note_unsafe_buffer_printf_call : Note<
12424+
"%select{|change to 'snprintf' for explicit bounds checking | buffer pointer and size may not match"
12425+
"|string argument is not guaranteed to be null-terminated"
12426+
"|'va_list' is unsafe}0">;
1242012427
def note_unsafe_buffer_operation : Note<
1242112428
"used%select{| in pointer arithmetic| in buffer access}0 here">;
1242212429
def note_unsafe_buffer_variable_fixit_group : Note<

0 commit comments

Comments
 (0)