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

Code completion for function-like macros suggests parameters for resolved call

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • Qt Creator 4.7.1, Qt Creator 4.10.0-beta2
    • C/C++/Obj-C++ Support
    • Windows 7 x64
      Qt 5.9.1 for MinGW 5.3.0 32 bit
      Clang Code Model
    • Windows

    Description

      I have a macro COMPARE which is just a define:

      #define COMPARE(foo, bar) compare(foo, bar, __LINE__) 

      When I use the macro, I expect to see foo and bar as completion suggestions, but Creator offers me foo, bar and line from the underlying compare function.

      Example:

      #include <stdio.h>
      
      void compare(int foo, int bar, int line)
      {
        if (foo != bar)
          printf("Line %d: %d != %d", line, foo, bar);
      }
      #define COMPARE(foo, bar) compare(foo, bar, __LINE__)
      
      int main()
      {
        COMPARE(42, |)  // Cursor here, press Ctrl+Space
        // Expected: Suggestion COMPARE(foo, *bar*)
        // Actual:   Suggestion COMPARE(foo, *bar*, line)
        return 0;
      } 

      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
              aha_1980 André Hartmann
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes