Skip to content

Commit 7864b11

Browse files
Merge branch 'llvm:main' into gh-101657
2 parents 70f63f0 + f81f47e commit 7864b11

File tree

71 files changed

+2661
-1320
lines changed

Some content is hidden

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

71 files changed

+2661
-1320
lines changed

clang/docs/ClangFormat.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
3333
Clang-format options:
3434
3535
--Werror - If set, changes formatting warnings to errors
36-
--Wno-error=<value> - If set don't error out on the specified warning type.
36+
--Wno-error=<value> - If set, don't error out on the specified warning type.
3737
=unknown - If set, unknown format options are only warned about.
3838
This can be used to enable formatting, even if the
3939
configuration contains unknown (newer) options.

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,8 @@ Attribute Changes in Clang
471471
- Clang now supports ``[[clang::lifetime_capture_by(X)]]``. Similar to lifetimebound, this can be
472472
used to specify when a reference to a function parameter is captured by another capturing entity ``X``.
473473

474+
- The ``target_version`` attribute is now only supported for AArch64 and RISC-V architectures.
475+
474476
Improvements to Clang's diagnostics
475477
-----------------------------------
476478

@@ -714,6 +716,7 @@ Bug Fixes to C++ Support
714716
assumption if they also occur inside of a dependent lambda. (#GH114787)
715717
- Clang now uses valid deduced type locations when diagnosing functions with trailing return type
716718
missing placeholder return type. (#GH78694)
719+
- Fixed a bug where bounds of partially expanded pack indexing expressions were checked too early. (#GH116105)
717720

718721
Bug Fixes to AST Handling
719722
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/ExprCXX.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4390,17 +4390,17 @@ class PackIndexingExpr final
43904390
unsigned TransformedExpressions : 31;
43914391

43924392
LLVM_PREFERRED_TYPE(bool)
4393-
unsigned ExpandedToEmptyPack : 1;
4393+
unsigned FullySubstituted : 1;
43944394

43954395
PackIndexingExpr(QualType Type, SourceLocation EllipsisLoc,
43964396
SourceLocation RSquareLoc, Expr *PackIdExpr, Expr *IndexExpr,
43974397
ArrayRef<Expr *> SubstitutedExprs = {},
4398-
bool ExpandedToEmptyPack = false)
4398+
bool FullySubstituted = false)
43994399
: Expr(PackIndexingExprClass, Type, VK_LValue, OK_Ordinary),
44004400
EllipsisLoc(EllipsisLoc), RSquareLoc(RSquareLoc),
44014401
SubExprs{PackIdExpr, IndexExpr},
44024402
TransformedExpressions(SubstitutedExprs.size()),
4403-
ExpandedToEmptyPack(ExpandedToEmptyPack) {
4403+
FullySubstituted(FullySubstituted) {
44044404

44054405
auto *Exprs = getTrailingObjects<Expr *>();
44064406
std::uninitialized_copy(SubstitutedExprs.begin(), SubstitutedExprs.end(),
@@ -4424,12 +4424,16 @@ class PackIndexingExpr final
44244424
SourceLocation RSquareLoc, Expr *PackIdExpr,
44254425
Expr *IndexExpr, std::optional<int64_t> Index,
44264426
ArrayRef<Expr *> SubstitutedExprs = {},
4427-
bool ExpandedToEmptyPack = false);
4427+
bool FullySubstituted = false);
44284428
static PackIndexingExpr *CreateDeserialized(ASTContext &Context,
44294429
unsigned NumTransformedExprs);
44304430

4431+
bool isFullySubstituted() const { return FullySubstituted; }
4432+
44314433
/// Determine if the expression was expanded to empty.
4432-
bool expandsToEmptyPack() const { return ExpandedToEmptyPack; }
4434+
bool expandsToEmptyPack() const {
4435+
return isFullySubstituted() && TransformedExpressions == 0;
4436+
}
44334437

44344438
/// Determine the location of the 'sizeof' keyword.
44354439
SourceLocation getEllipsisLoc() const { return EllipsisLoc; }

clang/include/clang/AST/Type.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5922,12 +5922,12 @@ class PackIndexingType final
59225922
unsigned Size : 31;
59235923

59245924
LLVM_PREFERRED_TYPE(bool)
5925-
unsigned ExpandsToEmptyPack : 1;
5925+
unsigned FullySubstituted : 1;
59265926

59275927
protected:
59285928
friend class ASTContext; // ASTContext creates these.
59295929
PackIndexingType(const ASTContext &Context, QualType Canonical,
5930-
QualType Pattern, Expr *IndexExpr, bool ExpandsToEmptyPack,
5930+
QualType Pattern, Expr *IndexExpr, bool FullySubstituted,
59315931
ArrayRef<QualType> Expansions = {});
59325932

59335933
public:
@@ -5951,7 +5951,9 @@ class PackIndexingType final
59515951

59525952
bool hasSelectedType() const { return getSelectedIndex() != std::nullopt; }
59535953

5954-
bool expandsToEmptyPack() const { return ExpandsToEmptyPack; }
5954+
bool isFullySubstituted() const { return FullySubstituted; }
5955+
5956+
bool expandsToEmptyPack() const { return isFullySubstituted() && Size == 0; }
59555957

59565958
ArrayRef<QualType> getExpansions() const {
59575959
return {getExpansionsPtr(), Size};
@@ -5965,10 +5967,10 @@ class PackIndexingType final
59655967
if (hasSelectedType())
59665968
getSelectedType().Profile(ID);
59675969
else
5968-
Profile(ID, Context, getPattern(), getIndexExpr(), expandsToEmptyPack());
5970+
Profile(ID, Context, getPattern(), getIndexExpr(), isFullySubstituted());
59695971
}
59705972
static void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
5971-
QualType Pattern, Expr *E, bool ExpandsToEmptyPack);
5973+
QualType Pattern, Expr *E, bool FullySubstituted);
59725974

59735975
private:
59745976
const QualType *getExpansionsPtr() const {

clang/include/clang/AST/TypeProperties.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,12 +473,12 @@ let Class = PackIndexingType in {
473473
def : Property<"indexExpression", ExprRef> {
474474
let Read = [{ node->getIndexExpr() }];
475475
}
476-
def : Property<"expandsToEmptyPack", Bool> {
477-
let Read = [{ node->expandsToEmptyPack() }];
476+
def : Property<"isFullySubstituted", Bool> {
477+
let Read = [{ node->isFullySubstituted() }];
478478
}
479479

480480
def : Creator<[{
481-
return ctx.getPackIndexingType(pattern, indexExpression, expandsToEmptyPack);
481+
return ctx.getPackIndexingType(pattern, indexExpression, isFullySubstituted);
482482
}]>;
483483
}
484484

clang/include/clang/Basic/Attr.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3297,7 +3297,7 @@ def Target : InheritableAttr {
32973297
}];
32983298
}
32993299

3300-
def TargetVersion : InheritableAttr {
3300+
def TargetVersion : InheritableAttr, TargetSpecificAttr<TargetArch<!listconcat(TargetAArch64.Arches, TargetRISCV.Arches)>> {
33013301
let Spellings = [GCC<"target_version">];
33023302
let Args = [StringArgument<"NamesStr">];
33033303
let Subjects = SubjectList<[Function], ErrorDiag>;

clang/include/clang/Format/Format.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4970,12 +4970,11 @@ struct FormatStyle {
49704970
/// \version 12
49714971
std::vector<std::string> StatementAttributeLikeMacros;
49724972

4973-
/// A vector of macros that should be interpreted as complete
4974-
/// statements.
4973+
/// A vector of macros that should be interpreted as complete statements.
49754974
///
4976-
/// Typical macros are expressions, and require a semi-colon to be
4977-
/// added; sometimes this is not the case, and this allows to make
4978-
/// clang-format aware of such cases.
4975+
/// Typical macros are expressions and require a semicolon to be added.
4976+
/// Sometimes this is not the case, and this allows to make clang-format aware
4977+
/// of such cases.
49794978
///
49804979
/// For example: Q_UNUSED
49814980
/// \version 8

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14257,7 +14257,7 @@ class Sema final : public SemaBase {
1425714257
SourceLocation EllipsisLoc, Expr *IndexExpr,
1425814258
SourceLocation RSquareLoc,
1425914259
ArrayRef<Expr *> ExpandedExprs = {},
14260-
bool EmptyPack = false);
14260+
bool FullySubstituted = false);
1426114261

1426214262
/// Handle a C++1z fold-expression: ( expr op ... op expr ).
1426314263
ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS,

clang/lib/AST/ASTContext.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6223,13 +6223,11 @@ QualType ASTContext::getPackIndexingType(QualType Pattern, Expr *IndexExpr,
62236223
ArrayRef<QualType> Expansions,
62246224
int Index) const {
62256225
QualType Canonical;
6226-
bool ExpandsToEmptyPack = FullySubstituted && Expansions.empty();
62276226
if (FullySubstituted && Index != -1) {
62286227
Canonical = getCanonicalType(Expansions[Index]);
62296228
} else {
62306229
llvm::FoldingSetNodeID ID;
6231-
PackIndexingType::Profile(ID, *this, Pattern, IndexExpr,
6232-
ExpandsToEmptyPack);
6230+
PackIndexingType::Profile(ID, *this, Pattern, IndexExpr, FullySubstituted);
62336231
void *InsertPos = nullptr;
62346232
PackIndexingType *Canon =
62356233
DependentPackIndexingTypes.FindNodeOrInsertPos(ID, InsertPos);
@@ -6238,7 +6236,7 @@ QualType ASTContext::getPackIndexingType(QualType Pattern, Expr *IndexExpr,
62386236
PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
62396237
TypeAlignment);
62406238
Canon = new (Mem) PackIndexingType(*this, QualType(), Pattern, IndexExpr,
6241-
ExpandsToEmptyPack, Expansions);
6239+
FullySubstituted, Expansions);
62426240
DependentPackIndexingTypes.InsertNode(Canon, InsertPos);
62436241
}
62446242
Canonical = QualType(Canon, 0);
@@ -6248,7 +6246,7 @@ QualType ASTContext::getPackIndexingType(QualType Pattern, Expr *IndexExpr,
62486246
Allocate(PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
62496247
TypeAlignment);
62506248
auto *T = new (Mem) PackIndexingType(*this, Canonical, Pattern, IndexExpr,
6251-
ExpandsToEmptyPack, Expansions);
6249+
FullySubstituted, Expansions);
62526250
Types.push_back(T);
62536251
return QualType(T, 0);
62546252
}

clang/lib/AST/ComputeDependence.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,8 @@ ExprDependence clang::computeDependence(PackIndexingExpr *E) {
388388
ExprDependence::Instantiation;
389389

390390
ArrayRef<Expr *> Exprs = E->getExpressions();
391-
if (Exprs.empty())
391+
if (Exprs.empty() || !E->isFullySubstituted())
392392
D |= PatternDep | ExprDependence::Instantiation;
393-
394393
else if (!E->getIndexExpr()->isInstantiationDependent()) {
395394
std::optional<unsigned> Index = E->getSelectedIndex();
396395
assert(Index && *Index < Exprs.size() && "pack index out of bound");

0 commit comments

Comments
 (0)