I am the author of an package for Emacs that brings libclang power to Emacs. It has been reported to me (here: https://github.com/Sarcasm/irony-mode/issues/134) that libclang has some issues on Windows. After some search I have identified a situation that triggers the issue consistently.
I have a pair of file, source file and header files.
#endif /* !FOO_H_ */
foo.cpp is incomplete because it is used for requesting code-completion to libclang at the point of the pipe ‘|’.
If I request code completion a first time, everything work as expected.
If I edit foo.h to remove the method foobar() from the struct Foo, code completion still work as expected.
If I restore the foobar() method, code completion breaks with the following diagnostics in this case:
./foo.h:9:2: error: invalid preprocessing directive
./foo.h:1:2: error: unterminated conditional directive
I have tested with some bigger changes in terms of characters, removing a big comment (~1000 chars) for example and the errors was slightly different in this case, warning about null chars in the header file.
I have the feeling that the internal buffer Clang has for the header file foo.h get corrupted somehow.
Does anyone have opinion about this?
Some places to look for or ways to debug this?
This doesn’t seem to happen on Linux.
I just tried with the trunk (r225060), the issue is still present.
A slightly more detailed procedure is described here https://github.com/Sarcasm/irony-mode/issues/134#issuecomment-68412195 if someone want to reproduce the bug. It is using irony-server, a small C++ program that builds with CMake and depends on libclang. This program should be easy to get working for people already building Clang on Windows (should work with cl/clang-cl/mingw).