title: Debugging C++ language server errors: Invalid AST
body: <p>I've got a C++ project in which I can open up any .cpp or .h, and the LSP will crash/fail (I'm using emacs with <code>lsp-mode</code>).</p>
  <p>For instance if I try to open a file called <code>IDictionary.h</code>, clangd will fail with the following errors in the <em>clangd::stderr</em> buffer</p>
  <pre><code>I[17:33:37.200] BeginSourceFile() failed when building AST for /home/anlsh/work/horizon-runtime/src/prod/data/IDictionary.h
  I[17:33:37.246] &lt;-- textDocument/documentHighlight(103)
  I[17:33:37.246] --&gt; reply:textDocument/documentHighlight(103) 0 ms, error: invalid AST
  </code></pre>
  <p>ccls also fails (exits with signal), though its error messages aren't helpful either</p>
  <pre><code>17:36:44 indexer6          indexer.cc:1302 E failed to index /home/anlsh/work/horizon-runtime/src/prod/data/IDictionary.h
  /snap/ccls/48/bin/../usr/lib/x86_64-linux-gnu/libLLVM-7.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x2a)[0x7f2301010e8a]
  /snap/ccls/48/bin/../usr/lib/x86_64-linux-gnu/libLLVM-7.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0x34)[0x7f230100f544]
  /snap/ccls/48/bin/../usr/lib/x86_64-linux-gnu/libLLVM-7.so.1(+0x907682)[0x7f230100f682]
  /snap/core18/current/lib/x86_64-linux-gnu/libpthread.so.0(+0x128a0)[0x7f22fff5a8a0]
  /snap/ccls/48/bin/ccls(+0x24ae87)[0x5564df56ee87]
  /snap/core18/current/lib/x86_64-linux-gnu/libpthread.so.0(+0x76db)[0x7f22fff4f6db]
  /snap/core18/current/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7f22ffc78a3f]
  </code></pre>
  <p>Anyways, this happens for every single file in the project, even ones as simple as</p>
  <pre><code>#include &quot;stdafx.h&quot;
  using namespace Api;
  </code></pre>
  <p>My assumption was that some file being pulled in by the build/compile_commands.json is screwing everything up, but I can't be sure. VSCode (which I assume is using an LSP, though I know it has its own tricks) doesn't have any issues on my project at all.</p>
  <p>Anyways, I was hoping that someone could point me towards some more detailed <code>clangd</code> or <code>ccls</code> logs, and maybe some commands which could get me some more informative error messages or validate files in my project</p>