[all-commits] [llvm/llvm-project] 806342: [clangd] Resolve driver symlinks, and look up unkn...

Sam McCall via All-commits all-commits at lists.llvm.org
Mon Jun 8 08:25:14 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 806342b8ef54ec07511d0ce5d3d1335451e952da
      https://github.com/llvm/llvm-project/commit/806342b8ef54ec07511d0ce5d3d1335451e952da
  Author: Sam McCall <sam.mccall at gmail.com>
  Date:   2020-06-08 (Mon, 08 Jun 2020)

  Changed paths:
    M clang-tools-extra/clangd/ClangdLSPServer.cpp
    M clang-tools-extra/clangd/CompileCommands.cpp
    M clang-tools-extra/clangd/CompileCommands.h
    M clang-tools-extra/clangd/QueryDriverDatabase.cpp
    M clang-tools-extra/clangd/support/Threading.h
    M clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
    M clang-tools-extra/clangd/unittests/support/ThreadingTests.cpp

  Log Message:
  -----------
  [clangd] Resolve driver symlinks, and look up unknown relative drivers in PATH.

Summary:
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)

Reviewers: kadircet

Subscribers: jyknight, ormris, ilya-biryukov, MaskRay, jkorous, arphaman, jfb, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75414




More information about the All-commits mailing list