MaskRay / ccls

C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlighting
Apache License 2.0
3.78k stars 260 forks source link

ccls show unexpected diagnostic #431

Closed meritozh closed 5 years ago

meritozh commented 5 years ago

Observed behavior

Screen Shot 2019-07-01 at 11 34 58 PM

Expected behavior

No diagnostic

Steps to reproduce

  1. git clone git@github.com:llvm/llvm-project.git
  2. open VSCode, check clang/Basic/Diagnostic.h
  3. see unexpected diagnostic in L286-288

System information

MaskRay commented 5 years ago

https://github.com/MaskRay/ccls/wiki/Project-Setup#llvm-multirepo

LLVM_COMMON=(-GNinja -DCMAKE_CXX_COMPILER=$HOME/llvm/Stable/bin/clang++ -DCMAKE_C_COMPILER=$HOME/llvm/Stable/bin/clang -DBUILD_SHARED_LIBS=On -DLLVM_ENABLE_LLD=On)

cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release ${LLVM_COMMON}

cmake -H. -BDebug -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXE_LINKER_FLAGS=-Wl,--gdb-index -DCMAKE_SHARED_LINKER_FLAGS=-Wl,--gdb-index -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLLVM_OPTIMIZED_TABLEGEN=On -DLLVM_USE_SPLIT_DWARF=On ${LLVM_COMMON}
ln -s Debug/compile_commands.json

or https://github.com/MaskRay/ccls/wiki/Project-Setup#llvm-monorepo

meritozh commented 5 years ago

I have run,

cmake -G Ninja ../llvm -DLLVM_APPEND_VC_REV=OFF -DLLVM_ENABLE_PROJECTS="clang;llvm;libcxx;libcxxabi;lld;lldb;clang-tools-extra;libunwind;compiler-rt" -DCMAKE_INSTALL_PREFIX=/Users/gaoge/Develop/dev_tool -DCMAKE_BUILD_TYPE=RelWithDebInfo

Same result.

How I start from to solve this issue?

MaskRay commented 5 years ago

Your cmake command line should have -DCMAKE_EXPORT_COMPILE_COMMANDS=On. Then symlink it to the project root.

I enable -DCMAKE_EXPORT_COMPILE_COMMANDS=On for my Debug build as it (LLVM_ENABLE_ASSERTIONS=on) compiles some code that is not compiled into a Release/RelWithDebInfo build.

Also, take a look at https://github.com/MaskRay/ccls/wiki/Debugging#logs

meritozh commented 5 years ago

I have try ninja -t compdb and -DCMAKE_EXPORT_COMPILE_COMMANDS=On, same result. I will try to provide more helpful information about this issue.

By the way, you cannot reproduce?