Not sure this will help you, but here are two remarks:
Although it isn't explicitly mentioned in the documentation, I think that the
Filename
field should contain a full path to the file (which could be important for inclusions, especially when there are "-I" switches in the command-line)from libclang's documentation (emphasis mine):
const char* CXUnsavedFile::Filename
The file whose contents have not yet been saved. This file must already exist in the file system.
I suspect
libclang
relies on the filesystem for almost everything (finding the correct file to include, checking it exists, ...) and only account forCXUnsavedFile
s at the last step, when actual content must be read.
If you can, I would suggest creating empty files in a memory filesystem. This would not incur much resource usage, and could help libclang
find the correct include files.