Enable warnings zero-as-null-pointer-constant & suggest-override
ClosedPublic

Authored by kossebau on Jul 18 2018, 4:08 PM.

Diff Detail

Repository
R32 KDevelop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kossebau created this revision.Jul 18 2018, 4:08 PM
Restricted Application added a project: KDevelop. · View Herald TranscriptJul 18 2018, 4:08 PM
Restricted Application added a subscriber: kdevelop-devel. · View Herald Transcript
kossebau requested review of this revision.Jul 18 2018, 4:08 PM
kossebau added inline comments.Jul 18 2018, 4:10 PM
CMakeLists.txt
129

This typo fix would be done as separate commit. So far it had prevented -pedantic to be enabled with GCC :)

aaronpuchert added inline comments.
CMakeLists.txt
134

With Clang you could add -Winconsistent-missing-override, although it's not exactly the same. (It's a bit weaker.)

plugins/astyle/3rdparty/libastyle/CMakeLists.txt
10–11

Maybe you can remember in add_compile_flag_if_supported if a warning flag was enabled and check that here? That would seem more consistent to me.

kossebau added inline comments.Jul 18 2018, 8:04 PM
CMakeLists.txt
134

A bit weaker might be still better than no strength at all? If so, that one would be a candidate also for https://phabricator.kde.org/source/extra-cmake-modules/browse/master/kde-modules/KDEFrameworkCompilerSettings.cmake (where I took the base snippets from).

plugins/astyle/3rdparty/libastyle/CMakeLists.txt
10–11

Agreed, had the same idea. Though for now I was lazy and just copied the approach done for the -Wdocumentation flag. Left that improvement though for a latter separate patch, until the flag addition in general are accepted.

aaronpuchert accepted this revision.Jul 18 2018, 9:10 PM
Left that improvement though for a latter separate patch, until the flag addition in general are accepted.

The flags are definitely fine, there is no reason not to use nullptr and override these days.

This revision is now accepted and ready to land.Jul 18 2018, 9:10 PM
kossebau added inline comments.Jul 23 2018, 8:58 AM
CMakeLists.txt
134

The docs say the diagnostic "-Winconsistent-missing-override" is "enabled by default.":
https://clang.llvm.org/docs/DiagnosticsReference.html#winconsistent-missing-override

Other places claim it is part of "-Wall" at least since clang 3.5, but I could not find anything related in the release notes, so far unsure when this was added and when per default enabled.

So would you think it is still needed here to try to enable it as well?

I would assume disabling it for the 3rd-party makes sense still.

aaronpuchert added inline comments.Jul 23 2018, 11:35 AM
CMakeLists.txt
134

If -Winconsistent-missing-override is on by default, there is nothing you need to do. (I haven't seen the warning for third-party code, so disabling it might also not be necessary.)

kossebau updated this revision to Diff 38249.Jul 23 2018, 12:43 PM
  • add macro add_target_compile_flag_if_supported for use with the target-specific flags
  • move both macros into new file KDevelopMacrosInternal.cmake
kossebau added inline comments.Jul 23 2018, 12:49 PM
CMakeLists.txt
134

Okay, could also not see any traces for such warnings with freebsd clang builds on CI.
So I leave inconsistent-missing-override out for now then, can be still added by those using clang if needed :)

plugins/astyle/3rdparty/libastyle/CMakeLists.txt
10–11

After I had experimentally added support for -Winconsistent-missing-override and its inversion, I found being able to drop any version checks would be nice to have already now, so went and extended the macro side of things.

As I am not sure if one can rely on the "no-" version to be present for a flag, I simply have gone to propose testing the actual flag to be used to be present, so we are on the safe side.

kossebau added a comment.EditedJul 27 2018, 4:43 PM

Given only positive feedback (here and on irc, thanks everyone), going to push now :)

This revision was automatically updated to reflect the committed changes.