Skip to content

compile_commands.json is no longer used if containing folder is deleted and recreated #7030

@Wastus

Description

@Wastus

Type: LanguageService

Describe the bug

  • OS and Version: Windows 10 Pro 1909
  • VS Code Version: 1.53.2
  • C/C++ Extension Version: 1.21
  • Other extensions you installed (and if the issue persists after disabling them): quite a few and the issue persists after disabling them, if really needed I can list them
  • Does this issue involve using SSH remote to run the extension on a remote machine?: no

We have an embedded project, which we build using CMake, setup like this:

  • SoftwareUnits/BootPart/bin/debug
  • SoftwareUnits/BootPart/bin/release
  • SoftwareUnits/BootPart/CMakeLists.txt
  • SoftwareUnits/MainPart/bin/debug
  • SoftwareUnits/MainPart/bin/release
  • SoftwareUnits/MainPart/CMakeLists.txt
  • SoftwareComponents/xyz/src/...

CMake is generating a compile_commands.json in the debug/release directories and the c_cpp_properties.json is setup like this: "compileCommands": "${workspaceFolder}/SoftwareUnits/MainPart/bin/release/compile_commands.json", for the MainPart and accordingly for the BootPart.

Our project is not structured in a way that CMakeTools would be usable, so we do not use it, but build-batches and tasks.json. So CMakeTools is not the configuration provider or providing information about compile_commands.json.

In a complete rebuild the bin/release folder gets deleted and recreated (this is not the standard use case, but sometimes we want to make sure, no caching affects the outcome of our build, so everything is deleted).

After this, the compile_commands.json is no longer parsed and a Reload window is required to get the parsing of include paths working again.

Steps to reproduce

It's a bit difficult to provide a good example. Please use the attached zip file:
cpptools#1.zip

  1. Extract the ZIP-File to C:\test so that the paths in compile_commands.json match up.
  2. Open the cpptools#1 folder with VS Code
  3. Open main.cpp to verify that the two included headers are regognized
  4. Delete the folder SoftwareUnits/main/bin/release. Note that moving or renaming the folder does not produce this result. Also note, just deleting compile_commands.json also does not provoke this behavior.
  5. An error message should appear in the error log: "${workspaceFolder}/SoftwareUnits/main/bin/release/compile_commands.json" wurde nicht gefunden. Stattdessen wird "includePath" aus "c_cpp_properties.json" im Ordner "cpptools#1" verwendet. (Probably the English equivalent, where can I set the language of the extension?) And there should appear squiggly lines under the includes, mentioning that they cannot be found.
  6. Copy the release folder from the zip file back into place.
  7. Notice the squiggly lines persist although compile_commands.json is back where it should be
  8. Perform Developer: Reload Window
  9. The squiggly lines should be gone and the includes should be found again

Expected behavior

The compile_commands.json gets used again after it has been recreated and the include paths are parsed again.

Logs
-------- Diagnostics - 23.2.2021, 11:01:23
Version: 1.2.1
Current Configuration:
{
    "name": "MainPart",
    "compileCommands": "${workspaceFolder}/SoftwareUnits/main/bin/release/compile_commands.json",
    "intelliSenseMode": "clang-arm",
    "cStandard": "c11",
    "cppStandard": "c++14",
    "compilerArgs": [],
    "intelliSenseModeIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "compilerPathIsExplicit": true,
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ C:\test\cpptools#1\SoftwareUnits\main\src\main.cpp ]:
    C:\TEST\CPPTOOLS#1\SOFTWAREUNITS\MAIN\SRC\MAIN.CPP
Translation Unit Configurations:
[ C:\test\cpptools#1\SoftwareUnits\main\src\main.cpp ]:
    Process ID: 19020
    Memory Usage: 12 MB
    Standard Version: c++14
    IntelliSense Mode: windows-clang-arm
    Other Flags:
        --clang
        --clang_version=100000
Total Memory Usage: 12 MB

------- Workspace parsing diagnostics -------
Number of folders and files enumerated: 3
Number of files discovered (not excluded): 3

cpptools/didChangeCppProperties
Es wurde kein geeigneter Compiler gefunden. Legen Sie "compilerPath" in "c_cpp_properties.json" fest.
Codesuchdienst initialisiert.
Es wurde kein geeigneter Compiler gefunden. Legen Sie "compilerPath" in "c_cpp_properties.json" fest.
Es wird versucht, Standardwerte vom C++-Compiler in der Datei "compile_commands.json" abzurufen: C:\Progra~2\IARSYS~1\EWARM_~2\arm\bin\iccarm.exe
Der Compiler für den Standard-C++-Sprachstandard wird über die Befehlszeile abgefragt: "C:\Progra~2\IARSYS~1\EWARM_~2\arm\bin\iccarm.exe" -x c++ -E -dM nul
Der Compiler für den Standard-C++-Sprachstandard wird über die Befehlszeile abgefragt: "C:\Progra~2\IARSYS~1\EWARM_~2\arm\bin\iccarm.exe" -x c++ -E -dM /dev/null
Der Compiler für den Standard-C-Sprachstandard wird über die Befehlszeile abgefragt: "C:\Progra~2\IARSYS~1\EWARM_~2\arm\bin\iccarm.exe" -x c -E -dM nul
Der Compiler für den Standard-C-Sprachstandard wird über die Befehlszeile abgefragt: "C:\Progra~2\IARSYS~1\EWARM_~2\arm\bin\iccarm.exe" -x c -E -dM /dev/null
Das Standardziel des Compilers wird über die Befehlszeile abgefragt: "C:\Progra~2\IARSYS~1\EWARM_~2\arm\bin\iccarm.exe" -dumpmachine
Unbehandelter Standardzielwert für Compiler erkannt: 
Es wurde kein geeigneter Compiler gefunden. Legen Sie "compilerPath" in "c_cpp_properties.json" fest.
  Ordner: C:/TEST/CPPTOOLS#1/SOFTWARECOMPONENTS/COMPONENT/SRC/ werden indiziert.
  Ordner: C:/TEST/CPPTOOLS#1/SOFTWAREUNITS/MAIN/SRC/ werden indiziert.
textDocument/didOpen: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp
Füllen Sie den Cache für die Includevervollständigung auf.
Dateien werden ermittelt...
cpptools/activeDocumentChange: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp
cpptools/textEditorSelectionChange
cpptools/getCodeActions: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 2)
cpptools/getFoldingRanges: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 3)
cpptools/abortRequest
cpptools/getSemanticTokens: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 4)
cpptools/getFoldingRanges: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 5)
  Ordner wird verarbeitet (rekursiv): C:/TEST/CPPTOOLS#1/SOFTWARECOMPONENTS/COMPONENT/SRC/
  Ordner wird verarbeitet (rekursiv): C:/TEST/CPPTOOLS#1/SOFTWAREUNITS/MAIN/SRC/
  Dateiermittlung: 3 Datei(en) verarbeitet
  0 Datei(en) aus Datenbank entfernt
Die Ermittlung von Dateien ist abgeschlossen.
Offene Dateien werden analysiert...
Verbleibende Dateien werden analysiert...
  Analyse: 0 Datei(en) verarbeitet
Die Analyse verbleibender Dateien ist abgeschlossen.
Die Analyse geöffneter Dateien ist abgeschlossen.
Kompilierungsargumente für "C:\TEST\CPPTOOLS#1\SOFTWAREUNITS\MAIN\SRC\MAIN.CPP" werden gesendet.
  Includes: C:\TEST\CPPTOOLS#1\SOFTWARECOMPONENTS\COMPONENT\SRC
  Sonstige: --clang
  Sonstige: --clang_version=100000
  stdver: c++14
  intelliSenseMode: windows-clang-arm
Nach Syntaxfehlern wird gesucht: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp
IntelliSense-Update für Dateien in dieser Übersetzungseinheit wird in die Warteschlange eingereiht: C:\TEST\CPPTOOLS#1\SOFTWAREUNITS\MAIN\SRC\MAIN.CPP
cpptools/getCodeActions: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 6)
cpptools/getDocumentSymbols: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 7)
cpptools/getDocumentSymbols
cpptools/finishUpdateSquiggles
Anzahl von Fehlerwellenlinien: 0
IntelliSense-Zeit aktualisieren (Sek.): 0.34
cpptools/getFoldingRanges: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 8)
Leerlaufschleife: Das aktive Dokument wird erneut analysiert.
Nach Syntaxfehlern wird gesucht: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp
IntelliSense-Update für Dateien in dieser Übersetzungseinheit wird in die Warteschlange eingereiht: C:\TEST\CPPTOOLS#1\SOFTWAREUNITS\MAIN\SRC\MAIN.CPP
cpptools/finishUpdateSquiggles
Anzahl von Fehlerwellenlinien: 0
IntelliSense-Zeit aktualisieren (Sek.): 0.253
cpptools/getSemanticTokens: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 9)
cpptools/getFoldingRanges: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 10)
cpptools/fileDeleted: file:///c%3A/test/cpptools%231/SoftwareUnits/main/bin/release
Nach Syntaxfehlern wird gesucht: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp
IntelliSense-Update für Dateien in dieser Übersetzungseinheit wird in die Warteschlange eingereiht: C:\TEST\CPPTOOLS#1\SOFTWAREUNITS\MAIN\SRC\MAIN.CPP
cpptools/finishUpdateSquiggles
Anzahl von Fehlerwellenlinien: 0
IntelliSense-Zeit aktualisieren (Sek.): 0.253
cpptools/getSemanticTokens: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 11)
cpptools/getFoldingRanges: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 12)
cpptools/didChangeCompileCommands: file:///c%3A/test/cpptools%231/SoftwareUnits/main/bin/release/compile_commands.json
IntelliSense-Server wird heruntergefahren: C:\TEST\CPPTOOLS#1\SOFTWAREUNITS\MAIN\SRC\MAIN.CPP
Nach Syntaxfehlern wird gesucht: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp
Kompilierungsargumente für "C:\TEST\CPPTOOLS#1\SOFTWAREUNITS\MAIN\SRC\MAIN.CPP" werden gesendet.
  Includes: C:\test\cpptools#1
  Sonstige: --clang
  Sonstige: --clang_version=100000
  stdver: c++14
  intelliSenseMode: windows-clang-arm
IntelliSense-Update für Dateien in dieser Übersetzungseinheit wird in die Warteschlange eingereiht: C:\TEST\CPPTOOLS#1\SOFTWAREUNITS\MAIN\SRC\MAIN.CPP
cpptools/finishUpdateSquiggles
Anzahl von Fehlerwellenlinien: 7
Fehlerwellenlinien werden deaktiviert in: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp
IntelliSense-Zeit aktualisieren (Sek.): 0.334
cpptools/getSemanticTokens: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 13)
cpptools/getFoldingRanges: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 14)
cpptools/getCodeActions: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 15)
cpptools/fileCreated: file:///c%3A/test/cpptools%231/SoftwareUnits/main/bin/release
cpptools/fileCreated: file:///c%3A/test/cpptools%231/SoftwareUnits/main/bin/release/compile_commands.json
Nach Syntaxfehlern wird gesucht: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp
IntelliSense-Update für Dateien in dieser Übersetzungseinheit wird in die Warteschlange eingereiht: C:\TEST\CPPTOOLS#1\SOFTWAREUNITS\MAIN\SRC\MAIN.CPP
cpptools/finishUpdateSquiggles
Anzahl von Fehlerwellenlinien: 7
IntelliSense-Zeit aktualisieren (Sek.): 0.254
cpptools/getSemanticTokens: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 16)
cpptools/getFoldingRanges: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 17)
cpptools/getCodeActions: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 18)
cpptools/textEditorSelectionChange
cpptools/getCodeActions: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 19)
Database safe to open
cpptools/activeDocumentChange: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp
cpptools/textEditorSelectionChange
Leerlaufschleife: Das aktive Dokument wird erneut analysiert.
Nach Syntaxfehlern wird gesucht: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp
IntelliSense-Update für Dateien in dieser Übersetzungseinheit wird in die Warteschlange eingereiht: C:\TEST\CPPTOOLS#1\SOFTWAREUNITS\MAIN\SRC\MAIN.CPP
cpptools/finishUpdateSquiggles
Anzahl von Fehlerwellenlinien: 7
IntelliSense-Zeit aktualisieren (Sek.): 0.253
cpptools/getSemanticTokens: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 20)
cpptools/getFoldingRanges: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 21)
cpptools/getCodeActions: file:///c%3A/test/cpptools%231/SoftwareUnits/main/src/main.cpp (id: 22)

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions