Skip to content

Commit db46420

Browse files
committed
Merge from 'main' to 'sycl-web' (138 commits)
CONFLICT (content): Merge conflict in clang/lib/Sema/SemaChecking.cpp CONFLICT (content): Merge conflict in clang/lib/Sema/SemaDeclAttr.cpp CONFLICT (content): Merge conflict in clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
2 parents 9fb6797 + bae2c54 commit db46420

File tree

464 files changed

+20947
-9666
lines changed

Some content is hidden

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

464 files changed

+20947
-9666
lines changed

clang-tools-extra/clang-doc/HTMLGenerator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,9 +993,9 @@ static llvm::Error serializeIndex(ClangDocContext &CDCtx) {
993993
});
994994
});
995995
};
996-
OS << "var JsonIndex = `\n";
996+
OS << "async function LoadIndex() {\nreturn";
997997
IndexToJSON(CDCtx.Idx);
998-
OS << "`;\n";
998+
OS << ";\n}";
999999
return llvm::Error::success();
10001000
}
10011001

clang-tools-extra/clang-doc/assets/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ function createIndex(Index) {
8080

8181
// Runs after DOM loads
8282
document.addEventListener("DOMContentLoaded", function() {
83-
// JsonIndex is a variable from another file that contains the index
84-
// in JSON format
85-
var Index = JSON.parse(JsonIndex);
86-
createIndex(Index);
83+
// LoadIndex is an asynchronous function that will be generated clang-doc.
84+
// It ensures that the function call will not block as soon the page loads,
85+
// since the index object are often huge and can contain thousands of lines.
86+
LoadIndex().then((Index) => { createIndex(Index); });
8787
});

clang-tools-extra/test/clang-doc/basic-project.test

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Rectangle.html -check-prefix=HTML-RECTANGLE
88
// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Circle.html -check-prefix=HTML-CIRCLE
99

10-
// JSON-INDEX: var JsonIndex = `
11-
// JSON-INDEX-NEXT: {
10+
// JSON-INDEX: async function LoadIndex() {
11+
// JSON-INDEX-NEXT: return{
1212
// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}",
1313
// JSON-INDEX-NEXT: "Name": "",
1414
// JSON-INDEX-NEXT: "RefType": "default",
@@ -51,7 +51,8 @@
5151
// JSON-INDEX-NEXT: ]
5252
// JSON-INDEX-NEXT: }
5353
// JSON-INDEX-NEXT: ]
54-
// JSON-INDEX-NEXT: }`;
54+
// JSON-INDEX-NEXT: };
55+
// JSON-INDEX-NEXT: }
5556

5657
// HTML-SHAPE: <!DOCTYPE html>
5758
// HTML-SHAPE-NEXT: <meta charset="utf-8"/>

clang/docs/ReleaseNotes.rst

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ C++ Specific Potentially Breaking Changes
7171
7272
To fix this, update libstdc++ to version 14.1.1 or greater.
7373

74-
- Clang now emits errors when Thread Safety Analysis trylock attributes are
75-
applied to functions or methods with incompatible return values, such as
76-
constructors, destructors, and void-returning functions. This only affects the
77-
``TRY_ACQUIRE`` and ``TRY_ACQUIRE_SHARED`` attributes (and any synonyms).
78-
7974
ABI Changes in This Version
8075
---------------------------
8176
- Fixed Microsoft name mangling of implicitly defined variables used for thread
@@ -152,6 +147,22 @@ Clang Frontend Potentially Breaking Changes
152147
- The ``hasTypeLoc`` AST matcher will no longer match a ``classTemplateSpecializationDecl``;
153148
existing uses should switch to ``templateArgumentLoc`` or ``hasAnyTemplateArgumentLoc`` instead.
154149

150+
- The comment parser now matches comments to declarations even if there is a
151+
preprocessor macro in between the comment and declaration. This change is
152+
intended to improve Clang's support for parsing documentation comments and
153+
to better conform to Doxygen's behavior.
154+
155+
This has the potential to cause ``-Wdocumentation`` warnings, especially in
156+
cases where a function-like macro has a documentation comment and is followed
157+
immediately by a normal function. The function-like macro's documentation
158+
comments will be attributed to the subsequent function and may cause
159+
``-Wdocumentation`` warnings such as mismatched parameter names, or invalid
160+
return documentation comments.
161+
162+
In cases where the ``-Wdocumentation`` warnings are thrown, the suggested fix
163+
is to document the declaration following the macro so that the warnings are
164+
fixed.
165+
155166
Clang Python Bindings Potentially Breaking Changes
156167
--------------------------------------------------
157168
- Renamed ``CursorKind`` variant 272 from ``OMP_TEAMS_DISTRIBUTE_DIRECTIVE``
@@ -623,10 +634,17 @@ Improvements to Clang's diagnostics
623634
- Clang no longer emits a "declared here" note for a builtin function that has no declaration in source.
624635
Fixes #GH93369.
625636

637+
- Clang now has an improved error message for captures that refer to a class member.
638+
Fixes #GH94764.
639+
626640
- Clang now diagnoses unsupported class declarations for ``std::initializer_list<E>`` when they are
627641
used rather than when they are needed for constant evaluation or when code is generated for them.
628642
The check is now stricter to prevent crashes for some unsupported declarations (Fixes #GH95495).
629643

644+
- Clang now diagnoses dangling cases where a pointer is assigned to a temporary
645+
that will be destroyed at the end of the full expression.
646+
Fixes #GH54492.
647+
630648
Improvements to Clang's time-trace
631649
----------------------------------
632650

@@ -735,11 +753,6 @@ Bug Fixes in This Version
735753

736754
- Fixed `static_cast` to array of unknown bound. Fixes (#GH62863).
737755

738-
- Clang's Thread Safety Analysis now evaluates trylock success arguments of enum
739-
types rather than silently defaulting to false. This fixes a class of false
740-
negatives where the analysis failed to detect unchecked access to guarded
741-
data.
742-
743756
Bug Fixes to Compiler Builtins
744757
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
745758

clang/docs/ThreadSafetyAnalysis.rst

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -420,17 +420,10 @@ TRY_ACQUIRE(<bool>, ...), TRY_ACQUIRE_SHARED(<bool>, ...)
420420
*Previously:* ``EXCLUSIVE_TRYLOCK_FUNCTION``, ``SHARED_TRYLOCK_FUNCTION``
421421

422422
These are attributes on a function or method that tries to acquire the given
423-
capability, and returns a boolean, integer, or pointer value indicating success
424-
or failure.
425-
426-
The attribute's first argument defines whether a zero or non-zero return value
427-
indicates success. Syntactically, it accepts ``NULL`` or ``nullptr``, ``bool``
428-
and ``int`` literals, as well as enumerator values. *The analysis only cares
429-
whether this success value is zero or non-zero.* This leads to some subtle
430-
consequences, discussed in the next section.
431-
432-
The remaining arguments are interpreted in the same way as ``ACQUIRE``. See
433-
:ref:`mutexheader`, below, for example uses.
423+
capability, and returns a boolean value indicating success or failure.
424+
The first argument must be ``true`` or ``false``, to specify which return value
425+
indicates success, and the remaining arguments are interpreted in the same way
426+
as ``ACQUIRE``. See :ref:`mutexheader`, below, for example uses.
434427

435428
Because the analysis doesn't support conditional locking, a capability is
436429
treated as acquired after the first branch on the return value of a try-acquire
@@ -452,44 +445,6 @@ function.
452445
}
453446
}
454447

455-
Subtle Consequences of Non-Boolean Success Values
456-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
457-
458-
The trylock attributes accept non-boolean expressions for the success value, but
459-
the analysis only cares whether the value is zero or non-zero.
460-
461-
Suppose you define an enum with two non-zero enumerators: ``LockAcquired = 1``
462-
and ``LockNotAcquired = 2``. If your trylock function returns ``LockAcquired``
463-
on success and ``LockNotAcquired`` on failure, the analysis may fail to detect
464-
access to guarded data without holding the mutex because they are both non-zero.
465-
466-
.. code-block:: c++
467-
468-
// *** Beware: this code demonstrates incorrect usage. ***
469-
470-
enum TrylockResult { LockAcquired = 1, LockNotAcquired = 2 };
471-
472-
class CAPABILITY("mutex") Mutex {
473-
public:
474-
TrylockResult TryLock() TRY_ACQUIRE(LockAcquired);
475-
};
476-
477-
Mutex mu;
478-
int a GUARDED_BY(mu);
479-
480-
void foo() {
481-
if (mu.TryLock()) { // This branch satisfies the analysis, but permits
482-
// unguarded access to `a`!
483-
a = 0;
484-
mu.Unlock();
485-
}
486-
}
487-
488-
It's also possible to return a pointer from the trylock function. Similarly, all
489-
that matters is whether the success value is zero or non-zero. For instance, a
490-
success value of `true` means the function returns a non-null pointer on
491-
success.
492-
493448

494449
ASSERT_CAPABILITY(...) and ASSERT_SHARED_CAPABILITY(...)
495450
--------------------------------------------------------

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,16 @@ def LogicalOpParentheses: DiagGroup<"logical-op-parentheses">;
435435
def LogicalNotParentheses: DiagGroup<"logical-not-parentheses">;
436436
def ShiftOpParentheses: DiagGroup<"shift-op-parentheses">;
437437
def OverloadedShiftOpParentheses: DiagGroup<"overloaded-shift-op-parentheses">;
438+
def DanglingAssignment: DiagGroup<"dangling-assignment">;
438439
def DanglingElse: DiagGroup<"dangling-else">;
439440
def DanglingField : DiagGroup<"dangling-field">;
440441
def DanglingInitializerList : DiagGroup<"dangling-initializer-list">;
441442
def DanglingGsl : DiagGroup<"dangling-gsl">;
442443
def ReturnStackAddress : DiagGroup<"return-stack-address">;
443444
// Name of this warning in GCC
444445
def : DiagGroup<"return-local-addr", [ReturnStackAddress]>;
445-
def Dangling : DiagGroup<"dangling", [DanglingField,
446+
def Dangling : DiagGroup<"dangling", [DanglingAssignment,
447+
DanglingField,
446448
DanglingInitializerList,
447449
DanglingGsl,
448450
ReturnStackAddress]>;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3356,23 +3356,11 @@ def warn_aligned_attr_underaligned : Warning<err_alignas_underaligned.Summary>,
33563356
def err_attribute_sizeless_type : Error<
33573357
"%0 attribute cannot be applied to sizeless type %1">;
33583358
def err_attribute_argument_n_type : Error<
3359-
"%0 attribute requires parameter %1 to be %select{"
3360-
"int or bool"
3361-
"|an integer constant"
3362-
"|a string"
3363-
"|an identifier"
3364-
"|a constant expression"
3365-
"|a builtin function"
3366-
"|nullptr or a bool, int, or enum literal}2">;
3359+
"%0 attribute requires parameter %1 to be %select{int or bool|an integer "
3360+
"constant|a string|an identifier|a constant expression|a builtin function}2">;
33673361
def err_attribute_argument_type : Error<
3368-
"%0 attribute requires %select{"
3369-
"int or bool"
3370-
"|an integer constant"
3371-
"|a string"
3372-
"|an identifier"
3373-
"|a constant expression"
3374-
"|a builtin function"
3375-
"|a pointer or a bool, int, or enum literal}1">;
3362+
"%0 attribute requires %select{int or bool|an integer "
3363+
"constant|a string|an identifier}1">;
33763364
def err_attribute_argument_out_of_range : Error<
33773365
"%0 attribute requires integer constant between %1 and %2 inclusive">;
33783366
def err_init_priority_object_attr : Error<
@@ -3833,8 +3821,7 @@ def warn_attribute_wrong_decl_type : Warning<
38333821
"|types and namespaces"
38343822
"|variables, functions and classes"
38353823
"|kernel functions"
3836-
"|non-K&R-style functions"
3837-
"|functions that return bool, integer, or a pointer type}2">,
3824+
"|non-K&R-style functions}2">,
38383825
InGroup<IgnoredAttributes>;
38393826
def err_attribute_wrong_decl_type : Error<warn_attribute_wrong_decl_type.Summary>;
38403827
def warn_type_attribute_wrong_type : Warning<
@@ -8300,6 +8287,8 @@ let CategoryName = "Lambda Issue" in {
83008287
"'&' must precede a capture when the capture default is '='">;
83018288
def err_capture_does_not_name_variable : Error<
83028289
"%0 in capture list does not name a variable">;
8290+
def err_capture_class_member_does_not_name_variable : Error<
8291+
"class member %0 cannot appear in capture list as it is not a variable">;
83038292
def err_capture_non_automatic_variable : Error<
83048293
"%0 cannot be captured because it does not have automatic storage "
83058294
"duration">;
@@ -10223,6 +10212,11 @@ def warn_new_dangling_initializer_list : Warning<
1022310212
"the allocated initializer list}0 "
1022410213
"will be destroyed at the end of the full-expression">,
1022510214
InGroup<DanglingInitializerList>;
10215+
def warn_dangling_pointer_assignment : Warning<
10216+
"object backing the pointer %0 "
10217+
"will be destroyed at the end of the full-expression">,
10218+
InGroup<DanglingAssignment>;
10219+
1022610220
def warn_unsupported_lifetime_extension : Warning<
1022710221
"lifetime extension of "
1022810222
"%select{temporary|backing array of initializer list}0 created "

clang/include/clang/Basic/arm_sme.td

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,4 +805,16 @@ defm SVREADZ_ZA16 : ZAReadzSingle<"za16", "sUshb", "aarch64_sme_readz", [ImmChe
805805
defm SVREADZ_ZA32 : ZAReadzSingle<"za32", "iUif", "aarch64_sme_readz", [ImmCheck<0, ImmCheck0_3>]>;
806806
defm SVREADZ_ZA64 : ZAReadzSingle<"za64", "lUld", "aarch64_sme_readz", [ImmCheck<0, ImmCheck0_7>]>;
807807
defm SVREADZ_ZA128 : ZAReadzSingle<"za128", "csilUcUiUsUlbhfd", "aarch64_sme_readz_q", [ImmCheck<0, ImmCheck0_15>]>;
808+
809+
multiclass ZAReadzArray<string vg_num>{
810+
let SMETargetGuard = "sme2p1" in {
811+
def NAME # _B : SInst<"svreadz_za8_{d}_vg1x" # vg_num, vg_num # "m", "cUc", MergeNone, "aarch64_sme_readz_x" # vg_num, [IsStreaming, IsInOutZA]>;
812+
def NAME # _H : SInst<"svreadz_za16_{d}_vg1x" # vg_num, vg_num # "m", "sUsbh", MergeNone, "aarch64_sme_readz_x" # vg_num, [IsStreaming, IsInOutZA]>;
813+
def NAME # _S : SInst<"svreadz_za32_{d}_vg1x" # vg_num, vg_num # "m", "iUif", MergeNone, "aarch64_sme_readz_x" # vg_num, [IsStreaming, IsInOutZA]>;
814+
def NAME # _D : SInst<"svreadz_za64_{d}_vg1x" # vg_num, vg_num # "m", "lUld", MergeNone, "aarch64_sme_readz_x" # vg_num, [IsStreaming, IsInOutZA]>;
815+
}
816+
}
817+
818+
defm SVREADZ_VG2 : ZAReadzArray<"2">;
819+
defm SVREADZ_VG4 : ZAReadzArray<"4">;
808820
} // let SVETargetGuard = InvalidMode

clang/include/clang/Sema/ParsedAttr.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,6 @@ enum AttributeArgumentNType {
10881088
AANT_ArgumentIdentifier,
10891089
AANT_ArgumentConstantExpr,
10901090
AANT_ArgumentBuiltinFunction,
1091-
AANT_ArgumentNullptrOrBoolIntOrEnumLiteral,
10921091
};
10931092

10941093
/// These constants match the enumerated choices of
@@ -1107,7 +1106,6 @@ enum AttributeDeclKind {
11071106
ExpectedFunctionVariableOrClass,
11081107
ExpectedKernelFunction,
11091108
ExpectedFunctionWithProtoType,
1110-
ExpectedFunctionReturningPointerBoolIntOrEnum,
11111109
};
11121110

11131111
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,

0 commit comments

Comments
 (0)