Skip to content

Commit 728aa09

Browse files
committed
Addressing review comments
1 parent dc42595 commit 728aa09

15 files changed

+378
-306
lines changed

clang/include/clang/AST/Decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2530,7 +2530,7 @@ class FunctionDecl : public DeclaratorDecl,
25302530
/// Determine whether this is a destroying operator delete.
25312531
bool isDestroyingOperatorDelete() const;
25322532

2533-
bool IsTypeAwareOperatorNewOrDelete() const;
2533+
bool isTypeAwareOperatorNewOrDelete() const;
25342534

25352535
/// Compute the language linkage.
25362536
LanguageLinkage getLanguageLinkage() const;

clang/include/clang/AST/Type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2703,7 +2703,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
27032703
return static_cast<TypeDependence>(TypeBits.Dependence);
27042704
}
27052705

2706-
TemplateDecl *getSpecializedTemplateDecl() const;
2706+
const TemplateDecl *getSpecializedTemplateDecl() const;
27072707

27082708
/// Whether this type is an error type.
27092709
bool containsErrors() const {

clang/include/clang/Sema/Sema.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4756,13 +4756,13 @@ class Sema final : public SemaBase {
47564756
CXXRecordDecl *getStdBadAlloc() const;
47574757
EnumDecl *getStdAlignValT() const;
47584758
ClassTemplateDecl *getStdTypeIdentity() const;
4759-
std::optional<QualType> InstantiateSpecializedTypeIdentity(QualType Subject);
4760-
bool IsTypeIdentitySpecialization(QualType Type) const;
4761-
bool IsTypeAwareOperatorNewOrDelete(const FunctionDecl *FnDecl) const;
4762-
bool IsTypeAwareOperatorNewOrDelete(const FunctionTemplateDecl *FnDecl) const;
4763-
bool IsTypeAwareOperatorNewOrDelete(const NamedDecl *FnDecl) const;
4759+
std::optional<QualType> instantiateSpecializedTypeIdentity(QualType Subject);
4760+
bool isTypeIdentitySpecialization(QualType Type) const;
4761+
bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FnDecl) const;
4762+
bool isTypeAwareOperatorNewOrDelete(const FunctionTemplateDecl *FnDecl) const;
4763+
bool isTypeAwareOperatorNewOrDelete(const NamedDecl *FnDecl) const;
47644764
std::optional<FunctionDecl *>
4765-
InstantiateTypeAwareUsualDelete(FunctionTemplateDecl *FnDecl,
4765+
instantiateTypeAwareUsualDelete(FunctionTemplateDecl *FnDecl,
47664766
QualType AllocType);
47674767

47684768
ValueDecl *tryLookupUnambiguousFieldDecl(RecordDecl *ClassDecl,

clang/lib/AST/Decl.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3360,9 +3360,7 @@ bool FunctionDecl::isReservedGlobalPlacementOperator() const {
33603360
const auto *proto = getType()->castAs<FunctionProtoType>();
33613361
if (proto->getNumParams() < 2)
33623362
return false;
3363-
bool IsTypeAwareAllocator =
3364-
proto->getParamType(0)->isTypeIdentitySpecialization();
3365-
if (IsTypeAwareAllocator)
3363+
if (proto->getParamType(0)->isTypeIdentitySpecialization())
33663364
return false;
33673365
if (proto->getNumParams() != 2 || proto->isVariadic())
33683366
return false;
@@ -3492,7 +3490,7 @@ bool FunctionDecl::isDestroyingOperatorDelete() const {
34923490
if (!isa<CXXMethodDecl>(this) || getOverloadedOperator() != OO_Delete)
34933491
return false;
34943492

3495-
auto NumParams = getNumParams();
3493+
unsigned NumParams = getNumParams();
34963494
unsigned DestroyingDeleteTagParam = 1;
34973495
bool IsTypeAware = false;
34983496
if (NumParams > 0)
@@ -3510,7 +3508,7 @@ bool FunctionDecl::isDestroyingOperatorDelete() const {
35103508
RD->getIdentifier()->isStr("destroying_delete_t");
35113509
}
35123510

3513-
bool FunctionDecl::IsTypeAwareOperatorNewOrDelete() const {
3511+
bool FunctionDecl::isTypeAwareOperatorNewOrDelete() const {
35143512
if (getDeclName().getNameKind() != DeclarationName::CXXOperatorName)
35153513
return false;
35163514
if (getDeclName().getCXXOverloadedOperator() != OO_New &&

clang/lib/AST/DeclCXX.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,13 +2474,13 @@ bool CXXMethodDecl::isUsualDeallocationFunction(
24742474
getOverloadedOperator() != OO_Array_Delete)
24752475
return false;
24762476

2477-
auto NumParams = getNumParams();
2478-
bool IsTypeAware = IsTypeAwareOperatorNewOrDelete();
2477+
unsigned NumParams = getNumParams();
2478+
bool IsTypeAware = isTypeAwareOperatorNewOrDelete();
24792479

24802480
// C++ [basic.stc.dynamic.deallocation]p2:
24812481
// A template instance is never a usual deallocation function,
24822482
// regardless of its signature.
2483-
if (auto *PrimaryTemplate = getPrimaryTemplate()) {
2483+
if (FunctionTemplateDecl *PrimaryTemplate = getPrimaryTemplate()) {
24842484
// Addendum: a template instance is a usual deallocation function if there
24852485
// is a single template parameter, that parameter is a type, only the first
24862486
// parameter is dependent, and that parameter is a specialization of
@@ -2490,8 +2490,8 @@ bool CXXMethodDecl::isUsualDeallocationFunction(
24902490
return false;
24912491
}
24922492

2493-
auto *SpecializedDecl = PrimaryTemplate->getTemplatedDecl();
2494-
if (!SpecializedDecl->IsTypeAwareOperatorNewOrDelete()) {
2493+
FunctionDecl *SpecializedDecl = PrimaryTemplate->getTemplatedDecl();
2494+
if (!SpecializedDecl->isTypeAwareOperatorNewOrDelete()) {
24952495
// The underlying template decl must also be explicitly type aware
24962496
// e.g. template <typename T> void operator delete(T, ...)
24972497
// specialized on T=type_identity<X> is not usual

clang/lib/AST/Type.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3098,8 +3098,8 @@ bool Type::isStdByteType() const {
30983098
return false;
30993099
}
31003100

3101-
TemplateDecl *Type::getSpecializedTemplateDecl() const {
3102-
const auto *DesugaredType = getUnqualifiedDesugaredType();
3101+
const TemplateDecl *Type::getSpecializedTemplateDecl() const {
3102+
const Type *DesugaredType = getUnqualifiedDesugaredType();
31033103
if (const auto *Specialization = DesugaredType->getAs<TemplateSpecializationType>())
31043104
return Specialization->getTemplateName().getAsTemplateDecl();
31053105
if (const auto *Record = DesugaredType->getAsCXXRecordDecl()) {

clang/lib/CodeGen/CGExprCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ static UsualDeleteParams getUsualDeleteParams(const FunctionDecl *FD) {
13931393
const FunctionProtoType *FPT = FD->getType()->castAs<FunctionProtoType>();
13941394
auto AI = FPT->param_type_begin(), AE = FPT->param_type_end();
13951395

1396-
if (FD->IsTypeAwareOperatorNewOrDelete()) {
1396+
if (FD->isTypeAwareOperatorNewOrDelete()) {
13971397
// Assume Sema has ensured a non-pointer first parameter is
13981398
// a type identity
13991399
Params.TypedAwareDelete = true;

clang/lib/Sema/SemaCoroutine.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,13 +1599,13 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() {
15991599

16001600
SmallVector<Expr *, 3> NewArgs;
16011601
if (IAP.PassTypeIdentity) {
1602-
auto SpecializedTypeIdentity =
1603-
S.InstantiateSpecializedTypeIdentity(PromiseType);
1602+
std::optional<QualType> SpecializedTypeIdentity =
1603+
S.instantiateSpecializedTypeIdentity(PromiseType);
16041604
if (!SpecializedTypeIdentity)
16051605
return false;
1606-
auto *SpecializedTypeInfo =
1606+
TypeSourceInfo *SpecializedTypeInfo =
16071607
S.Context.getTrivialTypeSourceInfo(*SpecializedTypeIdentity, Loc);
1608-
auto TypeIdentity =
1608+
ExprResult TypeIdentity =
16091609
S.BuildCXXTypeConstructExpr(SpecializedTypeInfo, Loc, {}, Loc, false);
16101610
if (TypeIdentity.isInvalid())
16111611
return false;

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9711,7 +9711,7 @@ bool Sema::ShouldDeleteSpecialMember(CXXMethodDecl *MD,
97119711
// results in an ambiguity or in a function that is deleted or inaccessible
97129712
if (CSM == CXXSpecialMemberKind::Destructor && MD->isVirtual()) {
97139713
FunctionDecl *OperatorDelete = nullptr;
9714-
auto DeallocType = Context.getRecordType(RD);
9714+
QualType DeallocType = Context.getRecordType(RD);
97159715
DeclarationName Name =
97169716
Context.DeclarationNames.getCXXOperatorName(OO_Delete);
97179717
ImplicitDeallocationParameters IDP = {.PassTypeIdentity =
@@ -10872,7 +10872,7 @@ bool Sema::CheckDestructor(CXXDestructorDecl *Destructor) {
1087210872
// first parameter, perform that conversion now.
1087310873
if (OperatorDelete->isDestroyingOperatorDelete()) {
1087410874
unsigned PointerParam = 0;
10875-
if (IsTypeAwareOperatorNewOrDelete(OperatorDelete)) {
10875+
if (isTypeAwareOperatorNewOrDelete(OperatorDelete)) {
1087610876
++PointerParam;
1087710877
}
1087810878
QualType ParamType =
@@ -16123,47 +16123,47 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor,
1612316123
return Invalid;
1612416124
}
1612516125

16126-
bool Sema::IsTypeIdentitySpecialization(QualType Type) const {
16127-
auto *TypeIdentity = getStdTypeIdentity();
16126+
bool Sema::isTypeIdentitySpecialization(QualType Type) const {
16127+
ClassTemplateDecl *TypeIdentity = getStdTypeIdentity();
1612816128
if (!TypeIdentity)
1612916129
return false;
16130-
auto *SpecializedDecl = Type->getSpecializedTemplateDecl();
16130+
const TemplateDecl *SpecializedDecl = Type->getSpecializedTemplateDecl();
1613116131
return TypeIdentity == SpecializedDecl;
1613216132
}
1613316133

16134-
bool Sema::IsTypeAwareOperatorNewOrDelete(const FunctionDecl *FnDecl) const {
16134+
bool Sema::isTypeAwareOperatorNewOrDelete(const FunctionDecl *FnDecl) const {
1613516135
// Type aware operators
1613616136
if (FnDecl->getNumParams() < 2)
1613716137
return false;
16138-
const auto *ParamDecl = FnDecl->getParamDecl(0);
16139-
return IsTypeIdentitySpecialization(ParamDecl->getType());
16138+
const ParmVarDecl *ParamDecl = FnDecl->getParamDecl(0);
16139+
return isTypeIdentitySpecialization(ParamDecl->getType());
1614016140
}
1614116141

16142-
bool Sema::IsTypeAwareOperatorNewOrDelete(
16142+
bool Sema::isTypeAwareOperatorNewOrDelete(
1614316143
const FunctionTemplateDecl *FTD) const {
16144-
return IsTypeAwareOperatorNewOrDelete(FTD->getTemplatedDecl());
16144+
return isTypeAwareOperatorNewOrDelete(FTD->getTemplatedDecl());
1614516145
}
1614616146

16147-
bool Sema::IsTypeAwareOperatorNewOrDelete(const NamedDecl *ND) const {
16147+
bool Sema::isTypeAwareOperatorNewOrDelete(const NamedDecl *ND) const {
1614816148
if (auto *FTD = dyn_cast<FunctionTemplateDecl>(ND))
16149-
return IsTypeAwareOperatorNewOrDelete(FTD->getTemplatedDecl());
16149+
return isTypeAwareOperatorNewOrDelete(FTD->getTemplatedDecl());
1615016150
if (auto *FnDecl = dyn_cast<FunctionDecl>(ND))
16151-
return IsTypeAwareOperatorNewOrDelete(FnDecl);
16151+
return isTypeAwareOperatorNewOrDelete(FnDecl);
1615216152
return false;
1615316153
}
1615416154

1615516155
std::optional<FunctionDecl *>
16156-
Sema::InstantiateTypeAwareUsualDelete(FunctionTemplateDecl *FnTemplateDecl,
16156+
Sema::instantiateTypeAwareUsualDelete(FunctionTemplateDecl *FnTemplateDecl,
1615716157
QualType DeallocType) {
1615816158
if (!AllowTypeAwareAllocators())
1615916159
return std::nullopt;
1616016160

16161-
auto TemplateParameters = FnTemplateDecl->getTemplateParameters();
16161+
TemplateParameterList *TemplateParameters = FnTemplateDecl->getTemplateParameters();
1616216162
if (TemplateParameters->hasParameterPack())
1616316163
return std::nullopt;
1616416164

16165-
auto FnDecl = FnTemplateDecl->getTemplatedDecl();
16166-
if (!IsTypeAwareOperatorNewOrDelete(FnDecl))
16165+
FunctionDecl *FnDecl = FnTemplateDecl->getTemplatedDecl();
16166+
if (!isTypeAwareOperatorNewOrDelete(FnDecl))
1616716167
return std::nullopt;
1616816168

1616916169
if (FnDecl->isVariadic())
@@ -16176,13 +16176,13 @@ Sema::InstantiateTypeAwareUsualDelete(FunctionTemplateDecl *FnTemplateDecl,
1617616176
for (size_t Idx = 1; Idx < NumParams; ++Idx) {
1617716177
// A type aware allocation is only usual if the only dependent parameter is
1617816178
// the first parameter
16179-
const auto *ParamDecl = FnDecl->getParamDecl(Idx);
16179+
const ParmVarDecl *ParamDecl = FnDecl->getParamDecl(Idx);
1618016180
if (ParamDecl->getType()->isDependentType())
1618116181
return std::nullopt;
1618216182
}
1618316183

16184-
auto SpecializedTypeIdentity =
16185-
InstantiateSpecializedTypeIdentity(DeallocType);
16184+
std::optional<QualType> SpecializedTypeIdentity =
16185+
instantiateSpecializedTypeIdentity(DeallocType);
1618616186
if (!SpecializedTypeIdentity)
1618716187
return std::nullopt;
1618816188
SmallVector<QualType, 4> ArgTypes;
@@ -16191,21 +16191,21 @@ Sema::InstantiateTypeAwareUsualDelete(FunctionTemplateDecl *FnTemplateDecl,
1619116191
ArgTypes.push_back(FnDecl->getParamDecl(1)->getType());
1619216192
unsigned UsualParamsIdx = 2;
1619316193
if (UsualParamsIdx < NumParams && FnDecl->isDestroyingOperatorDelete()) {
16194-
auto Type = FnDecl->getParamDecl(UsualParamsIdx)->getType();
16194+
QualType Type = FnDecl->getParamDecl(UsualParamsIdx)->getType();
1619516195
ArgTypes.push_back(Type);
1619616196
++UsualParamsIdx;
1619716197
}
1619816198

1619916199
if (UsualParamsIdx < NumParams) {
16200-
auto Type = FnDecl->getParamDecl(UsualParamsIdx)->getType();
16200+
QualType Type = FnDecl->getParamDecl(UsualParamsIdx)->getType();
1620116201
if (Context.hasSameUnqualifiedType(Type, Context.getSizeType())) {
1620216202
ArgTypes.push_back(Type);
1620316203
++UsualParamsIdx;
1620416204
}
1620516205
}
1620616206

1620716207
if (UsualParamsIdx < NumParams) {
16208-
auto Type = FnDecl->getParamDecl(UsualParamsIdx)->getType();
16208+
QualType Type = FnDecl->getParamDecl(UsualParamsIdx)->getType();
1620916209
if (Type->isAlignValT()) {
1621016210
ArgTypes.push_back(Type);
1621116211
++UsualParamsIdx;
@@ -16216,7 +16216,7 @@ Sema::InstantiateTypeAwareUsualDelete(FunctionTemplateDecl *FnTemplateDecl,
1621616216
return std::nullopt;
1621716217

1621816218
FunctionProtoType::ExtProtoInfo EPI;
16219-
auto ExpectedFunctionType =
16219+
QualType ExpectedFunctionType =
1622016220
Context.getFunctionType(Context.VoidTy, ArgTypes, EPI);
1622116221
SourceLocation Loc;
1622216222
sema::TemplateDeductionInfo Info(Loc);
@@ -16228,17 +16228,17 @@ Sema::InstantiateTypeAwareUsualDelete(FunctionTemplateDecl *FnTemplateDecl,
1622816228
}
1622916229

1623016230
std::optional<QualType>
16231-
Sema::InstantiateSpecializedTypeIdentity(QualType Subject) {
16231+
Sema::instantiateSpecializedTypeIdentity(QualType Subject) {
1623216232
assert(AllowTypeAwareAllocators());
16233-
auto *TypeIdentity = getStdTypeIdentity();
16233+
ClassTemplateDecl *TypeIdentity = getStdTypeIdentity();
1623416234
if (!TypeIdentity) {
1623516235
return std::nullopt;
1623616236
}
1623716237
auto TN = TemplateName(TypeIdentity);
1623816238
TemplateArgumentListInfo Arguments;
1623916239
Arguments.addArgument(getTrivialTemplateArgumentLoc(
1624016240
TemplateArgument(Subject), QualType(), SourceLocation()));
16241-
auto Result = CheckTemplateIdType(TN, SourceLocation(), Arguments);
16241+
QualType Result = CheckTemplateIdType(TN, SourceLocation(), Arguments);
1624216242
if (Result.isNull())
1624316243
return std::nullopt;
1624416244
return Result;
@@ -16288,8 +16288,8 @@ static inline bool CheckOperatorNewDeleteTypes(
1628816288
};
1628916289
auto *FnType = FnDecl->getType()->castAs<FunctionType>();
1629016290
QualType CanResultType = NormalizeType(FnType->getReturnType());
16291-
auto CanExpectedResultType = NormalizeType(ExpectedResultType);
16292-
auto CanExpectedFirstParamType = NormalizeType(ExpectedFirstParamType);
16291+
QualType CanExpectedResultType = NormalizeType(ExpectedResultType);
16292+
QualType CanExpectedFirstParamType = NormalizeType(ExpectedFirstParamType);
1629316293

1629416294
// Check that the result type is what we expect.
1629516295
if (CanResultType != CanExpectedResultType) {
@@ -16310,7 +16310,7 @@ static inline bool CheckOperatorNewDeleteTypes(
1631016310
<< FnDecl->getDeclName();
1631116311

1631216312
unsigned FirstNonTypeParam = 0;
16313-
if (FnDecl->IsTypeAwareOperatorNewOrDelete()) {
16313+
if (FnDecl->isTypeAwareOperatorNewOrDelete()) {
1631416314
if (!SemaRef.getLangOpts().TypeAwareAllocators) {
1631516315
return SemaRef.Diag(FnDecl->getLocation(),
1631616316
diag::err_unsupported_type_aware_allocator);
@@ -16367,7 +16367,7 @@ CheckOperatorNewDeclaration(Sema &SemaRef, const FunctionDecl *FnDecl) {
1636716367
// C++ [basic.stc.dynamic.allocation]p1:
1636816368
// The first parameter shall not have an associated default argument.
1636916369
for (unsigned Idx = 0; Idx < MinimumNonDefaultArgs; ++Idx) {
16370-
auto *ParamDecl = FnDecl->getParamDecl(Idx);
16370+
const ParmVarDecl *ParamDecl = FnDecl->getParamDecl(Idx);
1637116371
if (ParamDecl->hasDefaultArg()) {
1637216372
return SemaRef.Diag(FnDecl->getLocation(),
1637316373
diag::err_operator_new_default_arg)
@@ -16417,15 +16417,15 @@ CheckOperatorDeleteDeclaration(Sema &SemaRef, FunctionDecl *FnDecl) {
1641716417
diag::err_destroying_operator_delete_not_usual);
1641816418
return true;
1641916419
}
16420-
if (MD->IsTypeAwareOperatorNewOrDelete() &&
16420+
if (MD->isTypeAwareOperatorNewOrDelete() &&
1642116421
!SemaRef.getLangOpts().TypeAwareDestroyingDelete) {
1642216422
SemaRef.Diag(MD->getLocation(),
1642316423
diag::err_type_aware_destroying_operator_delete);
1642416424
return true;
1642516425
}
1642616426
}
1642716427
for (unsigned Idx = 0; Idx < MinimumNonDefaultArgs; ++Idx) {
16428-
auto *ParamDecl = FnDecl->getParamDecl(Idx);
16428+
const ParmVarDecl *ParamDecl = FnDecl->getParamDecl(Idx);
1642916429
if (ParamDecl->hasDefaultArg()) {
1643016430
return SemaRef.Diag(FnDecl->getLocation(),
1643116431
diag::err_operator_new_default_arg)

0 commit comments

Comments
 (0)