Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-17518

Q_OBJECT macro triggers override warning with Clang Code Model and no Clang compiler

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • Qt Creator 4.2.0
    • C/C++/Obj-C++ Support
    • None

    Description

      In one of the recent versions of Qt (5.5 I think) the issue of Clang compiler warning about missing override specifier in Q_OBJECT macro has been resolved by disabling said warning for the macro. The defines rely on the information about used compiler and thus the fix does not work when using only the Clang Code Model through Qt Creator plugin and not the Clang compiler itself.

      Steps to reproduce:
      1. Open Qt Creator and use non-Clang compiler
      1. Enable Clang Code Model plugin in Qt Creator
      2. Create a project and derive a class from QObject (include Q_OBJECT macro)
      3. Create another class that derives from the class created in step 2.

      Clang Code Model will issue warning about the override specifiers missing in the Q_OBJECT macro.

      Suggested solution:

      Since Q_OBJECT is only used in QObject class and in classes derived from it I would suggest creating a separate macro for QObject class (e.g. Q_OBJECT_BASE without any specifiers) and adding Q_DECL_OVERRIDE to the virtual methods in Q_OBJECT macro (used by subclasses). That will satisfy the Clang static analysis and it would not be even needed to use Q_OBJECT_NO_OVERRIDE_WARNING I believe.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              thiago Thiago Macieira
              resurr3ction Michael Vlach
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes