This is an archive of the discontinued LLVM Phabricator instance.

Only enable -Wsuggest-override if it doesn't suggest adding override to functions that are already final
ClosedPublic

Authored by logan-5 on Jul 21 2020, 9:35 PM.

Details

Summary

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) which suggest adding override to functions that are only marked final. The current flags in both GCC >=9 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().

Diff Detail

Event Timeline

logan-5 created this revision.Jul 21 2020, 9:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 21 2020, 9:35 PM
erichkeane accepted this revision.Jul 22 2020, 10:00 AM
erichkeane added a subscriber: erichkeane.

Fix the comment as I mentioned, otherwise this LGTM.

llvm/cmake/modules/HandleLLVMOptions.cmake
677

This comment isn't exactly right, the differentation is GCC 9.1 vs GCC9.2. So it should likely be (which means it is disabled for GCC < 9.2).

ADDITIONALLY, you have the word 'it' twice.

This revision is now accepted and ready to land.Jul 22 2020, 10:00 AM
This revision was automatically updated to reflect the committed changes.