[PATCH] D75414: [clangd] Resolve driver symlinks, and look up unknown relative drivers in PATH.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 29 16:07:43 PST 2020


sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, jfb, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

This fixes a reported bug: if clang and libc++ are installed under
/usr/lib/llvm-11/...  but there'- a symlink /usr/bin/clang++-11, then a
compile_commands.json with "/usr/bin/clang++-11 -stdlib=libc++" would previously
look for libc++ under /usr/include instead of /usr/lib/llvm-11/include.
The PATH change makes this work if the compiler is just "clang++-11" too.

As this is now doing IO potentially on every getCompileCommand(), we cache
the results for each distinct driver.

While here:

- Added a Memoize helper for this as multithreaded caching is a bit noisy.
- Used this helper to simplify QueryDriverDatabase and reduce blocking there. (This makes use of the fact that llvm::Regex is now threadsafe)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75414

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/CompileCommands.h
  clang-tools-extra/clangd/QueryDriverDatabase.cpp
  clang-tools-extra/clangd/Threading.h
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
  clang-tools-extra/clangd/unittests/ThreadingTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75414.247469.patch
Type: text/x-patch
Size: 14825 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200301/d82279ee/attachment-0001.bin>


More information about the cfe-commits mailing list