I am facing a problem with the recent version of libclang on Windows.
The first problem: file save permission error within codelite IDE:
In codelite IDE I am using libclang in the following manner:
- When a file is loaded into the editor I am calling libclang API to create a TU which is later then cache (up to 5 TUs are cached). Note that I am using the preamble flag to boost completion speed (and indeed it does)
- A subsequent calls to code complete (Ctrl-SPACE) are re-using the TU (which works great and in acceptable response time)
The following causes an issue within codelite:
If I load into the IDE a file (e.g. file.cpp) which has an include statement to another header file (e.g. file.h) - codelite will compile and cache the TU for file.cpp
Now, if I will try to open, edit and save file.h - I will get a “Save” error (this is because apparently the file.h is being kept opened by the libclang)
The only way to unlock and release the file is by calling clang_disposeTranslationUnit() for the cache TU for file.cpp
I can workaround it in the IDE in 2 ways:
- When a tab is changed inside the IDE - I can clear the TU cache. This will probably work, but will force a recreation of the TU object each time user loads the file
- whenever user faces a write error (permission denied) codelite will dispose the cached TU and try to save the file again (internally)
The Second problem:
My SSD drive size is about 120GB of free space, I noticed that its size was reduced to ~70GB … searching around the file system, I noticed that under %TMP% there are hundreds of preamble*.pch files
It seems as if when disposing a TU the PCH file is not removed from the file system.
Again, I worked around it by adding a cleaner thread that will periodically remove all preamble*.pch files (and silently ignore those who are opened in codelite)