If -resource-dir is not specified as part of the compilation command, then by default
clang-scan-deps picks up a directory relative to its own path as resource-directory.
This is probably not the right behavior - since resource directory should be picked relative
to the path of the clang-compiler in the compilation command.
This patch adds support for it along with a cache to store the resource-dir paths based on
compiler paths.
Notes:
- "-resource-dir" is a behavior that's specific to clang, gcc does not have that flag. That's why if I'm not able to find a resource-dir, I quietly ignore it.
- Should I also use the mtime of the compiler in the cache? I think its not strictly necessary since we assume the filesystem is immutable.
- From my testing, this does not regress performance.
- Will try to get this tested on Windows.
But basically the problem that this patch is trying to solve is, clients might not always want to specify
"-resource-dir" in their compile commands, so scan-deps must auto-infer it correctly.
This doesn't need to return a std::string as the lifetime of the returned string is the same as the lifetime of ResourceDirectoryCache::Cache. It can be a StringRef instead.