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

Find references doesn't work for shared_ptr on msvc2017 compiler

    XMLWordPrintable

Details

    • Windows
    • 9ee693ee229d28bd618e8dd44bc6b12750d43a29 (qt-creator/qt-creator/master)

    Description

      "Find References to Symbol Under Cursor" doesn't work for std::shared_ptr's function call (right click on bar() in example) when using MSVC 2017.

      #include <memory>
      struct foo
      {
          int bar(){return 1;}
      };
      int main()
      {
          std::shared_ptr<foo> sharedPtr(new foo());
          int res=sharedPtr->bar(); // <<< --- HERE find references on "bar" doesn't work
          return res;
      }
      

      It fails in cpprefactoringengine.cpp - canonicalSymbol is null:

      void CppRefactoringEngine::findUsages(const CursorInEditor &data,
                                            UsagesCallback &&) const
      {
          [...]
          if (const CPlusPlus::Macro *macro = findCanonicalMacro(cursor, info.doc)) {
              modelManager->findMacroUsages(*macro);
          } else {
              CanonicalSymbol cs(info.doc, info.snapshot);
              CPlusPlus::Symbol *canonicalSymbol = cs(cursor);
              if (canonicalSymbol) // <<< --- HERE
                  modelManager->findUsages(canonicalSymbol, cs.context());
          }
      }
      

      It works OK when MSVC 2015 compiler used.

      Attachments

        Issue Links

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

          Activity

            People

              bubke Marco Bubke
              volodymyr.zibarov Volodymyr Zibarov
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes