[clang] [RFC] Initial implementation of P2719 (PR #113510)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 31 21:11:00 PDT 2025
================
@@ -1098,12 +1098,39 @@ static TypeSourceInfo *getTypeSourceInfoForStdAlignValT(Sema &S,
return S.Context.getTrivialTypeSourceInfo(StdAlignValDecl);
}
+// When searching for custom allocators on the PromiseType we want to
+// warn that we will ignore type aware allocators.
+static bool DiagnoseTypeAwareAllocators(Sema &S, SourceLocation Loc,
+ unsigned DiagnosticID,
+ DeclarationName Name,
+ QualType PromiseType) {
+ assert(PromiseType->isRecordType());
+
+ LookupResult R(S, Name, Loc, Sema::LookupOrdinaryName);
+ S.LookupQualifiedName(R, PromiseType->getAsCXXRecordDecl());
+ bool HaveIssuedWarning = false;
+ for (auto Decl : R) {
+ if (!Decl->getAsFunction()->isTypeAwareOperatorNewOrDelete())
+ continue;
+ if (!HaveIssuedWarning) {
+ S.Diag(Loc, DiagnosticID) << Name;
+ HaveIssuedWarning = true;
+ }
+ S.Diag(Decl->getLocation(), diag::note_type_aware_operator_declared)
+ << /* isTypeAware */ 1 << Decl << Decl->getDeclContext();
----------------
mizvekov wrote:
I think this is fine, you just have to be careful if the semantic context is the always the same as the lexical context.
https://github.com/llvm/llvm-project/pull/113510
More information about the cfe-commits
mailing list