cfg/qt.cfg - Change the Q_D definition to avoid false positives#7629
cfg/qt.cfg - Change the Q_D definition to avoid false positives#7629winterz wants to merge 23 commits intocppcheck-opensource:mainfrom
Conversation
Add support for Qt macros Q_DECL_DEPRECATED and Q_DECL_DEPRECATED_X for people use the Qt library.
Change the O_D macro definition by moving the 'const' qualifier to the front of the statement. Without this change we get false positives "style: Variable 'd' can be declared as pointer to const [constVariablePointer]" The current definition follows Qt correctly as we see this define in the `QtCore/qtclasshelpermacros.h` file: Q_D(Class) Class##Private * const d = d_func() but apparently cppcheck doesn't properly recognize that as a const variable pointer.
|
Can you add a test in |
|
yes, I can add a test. however, I think a larger problem is that cppcheck seems to not like |
some simple sample code that demonstrate a problem would be nice. we should like the first code as far as I know. |
…ce#7633) Create new `QThread`s for each check, as well as for whole-program analysis, instead of restarting finished threads which is undefined behavior (see https://doc.qt.io/qt-6/qthread.html#create). Fixes Trac #13852.
In cppcheck html report, points to libera.chat rather than freenode.net
…h `--report-type=misra-cpp-2023` (cppcheck-opensource#7624)
…-opensource#7630) Add the bool isValid() signature. bool isValid(int, int, int) is already there.
…onstructor is implicitly defined (cppcheck-opensource#7637)
…e#7638) also cleaned up some `externals` includes and the order.
|
I wrote a test here but it isn't showing any problems. in my test, I did run into a checkLibraryFunction issue for |
hmm.. you already identified that it's from Q_DECLARE_PRIVATE if a simple configuration is provided like: does it work better then? That configuration is not ideal. Cppcheck can not know what value it returns then. However I am not sure that providing the template would help neither the type deduction can be too complex. |
|
I am not 100% sure that providing the exact real replacement lists for various macros is always a great idea. Maybe sometimes it's preferable to simplify the code. |
Change the O_D macro definition by moving the 'const' qualifier
to the front of the statement.
Without this change we get false positives "style: Variable 'd' can be
declared as pointer to const [constVariablePointer]"
The current definition follows Qt correctly as we see this
define in the
QtCore/qtclasshelpermacros.hfile:#define Q_D(Class) Class##Private * const d = d_func()
but apparently cppcheck doesn't properly recognize that
as a const variable pointer.