This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Don't mangle workdir-relevant driver path in compile commands
ClosedPublic

Authored by sammccall on Jun 17 2020, 6:56 AM.

Details

Summary

We can't resolve this (if it's a symlink) without further refactoring, but the
current behaviour is just incorrect.

Diff Detail

Event Timeline

sammccall created this revision.Jun 17 2020, 6:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 17 2020, 6:56 AM
kadircet accepted this revision.Jun 17 2020, 7:07 AM

LGTM, thanks!

clang-tools-extra/clangd/CompileCommands.cpp
141

I believe it would be clearer if you put it below, into else if (ClangPath) part.

i.e.

if (Absolute ...)
  ..
// If we couldn't find program and driver is just a filename, use clang dir
// FIXME: Note that Driver can still be relative to workdir even if it doesn't have any path separators.
// We should pass WD into here and try to make Driver absolute.
else if(ClangPath && !hasPathSeparators(Driver))
 ...
This revision is now accepted and ready to land.Jun 17 2020, 7:07 AM
sammccall marked an inline comment as done.Jun 17 2020, 10:49 AM
sammccall added inline comments.
clang-tools-extra/clangd/CompileCommands.cpp
141

This would rely on the undocumented behaviour of findProgramByName with workdir-relative paths, which I think would be nice to avoid (for clarity to the reader if nothing else).
Doing (what looks like) a PATH search for a workdir-relative path is just conceptually wrong.

kadircet added inline comments.Jun 19 2020, 3:47 AM
clang-tools-extra/clangd/CompileCommands.cpp
141

makes sense, i think we should land this soon-ish to stop the bleeding.

This revision was automatically updated to reflect the committed changes.