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

clang-tidy does not detect 'bugprone-assert-side-effect' for Q_ASSERT and Q_ASSERT_X

    XMLWordPrintable

Details

    • Linux/X11
    • 1a09f816a38cd4672172229971784d6bf9969846 (qt-creator/qt-creator/master)

    Description

      I wanted to use clang-tidy to detect side effects in Q_ASSERT_X like in:

      Q_ASSERT_X(x++ > 0, Q_FUNC_INFO, "x is >= 0!");

      I can choose bugprone-assert-side-effect

      but this seems to detect 'only' assert but not Q_ASSERT_X.

      Following the link: "Web Page" you can read on https://releases.llvm.org/11.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/bugprone-assert-side-effect.html#bugprone-assert-side-effect

      But there is no GUI element to set the 'Options'.

      It would be great to have a way to set the options.

       

      Work around + suggestion:

      Digging some further I finally found how to create a .clang-tidy file and put it in the folder of the source file and set the combo box from 'Select Checks' to 'Use .clang-tidy config file'.

      The .clang-tidy file had to be:

      Checks:          '-*,bugprone-assert-side-effect'
      CheckOptions:
        - key: bugprone-assert-side-effect.CheckFunctionCalls
          value: '1'
        - key: bugprone-assert-side-effect.AssertMacros
          value: 'Q_ASSERT_X,Q_ASSERT,assert,assert2,my_assert,convoluted_assert,msvc_assert'
      

      and so:

      I'm missing a way to set the CheckOptions ( a list of key - value pairs) in the GUI.

      Maybe a column between the check and the link to the web page could have a button to edit options?

      At least a button next to 'Edit Checks as String...' on inside of the dialog that creates a dump to have a starting .clang-tidy would be great.

      Something like this was started in https://bugreports.qt.io/browse/QTCREATORBUG-23223?jql=project%20%3D%20QTCREATORBUG%20AND%20text%20~%20%22clang-tidy%20CheckOptions%22

      resulting to this

      https://codereview.qt-project.org/c/qt-creator/qt-creator/+/285656

      started by Nikolai Kosjar (now not with Qt anymore) , but with changes under radar (not reviewers).

       

      Attachments

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

        Activity

          People

            kandeler Christian Kandeler
            moellney Michael Möllney
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes