[PATCH] D99758: [index] Improve macro indexing support

Ben Langmuir via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 1 11:50:07 PDT 2021


benlangmuir created this revision.
benlangmuir added reviewers: akyrtzi, sammccall.
Herald added a subscriber: arphaman.
benlangmuir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99758

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99758.334786.patch
Type: text/x-patch
Size: 23702 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210401/60ed1b2d/attachment-0001.bin>


More information about the cfe-commits mailing list