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

CompilationDatabaseProjectManager ignores flags containing the file's basename

    XMLWordPrintable

Details

    • Linux/X11
    • 98a39401db (qt-creator/qt-creator/8.0) 98a39401db (qt-creator/qt-creator/master) 98a39401db (qt-creator/qt-creator/qds-3.6) 98a39401db (qt-creator/qt-creator/qds-dev) 98a39401db (qt-creator/qt-creator/9.0) 98a39401db (qt-creator/qt-creator/qds-3.7)

    Description

      To reproduce:

      • Create a compile_commands.json file with the following contents. (The other referenced filenames don't necessarily need to exist).

       

      [
        {
          "directory": "/",
          "file": "main.cpp",
          "output": "main.o",
          "arguments": [
            "g++",
            "-o",
            "main.o",
            "-c",
            "-std=c++17",
            "-DDEFINEA=\"/path/to/main.xml\"",
            "-DDEFINEB=\"/path/to/other.xml\"",
            "main.cpp"
          ]
        }
      ]
      
      • Open compile_commands.json in QtCreator to create a project.
      • Ask QtCreator to convert the project back into a compile_commands.json file (via Build -> Generate Compilation Database)

      Observed behaviour:

      QtCreator and clangd will behave as though the `DEFINEA` macro was never defined. This can be directly observed by looking at QtCreator's output compile_commands.json file, which for me contains this:

       

      [
      {
          "arguments": [
              "/usr/bin/gcc",
              "-c",
              "--target=x86_64-linux-gnu",
              "-m64",
              "-std=c++17",
              "-DDEFINEB=\"/path/to/other.xml\"",
              "-x",
              "c++",
              "/main.cpp"
          ],
          "directory": "/tmp/QtCreator-lSGjam",
          "file": "/main.cpp"
      }
      ]
      
      

      I believe this behaviour is related to the filterFromFileName function in compilationdatabaseutils.cpp, which is filtering out all flags that contain the file's basename.

      Attachments

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

        Activity

          People

            kandeler Christian Kandeler
            dphoyes David Hoyes
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes