[all-commits] [llvm/llvm-project] 69e920: [Coroutines] Use LookupAllocationFunction to find ...

Chuanqi Xu via All-commits all-commits at lists.llvm.org
Mon Sep 5 00:20:42 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 69e920d42677872ac39d3475312092404193bf24
      https://github.com/llvm/llvm-project/commit/69e920d42677872ac39d3475312092404193bf24
  Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
  Date:   2022-09-05 (Mon, 05 Sep 2022)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Sema/SemaCoroutine.cpp
    A clang/test/SemaCXX/coroutine-alloc-2.cpp
    A clang/test/SemaCXX/coroutine-alloc-3.cpp

  Log Message:
  -----------
  [Coroutines] Use LookupAllocationFunction to find allocation functions for coroutines consistently

Previously we may call Sema::FindAllocationFunctions directly to lookup
allocation functions directly instead of using our wrapped lambda
LookupAllocationFunction, which is slightly incosnsistent. It will be
helpful to refactor this for further changes.

Also previously, when we lookup 'operator new(std::size_t, std::nothrow_t)' in
case we found `get_­return_­object_­on_­allocation_­failure` in the
promise_type, the compiler will try to look at the allocation function
in promise_type. However, this is not wanted actually. According to
[dcl.fct.def.coroutine]p10:

> if a global allocation function is selected, the
> ::operator new(size_­t, nothrow_­t) form is used.

So we should only lookup for `::operator (size_t, nothrow_t)` for the
global allocation function. For the allocation function in the
promise_type, the requirement is that it shouldn't throw, which has
already been checked.

Given users generally include headers from standard libs so it will
generally include the <new> header, so this change should be a trivial
one and shouldn't affect almost any user.




More information about the All-commits mailing list