[all-commits] [llvm/llvm-project] 516803: [Coroutines] Ensure co_await promise.final_suspend...

Xun Li via All-commits all-commits at lists.llvm.org
Mon Jun 22 15:02:00 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 516803dc8685ebcc5bce38b05391958ffee22643
      https://github.com/llvm/llvm-project/commit/516803dc8685ebcc5bce38b05391958ffee22643
  Author: Xun Li <xun at fb.com>
  Date:   2020-06-22 (Mon, 22 Jun 2020)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Sema/SemaCoroutine.cpp
    M clang/lib/Sema/SemaExceptionSpec.cpp
    M clang/test/AST/Inputs/std-coroutine.h
    M clang/test/AST/coroutine-source-location-crash.cpp
    M clang/test/Analysis/more-dtors-cfg-output.cpp
    M clang/test/CodeGenCXX/ubsan-coroutines.cpp
    M clang/test/CodeGenCoroutines/Inputs/coroutine.h
    M clang/test/CodeGenCoroutines/coro-alloc.cpp
    M clang/test/CodeGenCoroutines/coro-always-inline.cpp
    M clang/test/CodeGenCoroutines/coro-await-domination.cpp
    M clang/test/CodeGenCoroutines/coro-await-resume-eh.cpp
    M clang/test/CodeGenCoroutines/coro-await.cpp
    M clang/test/CodeGenCoroutines/coro-dest-slot.cpp
    M clang/test/CodeGenCoroutines/coro-gro-nrvo.cpp
    M clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
    M clang/test/CodeGenCoroutines/coro-params.cpp
    M clang/test/CodeGenCoroutines/coro-promise-dtor.cpp
    M clang/test/CodeGenCoroutines/coro-ret-void.cpp
    M clang/test/CodeGenCoroutines/coro-return-voidtype-initlist.cpp
    M clang/test/CodeGenCoroutines/coro-return.cpp
    M clang/test/CodeGenCoroutines/coro-unhandled-exception.cpp
    M clang/test/Index/coroutines.cpp
    M clang/test/SemaCXX/Inputs/std-coroutine.h
    M clang/test/SemaCXX/co_await-range-for.cpp
    M clang/test/SemaCXX/coreturn-eh.cpp
    M clang/test/SemaCXX/coreturn.cpp
    A clang/test/SemaCXX/coroutine-final-suspend-noexcept.cpp
    M clang/test/SemaCXX/coroutine-rvo.cpp
    M clang/test/SemaCXX/coroutine-unhandled_exception-warning.cpp
    M clang/test/SemaCXX/coroutine-uninitialized-warning-crash.cpp
    M clang/test/SemaCXX/coroutines.cpp

  Log Message:
  -----------
  [Coroutines] Ensure co_await promise.final_suspend() does not throw

Summary:
This patch addresses https://bugs.llvm.org/show_bug.cgi?id=46256
The spec of coroutine requires that the expression co_­await promise.final_­suspend() shall not be potentially-throwing.
To check this, we recursively look at every call (including Call, MemberCall, OperatorCall and Constructor) in all code
generated by the final suspend, and ensure that the callees are declared with noexcept. We also look at any returned data
type that requires explicit destruction, and check their destructors for noexcept.

This patch does not check declarations with dependent types yet, which will be done in future patches.

Updated all tests to add noexcept to the required functions, and added a dedicated test for this patch.

This patch might start to cause existing codebase fail to compile because most people may not have been strict in tagging
all the related functions noexcept.

Reviewers: lewissbaker, modocache, junparser

Reviewed By: modocache

Subscribers: arphaman, junparser, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D82029




More information about the All-commits mailing list