================ @@ -305,7 +342,32 @@ int main(int argc, const char **argv) { } } - clang::tooling::ClangTool Tool(OptionsParser->getCompilations(), + auto &CompilationDatabase = OptionsParser->getCompilations(); ---------------- kadircet wrote:
i think this can be simplified with something like: ``` auto VFS = llvm::vfs::getRealFileSystem(); auto &CDB = OptionsParser->getCompilations(); std::map<std::string, std::string> CDBToAbsPaths; for (auto &Source : OptionsParser->getSourcePathList()) { llvm::SmallString<256> AbsPath(Source); if (auto Err = VFS.makeAbsolute(AbsPath)) { llvm::errs() << "Failed to get absolute path for " << Source << " : " << Err.message() << '\n'; return 1; } for(auto Cmd : CDB.getCompilecommands(AbsPath)) { llvm::SmallString<256> CDBPath(Cmd.Filename); llvm::sys::fs::make_absolute(Cmd.Directory, CDBPath); CDBToAbsPaths[CDBPath] = AbsPath; } } .... if (Edit) { for (const auto &NameAndContent : Factory.editedFiles()) { llvm::StringRef FileName = NameAndContent.first(); if (auto It = CDBToAbsPaths.find(FileName); It != CDBToAbsPaths.end()) FileName = It->second; ... } } ``` https://github.com/llvm/llvm-project/pull/111375 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits