From a144002bf00c4789efb59ec287d27c5cf4b41461 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Mon, 19 Feb 2024 00:21:48 +0700 Subject: [PATCH] Tweaks from clang-tidy (#92) This is (perhaps) mainly for discussion as I saw you removed `clang-tidy` checks last year. These fix a variety of minor things. With one of the options that I was using, these still remain: ``` /Users/bruce/Development/custodian/cpptrace/src/symbols/../utils/utils.hpp:235:22: warning: noexcept specifier on the move constructor evaluates to 'false' [performance-noexcept-move-constructor] 235 | noexcept(std::is_nothrow_move_constructible::value) | ^ /Users/bruce/Development/custodian/cpptrace/src/symbols/../utils/utils.hpp:250:64: warning: noexcept specifier on the move assignment operator evaluates to 'false' [performance-noexcept-move-constructor] 250 | noexcept(std::is_nothrow_move_assignable::value && std::is_nothrow_move_constructible::value) | ^ ``` --- include/cpptrace/cpptrace.hpp | 4 ++-- src/binary/mach-o.hpp | 4 ++-- src/cpptrace.cpp | 6 +++--- src/symbols/symbols_with_libdwarf.cpp | 6 +++--- src/utils/utils.hpp | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/cpptrace/cpptrace.hpp b/include/cpptrace/cpptrace.hpp index 2a03162..b4bb01f 100644 --- a/include/cpptrace/cpptrace.hpp +++ b/include/cpptrace/cpptrace.hpp @@ -293,7 +293,7 @@ namespace cpptrace { // Interface for a traced exception object class CPPTRACE_EXPORT exception : public std::exception { public: - virtual const char* what() const noexcept = 0; + const char* what() const noexcept override = 0; virtual const char* message() const noexcept = 0; virtual const stacktrace& trace() const noexcept = 0; }; @@ -413,7 +413,7 @@ namespace cpptrace { mutable std::string message_value; public: explicit nested_exception( - std::exception_ptr exception_ptr, + const std::exception_ptr& exception_ptr, raw_trace&& trace = detail::get_raw_trace_and_absorb() ) noexcept : lazy_exception(std::move(trace)), ptr(exception_ptr) {} diff --git a/src/binary/mach-o.hpp b/src/binary/mach-o.hpp index b0260a3..7769089 100644 --- a/src/binary/mach-o.hpp +++ b/src/binary/mach-o.hpp @@ -372,7 +372,7 @@ namespace detail { // produce information similar to dsymutil -dump-debug-map static void print_debug_map(const debug_map& debug_map) { for(const auto& entry : debug_map) { - std::cout<"<" << '\n'; return; } const auto reset = color ? ESC "0m" : ""; @@ -237,7 +237,7 @@ namespace cpptrace { } } if(newline_at_end || &frame != &frames.back()) { - stream << std::endl; + stream << '\n'; } counter++; } diff --git a/src/symbols/symbols_with_libdwarf.cpp b/src/symbols/symbols_with_libdwarf.cpp index 20d691b..d357fdf 100644 --- a/src/symbols/symbols_with_libdwarf.cpp +++ b/src/symbols/symbols_with_libdwarf.cpp @@ -186,7 +186,7 @@ namespace libdwarf { } CPPTRACE_FORCE_NO_INLINE_FOR_PROFILING - ~dwarf_resolver() { + ~dwarf_resolver() override { // TODO: Maybe redundant since dwarf_finish(dbg); will clean up the line stuff anyway but may as well just // for thoroughness for(auto& entry : line_contexts) { @@ -928,7 +928,7 @@ namespace libdwarf { optional> symbols; std::unique_ptr resolver; - target_object(std::string object_path) : object_path(object_path) {} + target_object(std::string object_path) : object_path(std::move(object_path)) {} std::unique_ptr& get_resolver() { if(!resolver) { @@ -1003,7 +1003,7 @@ namespace libdwarf { // get symbol entries from debug map, as well as the various object files used to make this binary for(auto& entry : source_debug_map) { // object it came from - target_objects.push_back({std::move(entry.first)}); + target_objects.push_back({entry.first}); // push the symbols auto& map_entry_symbols = entry.second; symbols.reserve(symbols.size() + map_entry_symbols.size()); diff --git a/src/utils/utils.hpp b/src/utils/utils.hpp index c51a2a2..c61db30 100644 --- a/src/utils/utils.hpp +++ b/src/utils/utils.hpp @@ -280,7 +280,7 @@ namespace detail { return *this; } - void swap(optional& other) { + void swap(optional& other) noexcept { if(holds_value && other.holds_value) { std::swap(uvalue, other.uvalue); } else if(holds_value && !other.holds_value) { @@ -409,7 +409,7 @@ namespace detail { optional deleter; public: raii_wrapper(T obj, D deleter) : obj(obj), deleter(deleter) {} - raii_wrapper(raii_wrapper&& other) noexcept : obj(std::move(other.obj)), deleter(other.deleter) { + raii_wrapper(raii_wrapper&& other) noexcept : obj(std::move(other.obj)), deleter(std::move(other.deleter)) { other.deleter = nullopt; } raii_wrapper(const raii_wrapper&) = delete;