GCC Code Coverage Report


ernie/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
32 / 54
59.3%
Branches:
16 / 36
44.4%
Functions:
10 / 13, 1 excl
76.9%

util/on_failure.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 /// @file on_failure.h
3 /// @brief Undoing a step when what follows it throws, so constructors that make several handles
4 /// leak none when one fails.
5 #pragma once
6
7 #include <exception>
8 #include <utility>
9
10 namespace ernie {
11
12 /// @brief Runs `undo` when destroyed by an exception's unwinding, and not otherwise.
13 template <typename Undo> class OnFailure {
14 public:
15 985 explicit OnFailure(Undo undo)
16
6/10
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 603 times.
✓ Branch 1 taken 95 times.
✗ Branch 2 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 78 times.
✓ Branch 4 taken 15 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 5 not taken.
985 : undo_(std::move(undo)), exceptions_(std::uncaught_exceptions()) {}
17 985 ~OnFailure() {
18
10/26
ernie::OnFailure<ernie::BindlessHeap::BindlessHeap(ernie::DeviceContext&)::{lambda()#1}>::~OnFailure():
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
ernie::OnFailure<ernie::BindlessHeap::BindlessHeap(ernie::DeviceContext&)::{lambda()#2}>::~OnFailure():
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
ernie::OnFailure<ernie::ComputeKernel::ComputeKernel(ernie::DeviceContext&, std::span<unsigned int const, 18446744073709551615ul>, std::basic_string_view<char, std::char_traits<char> >, unsigned int, ernie::BindlessHeap const*, std::basic_string_view<char, std::char_traits<char> >)::{lambda()#1}>::~OnFailure():
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
ernie::OnFailure<ernie::CreateImportedBuffer(VkDevice_T*, VkPhysicalDevice_T*, VkBufferCreateInfo const&, ernie::ExternalHandle&, VkBuffer_T*&, VkDeviceMemory_T*&)::{lambda()#1}>::~OnFailure():
✗ Branch 0 not taken.
✗ Branch 1 not taken.
ernie::OnFailure<ernie::CreateImportedBuffer(VkDevice_T*, VkPhysicalDevice_T*, VkBufferCreateInfo const&, ernie::ExternalHandle&, VkBuffer_T*&, VkDeviceMemory_T*&)::{lambda()#2}>::~OnFailure():
✗ Branch 0 not taken.
✗ Branch 1 not taken.
ernie::OnFailure<ernie::DeviceColumn::Resize(unsigned long, ernie::Queue&, std::span<ernie::Ticket const, 18446744073709551615ul>)::{lambda()#1}>::~OnFailure():
✗ Branch 0 not taken.
✓ Branch 1 taken 460 times.
ernie::OnFailure<ernie::DeviceContext::DeviceContext(ernie::DeviceContextOptions const&)::{lambda()#1}>::~OnFailure():
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
ernie::OnFailure<ernie::DeviceContext::DeviceContext(ernie::DeviceContextOptions const&)::{lambda()#2}>::~OnFailure():
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
ernie::OnFailure<ernie::DeviceContext::DeviceContext(ernie::DeviceContextOptions const&)::{lambda()#3}>::~OnFailure():
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
ernie::OnFailure<ernie::DeviceImage::DeviceImage(ernie::DeviceContext&, ernie::ImageDescription const&, std::basic_string_view<char, std::char_traits<char> >)::{lambda()#1}>::~OnFailure():
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
ernie::OnFailure<ernie::DeviceImage::DeviceImage(ernie::DeviceContext&, ernie::ImageDescription const&, std::basic_string_view<char, std::char_traits<char> >)::{lambda()#2}>::~OnFailure():
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
ernie::OnFailure<ernie::Instance::Instance(ernie::InstanceOptions const&)::{lambda()#1}>::~OnFailure():
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
ernie::OnFailure<ernie::Timeline::Timeline(VkDevice_T*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, ernie::ExternalHandle)::{lambda()#1}>::~OnFailure():
✗ Branch 0 not taken.
✗ Branch 1 not taken.
985 if (std::uncaught_exceptions() > exceptions_) {
19 ✗ undo_();
20 }
21 985 }
22 OnFailure(const OnFailure&) = delete;
23 OnFailure& operator=(const OnFailure&) = delete;
24
25 private:
26 Undo undo_;
27 int exceptions_;
28 };
29
30 } // namespace ernie
31