Absolute paths for UnsavedFiles

Hello,

I’ve recently stumbled upon a bug in one of the clang-related projects: we’ve been calling clang_parseTranslationUnit() from clang C API there, and we have not been able to pass both saved and unsaved files - apparently commandline we’ve been passing was not correct.
After looking into this for a while I’ve figured out that while clang is OK with accepting just file names (without paths) for real files, it demands absolute paths for the unsaved files.
So I’ve got a couple of questions:

  • Is my understanding correct, or I’ve missed something?
  • What is the motivation for this behaviour, and is there any chance we could work it around by using -I directives or anything else?
  • Could you please elaborate on the following bit from the docs on CXUnsavedFile::Filename:
    “This file must already exist in the file system”. Does it mean we have to explicitly create it in virtual FS beforehand? And if so, why does specifying the full path seem to override this requirement?

I’ve tried debugging this, but unfortunately, I didn’t manage to fully understand the logic behind it :frowning:

Thank you!