[clang] [RFC] Initial implementation of P2719 (PR #113510)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 30 10:24:05 PDT 2025
================
@@ -16327,79 +16531,181 @@ static CanQualType RemoveAddressSpaceFromPtr(Sema &SemaRef,
PtrTy->getPointeeType().getUnqualifiedType(), PtrQuals)));
}
-static inline bool
-CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl,
- CanQualType ExpectedResultType,
- CanQualType ExpectedFirstParamType,
- unsigned DependentParamTypeDiag,
- unsigned InvalidParamTypeDiag) {
- QualType ResultType =
- FnDecl->getType()->castAs<FunctionType>()->getReturnType();
+enum class AllocationOperatorKind { New, Delete };
+
+static bool IsPotentiallyTypeAwareOperatorNewOrDelete(Sema &SemaRef,
+ const FunctionDecl *FD,
+ bool *WasMalformed) {
+ const Decl *MalformedDecl = nullptr;
+ if (FD->getNumParams() > 0 &&
+ SemaRef.isStdTypeIdentity(FD->getParamDecl(0)->getType(),
+ /*TypeArgument=*/nullptr, &MalformedDecl))
+ return true;
- if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
- // The operator is valid on any address space for OpenCL.
- // Drop address space from actual and expected result types.
- if (const auto *PtrTy = ResultType->getAs<PointerType>())
- ResultType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
+ if (!MalformedDecl)
+ return false;
+
+ if (WasMalformed)
+ *WasMalformed = true;
+
+ // SemaRef.Diag(MalformedDecl->getLocation(),
+ // diag::err_malformed_std_class_template) << "type_identity";
----------------
mizvekov wrote:
Leftovers?
```suggestion
```
https://github.com/llvm/llvm-project/pull/113510
More information about the cfe-commits
mailing list