Skip exception cleanups when the innermost scope is EHTerminateScope.
authorJames Y Knight <jyknight@google.com>
Wed, 2 Feb 2022 16:32:41 +0000 (11:32 -0500)
committerJames Y Knight <jyknight@google.com>
Wed, 2 Feb 2022 22:50:18 +0000 (17:50 -0500)
commitfa87fa97fb79e4205a84b12a8c4f2f7d819473d5
treef270a0052d259c3f64ac814e24928b5c25935582
parent8e123ca65f5f9286e59f2c79184d01673c87aa42
Skip exception cleanups when the innermost scope is EHTerminateScope.

EHTerminateScope is used to implement C++ noexcept semantics. Per C++
[except.terminate], it is implemented-defined whether no, some, or all
cleanups are run prior to terminatation.

Therefore, the code to run cleanups on the way towards termination is
unnecessary, and may be omitted.

After this change, we will still run some cleanups: any cleanups in a
function called from the noexcept function will continue to run, while
those in the noexcept function itself will not.

(Commit attempt 2: check InnermostEHScope != stable_end() before accessing it.)

Differential Revision: https://reviews.llvm.org/D113620
clang/lib/CodeGen/CGCleanup.cpp
clang/test/CodeGenCXX/noexcept.cpp
clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
clang/test/OpenMP/openmp_win_codegen.cpp
clang/test/OpenMP/ordered_doacross_codegen.cpp
clang/test/OpenMP/parallel_master_codegen.cpp
clang/test/OpenMP/single_codegen.cpp
clang/test/OpenMP/taskgroup_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp