Skip to content

Commit 74a9cf0

Browse files
committed
Yet more review comments
1 parent 1207f8c commit 74a9cf0

File tree

7 files changed

+21
-19
lines changed

7 files changed

+21
-19
lines changed

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,10 +1524,6 @@ in addition with the pragmas or -fmax-tokens flag to get any warnings.
15241524
}];
15251525
}
15261526

1527-
// Warning group for type aware allocators
1528-
def TypeAwareAllocatorMismatch :
1529-
DiagGroup<"type-aware-allocator-mismatch">;
1530-
15311527
def WebAssemblyExceptionSpec : DiagGroup<"wasm-exception-spec">;
15321528

15331529
def RTTI : DiagGroup<"rtti">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9717,7 +9717,7 @@ def err_type_aware_operator_found : Note<
97179717
"type aware %0 found in %1">;
97189718
def warn_mismatching_type_aware_cleanup_deallocator : Warning<
97199719
"mismatched type aware allocation operators for constructor cleanup">,
9720-
InGroup<TypeAwareAllocatorMismatch>;
9720+
InGroup<DiagGroup<"type-aware-allocator-mismatch">>;
97219721
def note_type_aware_operator_declared : Note<
97229722
"%select{|non-}0type aware %1 declared here">;
97239723
def note_implicit_delete_this_in_destructor_here : Note<

clang/include/clang/Sema/Sema.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4757,7 +4757,8 @@ class Sema final : public SemaBase {
47574757

47584758
CXXRecordDecl *getStdBadAlloc() const;
47594759
EnumDecl *getStdAlignValT() const;
4760-
ClassTemplateDecl *getStdTypeIdentity() const;
4760+
const ClassTemplateDecl *getStdTypeIdentity() const;
4761+
ClassTemplateDecl *getStdTypeIdentity();
47614762
std::optional<QualType> instantiateSpecializedTypeIdentity(QualType Subject);
47624763
bool isTypeIdentitySpecialization(QualType Type) const;
47634764
bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FnDecl) const;
@@ -8146,7 +8147,7 @@ class Sema final : public SemaBase {
81468147

81478148
/// The scope in which to find allocation functions.
81488149
enum AllocationFunctionScope {
8149-
/// Only look for allocation functions in the global scope
8150+
/// Only look for allocation functions in the global scope.
81508151
AFS_Global,
81518152
/// Only look for allocation functions in the scope of the
81528153
/// allocated class.

clang/lib/AST/Type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3103,7 +3103,7 @@ const TemplateDecl *Type::getSpecializedTemplateDecl() const {
31033103
if (const auto *Specialization = DesugaredType->getAs<TemplateSpecializationType>())
31043104
return Specialization->getTemplateName().getAsTemplateDecl();
31053105
if (const auto *Record = DesugaredType->getAsCXXRecordDecl()) {
3106-
if (auto *CTS = dyn_cast<ClassTemplateSpecializationDecl>(Record))
3106+
if (const auto *CTS = dyn_cast<ClassTemplateSpecializationDecl>(Record))
31073107
return CTS->getSpecializedTemplate();
31083108
}
31093109
return nullptr;

clang/lib/CodeGen/CGExprCXX.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,7 @@ static UsualDeleteParams getUsualDeleteParams(const FunctionDecl *FD) {
13951395

13961396
if (FD->isTypeAwareOperatorNewOrDelete()) {
13971397
// Assume Sema has ensured a non-pointer first parameter is
1398-
// a type identity
1398+
// a type identity.
13991399
Params.TypedAwareDelete = true;
14001400
assert(AI != AE);
14011401
++AI;
@@ -1441,7 +1441,7 @@ namespace {
14411441
QualType ArgType;
14421442
};
14431443

1444-
unsigned NumPlacementArgs : 31;
1444+
unsigned NumPlacementArgs : 30;
14451445
LLVM_PREFERRED_TYPE(bool)
14461446
unsigned PassAlignmentToPlacementDelete : 1;
14471447
LLVM_PREFERRED_TYPE(bool)
@@ -1829,7 +1829,7 @@ void CodeGenFunction::EmitDeleteCall(const FunctionDecl *DeleteFD,
18291829
auto Params = getUsualDeleteParams(DeleteFD);
18301830
auto ParamTypeIt = DeleteFTy->param_type_begin();
18311831

1832-
llvm::AllocaInst *TypeIdentityag = nullptr;
1832+
llvm::AllocaInst *TypeIdentityArg = nullptr;
18331833
if (Params.TypedAwareDelete) {
18341834
QualType SpecializedTypeIdentity = *ParamTypeIt++;
18351835
CXXScalarValueInitExpr TypeIdentityParam(SpecializedTypeIdentity, nullptr,
@@ -1890,8 +1890,8 @@ void CodeGenFunction::EmitDeleteCall(const FunctionDecl *DeleteFD,
18901890
// Emit the call to delete.
18911891
EmitNewDeleteCall(*this, DeleteFD, DeleteFTy, DeleteArgs);
18921892

1893-
if (TypeIdentityag && TypeIdentityag->use_empty())
1894-
TypeIdentityag->eraseFromParent();
1893+
if (TypeIdentityArg && TypeIdentityArg->use_empty())
1894+
TypeIdentityArg->eraseFromParent();
18951895

18961896
// If call argument lowering didn't use the destroying_delete_t alloca,
18971897
// remove it again.

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11740,7 +11740,12 @@ NamespaceDecl *Sema::getStdNamespace() const {
1174011740
StdNamespace.get(Context.getExternalSource()));
1174111741
}
1174211742

11743-
ClassTemplateDecl *Sema::getStdTypeIdentity() const {
11743+
const ClassTemplateDecl *Sema::getStdTypeIdentity() const {
11744+
return cast_or_null<ClassTemplateDecl>(
11745+
StdTypeIdentity.get(Context.getExternalSource()));
11746+
}
11747+
11748+
ClassTemplateDecl *Sema::getStdTypeIdentity() {
1174411749
return cast_or_null<ClassTemplateDecl>(
1174511750
StdTypeIdentity.get(Context.getExternalSource()));
1174611751
}
@@ -16124,7 +16129,7 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor,
1612416129
}
1612516130

1612616131
bool Sema::isTypeIdentitySpecialization(QualType Type) const {
16127-
ClassTemplateDecl *TypeIdentity = getStdTypeIdentity();
16132+
const ClassTemplateDecl *TypeIdentity = getStdTypeIdentity();
1612816133
if (!TypeIdentity)
1612916134
return false;
1613016135
const TemplateDecl *SpecializedDecl = Type->getSpecializedTemplateDecl();
@@ -16175,7 +16180,7 @@ Sema::instantiateTypeAwareUsualDelete(FunctionTemplateDecl *FnTemplateDecl,
1617516180

1617616181
for (size_t Idx = 1; Idx < NumParams; ++Idx) {
1617716182
// A type aware allocation is only usual if the only dependent parameter is
16178-
// the first parameter
16183+
// the first parameter.
1617916184
const ParmVarDecl *ParamDecl = FnDecl->getParamDecl(Idx);
1618016185
if (ParamDecl->getType()->isDependentType())
1618116186
return std::nullopt;
@@ -16231,9 +16236,9 @@ std::optional<QualType>
1623116236
Sema::instantiateSpecializedTypeIdentity(QualType Subject) {
1623216237
assert(AllowTypeAwareAllocators());
1623316238
ClassTemplateDecl *TypeIdentity = getStdTypeIdentity();
16234-
if (!TypeIdentity) {
16239+
if (!TypeIdentity)
1623516240
return std::nullopt;
16236-
}
16241+
1623716242
auto TN = TemplateName(TypeIdentity);
1623816243
TemplateArgumentListInfo Arguments;
1623916244
Arguments.addArgument(getTrivialTemplateArgumentLoc(

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,7 @@ namespace {
17811781
Destroying(false), HasSizeT(false), HasAlignValT(false),
17821782
HasTypeIdentity(false), CUDAPref(SemaCUDA::CFP_Native) {
17831783
// A function template declaration is only a usual deallocation function
1784-
// if it is a typed delete
1784+
// if it is a typed delete.
17851785
if (!FD) {
17861786
auto *FTD = dyn_cast<FunctionTemplateDecl>(Found->getUnderlyingDecl());
17871787
if (!FTD)

0 commit comments

Comments
 (0)