Skip to content

Commit 833f2df

Browse files
authored
Merge branch 'main' into loop_unroll_zero
2 parents 1e0cdfd + 26101e8 commit 833f2df

File tree

577 files changed

+18688
-10181
lines changed

Some content is hidden

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

577 files changed

+18688
-10181
lines changed

.github/new-prs-labeler.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
ClangIR:
2+
- clang/include/clang/CIR/**/*
3+
- clang/lib/CIR/**/*
4+
- clang/tools/cir-*/**/*
5+
- clang/test/CIR/**/*
6+
17
clang:dataflow:
28
- clang/include/clang/Analysis/FlowSensitive/**/*
39
- clang/lib/Analysis/FlowSensitive/**/*
@@ -938,3 +944,6 @@ openmp:libomptarget:
938944

939945
bazel:
940946
- utils/bazel/**
947+
948+
offload:
949+
- offload/**

clang-tools-extra/docs/clang-tidy/checks/bugprone/sizeof-expression.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,6 @@ Options
190190

191191
.. option:: WarnOnSizeOfPointerToAggregate
192192

193-
When `true, the check will warn on an expression like
193+
When `true`, the check will warn on an expression like
194194
``sizeof(expr)`` where the expression is a pointer
195195
to aggregate. Default is `true`.

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ Improvements to Clang's diagnostics
364364
- Clang now uses the correct type-parameter-key (``class`` or ``typename``) when printing
365365
template template parameter declarations.
366366

367+
- Clang now diagnoses requires expressions with explicit object parameters.
368+
367369
Improvements to Clang's time-trace
368370
----------------------------------
369371

clang/include/clang/Basic/DiagnosticGroups.td

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

1415-
// A warning group related to AArch64 SME function attribues.
1416-
def AArch64SMEAttributes : DiagGroup<"aarch64-sme-attributes">;
1417-
14181415
// A warning group for things that will change semantics in the future.
14191416
def FutureCompat : DiagGroup<"future-compat">;
14201417

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,8 @@ def err_empty_requires_expr : Error<
863863
"a requires expression must contain at least one requirement">;
864864
def err_requires_expr_parameter_list_ellipsis : Error<
865865
"varargs not allowed in requires expression">;
866+
def err_requires_expr_explicit_object_parameter: Error<
867+
"a requires expression cannot have an explicit object parameter">;
866868
def err_expected_semi_requirement : Error<
867869
"expected ';' at end of requirement">;
868870
def err_requires_expr_missing_arrow : Error<

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3751,16 +3751,6 @@ def err_sme_definition_using_za_in_non_sme_target : Error<
37513751
"function using ZA state requires 'sme'">;
37523752
def err_sme_definition_using_zt0_in_non_sme2_target : Error<
37533753
"function using ZT0 state requires 'sme2'">;
3754-
def warn_sme_streaming_pass_return_vl_to_non_streaming : Warning<
3755-
"passing a VL-dependent argument to/from a function that has a different"
3756-
" streaming-mode. The streaming and non-streaming vector lengths may be"
3757-
" different">,
3758-
InGroup<AArch64SMEAttributes>, DefaultIgnore;
3759-
def warn_sme_locally_streaming_has_vl_args_returns : Warning<
3760-
"passing/returning a VL-dependent argument to/from a __arm_locally_streaming"
3761-
" function. The streaming and non-streaming vector"
3762-
" lengths may be different">,
3763-
InGroup<AArch64SMEAttributes>, DefaultIgnore;
37643754
def err_conflicting_attributes_arm_state : Error<
37653755
"conflicting attributes for state '%0'">;
37663756
def err_sme_streaming_cannot_be_multiversioned : Error<

clang/include/clang/Sema/Lookup.h

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -153,28 +153,30 @@ class LookupResult {
153153

154154
using iterator = UnresolvedSetImpl::iterator;
155155

156-
LookupResult(Sema &SemaRef, const DeclarationNameInfo &NameInfo,
157-
Sema::LookupNameKind LookupKind,
158-
Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration)
156+
LookupResult(
157+
Sema &SemaRef, const DeclarationNameInfo &NameInfo,
158+
Sema::LookupNameKind LookupKind,
159+
RedeclarationKind Redecl = RedeclarationKind::NotForRedeclaration)
159160
: SemaPtr(&SemaRef), NameInfo(NameInfo), LookupKind(LookupKind),
160-
Redecl(Redecl != Sema::NotForRedeclaration),
161-
ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
162-
DiagnoseAccess(Redecl == Sema::NotForRedeclaration),
163-
DiagnoseAmbiguous(Redecl == Sema::NotForRedeclaration) {
161+
Redecl(Redecl != RedeclarationKind::NotForRedeclaration),
162+
ExternalRedecl(Redecl == RedeclarationKind::ForExternalRedeclaration),
163+
DiagnoseAccess(Redecl == RedeclarationKind::NotForRedeclaration),
164+
DiagnoseAmbiguous(Redecl == RedeclarationKind::NotForRedeclaration) {
164165
configure();
165166
}
166167

167168
// TODO: consider whether this constructor should be restricted to take
168169
// as input a const IdentifierInfo* (instead of Name),
169170
// forcing other cases towards the constructor taking a DNInfo.
170-
LookupResult(Sema &SemaRef, DeclarationName Name, SourceLocation NameLoc,
171-
Sema::LookupNameKind LookupKind,
172-
Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration)
171+
LookupResult(
172+
Sema &SemaRef, DeclarationName Name, SourceLocation NameLoc,
173+
Sema::LookupNameKind LookupKind,
174+
RedeclarationKind Redecl = RedeclarationKind::NotForRedeclaration)
173175
: SemaPtr(&SemaRef), NameInfo(Name, NameLoc), LookupKind(LookupKind),
174-
Redecl(Redecl != Sema::NotForRedeclaration),
175-
ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
176-
DiagnoseAccess(Redecl == Sema::NotForRedeclaration),
177-
DiagnoseAmbiguous(Redecl == Sema::NotForRedeclaration) {
176+
Redecl(Redecl != RedeclarationKind::NotForRedeclaration),
177+
ExternalRedecl(Redecl == RedeclarationKind::ForExternalRedeclaration),
178+
DiagnoseAccess(Redecl == RedeclarationKind::NotForRedeclaration),
179+
DiagnoseAmbiguous(Redecl == RedeclarationKind::NotForRedeclaration) {
178180
configure();
179181
}
180182

@@ -285,9 +287,10 @@ class LookupResult {
285287
return ExternalRedecl;
286288
}
287289

288-
Sema::RedeclarationKind redeclarationKind() const {
289-
return ExternalRedecl ? Sema::ForExternalRedeclaration :
290-
Redecl ? Sema::ForVisibleRedeclaration : Sema::NotForRedeclaration;
290+
RedeclarationKind redeclarationKind() const {
291+
return ExternalRedecl ? RedeclarationKind::ForExternalRedeclaration
292+
: Redecl ? RedeclarationKind::ForVisibleRedeclaration
293+
: RedeclarationKind::NotForRedeclaration;
291294
}
292295

293296
/// Specify whether hidden declarations are visible, e.g.,
@@ -615,9 +618,9 @@ class LookupResult {
615618
}
616619

617620
/// Change this lookup's redeclaration kind.
618-
void setRedeclarationKind(Sema::RedeclarationKind RK) {
619-
Redecl = (RK != Sema::NotForRedeclaration);
620-
ExternalRedecl = (RK == Sema::ForExternalRedeclaration);
621+
void setRedeclarationKind(RedeclarationKind RK) {
622+
Redecl = (RK != RedeclarationKind::NotForRedeclaration);
623+
ExternalRedecl = (RK == RedeclarationKind::ForExternalRedeclaration);
621624
configure();
622625
}
623626

clang/include/clang/Sema/ParsedAttr.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ struct PropertyData {
9494
: GetterId(getterId), SetterId(setterId) {}
9595
};
9696

97-
} // namespace
97+
} // namespace detail
9898

9999
/// Wraps an identifier and optional source location for the identifier.
100100
struct IdentifierLoc {
@@ -743,11 +743,6 @@ class AttributePool {
743743
IdentifierInfo *scopeName, SourceLocation scopeLoc,
744744
ArgsUnion *args, unsigned numArgs, ParsedAttr::Form form,
745745
SourceLocation ellipsisLoc = SourceLocation()) {
746-
size_t temp =
747-
ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
748-
detail::TypeTagForDatatypeData, ParsedType,
749-
detail::PropertyData>(numArgs, 0, 0, 0, 0);
750-
(void)temp;
751746
void *memory = allocate(
752747
ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
753748
detail::TypeTagForDatatypeData, ParsedType,
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//===- Redeclaration.h - Redeclarations--------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file defines RedeclarationKind enum.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef LLVM_CLANG_SEMA_REDECLARATION_H
14+
#define LLVM_CLANG_SEMA_REDECLARATION_H
15+
16+
/// Specifies whether (or how) name lookup is being performed for a
17+
/// redeclaration (vs. a reference).
18+
enum class RedeclarationKind {
19+
/// The lookup is a reference to this name that is not for the
20+
/// purpose of redeclaring the name.
21+
NotForRedeclaration = 0,
22+
/// The lookup results will be used for redeclaration of a name,
23+
/// if an entity by that name already exists and is visible.
24+
ForVisibleRedeclaration,
25+
/// The lookup results will be used for redeclaration of a name
26+
/// with external linkage; non-visible lookup results with external linkage
27+
/// may also be found.
28+
ForExternalRedeclaration
29+
};
30+
31+
#endif // LLVM_CLANG_SEMA_REDECLARATION_H

clang/include/clang/Sema/Sema.h

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include "clang/Sema/IdentifierResolver.h"
5353
#include "clang/Sema/ObjCMethodList.h"
5454
#include "clang/Sema/Ownership.h"
55+
#include "clang/Sema/Redeclaration.h"
5556
#include "clang/Sema/Scope.h"
5657
#include "clang/Sema/SemaBase.h"
5758
#include "clang/Sema/SemaConcept.h"
@@ -7443,40 +7444,17 @@ class Sema final : public SemaBase {
74437444
typedef std::function<ExprResult(Sema &, TypoExpr *, TypoCorrection)>
74447445
TypoRecoveryCallback;
74457446

7446-
/// Specifies whether (or how) name lookup is being performed for a
7447-
/// redeclaration (vs. a reference).
7448-
enum RedeclarationKind {
7449-
/// The lookup is a reference to this name that is not for the
7450-
/// purpose of redeclaring the name.
7451-
NotForRedeclaration = 0,
7452-
/// The lookup results will be used for redeclaration of a name,
7453-
/// if an entity by that name already exists and is visible.
7454-
ForVisibleRedeclaration,
7455-
/// The lookup results will be used for redeclaration of a name
7456-
/// with external linkage; non-visible lookup results with external linkage
7457-
/// may also be found.
7458-
ForExternalRedeclaration
7459-
};
7460-
7461-
RedeclarationKind forRedeclarationInCurContext() const {
7462-
// A declaration with an owning module for linkage can never link against
7463-
// anything that is not visible. We don't need to check linkage here; if
7464-
// the context has internal linkage, redeclaration lookup won't find things
7465-
// from other TUs, and we can't safely compute linkage yet in general.
7466-
if (cast<Decl>(CurContext)
7467-
->getOwningModuleForLinkage(/*IgnoreLinkage*/ true))
7468-
return ForVisibleRedeclaration;
7469-
return ForExternalRedeclaration;
7470-
}
7447+
RedeclarationKind forRedeclarationInCurContext() const;
74717448

74727449
/// Look up a name, looking for a single declaration. Return
74737450
/// null if the results were absent, ambiguous, or overloaded.
74747451
///
74757452
/// It is preferable to use the elaborated form and explicitly handle
74767453
/// ambiguity and overloaded.
7477-
NamedDecl *LookupSingleName(Scope *S, DeclarationName Name,
7478-
SourceLocation Loc, LookupNameKind NameKind,
7479-
RedeclarationKind Redecl = NotForRedeclaration);
7454+
NamedDecl *LookupSingleName(
7455+
Scope *S, DeclarationName Name, SourceLocation Loc,
7456+
LookupNameKind NameKind,
7457+
RedeclarationKind Redecl = RedeclarationKind::NotForRedeclaration);
74807458
bool LookupBuiltin(LookupResult &R);
74817459
void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID);
74827460
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation = false,
@@ -7488,9 +7466,9 @@ class Sema final : public SemaBase {
74887466
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS,
74897467
bool AllowBuiltinCreation = false,
74907468
bool EnteringContext = false);
7491-
ObjCProtocolDecl *
7492-
LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc,
7493-
RedeclarationKind Redecl = NotForRedeclaration);
7469+
ObjCProtocolDecl *LookupProtocol(
7470+
IdentifierInfo *II, SourceLocation IdLoc,
7471+
RedeclarationKind Redecl = RedeclarationKind::NotForRedeclaration);
74947472
bool LookupInSuper(LookupResult &R, CXXRecordDecl *Class);
74957473

