[all-commits] [llvm/llvm-project] 93c87f: [index] Improve macro indexing support

Ben Langmuir via All-commits all-commits at lists.llvm.org
Tue Apr 6 09:13:22 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 93c87fc06eca8d8a65ff6c0bdd9f2671227224ac
      https://github.com/llvm/llvm-project/commit/93c87fc06eca8d8a65ff6c0bdd9f2671227224ac
  Author: Ben Langmuir <blangmuir at apple.com>
  Date:   2021-04-06 (Tue, 06 Apr 2021)

  Changed paths:
    M clang/include/clang/Index/DeclOccurrence.h
    M clang/include/clang/Index/IndexingOptions.h
    M clang/lib/Index/FileIndexRecord.cpp
    M clang/lib/Index/FileIndexRecord.h
    M clang/lib/Index/IndexingAction.cpp
    M clang/lib/Index/IndexingContext.cpp
    M clang/lib/Index/IndexingContext.h
    M clang/lib/Index/USRGeneration.cpp
    M clang/test/Index/Core/Inputs/module/ModA.h
    M clang/test/Index/Core/Inputs/module/SubModA.h
    M clang/test/Index/Core/Inputs/sys/system-head.h
    M clang/test/Index/Core/index-macros.c
    M clang/test/Index/Core/index-with-module.m
    M clang/tools/c-index-test/core_main.cpp
    M clang/unittests/Index/IndexTests.cpp

  Log Message:
  -----------
  [index] Improve macro indexing support

The major change here is to index macro occurrences in more places than
before, specifically

* In non-expansion references such as `#if`, `#ifdef`, etc.
* When the macro is a reference to a builtin macro such as __LINE__.
* When using the preprocessor state instead of callbacks, we now include
  all definition locations and undefinitions instead of just the latest
  one (which may also have had the wrong location previously).
* When indexing an existing module file (.pcm), we now include module
  macros, and we no longer report unrelated preprocessor macros during
  indexing the module, which could have caused duplication.

Additionally, we now correctly obey the system symbol filter for macros,
so by default in system headers only definition/undefinition occurrences
are reported, but it can be configured to report references as well if
desired.

Extends FileIndexRecord to support occurrences of macros. Since the
design of this type is to keep a single list of entities organized by
source location, we incorporate macros into the existing DeclOccurrence
struct.

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




More information about the All-commits mailing list