This is an archive of the discontinued LLVM Phabricator instance.

[index] Improve macro indexing support
ClosedPublic

Authored by benlangmuir on Apr 1 2021, 11:50 AM.

Details

Summary

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.

Diff Detail

Event Timeline

benlangmuir created this revision.Apr 1 2021, 11:50 AM
benlangmuir requested review of this revision.Apr 1 2021, 11:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2021, 11:50 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
benlangmuir edited the summary of this revision. (Show Details)Apr 1 2021, 11:50 AM

Fixed clang-format issue.

Fix the incomplete type issue with PointerUnion in DeclOccurrence. h. I'm not actually sure how that code compiles without error with other versions of clang.

Fix clang-tidy warnings

akyrtzi accepted this revision.Apr 5 2021, 3:51 PM
This revision is now accepted and ready to land.Apr 5 2021, 3:51 PM
This revision was automatically updated to reflect the committed changes.