Skip to content

Commit c8c565e

Browse files
committed
More review comments
1 parent ba2b942 commit c8c565e

28 files changed

+123
-252
lines changed

clang/include/clang/AST/DeclarationName.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -502,17 +502,7 @@ class DeclarationName {
502502
}
503503

504504
bool isOperatorNewOrDelete() const {
505-
if (getNameKind() != DeclarationName::CXXOperatorName)
506-
return false;
507-
switch (getCXXOverloadedOperator()) {
508-
case OO_New:
509-
case OO_Array_New:
510-
case OO_Delete:
511-
case OO_Array_Delete:
512-
return true;
513-
default:
514-
return false;
515-
}
505+
return isOperatorNew() || isOperatorDelete();
516506
}
517507

518508
/// If this name is the name of a literal operator,

clang/include/clang/AST/Type.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2637,7 +2637,6 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
26372637
bool isTypedefNameType() const; // typedef or alias template
26382638

26392639
bool isTypeIdentitySpecialization() const; // std::type_identity<X> for any X
2640-
bool isDestroyingDeleteT() const;
26412640

26422641
/// If this type is a template specialization return the TemplateDecl
26432642
/// that was specialized. It this is not a template specialization,

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9842,8 +9842,6 @@ def err_destroying_operator_delete_not_usual : Error<
98429842

98439843
def err_type_aware_destroying_operator_delete : Error<
98449844
"type aware destroying delete is not permitted in C++26">;
9845-
def err_unsupported_type_aware_allocator : Error<
9846-
"type aware allocation operators are disabled, enable with '-fcxx-type-aware-allocators'">;
98479845

98489846
def ext_cxx26_type_aware_allocators : ExtWarn<
98499847
"type aware allocators are a C++2c extension">, InGroup<CXX26>;

clang/include/clang/Basic/Features.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,6 @@ FEATURE(cxx_abi_relative_vtable, LangOpts.CPlusPlus && LangOpts.RelativeCXXABIVT
315315

316316
FEATURE(clang_atomic_attributes, true)
317317

318-
// Type aware allocators
319-
FEATURE(cxx_type_aware_allocators, LangOpts.TypeAwareAllocators)
320-
321318
// CUDA/HIP Features
322319
FEATURE(cuda_noinline_keyword, LangOpts.CUDA)
323320
EXTENSION(cuda_implicit_host_device_templates, LangOpts.CUDA && LangOpts.OffloadImplicitHostDeviceTemplates)

clang/include/clang/Basic/LangOptions.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ LANGOPT(OpenACC , 1, 0, "OpenACC Enabled")
312312

313313
LANGOPT(MSVCEnableStdcMacro , 1, 0, "Define __STDC__ with '-fms-compatibility'")
314314
LANGOPT(SizedDeallocation , 1, 0, "sized deallocation")
315-
LANGOPT(TypeAwareAllocators , 1, 1, "type aware C++ allocation operators")
316315
LANGOPT(AlignedAllocation , 1, 0, "aligned allocation")
317316
LANGOPT(AlignedAllocationUnavailable, 1, 0, "aligned allocation functions are unavailable")
318317
LANGOPT(NewAlignOverride , 32, 0, "maximum alignment guaranteed by '::operator new(size_t)'")

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3522,10 +3522,6 @@ def : Flag<["-"], "faligned-new">, Alias<faligned_allocation>;
35223522
def : Flag<["-"], "fno-aligned-new">, Alias<fno_aligned_allocation>;
35233523
def faligned_new_EQ : Joined<["-"], "faligned-new=">;
35243524

3525-
defm cxx_type_aware_allocators : BoolFOption<"cxx-type-aware-allocators",
3526-
LangOpts<"TypeAwareAllocators">, Default<cpp26.KeyPath>,
3527-
PosFlag<SetTrue, [], [ClangOption], "Enable C++26 type aware allocator operators">,
3528-
NegFlag<SetFalse>, BothFlags<[], [ClangOption, CC1Option]>>;
35293525
def fobjc_legacy_dispatch : Flag<["-"], "fobjc-legacy-dispatch">, Group<f_Group>;
35303526
def fobjc_new_property : Flag<["-"], "fobjc-new-property">, Group<clang_ignored_f_Group>;
35313527
defm objc_infer_related_result_type : BoolFOption<"objc-infer-related-result-type",

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7188,14 +7188,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
71887188
types::isCXX(InputType))
71897189
CmdArgs.push_back("-fcoro-aligned-allocation");
71907190

