Only enable -Wsuggest-override if it doesn't suggest adding override to functions...
authorLogan Smith <logan.r.smith0@gmail.com>
Wed, 22 Jul 2020 17:03:49 +0000 (10:03 -0700)
committerLogan Smith <logan.r.smith0@gmail.com>
Wed, 22 Jul 2020 17:03:49 +0000 (10:03 -0700)
commit274b6b0c7a8b584662595762eaeff57d61c6807f
tree9b800fc5c4c02b02fbb2a7e8a6e9bafe7f89a773
parenta1d99aff7c2ab47e3621c26a39eb1b4c287dee68
Only enable -Wsuggest-override if it doesn't suggest adding override to functions that are already final

A previous patch added -Wsuggest-override using a simple add_flag_if_supported(). This causes lots of warnings in LLVM when building with older GCC versions (< 9.2) which suggest adding override to functions that are only marked final. The current flags in both GCC >=9.2 and Clang accept plain final as equivalent to override final.

This patch adds logic to detect versions of -Wsuggest-override that warn on void foo() final and disables them to avoid warning spam in builds using older GCC's. This has the added minor benefit of getting rid of the useless C_SUPPORTS_SUGGEST_OVERRIDE_FLAG CMake cache variable which was set by add_flag_if_supported().

Differential Revision: https://reviews.llvm.org/D84292
llvm/cmake/modules/HandleLLVMOptions.cmake