ccls: Wrong diagnostics on macOS w/ clang10

Observed behavior

  • compile_commands.json
[
  {
    "directory": "/Users/flanggut/tmp/ccls",
    "file": "/Users/flanggut/tmp/ccls/main.cpp",
    "arguments": [
      "/usr/local/opt/llvm/bin/clang++",
      "-std=c++17",
      "-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include",
      "-isystem /Library/Developer/CommandLineTools/usr/lib/clang/11.0.3/include/",
      "-I.",
      "main.cpp"
    ]
  }
]
  • main.cpp
#include <chrono>
auto clk() {
  return std::chrono::high_resolution_clock::now();
}
int main(int /*argc*/, char** /*argv*/) {
  auto clk0 = clk();
}

ccls --index=. -v=2 Correctly identifies and and indexes all headers.

/usr/local/opt/llvm/bin/clang++ --driver-mode=g++ -std=c++17 -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -isystem /Library/Developer/CommandLineTools/usr/lib/clang/11.0.3/include/ -I. main.cpp

File compiles without issues.

In my editor ccls claims that <chrono> include cannot be found under ./chrono, note that the error is always shown for the include path -I., if I change that to -I.. the error will show that ../chrono cannot be found.

This only happens since clang/llvm10 and does not happen if I compile ccls against clang/llvm9.

Expected behavior

No diagnostics should be shown in an editor.

Steps to reproduce

  1. brew install ccls (recently updated to use llvm10)
  2. Open file in editor w/ ccls as language server

System information

  • ccls version (git describe --tags --long): brew info ccls
  • clang version: clang version 10.0.0
  • OS: x86_64-apple-darwin19.4.0
  • Editor: nvim / vscode
  • Language client (and version): coc.nvim / vscode-ccls

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 9
  • Comments: 25 (3 by maintainers)

Most upvoted comments

It might be a weird interaction in the homebrew version of things. I managed to build a version using the official llvm release that runs without issues. If anyone needs a workaround for now:

  1. Download the official llvm release from https://releases.llvm.org/download.html#10.0.0 (direct link) and unpack.
  2. Manually install ccls HEAD version in homebrew
brew uninstall ccls
brew install ccls --HEAD -i

this will open a terminal in a temp directory that allows you to “manually” compile and install ccls within homebrew. In there I ran

cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/Users/flanggut/local/clang+llvm-10.0.0-x86_64-apple-darwin/ -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/ccls/HEAD-c5acf62 -DUSE_SYSTEM_RAPIDJSON=OFF -DCMAKE_CXX_COMPILER=/Users/flanggut/local/clang+llvm-10.0.0-x86_64-apple-darwin/bin/clang++

pointing cmake directly to the official llvm release (make sure the install prefix points to the right directory, homebrew will tell you where it expects the installed files). Then you just do

cd Release
make install
exit

And homebrew automatically links ccls if you’ve installed it to the right directory.