<div dir="ltr">Hi Su,<div><br></div><div>Since compile_commands.json only contains compile commands for .cpp files, we use a heuristics-based approach to infer compile commands for headers.</div><div>More precisely, based on the path to the header file we try to guess the best .cpp file for a header (e.g. an implementation file) and pick the compile command from it.</div><div><br></div><div>In your case, we fail to guess a good compile command. I don't know of a good workaround, unfortunately.</div><div><a class="gmail_plusreply" id="plusReplyChip-0" href="mailto:sammccall@google.com" tabindex="-1">+Sam McCall</a> is the author of this approach, he might have ideas on how to fix this.</div><div><br></div><div>Is the project you're working on open-source? If so, could you provide a link to the source code? If not, compilation database should also be enough to reproduce.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 21, 2019 at 10:41 PM yus via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi,<div>I encounter an error in clangd</div><div><br></div><div><div><div>I[12:49:12.197] Updating file /root/workspace/eos4/libraries/chain/include/eosio/chain/types.hpp with command<b><font color="#cc0000"> [/root/workspace/eos4/build/libraries/wasm-jit/Source/IR] </font></b>/usr/bin/clang++-4.0 -D ENABLE_SIMD_PROTOTYPE=0 -D ENABLE_THREADING_PROTOTYPE=0 -D IR_API=DLL_EXPORT -D PRETEND_32BIT_ADDRESS_SPACE=0 -D WAVM_METRICS_OUTPUT=0 -I /root/workspace/eos4/libraries/wasm-jit/Include -I /root/workspace/eos4/libraries/wasm-jit/Include/IR -Wall -Wno-invalid-partial-specialization -O3 -D NDEBUG -c -std=gnu++14 /root/workspace/eos4/libraries/chain/include/eosio/chain/types.hpp -resource-dir=/root/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/clang/lib/clang/7.0.0</div><div>V[12:49:12.199] Preamble for file /root/workspace/eos4/libraries/chain/include/eosio/chain/types.hpp cannot be reused. Attempting to rebuild it.</div><div>V[12:49:12.238] Built preamble of size 213512 for file /root/workspace/eos4/libraries/chain/include/eosio/chain/types.hpp</div><div>I[12:49:12.242] Dropped diagnostic outside main file: : too many errors emitted, stopping now</div></div></div><div><br></div><div>some other file in same folder update correctly</div><div><br></div><div><div>I[12:49:03.898] Updating file /root/workspace/eos4/libraries/chain/include/eosio/chain/resource_limits.hpp with command <font color="#cc0000"><b>[/root/workspace/eos4/build/libraries/chain] </b></font>/usr/bin/clang++-4.0 -I /root/workspace/eos4/libraries/chain/include -I /root/workspace/eos4/build/libraries/chain/include -I /root/workspace/eos4/libraries/chain/../wasm-jit/Include -I /root/workspace/eos4/libraries/chain/../../externals/binaryen/src -I /root/workspace/eos4/libraries/utilities/include -I /root/workspace/eos4/libraries/utilities/../wasm-jit/Include -I /root/workspace/eos4/libraries/fc/include -I /root/opt/boost/include -I /usr/local/include -I /root/workspace/eos4/libraries/fc/vendor/websocketpp -I /root/workspace/eos4/libraries/chainbase/include -I /root/workspace/eos4/libraries/wasm-jit/Source/Runtime/../../../chain/include -I /root/workspace/eos4/libraries/softfloat/source/include -I /root/workspace/eos4/libraries/softfloat/source/8086-SSE -I /root/workspace/eos4/libraries/softfloat/build/Linux-x86_64-GCC -I /root/workspace/eos4/libraries/builtins -I /root/workspace/eos4/libraries/builtins../softfloat/source/include -Wall -Wno-invalid-partial-specialization -O3 -D NDEBUG -c -std=gnu++14 /root/workspace/eos4/libraries/chain/include/eosio/chain/resource_limits.hpp -resource-dir=/root/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/clang/lib/clang/7.0.0</div><div>V[12:49:03.901] Preamble for file /root/workspace/eos4/libraries/chain/include/eosio/chain/resource_limits.hpp cannot be reused. Attempting to rebuild it.</div><div>V[12:49:10.676] <<< {"id":"3","jsonrpc":"2.0","method":"textDocument/definition","params":{"position":{"character":51,"line":53},"textDocument":{"uri":"file:///root/workspace/eos4/libraries/chain/include/eosio/chain/resource_limits.hpp"}}}</div></div><div><br></div><div>I don't know why, and what's the difference. why the flags are different.</div><div>How to fix the problem</div><div><br></div><div><div>root@39470746ee31:~/workspace/eos4# /usr/bin/clang++-4.0 -D ENABLE_SIMD_PROTOTYPE=0 -D ENABLE_THREADING_PROTOTYPE=0 -D IR_API=DLL_EXPORT -D PRETEND_32BIT_ADDRESS_SPACE=0 -D WAVM_METRICS_OUTPUT=0 -I /root/workspace/eos4/libraries/wasm-jit/Include -I /root/workspace/eos4/libraries/wasm-jit/Include/IR -Wall -Wno-invalid-partial-specialization -O3 -D NDEBUG -c -std=gnu++14 /root/workspace/eos4/libraries/chain/include/eosio/chain/types.hpp -resource-dir=/root/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/clang/lib/clang/7.0.0</div><div>/root/workspace/eos4/libraries/chain/include/eosio/chain/types.hpp:6:10: fatal error: 'eosio/chain/name.hpp' file not found</div><div>#include <eosio/chain/name.hpp></div><div> ^~~~~~~~~~~~~~~~~~~~~~</div><div>1 error generated.</div></div><div><br></div><div>attach the error and compilation database</div><div><br></div><div>Thanks.</div><div><br></div><div>Brs</div><div>Su Yu</div><div><br></div></div></div></div></div></div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Regards,</div><div>Ilya Biryukov</div></div></div></div></div>