[all-commits] [llvm/llvm-project] 33c3ef: [CodeCompletion][clangd] Clean __uglified paramete...

Sam McCall via All-commits all-commits at lists.llvm.org
Wed Jan 26 06:51:36 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 33c3ef2fbeec4ede5fc303b09cdca99ae2c0522a
      https://github.com/llvm/llvm-project/commit/33c3ef2fbeec4ede5fc303b09cdca99ae2c0522a
  Author: Sam McCall <sam.mccall at gmail.com>
  Date:   2022-01-26 (Wed, 26 Jan 2022)

  Changed paths:
    M clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
    M clang/include/clang/AST/PrettyPrinter.h
    M clang/include/clang/Basic/IdentifierTable.h
    M clang/lib/AST/DeclPrinter.cpp
    M clang/lib/AST/StmtPrinter.cpp
    M clang/lib/AST/TemplateName.cpp
    M clang/lib/AST/TypePrinter.cpp
    M clang/lib/Basic/IdentifierTable.cpp
    M clang/lib/Sema/SemaCodeComplete.cpp
    A clang/test/CodeCompletion/deuglify.cpp
    M clang/unittests/AST/DeclPrinterTest.cpp
    M clang/unittests/AST/StmtPrinterTest.cpp
    M clang/unittests/AST/TypePrinterTest.cpp

  Log Message:
  -----------
  [CodeCompletion][clangd] Clean __uglified parameter names in completion & hover

Underscore-uglified identifiers are used in standard library implementations to
guard against collisions with macros, and they hurt readability considerably.
(Consider `push_back(Tp_ &&__value)` vs `push_back(Tp value)`.
When we're describing an interface, the exact names of parameters are not
critical so we can drop these prefixes.

This patch adds a new PrintingPolicy flag that can applies this stripping
when recursively printing pieces of AST.
We set it in code completion/signature help, and in clangd's hover display.
All three features also do a bit of manual poking at names, so fix up those too.

Fixes https://github.com/clangd/clangd/issues/736

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




More information about the All-commits mailing list