[all-commits] [llvm/llvm-project] 53b919: [clangd] Fix crash-bug in preamble indexing when u...

Adam Czachorowski via All-commits all-commits at lists.llvm.org
Thu Aug 20 05:33:39 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 53b9199a5cdba8a6e294e1fb183f308ec558db22
      https://github.com/llvm/llvm-project/commit/53b9199a5cdba8a6e294e1fb183f308ec558db22
  Author: Adam Czachorowski <adamcz at google.com>
  Date:   2020-08-20 (Thu, 20 Aug 2020)

  Changed paths:
    M clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
    M clang-tools-extra/clangd/unittests/TestFS.h
    M clang-tools-extra/clangd/unittests/TestTU.cpp
    M clang-tools-extra/clangd/unittests/TestTU.h
    M clang/lib/Index/IndexingAction.cpp

  Log Message:
  -----------
  [clangd] Fix crash-bug in preamble indexing when using modules.

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 makes clangd ignore any #undef without a matching #define
inside the same TU.

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.

This was previously attempted in
4061d9e42cff621462931ac7df9666806c77a237, but had to be reverted due to
broken test. This version fixes that test-only bug by setting a custom module
cache path to avoid re-use of modules across test invocations.

Differential Revision: https://reviews.llvm.org/D85923


  Commit: baeff989b050e0f63412c52c1b8f9d8f3e91f671
      https://github.com/llvm/llvm-project/commit/baeff989b050e0f63412c52c1b8f9d8f3e91f671
  Author: Adam Czachorowski <adamcz at google.com>
  Date:   2020-08-20 (Thu, 20 Aug 2020)

  Changed paths:
    M clang-tools-extra/clangd/unittests/ModulesTests.cpp
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Serialization/ASTReader.cpp
    M clang/test/PCH/Inputs/modules/Foo.h
    A clang/test/PCH/preamble-modules.cpp

  Log Message:
  -----------
  [clang] When loading preamble from AST file, re-export modules in Sema.

This addresses a FIXME in ASTReader.

Modules were already re-exported for Preprocessor, but not for Sema.
The result was that, with -fmodules-local-submodule-visibility, all AST
nodes belonging to a module that was loaded in a premable where not
accesible from the main part of the file and a diagnostic recommending
importing those modules would be generated.

Differential Revision: https://reviews.llvm.org/D86069


Compare: https://github.com/llvm/llvm-project/compare/0ee23b286ac4...baeff989b050


More information about the All-commits mailing list