Skip to content

Commit

Permalink
refactor: disable non-virtual-destructor warnings
Browse files Browse the repository at this point in the history
-Wnon-virtual-dtor is noisy and we keep disabling it. I never made the
mistake it tries to fix. Disable the warning codebase-wide.
  • Loading branch information
strager committed Sep 3, 2023
1 parent 03a8af3 commit e0bbda1
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ quick_lint_js_configure_exception_handling()
quick_lint_js_configure_rtti()
quick_lint_js_work_around_implicit_link_directories()
quick_lint_js_enable_dead_code_stripping()
quick_lint_js_disable_unwanted_warnings()

if (WIN32)
add_definitions(-D_WIN32_WINNT=0x0602)
Expand Down
23 changes: 23 additions & 0 deletions cmake/QuickLintJSCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,29 @@ function (quick_lint_js_enable_dead_code_stripping)
quick_lint_js_add_cxx_linker_flag_if_supported(-Wl,--gc-sections QUICK_LINT_JS_HAVE_GC_SECTIONS)
endfunction ()

function (quick_lint_js_disable_unwanted_warnings)
quick_lint_js_get_supported_warning_options(
"-Wno-non-virtual-dtor"
WARNING_OPTIONS_TO_ADD
)
if (WARNING_OPTIONS_TO_ADD)
# HACK(strager): CMake likes to deduplicate options. This can change
# semantics. For example:
#
# # NOTE: -Weffc++ implies -Wnon-virtual-dtor
# -Wno-non-virtual-dtor -Weffc++ -Wno-non-virtual-dtor
#
# # Deduplication by CMake:
# -Wno-non-virtual-dtor -Weffc++
# # Now -Wnon-virtual-dtor is enabled!
#
# Prevent deduplication by prefixing options with "SHELL:".
foreach (WARNING_OPTION IN LISTS WARNING_OPTIONS_TO_ADD)
add_compile_options("SHELL:${WARNING_OPTION}")
endforeach ()
endif ()
endfunction ()

function (quick_lint_js_optimize_target_for_code_size TARGET)
quick_lint_js_target_add_c_cxx_flag_if_supported("${TARGET}" -Oz QUICK_LINT_JS_HAVE_OPTIMIZE_GNU_OZ)
if (QUICK_LINT_JS_HAVE_OPTIMIZE_GNU_OZ_C OR QUICK_LINT_JS_HAVE_OPTIMIZE_GNU_OZ_CXX)
Expand Down
3 changes: 0 additions & 3 deletions src/quick-lint-js/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@
#include <unistd.h>
#endif

QLJS_WARNING_IGNORE_CLANG("-Wnon-virtual-dtor")
QLJS_WARNING_IGNORE_GCC("-Wnon-virtual-dtor")

namespace quick_lint_js {
namespace {
bool stderr_supports_terminal_escapes() {
Expand Down
7 changes: 0 additions & 7 deletions src/quick-lint-js/io/event-loop.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <quick-lint-js/port/char8.h>
#include <quick-lint-js/port/have.h>
#include <quick-lint-js/port/span.h>
#include <quick-lint-js/port/warning.h>

#if QLJS_HAVE_KQUEUE
struct kevent;
Expand All @@ -40,10 +39,6 @@ struct kevent;
#define QLJS_EVENT_LOOP2_PIPE_WRITE 1
#endif

QLJS_WARNING_PUSH
QLJS_WARNING_IGNORE_CLANG("-Wnon-virtual-dtor")
QLJS_WARNING_IGNORE_GCC("-Wnon-virtual-dtor")

namespace quick_lint_js {
class Event_Loop_Base;

Expand Down Expand Up @@ -519,8 +514,6 @@ using Event_Loop =
;
}

QLJS_WARNING_POP

#endif

// quick-lint-js finds bugs in JavaScript programs.
Expand Down
4 changes: 0 additions & 4 deletions test/test-event-loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <quick-lint-js/port/have.h>
#include <quick-lint-js/port/kqueue.h>
#include <quick-lint-js/port/thread.h>
#include <quick-lint-js/port/warning.h>
#include <quick-lint-js/util/synchronized.h>
#include <thread>
#include <vector>
Expand All @@ -32,9 +31,6 @@
#include <quick-lint-js/port/windows-error.h>
#endif

QLJS_WARNING_IGNORE_CLANG("-Wnon-virtual-dtor")
QLJS_WARNING_IGNORE_GCC("-Wnon-virtual-dtor")

using ::testing::ElementsAreArray;
using namespace std::literals::chrono_literals;

Expand Down

0 comments on commit e0bbda1

Please sign in to comment.