Skip to content

Commit c5f15c0

Browse files
authored
Merge branch 'main' into loop-define-bitconvert
2 parents e2a7288 + f68a518 commit c5f15c0

File tree

582 files changed

+19494
-12131
lines changed

Some content is hidden

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

582 files changed

+19494
-12131
lines changed

clang/bindings/python/tests/cindex/test_diagnostics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def test_diagnostic_category(self):
7979
self.assertEqual(d.location.line, 1)
8080
self.assertEqual(d.location.column, 11)
8181

82-
self.assertEqual(d.category_number, 2)
82+
self.assertEqual(d.category_number, 3)
8383
self.assertEqual(d.category_name, "Semantic Issue")
8484

8585
def test_diagnostic_option(self):
@@ -123,7 +123,7 @@ def test_diagnostic_string_format(self):
123123
self.assertEqual(str(d), "t.c:1:26: error: expected ';' after struct")
124124
self.assertEqual(
125125
d.format(0b111111),
126-
"t.c:1:26: error: expected ';' after struct [3, Parse Issue]",
126+
"t.c:1:26: error: expected ';' after struct [2, Parse Issue]",
127127
)
128128
with self.assertRaises(ValueError):
129129
d.format(0b1000000)

clang/docs/ReleaseNotes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,15 @@ C23 Feature Support
159159
which clarified that a compound literal used within a function prototype is
160160
treated as if the compound literal were within the body rather than at file
161161
scope.
162+
- Fixed a bug where you could not cast a null pointer constant to type
163+
``nullptr_t``. Fixes #GH133644.
162164

163165
Non-comprehensive list of changes in this release
164166
-------------------------------------------------
165167

166168
- Support parsing the `cc` operand modifier and alias it to the `c` modifier (#GH127719).
167169
- Added `__builtin_elementwise_exp10`.
170+
- For AMDPGU targets, added `__builtin_v_cvt_off_f32_i4` that maps to the `v_cvt_off_f32_i4` instruction.
168171

169172
New Compiler Flags
170173
------------------
@@ -187,6 +190,8 @@ Modified Compiler Flags
187190

188191
- The compiler flag `-fbracket-depth` default value is increased from 256 to 2048. (#GH94728)
189192

193+
- `-Wpadded` option implemented for the `x86_64-windows-msvc` target. Fixes #61702
194+
190195
Removed Compiler Flags
191196
-------------------------
192197

@@ -311,6 +316,8 @@ Improvements to Clang's diagnostics
311316
312317
Fixes #GH61635
313318

319+
- Split diagnosing base class qualifiers from the ``-Wignored-Qualifiers`` diagnostic group into a new ``-Wignored-base-class-qualifiers`` diagnostic group (which is grouped under ``-Wignored-qualifiers``). Fixes #GH131935.
320+
314321
Improvements to Clang's time-trace
315322
----------------------------------
316323

@@ -337,6 +344,9 @@ Bug Fixes in This Version
337344
- Fixed a problematic case with recursive deserialization within ``FinishedDeserializing()`` where
338345
``PassInterestingDeclsToConsumer()`` was called before the declarations were safe to be passed. (#GH129982)
339346
- Fixed a modules crash where an explicit Constructor was deserialized. (#GH132794)
347+
- Defining an integer literal suffix (e.g., ``LL``) before including
348+
``<stdint.h>`` in a freestanding build no longer causes invalid token pasting
349+
when using the ``INTn_C`` macros. (#GH85995)
340350

341351
Bug Fixes to Compiler Builtins
342352
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/ASTContext.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,10 +1795,10 @@ class ASTContext : public RefCountedBase<ASTContext> {
17951795
QualType Wrapped, QualType Contained,
17961796
const HLSLAttributedResourceType::Attributes &Attrs);
17971797

1798-
QualType
1799-
getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl,
1800-
unsigned Index,
1801-
std::optional<unsigned> PackIndex) const;
1798+
QualType getSubstTemplateTypeParmType(QualType Replacement,
1799+
Decl *AssociatedDecl, unsigned Index,
1800+
std::optional<unsigned> PackIndex,
1801+
bool Final) const;
18021802
QualType getSubstTemplateTypeParmPackType(Decl *AssociatedDecl,
18031803
unsigned Index, bool Final,
18041804
const TemplateArgument &ArgPack);
@@ -2393,10 +2393,11 @@ class ASTContext : public RefCountedBase<ASTContext> {
23932393
TemplateName
23942394
getDependentTemplateName(const DependentTemplateStorage &Name) const;
23952395

2396-
TemplateName
2397-
getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl,
2398-
unsigned Index,
2399-
std::optional<unsigned> PackIndex) const;
2396+
TemplateName getSubstTemplateTemplateParm(TemplateName replacement,
2397+
Decl *AssociatedDecl,
2398+
unsigned Index,
2399+
std::optional<unsigned> PackIndex,
2400+
bool Final) const;
24002401
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack,
24012402
Decl *AssociatedDecl,
24022403
unsigned Index,

clang/include/clang/AST/DeclCXX.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2852,6 +2852,7 @@ class CXXDestructorDecl : public CXXMethodDecl {
28522852
// FIXME: Don't allocate storage for these except in the first declaration
28532853
// of a virtual destructor.
28542854
FunctionDecl *OperatorDelete = nullptr;
2855+
FunctionDecl *OperatorArrayDelete = nullptr;
28552856
Expr *OperatorDeleteThisArg = nullptr;
28562857

28572858
CXXDestructorDecl(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
@@ -2877,11 +2878,16 @@ class CXXDestructorDecl : public CXXMethodDecl {
28772878
static CXXDestructorDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
28782879

28792880
void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg);
2881+
void setOperatorArrayDelete(FunctionDecl *OD, Expr *ThisArg);
28802882

28812883
const FunctionDecl *getOperatorDelete() const {
28822884
return getCanonicalDecl()->OperatorDelete;
28832885
}
28842886

2887+
const FunctionDecl *getArrayOperatorDelete() const {
2888+
return getCanonicalDecl()->OperatorArrayDelete;
2889+
}
2890+
28852891
Expr *getOperatorDeleteThisArg() const {
28862892
return getCanonicalDecl()->OperatorDeleteThisArg;
28872893
}

clang/include/clang/AST/ExprCXX.h

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4514,7 +4514,9 @@ class SubstNonTypeTemplateParmExpr : public Expr {
45144514
llvm::PointerIntPair<Decl *, 1, bool> AssociatedDeclAndRef;
45154515

45164516
unsigned Index : 15;
4517-
unsigned PackIndex : 16;
4517+
unsigned PackIndex : 15;
4518+
LLVM_PREFERRED_TYPE(bool)
4519+
unsigned Final : 1;
45184520

45194521
explicit SubstNonTypeTemplateParmExpr(EmptyShell Empty)
45204522
: Expr(SubstNonTypeTemplateParmExprClass, Empty) {}
@@ -4523,11 +4525,12 @@ class SubstNonTypeTemplateParmExpr : public Expr {
45234525
SubstNonTypeTemplateParmExpr(QualType Ty, ExprValueKind ValueKind,
45244526
SourceLocation Loc, Expr *Replacement,
45254527
Decl *AssociatedDecl, unsigned Index,
4526-
std::optional<unsigned> PackIndex, bool RefParam)
4528+
std::optional<unsigned> PackIndex, bool RefParam,
4529+
bool Final)
45274530
: Expr(SubstNonTypeTemplateParmExprClass, Ty, ValueKind, OK_Ordinary),
45284531
Replacement(Replacement),
45294532
AssociatedDeclAndRef(AssociatedDecl, RefParam), Index(Index),
4530-
PackIndex(PackIndex ? *PackIndex + 1 : 0) {
4533+
PackIndex(PackIndex ? *PackIndex + 1 : 0), Final(Final) {
45314534
assert(AssociatedDecl != nullptr);
45324535
SubstNonTypeTemplateParmExprBits.NameLoc = Loc;
45334536
setDependence(computeDependence(this));
@@ -4555,6 +4558,10 @@ class SubstNonTypeTemplateParmExpr : public Expr {
45554558
return PackIndex - 1;
45564559
}
45574560

4561+
// This substitution is Final, which means the substitution is fully
4562+
// sugared: it doesn't need to be resugared later.
4563+
bool getFinal() const { return Final; }
4564+
45584565
NonTypeTemplateParmDecl *getParameter() const;
45594566

45604567
bool isReferenceParameter() const { return AssociatedDeclAndRef.getInt(); }
@@ -4598,7 +4605,10 @@ class SubstNonTypeTemplateParmPackExpr : public Expr {
45984605
const TemplateArgument *Arguments;
45994606

46004607
/// The number of template arguments in \c Arguments.
4601-
unsigned NumArguments : 16;
4608+
unsigned NumArguments : 15;
4609+
4610+
LLVM_PREFERRED_TYPE(bool)
4611+
unsigned Final : 1;
46024612

46034613
unsigned Index : 16;
46044614

@@ -4612,7 +4622,8 @@ class SubstNonTypeTemplateParmPackExpr : public Expr {
46124622
SubstNonTypeTemplateParmPackExpr(QualType T, ExprValueKind ValueKind,
46134623
SourceLocation NameLoc,
46144624
const TemplateArgument &ArgPack,
4615-
Decl *AssociatedDecl, unsigned Index);
4625+
Decl *AssociatedDecl, unsigned Index,
4626+
bool Final);
46164627

46174628
/// A template-like entity which owns the whole pattern being substituted.
46184629
/// This will own a set of template parameters.
@@ -4622,6 +4633,10 @@ class SubstNonTypeTemplateParmPackExpr : public Expr {
46224633
/// This should match the result of `getParameterPack()->getIndex()`.
46234634
unsigned getIndex() const { return Index; }
46244635

4636+
// This substitution will be Final, which means the substitution will be fully
4637+
// sugared: it doesn't need to be resugared later.
4638+
bool getFinal() const { return Final; }
4639+
46254640
/// Retrieve the non-type template parameter pack being substituted.
46264641
NonTypeTemplateParmDecl *getParameterPack() const;
46274642

clang/include/clang/AST/PropertiesBase.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,9 @@ let Class = PropertyTypeCase<TemplateName, "SubstTemplateTemplateParm"> in {
730730
def : Property<"packIndex", Optional<UInt32>> {
731731
let Read = [{ parm->getPackIndex() }];
732732
}
733+
def : Property<"final", Bool> { let Read = [{ parm->getFinal() }]; }
733734
def : Creator<[{
734-
return ctx.getSubstTemplateTemplateParm(replacement, associatedDecl, index, packIndex);
735+
return ctx.getSubstTemplateTemplateParm(replacement, associatedDecl, index, packIndex, final);
735736
}]>;
736737
}
737738
let Class = PropertyTypeCase<TemplateName, "SubstTemplateTemplateParmPack"> in {

clang/include/clang/AST/StmtOpenACC.h

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -829,24 +829,42 @@ class OpenACCUpdateConstruct final
829829

830830
// This class represents the 'atomic' construct, which has an associated
831831
// statement, but no clauses.
832-
class OpenACCAtomicConstruct final : public OpenACCAssociatedStmtConstruct {
832+
class OpenACCAtomicConstruct final
833+
: public OpenACCAssociatedStmtConstruct,
834+
private llvm::TrailingObjects<OpenACCAtomicConstruct,
835+
const OpenACCClause *> {
833836

834837
friend class ASTStmtReader;
838+
friend TrailingObjects;
835839
OpenACCAtomicKind AtomicKind = OpenACCAtomicKind::None;
836840

837-
OpenACCAtomicConstruct(EmptyShell)
841+
OpenACCAtomicConstruct(unsigned NumClauses)
838842
: OpenACCAssociatedStmtConstruct(
839843
OpenACCAtomicConstructClass, OpenACCDirectiveKind::Atomic,
840844
SourceLocation{}, SourceLocation{}, SourceLocation{},
841-
/*AssociatedStmt=*/nullptr) {}
845+
/*AssociatedStmt=*/nullptr) {
846+
std::uninitialized_value_construct(
847+
getTrailingObjects<const OpenACCClause *>(),
848+
getTrailingObjects<const OpenACCClause *>() + NumClauses);
849+
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
850+
NumClauses));
851+
}
842852

843853
OpenACCAtomicConstruct(SourceLocation Start, SourceLocation DirectiveLoc,
844854
OpenACCAtomicKind AtKind, SourceLocation End,
855+
ArrayRef<const OpenACCClause *> Clauses,
845856
Stmt *AssociatedStmt)
846857
: OpenACCAssociatedStmtConstruct(OpenACCAtomicConstructClass,
847858
OpenACCDirectiveKind::Atomic, Start,
848859
DirectiveLoc, End, AssociatedStmt),
849-
AtomicKind(AtKind) {}
860+
AtomicKind(AtKind) {
861+
// Initialize the trailing storage.
862+
std::uninitialized_copy(Clauses.begin(), Clauses.end(),
863+
getTrailingObjects<const OpenACCClause *>());
864+
865+
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
866+
Clauses.size()));
867+
}
850868

851869
void setAssociatedStmt(Stmt *S) {
852870
OpenACCAssociatedStmtConstruct::setAssociatedStmt(S);
@@ -857,10 +875,12 @@ class OpenACCAtomicConstruct final : public OpenACCAssociatedStmtConstruct {
857875
return T->getStmtClass() == OpenACCAtomicConstructClass;
858876
}
859877

860-
static OpenACCAtomicConstruct *CreateEmpty(const ASTContext &C);
878+
static OpenACCAtomicConstruct *CreateEmpty(const ASTContext &C,
879+
unsigned NumClauses);
861880
static OpenACCAtomicConstruct *
862881
Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
863-
OpenACCAtomicKind AtKind, SourceLocation End, Stmt *AssociatedStmt);
882+
OpenACCAtomicKind AtKind, SourceLocation End,
883+
ArrayRef<const OpenACCClause *> Clauses, Stmt *AssociatedStmt);
864884

865885
OpenACCAtomicKind getAtomicKind() const { return AtomicKind; }
866886
const Stmt *getAssociatedStmt() const {

clang/include/clang/AST/TemplateName.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,11 @@ class SubstTemplateTemplateParmStorage
414414

415415
SubstTemplateTemplateParmStorage(TemplateName Replacement,
416416
Decl *AssociatedDecl, unsigned Index,
417-
std::optional<unsigned> PackIndex)
417+
std::optional<unsigned> PackIndex,
418+
bool Final)
418419
: UncommonTemplateNameStorage(SubstTemplateTemplateParm, Index,
419-
PackIndex ? *PackIndex + 1 : 0),
420+
((PackIndex ? *PackIndex + 1 : 0) << 1) |
421+
Final),
420422
Replacement(Replacement), AssociatedDecl(AssociatedDecl) {
421423
assert(AssociatedDecl != nullptr);
422424
}
@@ -430,10 +432,15 @@ class SubstTemplateTemplateParmStorage
430432
/// This should match the result of `getParameter()->getIndex()`.
431433
unsigned getIndex() const { return Bits.Index; }
432434

435+
// This substitution is Final, which means the substitution is fully
436+
// sugared: it doesn't need to be resugared later.
437+
bool getFinal() const { return Bits.Data & 1; }
438+
433439
std::optional<unsigned> getPackIndex() const {
434-
if (Bits.Data == 0)
440+
auto Data = Bits.Data >> 1;
441+
if (Data == 0)
435442
return std::nullopt;
436-
return Bits.Data - 1;
443+
return Data - 1;
437444
}
438445

439446
TemplateTemplateParmDecl *getParameter() const;
@@ -443,7 +450,7 @@ class SubstTemplateTemplateParmStorage
443450

444451
static void Profile(llvm::FoldingSetNodeID &ID, TemplateName Replacement,
445452
Decl *AssociatedDecl, unsigned Index,
446-
std::optional<unsigned> PackIndex);
453+
std::optional<unsigned> PackIndex, bool Final);
447454
};
448455

449456
class DeducedTemplateStorage : public UncommonTemplateNameStorage,

clang/include/clang/AST/Type.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,12 +2158,15 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
21582158
// The index of the template parameter this substitution represents.
21592159
unsigned Index : 15;
21602160

2161+
LLVM_PREFERRED_TYPE(bool)
2162+
unsigned Final : 1;
2163+
21612164
/// Represents the index within a pack if this represents a substitution
21622165
/// from a pack expansion. This index starts at the end of the pack and
21632166
/// increments towards the beginning.
21642167
/// Positive non-zero number represents the index + 1.
21652168
/// Zero means this is not substituted from an expansion.
2166-
unsigned PackIndex : 16;
2169+
unsigned PackIndex : 15;
21672170
};
21682171

21692172
class SubstTemplateTypeParmPackTypeBitfields {
@@ -6397,7 +6400,8 @@ class SubstTemplateTypeParmType final
63976400
Decl *AssociatedDecl;
63986401

63996402
SubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl,
6400-
unsigned Index, std::optional<unsigned> PackIndex);
6403+
unsigned Index, std::optional<unsigned> PackIndex,
6404+
bool Final);
64016405

64026406
public:
64036407
/// Gets the type that was substituted for the template
@@ -6420,6 +6424,10 @@ class SubstTemplateTypeParmType final
64206424
/// This should match the result of `getReplacedParameter()->getIndex()`.
64216425
unsigned getIndex() const { return SubstTemplateTypeParmTypeBits.Index; }
64226426

6427+
// This substitution is Final, which means the substitution is fully
6428+
// sugared: it doesn't need to be resugared later.
6429+
unsigned getFinal() const { return SubstTemplateTypeParmTypeBits.Final; }
6430+
64236431
std::optional<unsigned> getPackIndex() const {
64246432
if (SubstTemplateTypeParmTypeBits.PackIndex == 0)
64256433
return std::nullopt;
@@ -6431,17 +6439,12 @@ class SubstTemplateTypeParmType final
64316439

64326440
void Profile(llvm::FoldingSetNodeID &ID) {
64336441
Profile(ID, getReplacementType(), getAssociatedDecl(), getIndex(),
6434-
getPackIndex());
6442+
getPackIndex(), getFinal());
64356443
}
64366444

64376445
static void Profile(llvm::FoldingSetNodeID &ID, QualType Replacement,
64386446
const Decl *AssociatedDecl, unsigned Index,
6439-
std::optional<unsigned> PackIndex) {
6440-
Replacement.Profile(ID);
6441-
ID.AddPointer(AssociatedDecl);
6442-
ID.AddInteger(Index);
6443-
ID.AddInteger(PackIndex ? *PackIndex - 1 : 0);
6444-
}
6447+
std::optional<unsigned> PackIndex, bool Final);
64456448

64466449
static bool classof(const Type *T) {
64476450
return T->getTypeClass() == SubstTemplateTypeParm;
@@ -6488,7 +6491,8 @@ class SubstTemplateTypeParmPackType : public Type, public llvm::FoldingSetNode {
64886491
/// This should match the result of `getReplacedParameter()->getIndex()`.
64896492
unsigned getIndex() const { return SubstTemplateTypeParmPackTypeBits.Index; }
64906493

6491-
// When true the substitution will be 'Final' (subst node won't be placed).
6494+
// This substitution will be Final, which means the substitution will be fully
6495+
// sugared: it doesn't need to be resugared later.
64926496
bool getFinal() const;
64936497

64946498
unsigned getNumArgs() const {

clang/include/clang/AST/TypeProperties.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,11 +842,11 @@ let Class = SubstTemplateTypeParmType in {
842842
def : Property<"PackIndex", Optional<UInt32>> {
843843
let Read = [{ node->getPackIndex() }];
844844
}
845+
def : Property<"Final", Bool> { let Read = [{ node->getFinal() }]; }
845846

846-
// The call to getCanonicalType here existed in ASTReader.cpp, too.
847847
def : Creator<[{
848848
return ctx.getSubstTemplateTypeParmType(
849-
replacementType, associatedDecl, Index, PackIndex);
849+
replacementType, associatedDecl, Index, PackIndex, Final);
850850
}]>;
851851
}
852852

0 commit comments

Comments
 (0)