7191-
if (Arg *A = Args.getLastArg(options::OPT_fcxx_type_aware_allocators,
7192-
options::OPT_fno_cxx_type_aware_allocators)) {
7193-
if (A->getOption().matches(options::OPT_fno_cxx_type_aware_allocators))
7194-
CmdArgs.push_back("-fno-cxx-type-aware-allocators");
7195-
else
7196-
CmdArgs.push_back("-fcxx-type-aware-allocators");
7197-
}
7198-
71997191
Args.AddLastArg(CmdArgs, options::OPT_fdouble_square_bracket_attributes,
72007192
options::OPT_fno_double_square_bracket_attributes);
72017193

clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,8 +774,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts,
774774
Builder.defineMacro("__cpp_impl_destroying_delete", "201806L");
775775

776776
// TODO: Final number?
777-
if (LangOpts.TypeAwareAllocators)
778-
Builder.defineMacro("__cpp_type_aware_allocators", "202500L");
777+
Builder.defineMacro("__cpp_type_aware_allocators", "202500L");
779778
}
780779

781780
/// InitializeOpenCLFeatureTestMacros - Define OpenCL macros based on target

clang/lib/Sema/SemaCoroutine.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,8 +1104,6 @@ static bool DiagnoseTypeAwareAllocators(Sema &S, SourceLocation Loc,
11041104
unsigned DiagnosticID,
11051105
DeclarationName Name,
11061106
QualType PromiseType) {
1107-
if (!S.getLangOpts().TypeAwareAllocators)
1108-
return false;
11091107
assert(PromiseType->isRecordType());
11101108

11111109
LookupResult R(S, Name, Loc, Sema::LookupOrdinaryName);
@@ -1121,6 +1119,7 @@ static bool DiagnoseTypeAwareAllocators(Sema &S, SourceLocation Loc,
11211119
S.Diag(Decl->getLocation(), diag::note_type_aware_operator_declared)
11221120
<< /* isTypeAware */ 1 << Decl;
11231121
}
1122+
R.suppressDiagnostics();
11241123
return HaveIssuedWarning;
11251124
}
11261125

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 63 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -7280,70 +7280,68 @@ void Sema::CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record) {
72807280
checkCUDADeviceBuiltinTextureClassTemplate(*this, Record);
72817281
}
72827282

7283-
if (getLangOpts().TypeAwareAllocators) {
7284-
llvm::SmallVector<const FunctionDecl *, 2> TypeAwareNewDecls;
7285-
llvm::SmallVector<const FunctionDecl *, 2> TypeAwareDeleteDecls;
7286-
llvm::SmallVector<const FunctionDecl *, 2> TypeAwareArrayNewDecls;
7287-
llvm::SmallVector<const FunctionDecl *, 2> TypeAwareArrayDeleteDecls;
7288-
7289-
for (auto *D : Record->decls()) {
7290-
const FunctionDecl *FnDecl = nullptr;
7291-
if (auto *FTD = dyn_cast<FunctionTemplateDecl>(D))
7292-
FnDecl = FTD->getTemplatedDecl();
7293-
else if (auto *FD = dyn_cast<FunctionDecl>(D))
7294-
FnDecl = FD;
7295-
if (!FnDecl || !FnDecl->isTypeAwareOperatorNewOrDelete())
7296-
continue;
7297-
switch (FnDecl->getOverloadedOperator()) {
7298-
case OO_New:
7299-
TypeAwareNewDecls.push_back(FnDecl);
7300-
break;
7301-
case OO_Array_New:
7302-
TypeAwareArrayNewDecls.push_back(FnDecl);
7303-
break;
7304-
case OO_Delete:
7305-
TypeAwareDeleteDecls.push_back(FnDecl);
7306-
break;
7307-
case OO_Array_Delete:
7308-
TypeAwareArrayDeleteDecls.push_back(FnDecl);
7309-
break;
7310-
default:
7311-
continue;
7312-
}
7283+
llvm::SmallVector<const FunctionDecl *, 2> TypeAwareNewDecls;
7284+
llvm::SmallVector<const FunctionDecl *, 2> TypeAwareDeleteDecls;
7285+
llvm::SmallVector<const FunctionDecl *, 2> TypeAwareArrayNewDecls;
7286+
llvm::SmallVector<const FunctionDecl *, 2> TypeAwareArrayDeleteDecls;
7287+
7288+
for (auto *D : Record->decls()) {
7289+
const FunctionDecl *FnDecl = nullptr;
7290+
if (auto *FTD = dyn_cast<FunctionTemplateDecl>(D))
7291+
FnDecl = FTD->getTemplatedDecl();
7292+
else if (auto *FD = dyn_cast<FunctionDecl>(D))
7293+
FnDecl = FD;
7294+
if (!FnDecl || !FnDecl->isTypeAwareOperatorNewOrDelete())
7295+
continue;
7296+
switch (FnDecl->getOverloadedOperator()) {
7297+
case OO_New:
7298+
TypeAwareNewDecls.push_back(FnDecl);
7299+
break;
7300+
case OO_Array_New:
7301+
TypeAwareArrayNewDecls.push_back(FnDecl);
7302+
break;
7303+
case OO_Delete:
7304+
TypeAwareDeleteDecls.push_back(FnDecl);
7305+
break;
7306+
case OO_Array_Delete:
7307+
TypeAwareArrayDeleteDecls.push_back(FnDecl);
7308+
break;
7309+
default:
7310+
continue;
73137311
}
7314-
auto CheckMismatchedTypeAwareAllocators =
7315-
[this, Record](
7316-
OverloadedOperatorKind NewKind,
7317-
const llvm::SmallVector<const FunctionDecl *, 2> &NewDecls,
7318-
OverloadedOperatorKind DeleteKind,
7319-
const llvm::SmallVector<const FunctionDecl *, 2> &DeleteDecls) {
7320-
if (NewDecls.empty() == DeleteDecls.empty())
7321-
return;
7322-
DeclarationName FoundOperator =
7323-
Context.DeclarationNames.getCXXOperatorName(
7324-
NewDecls.empty() ? DeleteKind : NewKind);
7325-
DeclarationName MissingOperator =
7326-
Context.DeclarationNames.getCXXOperatorName(
7327-
NewDecls.empty() ? NewKind : DeleteKind);
7328-
Diag(Record->getLocation(),
7329-
diag::err_type_aware_allocator_missing_matching_operator)
7330-
<< FoundOperator << Context.getRecordType(Record)
7331-
<< MissingOperator;
7332-
for (auto MD : NewDecls)
7333-
Diag(MD->getLocation(),
7334-
diag::note_unmatched_type_aware_allocator_declared)
7335-
<< MD;
7336-
for (auto MD : DeleteDecls)
7337-
Diag(MD->getLocation(),
7338-
diag::note_unmatched_type_aware_allocator_declared)
7339-
<< MD;
7340-
};
7341-
CheckMismatchedTypeAwareAllocators(OO_New, TypeAwareNewDecls, OO_Delete,
7342-
TypeAwareDeleteDecls);
7343-
CheckMismatchedTypeAwareAllocators(OO_Array_New, TypeAwareArrayNewDecls,
7344-
OO_Array_Delete,
7345-
TypeAwareArrayDeleteDecls);
73467312
}
7313+
auto CheckMismatchedTypeAwareAllocators =
7314+
[this,
7315+
Record](OverloadedOperatorKind NewKind,
7316+
const llvm::SmallVector<const FunctionDecl *, 2> &NewDecls,
7317+
OverloadedOperatorKind DeleteKind,
7318+
const llvm::SmallVector<const FunctionDecl *, 2> &DeleteDecls) {
7319+
if (NewDecls.empty() == DeleteDecls.empty())
7320+
return;
7321+
DeclarationName FoundOperator =
7322+
Context.DeclarationNames.getCXXOperatorName(
7323+
NewDecls.empty() ? DeleteKind : NewKind);
7324+
DeclarationName MissingOperator =
7325+
Context.DeclarationNames.getCXXOperatorName(
7326+
NewDecls.empty() ? NewKind : DeleteKind);
7327+
Diag(Record->getLocation(),
7328+
diag::err_type_aware_allocator_missing_matching_operator)
7329+
<< FoundOperator << Context.getRecordType(Record)
7330+
<< MissingOperator;
7331+
for (auto MD : NewDecls)
7332+
Diag(MD->getLocation(),
7333+
diag::note_unmatched_type_aware_allocator_declared)
7334+
<< MD;
7335+
for (auto MD : DeleteDecls)
7336+
Diag(MD->getLocation(),
7337+
diag::note_unmatched_type_aware_allocator_declared)
7338+
<< MD;
7339+
};
7340+
CheckMismatchedTypeAwareAllocators(OO_New, TypeAwareNewDecls, OO_Delete,
7341+
TypeAwareDeleteDecls);
7342+
CheckMismatchedTypeAwareAllocators(OO_Array_New, TypeAwareArrayNewDecls,
7343+
OO_Array_Delete,
7344+
TypeAwareArrayDeleteDecls);
73477345
}
73487346

73497347
/// Look up the special member function that would be called by a special
@@ -9876,9 +9874,8 @@ bool Sema::ShouldDeleteSpecialMember(CXXMethodDecl *MD,
98769874
DeclarationName Name =
98779875
Context.DeclarationNames.getCXXOperatorName(OO_Delete);
98789876
ImplicitDeallocationParameters IDP = {
9879-
DeallocType,
9880-
typeAwareAllocationModeFromBool(getLangOpts().TypeAwareAllocators),
9881-
AlignedAllocationMode::No, SizedDeallocationMode::No};
9877+
DeallocType, TypeAwareAllocationMode::Yes, AlignedAllocationMode::No,
9878+
SizedDeallocationMode::No};
98829879
if (FindDeallocationFunction(MD->getLocation(), MD->getParent(), Name,
98839880
OperatorDelete, IDP,
98849881
/*Diagnose*/ false)) {
@@ -16337,7 +16334,7 @@ bool Sema::isTypeAwareOperatorNewOrDelete(const NamedDecl *ND) const {
1633716334
FunctionDecl *
1633816335
Sema::BuildTypeAwareUsualDelete(FunctionTemplateDecl *FnTemplateDecl,
1633916336
QualType DeallocType, SourceLocation Loc) {
16340-
if (!getLangOpts().TypeAwareAllocators || DeallocType.isNull())
16337+
if (DeallocType.isNull())
1634116338
return nullptr;
1634216339

1634316340
FunctionDecl *FnDecl = FnTemplateDecl->getTemplatedDecl();
@@ -16441,9 +16438,6 @@ static inline bool CheckOperatorNewDeleteTypes(
1644116438
unsigned MinimumMandatoryArgumentCount = 1;
1644216439
unsigned SizeParameterIndex = 0;
1644316440
if (IsPotentiallyTypeAware) {
16444-
if (!SemaRef.getLangOpts().TypeAwareAllocators)
16445-
return SemaRef.Diag(FnDecl->getLocation(),
16446-
diag::err_unsupported_type_aware_allocator);
1644716441
if (!FnDecl->isTemplateInstantiation()) {
1644816442
unsigned DiagID = SemaRef.getLangOpts().CPlusPlus26
1644916443
? diag::warn_cxx26_type_aware_allocators
@@ -16557,7 +16551,6 @@ CheckOperatorNewDeclaration(Sema &SemaRef, const FunctionDecl *FnDecl) {
1655716551
CanQualType SizeTy =
1655816552
SemaRef.Context.getCanonicalType(SemaRef.Context.getSizeType());
1655916553

16560-
unsigned MinimumNonDefaultArgs = 0;
1656116554
// C++ [basic.stc.dynamic.allocation]p1:
1656216555
// The return type shall be void*. The first parameter shall have type
1656316556
// std::size_t.

0 commit comments

Comments
 (0)