Set CXX min version to C++11, fix of warnings
ClosedPublic

Authored by Kanedias on Oct 27 2017, 12:50 PM.

Details

Summary

Set CXX min version to C++11, fix of warnings

- Add `override` to virtual functions where needed
- Add `static` to functions wthout definition
- Replace `0` with `nullptr` where needed
Test Plan

Just cleaned up code, no changes yet

Diff Detail

Repository
R7 Konversation
Branch
wip/qtquick-c++11
Lint
Lint OK
Unit
No Unit Test Coverage
Kanedias created this revision.Oct 27 2017, 12:50 PM
hein added a comment.Oct 27 2017, 2:04 PM

This is nice, but it would be great to fix the other 20% of warnings it causes, too, otherwise it's a noisy build that hides more important warnings :)

Kanedias added a comment.EditedOct 27 2017, 3:55 PM
In D8520#160857, @hein wrote:

This is nice, but it would be great to fix the other 20% of warnings it causes, too, otherwise it's a noisy build that hides more important warnings :)

Will do, though some issues with old phonon headers will remain...

I just wanted to make sure CMake & C++ std version bump is OK for us :)

Kanedias updated this revision to Diff 21498.Oct 28 2017, 4:31 PM
Kanedias edited the summary of this revision. (Show Details)
  • Add out-of-tree translation unit for KonviSettingsPage
  • Remove redundant copy-constructor for ConnectionSettings
  • Fix rest of warnings
Kanedias added a comment.EditedOct 28 2017, 4:31 PM

Phew... that was interesting dive.
I guess this is now ready for review, @hein

In case you see other warnings I may have missed, please let me know.

Kanedias retitled this revision from Set CXX min version to C++11, fix ~80% of warnings to Set CXX min version to C++11, fix of warnings.Oct 29 2017, 7:42 AM
apol added a subscriber: apol.Oct 30 2017, 7:07 PM
apol added inline comments.
src/config/preferences.cpp
379

Make const.

src/config/warnings_config.cpp
209

warningDialogDefinitions should be const. Use either qAsConst or make const.

src/dbus.cpp
242

const

src/dcc/chat.cpp
421

Why do you need this if you have a default?

434

Why do you need this if you have a default?

src/dcc/chatcontainer.cpp
134

Why do you need this if you have a default?

src/sound.cpp
41

weird new line.

src/statusbar.cpp
67

Weird new line

src/unicode.cpp
58

Why do you need this if you have a default?

src/viewer/channeloptionsdialog.cpp
323

This looks wrong. Should it be QString::number()? Or just QVariant()? I may be wrong...

src/viewer/ignore.h
33

?

src/viewer/searchbar.cpp
123

const

Kanedias added inline comments.Oct 30 2017, 9:23 PM
src/dcc/chat.cpp
421

Clang complains about this an you asked to deal with all warnings so here it is :)

The rationale behind this is if you want to extend enum then it will fall through to default case which is probably not what you want.
With this check in place (-Wswitch-enum) it will warn you again if you missed one or more switches while extending enum.

I can remove this if you want.

434

Replied above

src/dcc/chatcontainer.cpp
134

Replied above

src/sound.cpp
41

Fixed

src/statusbar.cpp
67

Fixed

src/unicode.cpp
58

Replied above

src/viewer/channeloptionsdialog.cpp
323

Well it was effectively the same in the old variant, i is QChar here... let me indicate this in a loop init to make it more clear.

src/viewer/ignore.h
33

Enums are implicitly 'int's, 1 << 31 is 0x80 00 00 00, 8 here sets highest possible bit of 'int' variable, which is a sign digit and it flips the sign. I figured out that we need just a big value for the Exception flag, so 30 would suffice.

src/viewer/searchbar.cpp
123

Done

Kanedias updated this revision to Diff 21591.Oct 30 2017, 9:25 PM
Kanedias retitled this revision from Set CXX min version to C++11, fix of warnings to Set CXX min version to C++11, fix of warnings.

Fixes for review comments

Kanedias added inline comments.Oct 30 2017, 9:29 PM
src/config/warnings_config.cpp
209

But it's const... It looks like const struct {...} warningDialogDefinitions. Compiler gives me "duplicate const" warning if I try to add one between } and its name

apol added inline comments.Oct 31 2017, 1:23 AM
src/dcc/chat.cpp
421

If there's no other cases, I'd suggest to drop the default. But then this is @hein's decision.

hein added inline comments.Nov 1 2017, 9:47 AM
src/dcc/chat.cpp
421

I'm OK-ish with exhaustive matching, maybe getting biased from Rust pattern matching ...

src/irc/server.cpp
3310

Why?

3324

Why?

Kanedias added inline comments.Nov 1 2017, 10:53 AM
src/irc/server.cpp
3310

Unreachable statements

3324

Here too, first condition always returns.

hein added a comment.Nov 1 2017, 11:20 AM

About those unreachable statements: Could you leave them in but comment them out? I have a feeling that was someone's poor attempt at leaving a TODO in ...

In D8520#162766, @hein wrote:

About those unreachable statements: Could you leave them in but comment them out? I have a feeling that was someone's poor attempt at leaving a TODO in ...

Sure, will update when I'm home.

Kanedias updated this revision to Diff 21734.Nov 1 2017, 9:27 PM

Returned unreachable statements, commented out

hein accepted this revision.Nov 2 2017, 8:55 AM

Please put into wip/qtquick :)

This revision is now accepted and ready to land.Nov 2 2017, 8:55 AM
apol added a comment.Nov 2 2017, 2:29 PM

FWIW, note there's Qt's Q_UNREACHABLE macro for this (which asserts when hit).

Kanedias closed this revision.Nov 2 2017, 5:42 PM
In D8520#163530, @apol wrote:

FWIW, note there's Qt's Q_UNREACHABLE macro for this (which asserts when hit).

Clang still complaints with it but thanks, will keep in mind!