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

Symbol toolbar is populated with wrong items when using symbols across namespaces

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • Qt Creator 4.7.0, Qt Creator 4.8.0-beta1
    • C/C++/Obj-C++ Support
    • None

    Description

      When using symbols from namespace A in namespace B, the symbol toolbar is populated with wrong and repetitive items, and it does not show anymore the current method. The issue can be reproduced with the following code:
       

      #include <QCoreApplication>
      
      typedef int ERRCODE;
      #define MYRC_OK 0
      
      namespace Other
      {
      
      class MyClass
      {
      
      };
      
      }
      
      namespace Main
      {
      
      template <class X, class Y, class Z>
      class TemplateA
      {
        public:
        explicit TemplateA();
      };
      
      template< class X, class Y, class Z >
      TemplateA< X, Y, Z >::TemplateA()
      {
      
      }
      
      template< class X, class Y >
      class TemplateB : public TemplateA< X, Y, TemplateB< X, Y > >
      {
      public:
        explicit TemplateB();
      
        ERRCODE method(Other::MyClass& );
      };
      
      template< class X, class Y >
      TemplateB< X, Y >::TemplateB()
      {
      
      }
      
      template < class X, class Y >
      ERRCODE TemplateB< X, Y >::method(Other::MyClass& )
      {
        ERRCODE ret = MYRC_OK;
        return ret;
      }
      
      #define DEFINE_SPECIALIZED_METHOD(ValueType) \
        template <> \
        ERRCODE TemplateB< X, ValueType >::method(MyClass &) \
        { \
          ERRCODE rc = MYRC_OK \
          if (rc != MYRC_OK) \
            return rc; \
          return MYRC_OK; \
        }
      
      template < class X, class Y >
      struct TemplateC;
      
      #define DEFINE_OTHER_METHODS(ValueType) \
        template <> \
        void TemplateB< X, ValueType >::init(bool) \
        { \
        }
      
      
      #ifdef MY_DEF
      DEFINE_SPECIALIZED_METHOD(Other::MyClass)
      DEFINE_OTHER_METHODS(Other::MyClass)
      #endif
      #undef DEFINE_SPECIALIZED_METHOD
      
      #ifdef MY_OTHER_DEF
      template <>
      ERRCODE TemplateB< int, float >::method(MyClass &)
      {
        return MYRC_OK;
      }
      #endif
      }
      
      int main(int argc, char *argv[])
      {
        QCoreApplication a(argc, argv);
      
        return a.exec();
      }

      After the parsing, the toolbar is populated with wrong items, and if you place the cursor inside a method (example, the constructor of TemplateA), the MYRC_OK constant is displayed.

      This is a follow-up of the analysis of the issue reported here: QTCREATORBUG-20917 . Even when using the current 4.7 HEAD (i.e. that includes the fix for the bug reported in the link), the issue happens.

      Attachments

        Issue Links

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

          Activity

            People

              yvvan Ivan Donchevskii
              becrux Antonio Di Monaco
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes