[PATCH] D127082: Add Macro Expansion to Hover

Qingyuan Zheng via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 5 21:12:27 PDT 2022


daiyousei-qz created this revision.
daiyousei-qz added reviewers: nridge, sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: All.
daiyousei-qz requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

This patch adds macro expansion preview to hover info. Basically, the refactor infrastructure for expanding macro is used for this purpose. The following steps are added to getHoverContents for macros:

1. calling AST.getTokens().expansionStartingAt(...) to get expanded tokens
2. calling reformat(...) to format expanded tokens

Some opinions are wanted:

1. Should we present macro expansion before definition in the hover card?
2. Should we truncate/ignore macro expansion if it's too long?

Also, some limitation applies:

1. Expansion isn't available in macro definition/arguments as the refactor code action isn't either.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127082

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/unittests/HoverTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127082.434381.patch
Type: text/x-patch
Size: 6953 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220606/aa15c315/attachment.bin>


More information about the cfe-commits mailing list