74967474
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,

clang/lib/Interpreter/Interpreter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,8 @@ std::unique_ptr<RuntimeInterfaceBuilder> Interpreter::FindRuntimeInterface() {
550550

551551
auto LookupInterface = [&](Expr *&Interface, llvm::StringRef Name) {
552552
LookupResult R(S, &Ctx.Idents.get(Name), SourceLocation(),
553-
Sema::LookupOrdinaryName, Sema::ForVisibleRedeclaration);
553+
Sema::LookupOrdinaryName,
554+
RedeclarationKind::ForVisibleRedeclaration);
554555
S.LookupQualifiedName(R, Ctx.getTranslationUnitDecl());
555556
if (R.empty())
556557
return false;

clang/lib/Interpreter/InterpreterUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ NamedDecl *LookupNamed(Sema &S, llvm::StringRef Name,
7272
const DeclContext *Within) {
7373
DeclarationName DName = &S.Context.Idents.get(Name);
7474
LookupResult R(S, DName, SourceLocation(), Sema::LookupOrdinaryName,
75-
Sema::ForVisibleRedeclaration);
75+
RedeclarationKind::ForVisibleRedeclaration);
7676

7777
R.suppressDiagnostics();
7878

clang/lib/Parse/ParseDecl.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7660,8 +7660,21 @@ void Parser::ParseParameterDeclarationClause(
76607660
// Parse a C++23 Explicit Object Parameter
76617661
// We do that in all language modes to produce a better diagnostic.
76627662
SourceLocation ThisLoc;
7663-
if (getLangOpts().CPlusPlus && Tok.is(tok::kw_this))
7663+
if (getLangOpts().CPlusPlus && Tok.is(tok::kw_this)) {
76647664
ThisLoc = ConsumeToken();
7665+
// C++23 [dcl.fct]p6:
7666+
// An explicit-object-parameter-declaration is a parameter-declaration
7667+
// with a this specifier. An explicit-object-parameter-declaration
7668+
// shall appear only as the first parameter-declaration of a
7669+
// parameter-declaration-list of either:
7670+
// - a member-declarator that declares a member function, or
7671+
// - a lambda-declarator.
7672+
//
7673+
// The parameter-declaration-list of a requires-expression is not such
7674+
// a context.
7675+
if (DeclaratorCtx == DeclaratorContext::RequiresExpr)
7676+
Diag(ThisLoc, diag::err_requires_expr_explicit_object_parameter);
7677+
}
76657678

76667679
ParseDeclarationSpecifiers(DS, /*TemplateInfo=*/ParsedTemplateInfo(),
76677680
AS_none, DeclSpecContext::DSC_normal,

clang/lib/Parse/ParseExprCXX.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3910,10 +3910,10 @@ ExprResult Parser::ParseTypeTrait() {
39103910
SmallVector<ParsedType, 2> Args;
39113911
do {
39123912
// Parse the next type.
3913-
TypeResult Ty =
3914-
ParseTypeName(/*SourceRange=*/nullptr,
3915-
getLangOpts().CPlusPlus ? DeclaratorContext::TemplateArg
3916-
: DeclaratorContext::TypeName);
3913+
TypeResult Ty = ParseTypeName(/*SourceRange=*/nullptr,
3914+
getLangOpts().CPlusPlus
3915+
? DeclaratorContext::TemplateTypeArg
3916+
: DeclaratorContext::TypeName);
39173917
if (Ty.isInvalid()) {
39183918
Parens.skipToEnd();
39193919
return ExprError();
@@ -3955,8 +3955,8 @@ ExprResult Parser::ParseArrayTypeTrait() {
39553955
if (T.expectAndConsume())
39563956
return ExprError();
39573957

3958-
TypeResult Ty =
3959-
ParseTypeName(/*SourceRange=*/nullptr, DeclaratorContext::TemplateArg);
3958+
TypeResult Ty = ParseTypeName(/*SourceRange=*/nullptr,
3959+
DeclaratorContext::TemplateTypeArg);
39603960
if (Ty.isInvalid()) {
39613961
SkipUntil(tok::comma, StopAtSemi);
39623962
SkipUntil(tok::r_paren, StopAtSemi);

clang/lib/Sema/SemaChecking.cpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7949,7 +7949,6 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
79497949
// For variadic functions, we may have more args than parameters.
79507950
// For some K&R functions, we may have less args than parameters.
79517951
const auto N = std::min<unsigned>(Proto->getNumParams(), Args.size());
7952-
bool AnyScalableArgsOrRet = Proto->getReturnType()->isSizelessVectorType();
79537952
for (unsigned ArgIdx = 0; ArgIdx < N; ++ArgIdx) {
79547953
// Args[ArgIdx] can be null in malformed code.
79557954
if (const Expr *Arg = Args[ArgIdx]) {
@@ -7963,8 +7962,6 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
79637962
checkAIXMemberAlignment((Arg->getExprLoc()), Arg);
79647963

79657964
QualType ParamTy = Proto->getParamType(ArgIdx);
7966-
if (ParamTy->isSizelessVectorType())
7967-
AnyScalableArgsOrRet = true;
79687965
QualType ArgTy = Arg->getType();
79697966
CheckArgAlignment(Arg->getExprLoc(), FDecl, std::to_string(ArgIdx + 1),
79707967
ArgTy, ParamTy);
@@ -7985,23 +7982,6 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
79857982
}
79867983
}
79877984

7988-
// If the call requires a streaming-mode change and has scalable vector
7989-
// arguments or return values, then warn the user that the streaming and
7990-
// non-streaming vector lengths may be different.
7991-
const auto *CallerFD = dyn_cast<FunctionDecl>(CurContext);
7992-
if (CallerFD && (!FD || !FD->getBuiltinID()) && AnyScalableArgsOrRet) {
7993-
bool IsCalleeStreaming =
7994-
ExtInfo.AArch64SMEAttributes & FunctionType::SME_PStateSMEnabledMask;
7995-
bool IsCalleeStreamingCompatible =
7996-
ExtInfo.AArch64SMEAttributes &
7997-
FunctionType::SME_PStateSMCompatibleMask;
7998-
ArmStreamingType CallerFnType = getArmStreamingFnType(CallerFD);
7999-
if (!IsCalleeStreamingCompatible &&
8000-
(CallerFnType == ArmStreamingCompatible ||
8001-
((CallerFnType == ArmStreaming) ^ IsCalleeStreaming)))
8002-
Diag(Loc, diag::warn_sme_streaming_pass_return_vl_to_non_streaming);
8003-
}
8004-
80057985
FunctionType::ArmStateValue CalleeArmZAState =
80067986
FunctionType::getArmZAState(ExtInfo.AArch64SMEAttributes);
80077987
FunctionType::ArmStateValue CalleeArmZT0State =
@@ -8010,7 +7990,7 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
80107990
CalleeArmZT0State != FunctionType::ARM_None) {
80117991
bool CallerHasZAState = false;
80127992
bool CallerHasZT0State = false;
8013-
if (CallerFD) {
7993+
if (const auto *CallerFD = dyn_cast<FunctionDecl>(CurContext)) {
80147994
auto *Attr = CallerFD->getAttr<ArmNewAttr>();
80157995
if (Attr && Attr->isNewZA())
80167996
CallerHasZAState = true;

0 commit comments

Comments
 (0)