This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Extend CollectMainFileMacros.
ClosedPublic

Authored by hokein on Mar 17 2023, 2:43 AM.

Details

Summary

Extend the existing MainFileMacros structure:

  • record more information (InConditionalDirective) in MacroOccurrence
  • collect macro references inside macro body (fix a long-time FIXME)

So that the MainFileMacros preseve enough information, which allows a
just-in-time convertion to interop with include-cleaner::Macro for
include-cleaer features.

See the context in https://reviews.llvm.org/D146017.

Diff Detail

Event Timeline

hokein created this revision.Mar 17 2023, 2:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2023, 2:43 AM
Herald added a subscriber: arphaman. · View Herald Transcript
hokein requested review of this revision.Mar 17 2023, 2:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2023, 2:43 AM
kadircet accepted this revision.Mar 20 2023, 5:40 AM

thanks!

clang-tools-extra/clangd/CollectMacros.h
48

nit: you can get SM out of PP, no need to pass both.

70

nit: can you actually move macro bodies out-of-line ? it's unfortunate that we need to build half of the project everytime we touch this header.

clang-tools-extra/clangd/ParsedAST.cpp
615

nit: we seem to be calling Clang->getPreprocessor() in many places, maybe extract it into a variable instead?

This revision is now accepted and ready to land.Mar 20 2023, 5:40 AM
hokein updated this revision to Diff 507679.Mar 23 2023, 3:44 AM
hokein marked an inline comment as done.

address comments

clang-tools-extra/clangd/CollectMacros.h
48

oh, right!

70

Done (thanks for the define-out-line code action!)

This revision was landed with ongoing or failed builds.Mar 23 2023, 4:01 AM
This revision was automatically updated to reflect the committed changes.