[clang] 8a5c8eb - [NFC][Clang] Adopt simplified `getTrailingObjects` in AST/Type (#143258)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 8 07:42:04 PDT 2025
Author: Rahul Joshi
Date: 2025-06-08T07:42:00-07:00
New Revision: 8a5c8eb0be699db1c9b891e6fe6adf068299b9fc
URL: https://github.com/llvm/llvm-project/commit/8a5c8eb0be699db1c9b891e6fe6adf068299b9fc
DIFF: https://github.com/llvm/llvm-project/commit/8a5c8eb0be699db1c9b891e6fe6adf068299b9fc.diff
LOG: [NFC][Clang] Adopt simplified `getTrailingObjects` in AST/Type (#143258)
Added:
Modified:
clang/include/clang/AST/Type.h
clang/lib/AST/Type.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index a6c26a07800c3..7fff819cba25d 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -5352,10 +5352,6 @@ class FunctionProtoType final
return getNumFunctionEffects();
}
- unsigned numTrailingObjects(OverloadToken<EffectConditionExpr>) const {
- return getNumFunctionEffectConditions();
- }
-
/// Determine whether there are any argument types that
/// contain an unexpanded parameter pack.
static bool containsAnyUnexpandedParameterPack(const QualType *ArgArray,
@@ -5686,8 +5682,8 @@ class FunctionProtoType final
if (hasExtraBitfields()) {
const auto *Bitfields = getTrailingObjects<FunctionTypeExtraBitfields>();
if (Bitfields->NumFunctionEffects > 0)
- return {getTrailingObjects<FunctionEffect>(),
- Bitfields->NumFunctionEffects};
+ return getTrailingObjects<FunctionEffect>(
+ Bitfields->NumFunctionEffects);
}
return {};
}
@@ -5706,8 +5702,8 @@ class FunctionProtoType final
if (hasExtraBitfields()) {
const auto *Bitfields = getTrailingObjects<FunctionTypeExtraBitfields>();
if (Bitfields->EffectsHaveConditions)
- return {getTrailingObjects<EffectConditionExpr>(),
- Bitfields->NumFunctionEffects};
+ return getTrailingObjects<EffectConditionExpr>(
+ Bitfields->NumFunctionEffects);
}
return {};
}
@@ -5721,8 +5717,7 @@ class FunctionProtoType final
? Bitfields->NumFunctionEffects
: 0;
return FunctionEffectsRef(
- {getTrailingObjects<FunctionEffect>(),
- Bitfields->NumFunctionEffects},
+ getTrailingObjects<FunctionEffect>(Bitfields->NumFunctionEffects),
{NumConds ? getTrailingObjects<EffectConditionExpr>() : nullptr,
NumConds});
}
@@ -6063,8 +6058,6 @@ class PackIndexingType final
static TypeDependence computeDependence(QualType Pattern, Expr *IndexExpr,
ArrayRef<QualType> Expansions = {});
-
- unsigned numTrailingObjects(OverloadToken<QualType>) const { return Size; }
};
/// A unary type transform, which is a type constructed from another.
@@ -6491,8 +6484,7 @@ class HLSLInlineSpirvType final
for (size_t I = 0; I < NumOperands; I++) {
// Since Operands are stored as a trailing object, they have not been
// initialized yet. Call the constructor manually.
- auto *Operand =
- new (&getTrailingObjects<SpirvOperand>()[I]) SpirvOperand();
+ auto *Operand = new (&getTrailingObjects()[I]) SpirvOperand();
*Operand = Operands[I];
}
}
@@ -6502,7 +6494,7 @@ class HLSLInlineSpirvType final
uint32_t getSize() const { return Size; }
uint32_t getAlignment() const { return Alignment; }
ArrayRef<SpirvOperand> getOperands() const {
- return {getTrailingObjects<SpirvOperand>(), NumOperands};
+ return getTrailingObjects<SpirvOperand>(NumOperands);
}
bool isSugared() const { return false; }
@@ -6602,7 +6594,7 @@ class SubstTemplateTypeParmType final
/// parameter.
QualType getReplacementType() const {
return SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType
- ? *getTrailingObjects<QualType>()
+ ? *getTrailingObjects()
: getCanonicalTypeInternal();
}
@@ -7164,7 +7156,7 @@ class ElaboratedType final
ElaboratedTypeBits.HasOwnedTagDecl = false;
if (OwnedTagDecl) {
ElaboratedTypeBits.HasOwnedTagDecl = true;
- *getTrailingObjects<TagDecl *>() = OwnedTagDecl;
+ *getTrailingObjects() = OwnedTagDecl;
}
}
@@ -7184,8 +7176,7 @@ class ElaboratedType final
/// Return the (re)declaration of this type owned by this occurrence of this
/// type, or nullptr if there is none.
TagDecl *getOwnedTagDecl() const {
- return ElaboratedTypeBits.HasOwnedTagDecl ? *getTrailingObjects<TagDecl *>()
- : nullptr;
+ return ElaboratedTypeBits.HasOwnedTagDecl ? *getTrailingObjects() : nullptr;
}
void Profile(llvm::FoldingSetNodeID &ID) {
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 5bb39b12693fb..800cd2a91ec26 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -4019,12 +4019,11 @@ TypedefType::TypedefType(TypeClass tc, const TypedefNameDecl *D,
assert(!isa<TypedefType>(can) && "Invalid canonical type");
TypedefBits.hasTypeDifferentFromDecl = !Underlying.isNull();
if (!typeMatchesDecl())
- *getTrailingObjects<QualType>() = Underlying;
+ *getTrailingObjects() = Underlying;
}
QualType TypedefType::desugar() const {
- return typeMatchesDecl() ? Decl->getUnderlyingType()
- : *getTrailingObjects<QualType>();
+ return typeMatchesDecl() ? Decl->getUnderlyingType() : *getTrailingObjects();
}
UsingType::UsingType(const UsingShadowDecl *Found, QualType Underlying,
@@ -4033,14 +4032,14 @@ UsingType::UsingType(const UsingShadowDecl *Found, QualType Underlying,
Found(const_cast<UsingShadowDecl *>(Found)) {
UsingBits.hasTypeDifferentFromDecl = !Underlying.isNull();
if (!typeMatchesDecl())
- *getTrailingObjects<QualType>() = Underlying;
+ *getTrailingObjects() = Underlying;
}
QualType UsingType::getUnderlyingType() const {
return typeMatchesDecl()
? QualType(
cast<TypeDecl>(Found->getTargetDecl())->getTypeForDecl(), 0)
- : *getTrailingObjects<QualType>();
+ : *getTrailingObjects();
}
QualType MacroQualifiedType::desugar() const { return getUnderlyingType(); }
@@ -4146,7 +4145,7 @@ PackIndexingType::PackIndexingType(QualType Canonical, QualType Pattern,
Pattern(Pattern), IndexExpr(IndexExpr), Size(Expansions.size()),
FullySubstituted(FullySubstituted) {
- llvm::uninitialized_copy(Expansions, getTrailingObjects<QualType>());
+ llvm::uninitialized_copy(Expansions, getTrailingObjects());
}
UnsignedOrNone PackIndexingType::getSelectedIndex() const {
@@ -4369,7 +4368,7 @@ SubstTemplateTypeParmType::SubstTemplateTypeParmType(QualType Replacement,
SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType =
Replacement != getCanonicalTypeInternal();
if (SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType)
- *getTrailingObjects<QualType>() = Replacement;
+ *getTrailingObjects() = Replacement;
SubstTemplateTypeParmTypeBits.Index = Index;
SubstTemplateTypeParmTypeBits.Final = Final;
More information about the cfe-commits
mailing list