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

Clang: Highlighting of argument to user defined index operator is wrong

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • Qt Creator 3.6.0
    • C/C++/Obj-C++ Support

      struct Foo {
          Foo &operator[](int key);
      };
      
      void failsHere()
      {
          const int index = 3;
          Foo foo;
          foo[index]; // Ops, "index" is highlighted as "function"
      }
      
      void worksAsExpectedHere()
      {
          const int index = 3;
          int foo[100];
          foo[index]; // OK, "index" is highlighted as "local variable".
      }
      

      This is a libclang bug, re-producible with libclang 3.6 and the current (not yet released) 3.8.

      Underlying issue seems to be that the "referenced cursor" for "index" is of kind CXCursor_CXXMethod, not CXCursor_VarDecl.

        For Gerrit Dashboard: QTCREATORBUG-15473
        # Subject Branch Project Status CR V

            kosjar Nikolai Kosjar
            kosjar Nikolai Kosjar
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes