Skip to content

Commit 636b44b

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:65b85bf8bcb6 into origin/amd-gfx:b327f5fd8354
Local branch origin/amd-gfx b327f5f Merged main:b61e3874fa97 into origin/amd-gfx:01fc438e22db Remote branch main 65b85bf [flang] Fixed driver link LIT test for PPC targets. (llvm#134320)
2 parents b327f5f + 65b85bf commit 636b44b

File tree

487 files changed

+11624
-3329
lines changed

Some content is hidden

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

487 files changed

+11624
-3329
lines changed

clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ computeReferencedDecls(const clang::Expr *Expr) {
100100
TraverseLambdaCapture(LExpr, &Capture, Initializer);
101101
}
102102

103-
if (clang::Expr *const RequiresClause =
104-
LExpr->getTrailingRequiresClause()) {
105-
TraverseStmt(RequiresClause);
103+
if (const clang::Expr *RequiresClause =
104+
LExpr->getTrailingRequiresClause().ConstraintExpr) {
105+
TraverseStmt(const_cast<clang::Expr *>(RequiresClause));
106106
}
107107

108108
for (auto *const TemplateParam : LExpr->getExplicitTemplateParameters())

clang/docs/OpenMPSupport.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ implementation.
456456
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
457457
| ref modifier for map clauses | :none:`unclaimed` | :none:`unclaimed` | |
458458
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
459-
| map-type modifiers in arbitrary position | :none:`unclaimed` | :none:`unclaimed` | |
459+
| map-type modifiers in arbitrary position | :good:`done` | :none:`unclaimed` | https://github.com/llvm/llvm-project/pull/90499 |
460460
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
461461
| Lift nesting restriction on concurrent loop | :good:`done` | :none:`unclaimed` | https://github.com/llvm/llvm-project/pull/125621 |
462462
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ Bug Fixes to C++ Support
385385
- Improved fix for an issue with pack expansions of type constraints, where this
386386
now also works if the constraint has non-type or template template parameters.
387387
(#GH131798)
388+
- Fix crash when evaluating the trailing requires clause of generic lambdas which are part of
389+
a pack expansion.
388390
- Fixes matching of nested template template parameters. (#GH130362)
389391
- Correctly diagnoses template template paramters which have a pack parameter
390392
not in the last position.

clang/include/clang/AST/ASTConcept.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "clang/AST/NestedNameSpecifier.h"
1919
#include "clang/AST/TemplateBase.h"
2020
#include "clang/Basic/SourceLocation.h"
21+
#include "clang/Basic/UnsignedOrNone.h"
2122
#include "llvm/ADT/FoldingSet.h"
2223
#include "llvm/ADT/PointerUnion.h"
2324
#include "llvm/ADT/SmallVector.h"
@@ -229,15 +230,14 @@ class TypeConstraint {
229230
/// type-constraint.
230231
Expr *ImmediatelyDeclaredConstraint = nullptr;
231232
ConceptReference *ConceptRef;
232-
int ArgumentPackSubstitutionIndex;
233+
UnsignedOrNone ArgPackSubstIndex;
233234

234235
public:
235236
TypeConstraint(ConceptReference *ConceptRef,
236237
Expr *ImmediatelyDeclaredConstraint,
237-
int ArgumentPackSubstitutionIndex)
238+
UnsignedOrNone ArgPackSubstIndex)
238239
: ImmediatelyDeclaredConstraint(ImmediatelyDeclaredConstraint),
239-
ConceptRef(ConceptRef),
240-
ArgumentPackSubstitutionIndex(ArgumentPackSubstitutionIndex) {}
240+
ConceptRef(ConceptRef), ArgPackSubstIndex(ArgPackSubstIndex) {}
241241

242242
/// \brief Get the immediately-declared constraint expression introduced by
243243
/// this type-constraint, that is - the constraint expression that is added to
@@ -248,9 +248,7 @@ class TypeConstraint {
248248

249249
ConceptReference *getConceptReference() const { return ConceptRef; }
250250

251-
int getArgumentPackSubstitutionIndex() const {
252-
return ArgumentPackSubstitutionIndex;
253-
}
251+
UnsignedOrNone getArgPackSubstIndex() const { return ArgPackSubstIndex; }
254252

255253
// FIXME: Instead of using these concept related functions the callers should
256254
// directly work with the corresponding ConceptReference.

clang/include/clang/AST/ASTContext.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,7 +1797,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
17971797

17981798
QualType getSubstTemplateTypeParmType(QualType Replacement,
17991799
Decl *AssociatedDecl, unsigned Index,
1800-
std::optional<unsigned> PackIndex,
1800+
UnsignedOrNone PackIndex,
18011801
bool Final) const;
18021802
QualType getSubstTemplateTypeParmPackType(Decl *AssociatedDecl,
18031803
unsigned Index, bool Final,
@@ -1853,8 +1853,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
18531853
/// expansion is used in a context where the arity is inferred from
18541854
/// elsewhere, such as if the pattern contains a placeholder type or
18551855
/// if this is the canonical type of another pack expansion type.
1856-
QualType getPackExpansionType(QualType Pattern,
1857-
std::optional<unsigned> NumExpansions,
1856+
QualType getPackExpansionType(QualType Pattern, UnsignedOrNone NumExpansions,
18581857
bool ExpectPackInType = true) const;
18591858

18601859
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl,
@@ -1898,7 +1897,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
18981897
QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr,
18991898
bool FullySubstituted = false,
19001899
ArrayRef<QualType> Expansions = {},
1901-
int Index = -1) const;
1900+
UnsignedOrNone Index = std::nullopt) const;
19021901

19031902
/// Unary type transforms
19041903
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType,
@@ -2396,7 +2395,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
23962395
TemplateName getSubstTemplateTemplateParm(TemplateName replacement,
23972396
Decl *AssociatedDecl,
23982397
unsigned Index,
2399-
std::optional<unsigned> PackIndex,
2398+
UnsignedOrNone PackIndex,
24002399
bool Final) const;
24012400
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack,
24022401
Decl *AssociatedDecl,
@@ -2907,6 +2906,14 @@ class ASTContext : public RefCountedBase<ASTContext> {
29072906
/// that they may be used in declarations of the same template.
29082907
bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y) const;
29092908

2909+
/// Determine whether two 'requires' expressions are similar enough that they
2910+
/// may be used in re-declarations.
2911+
///
2912+
/// Use of 'requires' isn't mandatory, works with constraints expressed in
2913+
/// other ways too.
2914+
bool isSameAssociatedConstraint(const AssociatedConstraint &ACX,
2915+
const AssociatedConstraint &ACY) const;
2916+
29102917
/// Determine whether two 'requires' expressions are similar enough that they
29112918
/// may be used in re-declarations.
29122919
///

clang/include/clang/AST/ASTImporter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ class TypeSourceInfo;
592592
/// F should be a field (or indirect field) declaration.
593593
/// \returns The index of the field in its parent context (starting from 0).
594594
/// On error `std::nullopt` is returned (parent context is non-record).
595-
static std::optional<unsigned> getFieldIndex(Decl *F);
595+
static UnsignedOrNone getFieldIndex(Decl *F);
596596
};
597597

598598
} // namespace clang

clang/include/clang/AST/ASTNodeTraverser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,8 @@ class ASTNodeTraverser
538538
for (const auto *Parameter : D->parameters())
539539
Visit(Parameter);
540540

541-
if (const Expr *TRC = D->getTrailingRequiresClause())
542-
Visit(TRC);
541+
if (const AssociatedConstraint &TRC = D->getTrailingRequiresClause())
542+
Visit(TRC.ConstraintExpr);
543543

544544
if (Traversal == TK_IgnoreUnlessSpelledInSource && D->isDefaulted())
545545
return;

clang/include/clang/AST/ASTStructuralEquivalence.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ struct StructuralEquivalenceContext {
123123
///
124124
/// FIXME: This is needed by ASTImporter and ASTStructureEquivalence. It
125125
/// probably makes more sense in some other common place then here.
126-
static std::optional<unsigned>
127-
findUntaggedStructOrUnionIndex(RecordDecl *Anon);
126+
static UnsignedOrNone findUntaggedStructOrUnionIndex(RecordDecl *Anon);
128127

129128
// If ErrorOnTagTypeMismatch is set, return the error, otherwise get the
130129
// relevant warning for the input error diagnostic.

clang/include/clang/AST/Decl.h

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "clang/Basic/PragmaKinds.h"
3434
#include "clang/Basic/SourceLocation.h"
3535
#include "clang/Basic/Specifiers.h"
36+
#include "clang/Basic/UnsignedOrNone.h"
3637
#include "clang/Basic/Visibility.h"
3738
#include "llvm/ADT/APSInt.h"
3839
#include "llvm/ADT/ArrayRef.h"
@@ -81,13 +82,18 @@ enum class ImplicitParamKind;
8182
// Holds a constraint expression along with a pack expansion index, if
8283
// expanded.
8384
struct AssociatedConstraint {
84-
const Expr *ConstraintExpr;
85-
int ArgumentPackSubstitutionIndex;
85+
const Expr *ConstraintExpr = nullptr;
86+
UnsignedOrNone ArgPackSubstIndex = std::nullopt;
87+
88+
constexpr AssociatedConstraint() = default;
8689

8790
explicit AssociatedConstraint(const Expr *ConstraintExpr,
88-
int ArgumentPackSubstitutionIndex = -1)
89-
: ConstraintExpr(ConstraintExpr),
90-
ArgumentPackSubstitutionIndex(ArgumentPackSubstitutionIndex) {}
91+
UnsignedOrNone ArgPackSubstIndex = std::nullopt)
92+
: ConstraintExpr(ConstraintExpr), ArgPackSubstIndex(ArgPackSubstIndex) {}
93+
94+
explicit operator bool() const { return ConstraintExpr != nullptr; }
95+
96+
bool isNull() const { return !operator bool(); }
9197
};
9298

9399
/// The top declaration context.
@@ -754,7 +760,7 @@ class DeclaratorDecl : public ValueDecl {
754760
// and constrained function decls.
755761
struct ExtInfo : public QualifierInfo {
756762
TypeSourceInfo *TInfo = nullptr;
757-
Expr *TrailingRequiresClause = nullptr;
763+
AssociatedConstraint TrailingRequiresClause;
758764
};
759765

760766
llvm::PointerUnion<TypeSourceInfo *, ExtInfo *> DeclInfo;
@@ -823,17 +829,12 @@ class DeclaratorDecl : public ValueDecl {
823829
/// \brief Get the constraint-expression introduced by the trailing
824830
/// requires-clause in the function/member declaration, or null if no
825831
/// requires-clause was provided.
826-
Expr *getTrailingRequiresClause() {
827-
return hasExtInfo() ? getExtInfo()->TrailingRequiresClause
828-
: nullptr;
829-
}
830-
831-
const Expr *getTrailingRequiresClause() const {
832-
return hasExtInfo() ? getExtInfo()->TrailingRequiresClause
833-
: nullptr;
832+
const AssociatedConstraint &getTrailingRequiresClause() const {
833+
static constexpr AssociatedConstraint Null;
834+
return hasExtInfo() ? getExtInfo()->TrailingRequiresClause : Null;
834835
}
835836

836-
void setTrailingRequiresClause(Expr *TrailingRequiresClause);
837+
void setTrailingRequiresClause(const AssociatedConstraint &AC);
837838

838839
unsigned getNumTemplateParameterLists() const {
839840
return hasExtInfo() ? getExtInfo()->NumTemplParamLists : 0;
@@ -2102,7 +2103,7 @@ class FunctionDecl : public DeclaratorDecl,
21022103
const DeclarationNameInfo &NameInfo, QualType T,
21032104
TypeSourceInfo *TInfo, StorageClass S, bool UsesFPIntrin,
21042105
bool isInlineSpecified, ConstexprSpecKind ConstexprKind,
2105-
Expr *TrailingRequiresClause = nullptr);
2106+
const AssociatedConstraint &TrailingRequiresClause);
21062107

21072108
using redeclarable_base = Redeclarable<FunctionDecl>;
21082109

@@ -2138,7 +2139,7 @@ class FunctionDecl : public DeclaratorDecl,
21382139
TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin = false,
21392140
bool isInlineSpecified = false, bool hasWrittenPrototype = true,
21402141
ConstexprSpecKind ConstexprKind = ConstexprSpecKind::Unspecified,
2141-
Expr *TrailingRequiresClause = nullptr) {
2142+
const AssociatedConstraint &TrailingRequiresClause = {}) {
21422143
DeclarationNameInfo NameInfo(N, NLoc);
21432144
return FunctionDecl::Create(C, DC, StartLoc, NameInfo, T, TInfo, SC,
21442145
UsesFPIntrin, isInlineSpecified,
@@ -2151,7 +2152,7 @@ class FunctionDecl : public DeclaratorDecl,
21512152
const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo,
21522153
StorageClass SC, bool UsesFPIntrin, bool isInlineSpecified,
21532154
bool hasWrittenPrototype, ConstexprSpecKind ConstexprKind,
2154-
Expr *TrailingRequiresClause);
2155+
const AssociatedConstraint &TrailingRequiresClause);
21552156

21562157
static FunctionDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
21572158

@@ -2539,7 +2540,7 @@ class FunctionDecl : public DeclaratorDecl,
25392540
/// If this function is an allocation/deallocation function that takes
25402541
/// the `std::nothrow_t` tag, return true through IsNothrow,
25412542
bool isReplaceableGlobalAllocationFunction(
2542-
std::optional<unsigned> *AlignmentParam = nullptr,
2543+
UnsignedOrNone *AlignmentParam = nullptr,
25432544
bool *IsNothrow = nullptr) const;
25442545

25452546
/// Determine if this function provides an inline implementation of a builtin.
@@ -2644,9 +2645,9 @@ class FunctionDecl : public DeclaratorDecl,
26442645
/// Use this instead of getTrailingRequiresClause for concepts APIs that
26452646
/// accept an ArrayRef of constraint expressions.
26462647
void
2647-
getAssociatedConstraints(SmallVectorImpl<AssociatedConstraint> &AC) const {
2648-
if (auto *TRC = getTrailingRequiresClause())
2649-
AC.emplace_back(TRC);
2648+
getAssociatedConstraints(SmallVectorImpl<AssociatedConstraint> &ACs) const {
2649+
if (const AssociatedConstraint &AC = getTrailingRequiresClause())
2650+
ACs.emplace_back(AC);
26502651
}
26512652

26522653
/// Get the message that indicates why this function was deleted.

clang/include/clang/AST/DeclCXX.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,7 +1974,7 @@ class CXXDeductionGuideDecl : public FunctionDecl {
19741974
const DeclarationNameInfo &NameInfo, QualType T,
19751975
TypeSourceInfo *TInfo, SourceLocation EndLocation,
19761976
CXXConstructorDecl *Ctor, DeductionCandidate Kind,
1977-
Expr *TrailingRequiresClause,
1977+
const AssociatedConstraint &TrailingRequiresClause,
19781978
const CXXDeductionGuideDecl *GeneratedFrom,
19791979
SourceDeductionGuideKind SourceKind)
19801980
: FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo,
@@ -2007,7 +2007,7 @@ class CXXDeductionGuideDecl : public FunctionDecl {
20072007
TypeSourceInfo *TInfo, SourceLocation EndLocation,
20082008
CXXConstructorDecl *Ctor = nullptr,
20092009
DeductionCandidate Kind = DeductionCandidate::Normal,
2010-
Expr *TrailingRequiresClause = nullptr,
2010+
const AssociatedConstraint &TrailingRequiresClause = {},
20112011
const CXXDeductionGuideDecl *SourceDG = nullptr,
20122012
SourceDeductionGuideKind SK = SourceDeductionGuideKind::None);
20132013

@@ -2115,7 +2115,7 @@ class CXXMethodDecl : public FunctionDecl {
21152115
QualType T, TypeSourceInfo *TInfo, StorageClass SC,
21162116
bool UsesFPIntrin, bool isInline,
21172117
ConstexprSpecKind ConstexprKind, SourceLocation EndLocation,
2118-
Expr *TrailingRequiresClause = nullptr)
2118+
const AssociatedConstraint &TrailingRequiresClause = {})
21192119
: FunctionDecl(DK, C, RD, StartLoc, NameInfo, T, TInfo, SC, UsesFPIntrin,
21202120
isInline, ConstexprKind, TrailingRequiresClause) {
21212121
if (EndLocation.isValid())
@@ -2128,7 +2128,7 @@ class CXXMethodDecl : public FunctionDecl {
21282128
const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo,
21292129
StorageClass SC, bool UsesFPIntrin, bool isInline,
21302130
ConstexprSpecKind ConstexprKind, SourceLocation EndLocation,
2131-
Expr *TrailingRequiresClause = nullptr);
2131+
const AssociatedConstraint &TrailingRequiresClause = {});
21322132

21332133
static CXXMethodDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
21342134

@@ -2596,7 +2596,7 @@ class CXXConstructorDecl final
25962596
bool UsesFPIntrin, bool isInline,
25972597
bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind,
25982598
InheritedConstructor Inherited,
2599-
Expr *TrailingRequiresClause);
2599+
const AssociatedConstraint &TrailingRequiresClause);
26002600

26012601
void anchor() override;
26022602

@@ -2639,7 +2639,7 @@ class CXXConstructorDecl final
26392639
ExplicitSpecifier ES, bool UsesFPIntrin, bool isInline,
26402640
bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind,
26412641
InheritedConstructor Inherited = InheritedConstructor(),
2642-
Expr *TrailingRequiresClause = nullptr);
2642+
const AssociatedConstraint &TrailingRequiresClause = {});
26432643

26442644
void setExplicitSpecifier(ExplicitSpecifier ES) {
26452645
assert((!ES.getExpr() ||
@@ -2859,7 +2859,7 @@ class CXXDestructorDecl : public CXXMethodDecl {
28592859
const DeclarationNameInfo &NameInfo, QualType T,
28602860
TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline,
28612861
bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind,
2862-
Expr *TrailingRequiresClause = nullptr)
2862+
const AssociatedConstraint &TrailingRequiresClause = {})
28632863
: CXXMethodDecl(CXXDestructor, C, RD, StartLoc, NameInfo, T, TInfo,
28642864
SC_None, UsesFPIntrin, isInline, ConstexprKind,
28652865
SourceLocation(), TrailingRequiresClause) {
@@ -2874,7 +2874,7 @@ class CXXDestructorDecl : public CXXMethodDecl {
28742874
const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo,
28752875
bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared,
28762876
ConstexprSpecKind ConstexprKind,
2877-
Expr *TrailingRequiresClause = nullptr);
2877+
const AssociatedConstraint &TrailingRequiresClause = {});
28782878
static CXXDestructorDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
28792879

28802880
void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg);
@@ -2925,7 +2925,7 @@ class CXXConversionDecl : public CXXMethodDecl {
29252925
TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline,
29262926
ExplicitSpecifier ES, ConstexprSpecKind ConstexprKind,
29272927
SourceLocation EndLocation,
2928-
Expr *TrailingRequiresClause = nullptr)
2928+
const AssociatedConstraint &TrailingRequiresClause = {})
29292929
: CXXMethodDecl(CXXConversion, C, RD, StartLoc, NameInfo, T, TInfo,
29302930
SC_None, UsesFPIntrin, isInline, ConstexprKind,
29312931
EndLocation, TrailingRequiresClause),
@@ -2943,7 +2943,7 @@ class CXXConversionDecl : public CXXMethodDecl {
29432943
const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo,
29442944
bool UsesFPIntrin, bool isInline, ExplicitSpecifier ES,
29452945
ConstexprSpecKind ConstexprKind, SourceLocation EndLocation,
2946-
Expr *TrailingRequiresClause = nullptr);
2946+
const AssociatedConstraint &TrailingRequiresClause = {});
29472947
static CXXConversionDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
29482948

29492949
ExplicitSpecifier getExplicitSpecifier() {

0 commit comments

Comments
 (0)