llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clangd Author: Dmitrii Sharshakov (dsseng) <details> <summary>Changes</summary> A compile_commands.json with Windows paths would make clangd assert on a POSIX system, and vice versa. Make path traversal functions skip paths of the incompatible format. Could not invent a test for this one, should be trivial enough. Fixes #<!-- -->146798 --- Full diff: https://github.com/llvm/llvm-project/pull/148019.diff 1 Files Affected: - (modified) clang-tools-extra/clangd/GlobalCompilationDatabase.cpp (+6) ``````````diff diff --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp index 7c0eb9651feaa..4d934d268fdfd 100644 --- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp +++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp @@ -47,6 +47,9 @@ namespace { // deepest directory and going up to root. Stops whenever action succeeds. void actOnAllParentDirectories(PathRef FileName, llvm::function_ref<bool(PathRef)> Action) { + // Skip non-native paths which we cannot traverse or otherwise use. + if (!llvm::sys::path::is_absolute(FileName, llvm::sys::path::Style::native)) + return; for (auto Path = absoluteParent(FileName); !Path.empty() && !Action(Path); Path = absoluteParent(Path)) ; @@ -680,6 +683,9 @@ class DirectoryBasedGlobalCompilationDatabase::BroadcastThread::Filter { SearchPaths[I].setPointer(&Dirs[*Parent.Opts.CompileCommandsDir]); continue; } + // Skip non-native paths which we cannot traverse or otherwise use. + if (!llvm::sys::path::is_absolute(AllFiles[I], llvm::sys::path::Style::native)) + continue; if (ExitEarly()) // loading config may be slow return Filtered; WithContext WithProvidedContent(Parent.Opts.ContextProvider(AllFiles[I])); `````````` </details> https://github.com/llvm/llvm-project/pull/148019 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits