@@ -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 {
1633716334FunctionDecl *
1633816335Sema::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