Skip to content

Commit 8a95522

Browse files
committed
Merge from 'main' to 'sycl-web' (223 commits)
CONFLICT (content): Merge conflict in clang/lib/CodeGen/CGExprCXX.cpp
2 parents ab5f314 + 89ba7e1 commit 8a95522

File tree

919 files changed

+43414
-40539
lines changed

Some content is hidden

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

919 files changed

+43414
-40539
lines changed

.github/workflows/release-lit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
cd llvm/utils/lit
5959
# Remove 'dev' suffix from lit version.
6060
sed -i 's/ + "dev"//g' lit/__init__.py
61-
python3 setup.py sdist
61+
python3 setup.py sdist bdist_wheel
6262
6363
- name: Upload lit to test.pypi.org
6464
uses: pypa/gh-action-pypi-publish@release/v1

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#include "MissingStdForwardCheck.h"
1010
#include "../utils/Matchers.h"
1111
#include "clang/AST/ASTContext.h"
12-
#include "clang/AST/ExprConcepts.h"
1312
#include "clang/ASTMatchers/ASTMatchFinder.h"
13+
#include "clang/Basic/IdentifierTable.h"
1414

1515
using namespace clang::ast_matchers;
1616

@@ -79,6 +79,11 @@ AST_MATCHER_P(LambdaExpr, hasCaptureDefaultKind, LambdaCaptureDefault, Kind) {
7979
return Node.getCaptureDefault() == Kind;
8080
}
8181

82+
AST_MATCHER(VarDecl, hasIdentifier) {
83+
const IdentifierInfo *ID = Node.getIdentifier();
84+
return ID != NULL && !ID->isPlaceholder();
85+
}
86+
8287
} // namespace
8388

8489
void MissingStdForwardCheck::registerMatchers(MatchFinder *Finder) {
@@ -125,12 +130,14 @@ void MissingStdForwardCheck::registerMatchers(MatchFinder *Finder) {
125130
hasAncestor(expr(hasUnevaluatedContext())))));
126131

127132
Finder->addMatcher(
128-
parmVarDecl(parmVarDecl().bind("param"), isTemplateTypeParameter(),
129-
hasAncestor(functionDecl().bind("func")),
130-
hasAncestor(functionDecl(
131-
isDefinition(), equalsBoundNode("func"), ToParam,
132-
unless(anyOf(isDeleted(), hasDescendant(std::move(
133-
ForwardCallMatcher))))))),
133+
parmVarDecl(
134+
parmVarDecl().bind("param"), hasIdentifier(),
135+
unless(hasAttr(attr::Kind::Unused)), isTemplateTypeParameter(),
136+
hasAncestor(functionDecl().bind("func")),
137+
hasAncestor(functionDecl(
138+
isDefinition(), equalsBoundNode("func"), ToParam,
139+
unless(anyOf(isDeleted(),
140+
hasDescendant(std::move(ForwardCallMatcher))))))),
134141
this);
135142
}
136143

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,9 @@ Changes in existing checks
179179

180180
- Improved :doc:`cppcoreguidelines-missing-std-forward
181181
<clang-tidy/checks/cppcoreguidelines/missing-std-forward>` check by no longer
182-
giving false positives for deleted functions and fix false negative when some
183-
parameters are forwarded, but other aren't.
182+
giving false positives for deleted functions, by fixing false negatives when only
183+
a few parameters are forwarded and by ignoring parameters without a name (unused
184+
arguments).
184185

185186
- Improved :doc:`cppcoreguidelines-owning-memory
186187
<clang-tidy/checks/cppcoreguidelines/owning-memory>` check to properly handle

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,16 @@ struct S {
198198
};
199199

200200
} // namespace deleted_functions
201+
202+
namespace unused_arguments {
203+
204+
template<typename F>
205+
void unused_argument1(F&&) {}
206+
207+
template<typename F>
208+
void unused_argument2([[maybe_unused]] F&& f) {}
209+
210+
template<typename F>
211+
void unused_argument3(F&& _) {}
212+
213+
} // namespace unused_arguments

clang/docs/ReleaseNotes.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ C++20 Feature Support
110110
templates (`P1814R0 <https://wg21.link/p1814r0>`_).
111111
(#GH54051).
112112

113+
- We have sufficient confidence and experience with the concepts implementation
114+
to update the ``__cpp_concepts`` macro to `202002L`. This enables
115+
``<expected>`` from libstdc++ to work correctly with Clang.
116+
113117
C++23 Feature Support
114118
^^^^^^^^^^^^^^^^^^^^^
115119

@@ -198,6 +202,10 @@ Non-comprehensive list of changes in this release
198202

199203
New Compiler Flags
200204
------------------
205+
- ``-fsanitize=implicit-bitfield-conversion`` checks implicit truncation and
206+
sign change.
207+
- ``-fsanitize=implicit-integer-conversion`` a group that replaces the previous
208+
group ``-fsanitize=implicit-conversion``.
201209

202210
- ``-Wmissing-designated-field-initializers``, grouped under ``-Wmissing-field-initializers``.
203211
This diagnostic can be disabled to make ``-Wmissing-field-initializers`` behave
@@ -211,6 +219,9 @@ Modified Compiler Flags
211219
- Added a new diagnostic flag ``-Wreturn-mismatch`` which is grouped under
212220
``-Wreturn-type``, and moved some of the diagnostics previously controlled by
213221
``-Wreturn-type`` under this new flag. Fixes #GH72116.
222+
- ``-fsanitize=implicit-conversion`` is now a group for both
223+
``-fsanitize=implicit-integer-conversion`` and
224+
``-fsanitize=implicit-bitfield-conversion``.
214225

215226
- Added ``-Wcast-function-type-mismatch`` under the ``-Wcast-function-type``
216227
warning group. Moved the diagnostic previously controlled by
@@ -341,11 +352,20 @@ Improvements to Clang's diagnostics
341352
(with initializer) entirely consist the condition expression of a if/while/for construct
342353
but are not actually used in the body of the if/while/for construct. Fixes #GH41447
343354

355+
- Clang emits a diagnostic when a tentative array definition is assumed to have
356+
a single element, but that diagnostic was never given a diagnostic group.
357+
Added the ``-Wtentative-definition-array`` warning group to cover this.
358+
Fixes #GH87766
359+
344360
Improvements to Clang's time-trace
345361
----------------------------------
346362

347363
Bug Fixes in This Version
348364
-------------------------
365+
- Clang's ``-Wundefined-func-template`` no longer warns on pure virtual
366+
functions.
367+
(`#74016 <https://github.com/llvm/llvm-project/issues/74016>`_)
368+
349369
- Fixed missing warnings when comparing mismatched enumeration constants
350370
in C (`#29217 <https://github.com/llvm/llvm-project/issues/29217>`).
351371

@@ -500,10 +520,15 @@ Bug Fixes to C++ Support
500520
- Fix an issue caused by not handling invalid cases when substituting into the parameter mapping of a constraint. Fixes (#GH86757).
501521
- Fixed a bug that prevented member function templates of class templates declared with a deduced return type
502522
from being explicitly specialized for a given implicit instantiation of the class template.
523+
- Fixed a crash when ``this`` is used in a dependent class scope function template specialization
524+
that instantiates to a static member function.
503525

504526
- Fix crash when inheriting from a cv-qualified type. Fixes:
505527
(`#35603 <https://github.com/llvm/llvm-project/issues/35603>`_)
506528
- Fix a crash when the using enum declaration uses an anonymous enumeration. Fixes (#GH86790).
529+
- Clang now correctly tracks type dependence of by-value captures in lambdas with an explicit
530+
object parameter.
531+
Fixes (#GH70604), (#GH79754), (#GH84163), (#GH84425), (#GH86054), (#GH86398), and (#GH86399).
507532

508533
Bug Fixes to AST Handling
509534
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -626,6 +651,7 @@ AST Matchers
626651
- Add ``isExplicitObjectMemberFunction``.
627652
- Fixed ``forEachArgumentWithParam`` and ``forEachArgumentWithParamType`` to
628653
not skip the explicit object parameter for operator calls.
654+
- Fixed captureVars assertion failure if not capturesVariables. (#GH76425)
629655

630656
clang-format
631657
------------

clang/docs/UndefinedBehaviorSanitizer.rst

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ Available checks are:
148148
Issues caught by this sanitizer are not undefined behavior,
149149
but are often unintentional.
150150
- ``-fsanitize=integer-divide-by-zero``: Integer division by zero.
151+
- ``-fsanitize=implicit-bitfield-conversion``: Implicit conversion from
152+
integer of larger bit width to smaller bitfield, if that results in data
153+
loss. This includes unsigned/signed truncations and sign changes, similarly
154+
to how the ``-fsanitize=implicit-integer-conversion`` group works, but
155+
explicitly for bitfields.
151156
- ``-fsanitize=nonnull-attribute``: Passing null pointer as a function
152157
parameter which is declared to never be null.
153158
- ``-fsanitize=null``: Use of a null pointer or creation of a null
@@ -193,16 +198,16 @@ Available checks are:
193198
signed division overflow (``INT_MIN/-1``). Note that checks are still
194199
added even when ``-fwrapv`` is enabled. This sanitizer does not check for
195200
lossy implicit conversions performed before the computation (see
196-
``-fsanitize=implicit-conversion``). Both of these two issues are handled
197-
by ``-fsanitize=implicit-conversion`` group of checks.
201+
``-fsanitize=implicit-integer-conversion``). Both of these two issues are handled
202+
by ``-fsanitize=implicit-integer-conversion`` group of checks.
198203
- ``-fsanitize=unreachable``: If control flow reaches an unreachable
199204
program point.
200205
- ``-fsanitize=unsigned-integer-overflow``: Unsigned integer overflow, where
201206
the result of an unsigned integer computation cannot be represented in its
202207
type. Unlike signed integer overflow, this is not undefined behavior, but
203208
it is often unintentional. This sanitizer does not check for lossy implicit
204209
conversions performed before such a computation
205-
(see ``-fsanitize=implicit-conversion``).
210+
(see ``-fsanitize=implicit-integer-conversion``).
206211
- ``-fsanitize=vla-bound``: A variable-length array whose bound
207212
does not evaluate to a positive value.
208213
- ``-fsanitize=vptr``: Use of an object whose vptr indicates that it is of
@@ -224,11 +229,15 @@ You can also use the following check groups:
224229
- ``-fsanitize=implicit-integer-arithmetic-value-change``: Catches implicit
225230
conversions that change the arithmetic value of the integer. Enables
226231
``implicit-signed-integer-truncation`` and ``implicit-integer-sign-change``.
227-
- ``-fsanitize=implicit-conversion``: Checks for suspicious
228-
behavior of implicit conversions. Enables
232+
- ``-fsanitize=implicit-integer-conversion``: Checks for suspicious
233+
behavior of implicit integer conversions. Enables
229234
``implicit-unsigned-integer-truncation``,
230235
``implicit-signed-integer-truncation``, and
231236
``implicit-integer-sign-change``.
237+
- ``-fsanitize=implicit-conversion``: Checks for suspicious
238+
behavior of implicit conversions. Enables
239+
``implicit-integer-conversion``, and
240+
``implicit-bitfield-conversion``.
232241
- ``-fsanitize=integer``: Checks for undefined or suspicious integer
233242
behavior (e.g. unsigned integer overflow).
234243
Enables ``signed-integer-overflow``, ``unsigned-integer-overflow``,

clang/include/clang/AST/ExprCXX.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,7 @@ class CXXThisExpr : public Expr {
11491149
CXXThisExpr(SourceLocation L, QualType Ty, bool IsImplicit, ExprValueKind VK)
11501150
: Expr(CXXThisExprClass, Ty, VK, OK_Ordinary) {
11511151
CXXThisExprBits.IsImplicit = IsImplicit;
1152+
CXXThisExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter = false;
11521153
CXXThisExprBits.Loc = L;
11531154
setDependence(computeDependence(this));
11541155
}
@@ -1170,6 +1171,15 @@ class CXXThisExpr : public Expr {
11701171
bool isImplicit() const { return CXXThisExprBits.IsImplicit; }
11711172
void setImplicit(bool I) { CXXThisExprBits.IsImplicit = I; }
11721173

1174+
bool isCapturedByCopyInLambdaWithExplicitObjectParameter() const {
1175+
return CXXThisExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter;
1176+
}
1177+
1178+
void setCapturedByCopyInLambdaWithExplicitObjectParameter(bool Set) {
1179+
CXXThisExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter = Set;
1180+
setDependence(computeDependence(this));
1181+
}
1182+
11731183
static bool classof(const Stmt *T) {
11741184
return T->getStmtClass() == CXXThisExprClass;
11751185
}

clang/include/clang/AST/Stmt.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,11 @@ class alignas(void *) Stmt {
784784
LLVM_PREFERRED_TYPE(bool)
785785
unsigned IsImplicit : 1;
786786

787+
/// Whether there is a lambda with an explicit object parameter that
788+
/// captures this "this" by copy.
789+
LLVM_PREFERRED_TYPE(bool)
790+
unsigned CapturedByCopyInLambdaWithExplicitObjectParameter : 1;
791+
787792
/// The location of the "this".
788793
SourceLocation Loc;
789794
};

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4961,6 +4961,8 @@ AST_MATCHER_P(LambdaExpr, hasAnyCapture, internal::Matcher<LambdaCapture>,
49614961
/// capturesVar(hasName("x")) matches `x` and `x = 1`.
49624962
AST_MATCHER_P(LambdaCapture, capturesVar, internal::Matcher<ValueDecl>,
49634963
InnerMatcher) {
4964+
if (!Node.capturesVariable())
4965+
return false;
49644966
auto *capturedVar = Node.getCapturedVar();
49654967
return capturedVar && InnerMatcher.matches(*capturedVar, Finder, Builder);
49664968
}

clang/include/clang/Basic/Attr.td

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,10 @@ class Spelling<string name, string variety, int version = 1> {
328328
}
329329

330330
class GNU<string name> : Spelling<name, "GNU">;
331-
class Declspec<string name> : Spelling<name, "Declspec"> {
332-
bit PrintOnLeft = 1;
333-
}
331+
class Declspec<string name> : Spelling<name, "Declspec">;
334332
class Microsoft<string name> : Spelling<name, "Microsoft">;
335333
class CXX11<string namespace, string name, int version = 1>
336334
: Spelling<name, "CXX11", version> {
337-
bit CanPrintOnLeft = 0;
338335
string Namespace = namespace;
339336
}
340337
class C23<string namespace, string name, int version = 1>
@@ -608,12 +605,6 @@ class AttrSubjectMatcherAggregateRule<AttrSubject subject> {
608605
def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule<Named>;
609606

610607
class Attr {
611-
// Specifies that when printed, this attribute is meaningful on the
612-
// 'left side' of the declaration.
613-
bit CanPrintOnLeft = 1;
614-
// Specifies that when printed, this attribute is required to be printed on
615-
// the 'left side' of the declaration.
616-
bit PrintOnLeft = 0;
617608
// The various ways in which an attribute can be spelled in source
618609
list<Spelling> Spellings;
619610
// The things to which an attribute can appertain
@@ -978,7 +969,6 @@ def AVRSignal : InheritableAttr, TargetSpecificAttr<TargetAVR> {
978969
}
979970

980971
def AsmLabel : InheritableAttr {
981-
let CanPrintOnLeft = 0;
982972
let Spellings = [CustomKeyword<"asm">, CustomKeyword<"__asm__">];
983973
let Args = [
984974
// Label specifies the mangled name for the decl.
@@ -2175,7 +2165,6 @@ def AllocSize : InheritableAttr {
21752165
}
21762166

21772167
def EnableIf : InheritableAttr {
2178-
let CanPrintOnLeft = 0;
21792168
// Does not have a [[]] spelling because this attribute requires the ability
21802169
// to parse function arguments but the attribute is not written in the type
21812170
// position.
@@ -4177,7 +4166,6 @@ def Unavailable : InheritableAttr {
41774166
}
41784167

41794168
def DiagnoseIf : InheritableAttr {
4180-
let CanPrintOnLeft = 0;
41814169
// Does not have a [[]] spelling because this attribute requires the ability
41824170
// to parse function arguments but the attribute is not written in the type
41834171
// position.

clang/include/clang/Basic/CMakeLists.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,6 @@ clang_tablegen(AttrList.inc -gen-clang-attr-list
3131
SOURCE Attr.td
3232
TARGET ClangAttrList)
3333

34-
clang_tablegen(AttrLeftSideCanPrintList.inc -gen-clang-attr-can-print-left-list
35-
-I ${CMAKE_CURRENT_SOURCE_DIR}/../../
36-
SOURCE Attr.td
37-
TARGET ClangAttrCanPrintLeftList)
38-
39-
clang_tablegen(AttrLeftSideMustPrintList.inc -gen-clang-attr-must-print-left-list
40-
-I ${CMAKE_CURRENT_SOURCE_DIR}/../../
41-
SOURCE Attr.td
42-
TARGET ClangAttrMustPrintLeftList)
43-
4434
clang_tablegen(AttrSubMatchRulesList.inc -gen-clang-attr-subject-match-rule-list
4535
-I ${CMAKE_CURRENT_SOURCE_DIR}/../../
4636
SOURCE Attr.td

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,6 +1436,9 @@ def MultiGPU: DiagGroup<"multi-gpu">;
14361436
// libc and the CRT to be skipped.
14371437
def AVRRtlibLinkingQuirks : DiagGroup<"avr-rtlib-linking-quirks">;
14381438

1439+
// A warning group related to AArch64 SME function attribues.
1440+
def AArch64SMEAttributes : DiagGroup<"aarch64-sme-attributes">;
1441+
14391442
// A warning group for things that will change semantics in the future.
14401443
def FutureCompat : DiagGroup<"future-compat">;
14411444

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3835,6 +3835,16 @@ def err_sme_definition_using_za_in_non_sme_target : Error<
38353835
"function using ZA state requires 'sme'">;
38363836
def err_sme_definition_using_zt0_in_non_sme2_target : Error<
38373837
"function using ZT0 state requires 'sme2'">;
3838+
def warn_sme_streaming_pass_return_vl_to_non_streaming : Warning<
3839+
"passing a VL-dependent argument to/from a function that has a different"
3840+
" streaming-mode. The streaming and non-streaming vector lengths may be"
3841+
" different">,
3842+
InGroup<AArch64SMEAttributes>, DefaultIgnore;
3843+
def warn_sme_locally_streaming_has_vl_args_returns : Warning<
3844+
"passing/returning a VL-dependent argument to/from a __arm_locally_streaming"
3845+
" function. The streaming and non-streaming vector"
3846+
" lengths may be different">,
3847+
InGroup<AArch64SMEAttributes>, DefaultIgnore;
38383848
def err_conflicting_attributes_arm_state : Error<
38393849
"conflicting attributes for state '%0'">;
38403850
def err_sme_streaming_cannot_be_multiversioned : Error<
@@ -7228,7 +7238,8 @@ def ext_typecheck_decl_incomplete_type : ExtWarn<
72287238
def err_tentative_def_incomplete_type : Error<
72297239
"tentative definition has type %0 that is never completed">;
72307240
def warn_tentative_incomplete_array : Warning<
7231-
"tentative array definition assumed to have one element">;
7241+
"tentative array definition assumed to have one element">,
7242+
InGroup<DiagGroup<"tentative-definition-array">>;
72327243
def err_typecheck_incomplete_array_needs_initializer : Error<
72337244
"definition of variable with array type needs an explicit size "
72347245
"or an initializer">;
@@ -12538,6 +12549,8 @@ def warn_acc_clause_unimplemented
1253812549
def err_acc_construct_appertainment
1253912550
: Error<"OpenACC construct '%0' cannot be used here; it can only "
1254012551
"be used in a statement context">;
12552+
def err_acc_clause_appertainment
12553+
: Error<"OpenACC '%1' clause is not valid on '%0' directive">;
1254112554
def err_acc_branch_in_out_compute_construct
1254212555
: Error<"invalid %select{branch|return|throw}0 %select{out of|into}1 "
1254312556
"OpenACC Compute Construct">;

0 commit comments

Comments
 (0)