Skip to content

Commit b42241c

Browse files
committed
merge main into amd-staging
Change-Id: I11b555d784103812cb86fd7c2b795a6cd49be8bd
2 parents 3d08764 + fef6613 commit b42241c

File tree

244 files changed

+8344
-2987
lines changed

Some content is hidden

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

244 files changed

+8344
-2987
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ C++ Specific Potentially Breaking Changes
140140
unsigned operator""_udl_name(unsigned long long);
141141

142142
- Clang will now produce an error diagnostic when [[clang::lifetimebound]] is
143-
applied on a parameter of a function that returns void. This was previously
144-
ignored and had no effect. (#GH107556)
143+
applied on a parameter or an implicit object parameter of a function that
144+
returns void. This was previously ignored and had no effect. (#GH107556)
145145

146146
.. code-block:: c++
147147

clang/include/clang/AST/ASTContext.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1747,7 +1747,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
17471747
QualType
17481748
getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl,
17491749
unsigned Index,
1750-
std::optional<unsigned> PackIndex) const;
1750+
std::optional<unsigned> PackIndex,
1751+
SubstTemplateTypeParmTypeFlag Flag =
1752+
SubstTemplateTypeParmTypeFlag::None) const;
17511753
QualType getSubstTemplateTypeParmPackType(Decl *AssociatedDecl,
17521754
unsigned Index, bool Final,
17531755
const TemplateArgument &ArgPack);

clang/include/clang/AST/PropertiesBase.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def Selector : PropertyType;
137137
def SourceLocation : PropertyType;
138138
def StmtRef : RefPropertyType<"Stmt"> { let ConstWhenWriting = 1; }
139139
def ExprRef : SubclassPropertyType<"Expr", StmtRef>;
140+
def SubstTemplateTypeParmTypeFlag : EnumPropertyType;
140141
def TemplateArgument : PropertyType;
141142
def TemplateArgumentKind : EnumPropertyType<"TemplateArgument::ArgKind">;
142143
def TemplateName : DefaultValuePropertyType;

clang/include/clang/AST/Type.h

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,6 +1802,15 @@ enum class AutoTypeKeyword {
18021802
GNUAutoType
18031803
};
18041804

1805+
enum class SubstTemplateTypeParmTypeFlag {
1806+
None,
1807+
1808+
/// Whether to expand the pack using the stored PackIndex in place. This is
1809+
/// useful for e.g. substituting into an atomic constraint expression, where
1810+
/// that expression is part of an unexpanded pack.
1811+
ExpandPacksInPlace,
1812+
};
1813+
18051814
enum class ArraySizeModifier;
18061815
enum class ElaboratedTypeKeyword;
18071816
enum class VectorKind;
@@ -2171,6 +2180,9 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
21712180
LLVM_PREFERRED_TYPE(bool)
21722181
unsigned HasNonCanonicalUnderlyingType : 1;
21732182

2183+
LLVM_PREFERRED_TYPE(SubstTemplateTypeParmTypeFlag)
2184+
unsigned SubstitutionFlag : 1;
2185+
21742186
// The index of the template parameter this substitution represents.
21752187
unsigned Index : 15;
21762188

@@ -6387,7 +6399,8 @@ class SubstTemplateTypeParmType final
63876399
Decl *AssociatedDecl;
63886400

63896401
SubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl,
6390-
unsigned Index, std::optional<unsigned> PackIndex);
6402+
unsigned Index, std::optional<unsigned> PackIndex,
6403+
SubstTemplateTypeParmTypeFlag Flag);
63916404

63926405
public:
63936406
/// Gets the type that was substituted for the template
@@ -6416,21 +6429,31 @@ class SubstTemplateTypeParmType final
64166429
return SubstTemplateTypeParmTypeBits.PackIndex - 1;
64176430
}
64186431

6432+
SubstTemplateTypeParmTypeFlag getSubstitutionFlag() const {
6433+
return static_cast<SubstTemplateTypeParmTypeFlag>(
6434+
SubstTemplateTypeParmTypeBits.SubstitutionFlag);
6435+
}
6436+
64196437
bool isSugared() const { return true; }
64206438
QualType desugar() const { return getReplacementType(); }
64216439

64226440
void Profile(llvm::FoldingSetNodeID &ID) {
64236441
Profile(ID, getReplacementType(), getAssociatedDecl(), getIndex(),
6424-
getPackIndex());
6442+
getPackIndex(), getSubstitutionFlag());
64256443
}
64266444

64276445
static void Profile(llvm::FoldingSetNodeID &ID, QualType Replacement,
64286446
const Decl *AssociatedDecl, unsigned Index,
6429-
std::optional<unsigned> PackIndex) {
6447+
std::optional<unsigned> PackIndex,
6448+
SubstTemplateTypeParmTypeFlag Flag) {
64306449
Replacement.Profile(ID);
64316450
ID.AddPointer(AssociatedDecl);
64326451
ID.AddInteger(Index);
64336452
ID.AddInteger(PackIndex ? *PackIndex - 1 : 0);
6453+
ID.AddInteger(llvm::to_underlying(Flag));
6454+
assert((Flag != SubstTemplateTypeParmTypeFlag::ExpandPacksInPlace ||
6455+
PackIndex) &&
6456+
"ExpandPacksInPlace needs a valid PackIndex");
64346457
}
64356458

64366459
static bool classof(const Type *T) {

clang/include/clang/AST/TypeProperties.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,11 +824,14 @@ let Class = SubstTemplateTypeParmType in {
824824
def : Property<"PackIndex", Optional<UInt32>> {
825825
let Read = [{ node->getPackIndex() }];
826826
}
827+
def : Property<"SubstitutionFlag", SubstTemplateTypeParmTypeFlag> {
828+
let Read = [{ node->getSubstitutionFlag() }];
829+
}
827830

828831
// The call to getCanonicalType here existed in ASTReader.cpp, too.
829832
def : Creator<[{
830833
return ctx.getSubstTemplateTypeParmType(
831-
replacementType, associatedDecl, Index, PackIndex);
834+
replacementType, associatedDecl, Index, PackIndex, SubstitutionFlag);
832835
}]>;
833836
}
834837

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10103,9 +10103,12 @@ def err_lifetimebound_no_object_param : Error<
1010310103
def err_lifetimebound_ctor_dtor : Error<
1010410104
"'lifetimebound' attribute cannot be applied to a "
1010510105
"%select{constructor|destructor}0">;
10106-
def err_lifetimebound_void_return_type : Error<
10106+
def err_lifetimebound_parameter_void_return_type : Error<
1010710107
"'lifetimebound' attribute cannot be applied to a parameter of a function "
1010810108
"that returns void">;
10109+
def err_lifetimebound_implicit_object_parameter_void_return_type : Error<
10110+
"'lifetimebound' attribute cannot be applied to an implicit object "
10111+
"parameter of a function that returns void">;
1010910112

1011010113
// CHECK: returning address/reference of stack memory
1011110114
def warn_ret_stack_addr_ref : Warning<

clang/lib/AST/ASTContext.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5303,10 +5303,11 @@ QualType ASTContext::getHLSLAttributedResourceType(
53035303
/// Retrieve a substitution-result type.
53045304
QualType ASTContext::getSubstTemplateTypeParmType(
53055305
QualType Replacement, Decl *AssociatedDecl, unsigned Index,
5306-
std::optional<unsigned> PackIndex) const {
5306+
std::optional<unsigned> PackIndex,
5307+
SubstTemplateTypeParmTypeFlag Flag) const {
53075308
llvm::FoldingSetNodeID ID;
53085309
SubstTemplateTypeParmType::Profile(ID, Replacement, AssociatedDecl, Index,
5309-
PackIndex);
5310+
PackIndex, Flag);
53105311
void *InsertPos = nullptr;
53115312
SubstTemplateTypeParmType *SubstParm =
53125313
SubstTemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
@@ -5316,7 +5317,7 @@ QualType ASTContext::getSubstTemplateTypeParmType(
53165317
!Replacement.isCanonical()),
53175318
alignof(SubstTemplateTypeParmType));
53185319
SubstParm = new (Mem) SubstTemplateTypeParmType(Replacement, AssociatedDecl,
5319-
Index, PackIndex);
5320+
Index, PackIndex, Flag);
53205321
Types.push_back(SubstParm);
53215322
SubstTemplateTypeParmTypes.InsertNode(SubstParm, InsertPos);
53225323
}

