Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
Qt Creator 8.0.0
-
None
-
-
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.