The ResourceDirectoryCache is useful not only in the clang-scan-deps CLI tool, but also in the downstream libclang API. This NFC patch moves it to DependencyScanningService.h. to make it reusable.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I don't think this should be reused. If I'm reading the code correctly, this is just a super heavyweight (but cached) call to Driver::GetResourcesPath(). It should probably be deleted instead.
I suggest instead:
- Use Driver::GetResourcesPath() directly in the libclang application.
- Figure out if it's safe to do that here as well, and if so, delete this and use it here.
Regarding "is it safe?", the question is whether we expect the clang-scan-deps to be built from the same sources as the clang it's scanning for. I think we do. We're relying on that already for the results of the scan to be correct.
clang/tools/clang-scan-deps/ClangScanDeps.cpp | ||
---|---|---|
422–423 | This is likely much faster, since it avoids a lock: assert(!Args.empty()); std::string ResourceDir = Driver::GetResourcePath(Args[0]); But if the string operations turn out to be expensive we could add caching on top. Unless, is it supported/expected for clang-scan-deps to be from a different toolchain than clang? | |
424–427 | I assume this is for performance (to avoid doing the filesystem search in each invocation)? If so, please add a comment explaining that. |
clang-format not found in user’s local PATH; not linting file.