[all-commits] [llvm/llvm-project] 44bbf2: [clangd] Add Macro Expansion to Hover

Daiyousei via All-commits all-commits at lists.llvm.org
Wed Sep 7 08:50:26 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 44bbf20965d2c1e00bb805343ad80dbb7758bf3d
      https://github.com/llvm/llvm-project/commit/44bbf20965d2c1e00bb805343ad80dbb7758bf3d
  Author: Qingyuan Zheng <qyzheng2 at outlook.com>
  Date:   2022-09-07 (Wed, 07 Sep 2022)

  Changed paths:
    M clang-tools-extra/clangd/Hover.cpp
    M clang-tools-extra/clangd/unittests/HoverTests.cpp

  Log Message:
  -----------
  [clangd] Add Macro Expansion to Hover

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? For performance and presentation reason, it might not be a good idea to expand pages worth of tokens in hover card. If so, what's the preferred threshold?

Also, some limitation applies:
1. Expansion isn't available in macro definition/arguments as the refactor code action isn't either.

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




More information about the All-commits mailing list