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

Projects created from compile_commands.json cannot Switch Header/Source

    XMLWordPrintable

Details

    • 2c5808bada8cbca42131e63495f4dd251b36acfb (qt-creator/qt-creator/master)

    Description

      Source code project:

      File Content
      A.cpp
      #include "A.h"
       
      void A::Hey() { }
      
      int main() {}
      
      myincludes/A.h  
      class A {
        void Hey();
      }; 
      compile_commands.json
      [
          {
              "arguments": [
                  "/usr/bin/g++", 
                  "-c", 
                  "-I", 
                  "myincludes", 
                  "A.cpp"
              ], 
              "directory": "/bugs", 
              "file": "A.cpp"
          }
      ]

      Reproduction:

      0. Install Bear.
      1. With above sources, bear g++ -I myincludes A.cpp
      2. Enable the plugin CompilationDatabaseProjectManager.
      3. Open compile_commands.json (shown above for completeness).
      4. CTRL+K and open A.cpp.
      5. Tools -> C++ -> Switch Header/Source

      Actual:
      Nothing happens.

      Expected:
      A.h opens up.

      Note:
      To always hit the right header file, we will need to search header dirs in GCC/Clang's order, see lookup order in GCC's manual. For instance, if A.h is found in both . and -I myincludes then ./A.h should be picked up.

      Attachments

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

        Activity

          People

            hugoh Hugo Holgersson
            hugoh Hugo Holgersson
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There is 1 open Gerrit change