Skip to content

Commit 8a5c8eb

Browse files
authored
[NFC][Clang] Adopt simplified getTrailingObjects in AST/Type (#143258)
1 parent b0ff07e commit 8a5c8eb

File tree

2 files changed

+16
-26
lines changed

2 files changed

+16
-26
lines changed

clang/include/clang/AST/Type.h

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5352,10 +5352,6 @@ class FunctionProtoType final
53525352
return getNumFunctionEffects();
53535353
}
53545354

5355-
unsigned numTrailingObjects(OverloadToken<EffectConditionExpr>) const {
5356-
return getNumFunctionEffectConditions();
5357-
}
5358-
53595355
/// Determine whether there are any argument types that
53605356
/// contain an unexpanded parameter pack.
53615357
static bool containsAnyUnexpandedParameterPack(const QualType *ArgArray,
@@ -5686,8 +5682,8 @@ class FunctionProtoType final
56865682
if (hasExtraBitfields()) {
56875683
const auto *Bitfields = getTrailingObjects<FunctionTypeExtraBitfields>();
56885684
if (Bitfields->NumFunctionEffects > 0)
5689-
return {getTrailingObjects<FunctionEffect>(),
5690-
Bitfields->NumFunctionEffects};
5685+
return getTrailingObjects<FunctionEffect>(
5686+
Bitfields->NumFunctionEffects);
56915687
}
56925688
return {};
56935689
}
@@ -5706,8 +5702,8 @@ class FunctionProtoType final
57065702
if (hasExtraBitfields()) {
57075703
const auto *Bitfields = getTrailingObjects<FunctionTypeExtraBitfields>();
57085704
if (Bitfields->EffectsHaveConditions)
5709-
return {getTrailingObjects<EffectConditionExpr>(),
5710-
Bitfields->NumFunctionEffects};
5705+
return getTrailingObjects<EffectConditionExpr>(
5706+
Bitfields->NumFunctionEffects);
57115707
}
57125708
return {};
57135709
}
@@ -5721,8 +5717,7 @@ class FunctionProtoType final
57215717
? Bitfields->NumFunctionEffects
57225718
: 0;
57235719
return FunctionEffectsRef(
5724-
{getTrailingObjects<FunctionEffect>(),
5725-
Bitfields->NumFunctionEffects},
5720+
getTrailingObjects<FunctionEffect>(Bitfields->NumFunctionEffects),
57265721
{NumConds ? getTrailingObjects<EffectConditionExpr>() : nullptr,
57275722
NumConds});
57285723
}
@@ -6063,8 +6058,6 @@ class PackIndexingType final
60636058

60646059
static TypeDependence computeDependence(QualType Pattern, Expr *IndexExpr,
60656060
ArrayRef<QualType> Expansions = {});
6066-
6067-
unsigned numTrailingObjects(OverloadToken<QualType>) const { return Size; }
60686061
};
60696062

60706063
/// A unary type transform, which is a type constructed from another.
@@ -6491,8 +6484,7 @@ class HLSLInlineSpirvType final
64916484
for (size_t I = 0; I < NumOperands; I++) {
64926485
// Since Operands are stored as a trailing object, they have not been
64936486
// initialized yet. Call the constructor manually.
6494-
auto *Operand =
6495-
new (&getTrailingObjects<SpirvOperand>()[I]) SpirvOperand();
6487+
auto *Operand = new (&getTrailingObjects()[I]) SpirvOperand();
64966488
*Operand = Operands[I];
64976489
}
64986490
}
@@ -6502,7 +6494,7 @@ class HLSLInlineSpirvType final
65026494
uint32_t getSize() const { return Size; }
65036495
uint32_t getAlignment() const { return Alignment; }
65046496
ArrayRef<SpirvOperand> getOperands() const {
6505-
return {getTrailingObjects<SpirvOperand>(), NumOperands};
6497+
return getTrailingObjects<SpirvOperand>(NumOperands);
65066498
}
65076499

65086500
bool isSugared() const { return false; }
@@ -6602,7 +6594,7 @@ class SubstTemplateTypeParmType final
66026594
/// parameter.
66036595
QualType getReplacementType() const {
66046596
return SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType
6605-
? *getTrailingObjects<QualType>()
6597+
? *getTrailingObjects()
66066598
: getCanonicalTypeInternal();
66076599
}
66086600

@@ -7164,7 +7156,7 @@ class ElaboratedType final
71647156
ElaboratedTypeBits.HasOwnedTagDecl = false;
71657157
if (OwnedTagDecl) {
71667158
ElaboratedTypeBits.HasOwnedTagDecl = true;
7167-
*getTrailingObjects<TagDecl *>() = OwnedTagDecl;
7159+
*getTrailingObjects() = OwnedTagDecl;
71687160
}
71697161
}
71707162

@@ -7184,8 +7176,7 @@ class ElaboratedType final
71847176
/// Return the (re)declaration of this type owned by this occurrence of this
71857177
/// type, or nullptr if there is none.
71867178
TagDecl *getOwnedTagDecl() const {
7187-
return ElaboratedTypeBits.HasOwnedTagDecl ? *getTrailingObjects<TagDecl *>()
7188-
: nullptr;
7179+
return ElaboratedTypeBits.HasOwnedTagDecl ? *getTrailingObjects() : nullptr;
71897180
}
71907181

71917182
void Profile(llvm::FoldingSetNodeID &ID) {

clang/lib/AST/Type.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4019,12 +4019,11 @@ TypedefType::TypedefType(TypeClass tc, const TypedefNameDecl *D,
40194019
assert(!isa<TypedefType>(can) && "Invalid canonical type");
40204020
TypedefBits.hasTypeDifferentFromDecl = !Underlying.isNull();
40214021
if (!typeMatchesDecl())
4022-
*getTrailingObjects<QualType>() = Underlying;
4022+
*getTrailingObjects() = Underlying;
40234023
}
40244024

40254025
QualType TypedefType::desugar() const {
4026-
return typeMatchesDecl() ? Decl->getUnderlyingType()
4027-
: *getTrailingObjects<QualType>();
4026+
return typeMatchesDecl() ? Decl->getUnderlyingType() : *getTrailingObjects();
40284027
}
40294028

40304029
UsingType::UsingType(const UsingShadowDecl *Found, QualType Underlying,
@@ -4033,14 +4032,14 @@ UsingType::UsingType(const UsingShadowDecl *Found, QualType Underlying,
40334032
Found(const_cast<UsingShadowDecl *>(Found)) {
40344033
UsingBits.hasTypeDifferentFromDecl = !Underlying.isNull();
40354034
if (!typeMatchesDecl())
4036-
*getTrailingObjects<QualType>() = Underlying;
4035+
*getTrailingObjects() = Underlying;
40374036
}
40384037

40394038
QualType UsingType::getUnderlyingType() const {
40404039
return typeMatchesDecl()
40414040
? QualType(
40424041
cast<TypeDecl>(Found->getTargetDecl())->getTypeForDecl(), 0)
4043-
: *getTrailingObjects<QualType>();
4042+
: *getTrailingObjects();
40444043
}
40454044

40464045
QualType MacroQualifiedType::desugar() const { return getUnderlyingType(); }
@@ -4146,7 +4145,7 @@ PackIndexingType::PackIndexingType(QualType Canonical, QualType Pattern,
41464145
Pattern(Pattern), IndexExpr(IndexExpr), Size(Expansions.size()),
41474146
FullySubstituted(FullySubstituted) {
41484147

4149-
llvm::uninitialized_copy(Expansions, getTrailingObjects<QualType>());
4148+
llvm::uninitialized_copy(Expansions, getTrailingObjects());
41504149
}
41514150

41524151
UnsignedOrNone PackIndexingType::getSelectedIndex() const {
@@ -4369,7 +4368,7 @@ SubstTemplateTypeParmType::SubstTemplateTypeParmType(QualType Replacement,
43694368
SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType =
43704369
Replacement != getCanonicalTypeInternal();
43714370
if (SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType)
4372-
*getTrailingObjects<QualType>() = Replacement;
4371+
*getTrailingObjects() = Replacement;
43734372

43744373
SubstTemplateTypeParmTypeBits.Index = Index;
43754374
SubstTemplateTypeParmTypeBits.Final = Final;

0 commit comments

Comments
 (0)