This revision was automatically updated to reflect the committed changes. Closed by commit rGa3b793401255: [clangd] Don't mangle workdir-relevant driver path in compile commands (authored by sammccall).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82011/new/ https://reviews.llvm.org/D82011 Files: clang-tools-extra/clangd/CompileCommands.cpp clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp +++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp @@ -115,7 +115,7 @@ Cmd = {"foo/unknown-binary", "foo.cc"}; Mangler.adjust(Cmd); - EXPECT_EQ(testPath("fake/unknown-binary"), Cmd.front()); + EXPECT_EQ("foo/unknown-binary", Cmd.front()); } // Only run the PATH/symlink resolving test on unix, we need to fiddle Index: clang-tools-extra/clangd/CompileCommands.cpp =================================================================== --- clang-tools-extra/clangd/CompileCommands.cpp +++ clang-tools-extra/clangd/CompileCommands.cpp @@ -135,6 +135,12 @@ // First, eliminate relative paths. std::string Storage; if (!llvm::sys::path::is_absolute(Driver)) { + // If it's working-dir relative like bin/clang, we can't resolve it. + // FIXME: we could if we had the working directory here. + // Let's hope it's not a symlink. + if (llvm::any_of(Driver, + [](char C) { return llvm::sys::path::is_separator(C); })) + return Driver.str(); // If the driver is a generic like "g++" with no path, add clang dir. if (ClangPath && (Driver == "clang" || Driver == "clang++" || Driver == "gcc" ||
Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp +++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp @@ -115,7 +115,7 @@ Cmd = {"foo/unknown-binary", "foo.cc"}; Mangler.adjust(Cmd); - EXPECT_EQ(testPath("fake/unknown-binary"), Cmd.front()); + EXPECT_EQ("foo/unknown-binary", Cmd.front()); } // Only run the PATH/symlink resolving test on unix, we need to fiddle Index: clang-tools-extra/clangd/CompileCommands.cpp =================================================================== --- clang-tools-extra/clangd/CompileCommands.cpp +++ clang-tools-extra/clangd/CompileCommands.cpp @@ -135,6 +135,12 @@ // First, eliminate relative paths. std::string Storage; if (!llvm::sys::path::is_absolute(Driver)) { + // If it's working-dir relative like bin/clang, we can't resolve it. + // FIXME: we could if we had the working directory here. + // Let's hope it's not a symlink. + if (llvm::any_of(Driver, + [](char C) { return llvm::sys::path::is_separator(C); })) + return Driver.str(); // If the driver is a generic like "g++" with no path, add clang dir. if (ClangPath && (Driver == "clang" || Driver == "clang++" || Driver == "gcc" ||
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits