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

clang-format adds spaces around -> when emitting a signal

    XMLWordPrintable

Details

    • d66163c09 (15.0)

    Description

      When emitting the signal of a QObject returned by a function, clang-format adds spaces around ->

      // We have the following function:
      MyObject *getObject();
      
      // With clang-format 17 and before
      emit getObject()->mySignal();
      Q_EMIT getObject()->mySignal();
      
      // With clang-format 18
      emit getObject() -> mySignal();
      Q_EMIT getObject() -> mySignal();
      

      clang-format 19+ has the same behavior than clang-format 18,
      but setting StatementAttributeLikeMacros: [emit, Q_EMIT] restores the old behavior.

      StatementAttributeLikeMacros with clang-format 18 does not have any effect on this issue.

      Given that it is an upstream bug, the only required fixes would be to:

      • not use clang-format 18
      • add emit to StatementAttributeLikeMacros in Qt built-in style, as only Q_EMIT is set for now.

      Attachments

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

        Activity

          People

            artem.sokolovskii Artem Sokolovskii (Inactive)
            bterrier Benjamin Terrier
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes