[PATCH] D80525: [clangd] Fix crash-bug in preamble indexing when using modules.

Adam Czachorowski via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 25 09:38:08 PDT 2020


adamcz created this revision.
adamcz added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

When preamble contains #undef, indexing code finds the matching #define
and uses that during indexing. However, it would only look for local
definitions. If the macro was defined in a module, MacroInfo
would be nullptr and clangd would crash.

This change fixes the crash by looking for definition in module when
that happens. The indexing result is then exactly the same whether
modules are used or not.

The indexing of macros happens for preamble only, so then #undef must be
in the preamble, which is why we need two .h files in a test.

Note that clangd is currently not ready for module support, but this
brings us one step closer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80525

Files:
  clang-tools-extra/clangd/test/Inputs/symbols-modules/bar.h
  clang-tools-extra/clangd/test/Inputs/symbols-modules/compile_commands.json
  clang-tools-extra/clangd/test/Inputs/symbols-modules/foo.h
  clang-tools-extra/clangd/test/Inputs/symbols-modules/module.map
  clang-tools-extra/clangd/test/symbols-modules.test
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Index/IndexingAction.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80525.266039.patch
Type: text/x-patch
Size: 5990 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200525/b3e82c71/attachment-0001.bin>


More information about the cfe-commits mailing list