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

Wrong line found when going to declaration done by multi-line macro

    XMLWordPrintable

Details

    Description

      When using F2 or Shift+F2 to go to the declaration of a function which was declared by a multi-line preprocessor macro, Qt Creator will jump to the wrong line. It seems to add the number of lines from the preprocessor macro to the correct line.

      Steps to reproduce:

      1. Paste the following code in a file in Creator:

      #define DECLARE(x) \
          int get ## x () const; \
          void set ## x (int);
      
      struct Foo {
          DECLARE(X)
      
          DECLARE(Y)
      };
      
      void Foo::setX(int) {}
      

      2. Place the cursor on the cursor on the "setX" on the last line
      3. Press F2 or Shift+F2

      Expected outcome:
      The cursor jumps to line 6, the one with DECLARE(X).

      Actual outcome:
      The cursor jumps to line 8, two lines below the correct line. Note how two lines below is also the number of lines from the beginning of the macro to the declaration of the symbol we're looking for.

      Note also that the cursor ended up on DECLARE(Y), which is very similar and potentially very confusing.

      Attachments

        Issue Links

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

          Activity

            People

              kandeler Christian Kandeler
              thiago Thiago Macieira
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes