KCalCore: Misc clang-tidy fixes
ClosedPublic

Authored by winterz on May 5 2019, 5:45 PM.

Details

Summary

more clang-tidy fixes:

clang-analyzer-deaddode.DeadStores in recurrencerule.cpp
clang-analyzer-optin.cplusplus.VirtualCall in calendar.cpp, freebusy.cpp, incidence.cpp, memorycalendar.cpp
readability-redundant-control-flow in freebusy.cpp
readability-avoid-const-params-in-decls in memorycalendar.cpp
Test Plan

make && make test still work

Diff Detail

Repository
R172 KCalendar Core
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
winterz created this revision.May 5 2019, 5:45 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptMay 5 2019, 5:45 PM
Restricted Application added a subscriber: kde-pim. · View Herald Transcript
winterz requested review of this revision.May 5 2019, 5:45 PM
dvratil added a comment.EditedMay 6 2019, 2:33 PM

Well, technically, calling virtual methods from ctor in dtor in those particular cases is safe and your changes do not have any impact, since the standard says that when a ctor/dtor calls a virtual function of the object currently under construction/destruction the override called is that of the current ctor's/dtor's class - in other words, it will never call an override in a more-derived class (and calling an override in a superclass is safe, because that one is already constructed/not yet destroyed). This would only be a problem (or undefined behavior, rather) if any of those methods were pure virtual, which they are not so this might be considered a false-positive from clazy.

Edit: there's also some trickyness in this when non-linear inheritance in involved, but that's not the case here either.

Well, technically, calling virtual methods from ctor in dtor in those particular cases is safe and your changes do not have any impact, since the standard says that when a ctor/dtor calls a virtual function of the object currently under construction/destruction the override called is that of the current ctor's/dtor's class - in other words, it will never call an override in a more-derived class (and calling an override in a superclass is safe, because that one is already constructed/not yet destroyed). This would only be a problem (or undefined behavior, rather) if any of those methods were pure virtual, which they are not so this might be considered a false-positive from clazy.

Edit: there's also some trickyness in this when non-linear inheritance in involved, but that's not the case here either.

Right. I will mark them as false positives in the code

winterz updated this revision to Diff 57664.May 6 2019, 5:02 PM

remove unnecssary clang-analyzer-optin.cplusplus.VirtualCall fixes and add NOLINT comments so clang-tidy ignores them

dvratil accepted this revision.May 6 2019, 7:45 PM
This revision is now accepted and ready to land.May 6 2019, 7:45 PM
This revision was automatically updated to reflect the committed changes.