[PATCH] D126187: [C++20] [Coroutines] Conform the updates for CWG issue 2585

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 23 06:35:06 PDT 2022


erichkeane added a comment.

Also needs some release notes.



================
Comment at: clang/lib/Sema/SemaCoroutine.cpp:1293
   // that just takes the requested size.
-
-  FunctionDecl *OperatorNew = nullptr;
-  FunctionDecl *OperatorDelete = nullptr;
-  FunctionDecl *UnusedResult = nullptr;
-  bool PassAlignment = false;
-  SmallVector<Expr *, 1> PlacementArgs;
-
+  //
   // [dcl.fct.def.coroutine]p9
----------------
Extra comment line.


================
Comment at: clang/lib/Sema/SemaCoroutine.cpp:1355
+  // We don't expect to call to global operator new with (size, p0, …, pn).
+  if (PromiseContainNew && !collectPlacementArgs(S, FD, Loc, PlacementArgs))
+    return false;
----------------
Can you explain how this works?  I'm not seeing what part of the collection of placement args would prohibit the call you're talking about.


================
Comment at: clang/test/SemaCXX/coroutine-allocs2.cpp:2
+// Tests that we wouldn't generate an allocation call in global scope with (std::size_t, p0, ..., pn)
+// Although this test generates codes, it aims to test the semantics. So it is put here.
+// RUN: %clang_cc1 %s -std=c++20 -S -triple x86_64-unknown-linux-gnu -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s
----------------
I'm not a fan at all of having a FIleCheck-type-test in Sema, and this DOES validate semantics.  Is there any way to get this to emit an error instead?  Perhaps declare the generated operator-new as 'deleted' and show that it chooses THAT one instead by an error?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126187/new/

https://reviews.llvm.org/D126187



More information about the cfe-commits mailing list