[clang] [clang-tools-extra] [Tooling] Resolve relative "directory" against the compilation database (PR #235400)
Aleksandr Platonov via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 25 20:10:14 PDT 2026
================
@@ -409,19 +412,26 @@ bool JSONCompilationDatabase::parse(std::string &ErrorMessage) {
ErrorMessage = "Missing key: \"directory\".";
return false;
}
+ SmallString<8> DirectoryStorage;
+ SmallString<128> DirectoryPath(Directory->getValue(DirectoryStorage));
----------------
ArcsinX wrote:
nit: From my experience, in most cases `"directory"` value in `compile_commands.json` is the same for all records. So, here we do a heavy (relatively to [getRawValue](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Support/YAMLParser.h#L229)) call to [getValue](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Support/YAMLParser.cpp#L2032) and `DirectoryName` recalculation for every compile command.
Maybe we can keep previous values of `getRawValue` and `DirectoryName`, so if `getRawValue` is unchanged, we don't need to perform recalculate of `DirectoryName` and just use previous value?
https://github.com/llvm/llvm-project/pull/235400
More information about the cfe-commits
mailing list