clang/lib/AST/ASTImporter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,8 +1628,8 @@ ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmType(
16281628
return ToReplacementTypeOrErr.takeError();
16291629

16301630
return Importer.getToContext().getSubstTemplateTypeParmType(
1631-
*ToReplacementTypeOrErr, *ReplacedOrErr, T->getIndex(),
1632-
T->getPackIndex());
1631+
*ToReplacementTypeOrErr, *ReplacedOrErr, T->getIndex(), T->getPackIndex(),
1632+
T->getSubstitutionFlag());
16331633
}
16341634

16351635
ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmPackType(

clang/lib/AST/Type.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4219,7 +4219,7 @@ static const TemplateTypeParmDecl *getReplacedParameter(Decl *D,
42194219

42204220
SubstTemplateTypeParmType::SubstTemplateTypeParmType(
42214221
QualType Replacement, Decl *AssociatedDecl, unsigned Index,
4222-
std::optional<unsigned> PackIndex)
4222+
std::optional<unsigned> PackIndex, SubstTemplateTypeParmTypeFlag Flag)
42234223
: Type(SubstTemplateTypeParm, Replacement.getCanonicalType(),
42244224
Replacement->getDependence()),
42254225
AssociatedDecl(AssociatedDecl) {
@@ -4230,6 +4230,10 @@ SubstTemplateTypeParmType::SubstTemplateTypeParmType(
42304230

42314231
SubstTemplateTypeParmTypeBits.Index = Index;
42324232
SubstTemplateTypeParmTypeBits.PackIndex = PackIndex ? *PackIndex + 1 : 0;
4233+
SubstTemplateTypeParmTypeBits.SubstitutionFlag = llvm::to_underlying(Flag);
4234+
assert((Flag != SubstTemplateTypeParmTypeFlag::ExpandPacksInPlace ||
4235+
PackIndex) &&
4236+
"ExpandPacksInPlace needs a valid PackIndex");
42334237
assert(AssociatedDecl != nullptr);
42344238
}
42354239

clang/lib/Driver/ToolChain.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,20 @@ static void getAArch64MultilibFlags(const Driver &D,
230230
Result.push_back(BranchProtectionArg->getAsString(Args));
231231
}
232232

233+
if (Arg *AlignArg = Args.getLastArg(
234+
options::OPT_mstrict_align, options::OPT_mno_strict_align,
235+
options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) {
236+
if (AlignArg->getOption().matches(options::OPT_mstrict_align) ||
237+
AlignArg->getOption().matches(options::OPT_mno_unaligned_access))
238+
Result.push_back(AlignArg->getAsString(Args));
239+
}
240+
241+
if (Arg *Endian = Args.getLastArg(options::OPT_mbig_endian,
242+
options::OPT_mlittle_endian)) {
243+
if (Endian->getOption().matches(options::OPT_mbig_endian))
244+
Result.push_back(Endian->getAsString(Args));
245+
}
246+
233247
const Arg *ABIArg = Args.getLastArgNoClaim(options::OPT_mabi_EQ);
234248
if (ABIArg) {
235249
Result.push_back(ABIArg->getAsString(Args));
@@ -287,6 +301,20 @@ static void getARMMultilibFlags(const Driver &D,
287301
if (BranchProtectionArg) {
288302
Result.push_back(BranchProtectionArg->getAsString(Args));
289303
}
304+
305+
if (Arg *AlignArg = Args.getLastArg(
306+
options::OPT_mstrict_align, options::OPT_mno_strict_align,
307+
options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) {
308+
if (AlignArg->getOption().matches(options::OPT_mstrict_align) ||
309+
AlignArg->getOption().matches(options::OPT_mno_unaligned_access))
310+
Result.push_back(AlignArg->getAsString(Args));
311+
}
312+
313+
if (Arg *Endian = Args.getLastArg(options::OPT_mbig_endian,
314+
options::OPT_mlittle_endian)) {
315+
if (Endian->getOption().matches(options::OPT_mbig_endian))
316+
Result.push_back(Endian->getAsString(Args));
317+
}
290318
}
291319

292320
static void getRISCVMultilibFlags(const Driver &D, const llvm::Triple &Triple,

0 commit comments

Comments
 (0)