[PATCH] D140617: [clangd] Fix a clangd crash when indexing the standard library.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 3 07:35:21 PST 2023


sammccall added a comment.

As I understand, we're crashing if the ignorelist isn't found, and this patch fixes the searching so that we find the file (assuming the compile command is correct).

But we'll still crash if the compile command is wrong, which seems pretty bad.

Fixing the way the ignorelist is populated in clang would be nice but is a bit of a yakshave.
Failing that, I think in this case we can just clear out the langopt in `disableUnsupportedOptions()`. This seems much more robust (though doing both is also fine)

Most of the uses of the asan ignorelist are in codegen which we don't care about.
It also affects record layout: see RecordDecl::mayInsertExtraPadding. We do calculate and show record layouts on hover, but I don't think we should care about ignorelists when doing so - people almost certainly really care about the non-asan size.
(In practice, I couldn't actually see any asan-specific differences through clangd in casual inspection).



================
Comment at: clang-tools-extra/clangd/index/StdLib.cpp:227
   CI->getPreprocessorOpts().clearRemappedFiles();
+  std::string CWD = CI->getFileSystemOpts().WorkingDir;
   auto Clang = prepareCompilerInstance(
----------------
I can't see where this is set in clang itself - I thought it was just a customization point for programmatic use. However the fix works, so it seems like it must be getting the correct value... very misterious


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140617/new/

https://reviews.llvm.org/D140617



More information about the cfe-commits mailing list