[CodeCompletion][clangd] Clean __uglified parameter names in completion & hover
authorSam McCall <sam.mccall@gmail.com>
Thu, 30 Dec 2021 00:57:47 +0000 (01:57 +0100)
committerSam McCall <sam.mccall@gmail.com>
Wed, 26 Jan 2022 14:51:17 +0000 (15:51 +0100)
commit33c3ef2fbeec4ede5fc303b09cdca99ae2c0522a
treee5b2cf0e8f2eeba9ce6ff650981ff596d1470b9a
parenta5e324e3e2edcc72d9e402b4d846cae615192ad8
[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
13 files changed:
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
clang/include/clang/AST/PrettyPrinter.h
clang/include/clang/Basic/IdentifierTable.h
clang/lib/AST/DeclPrinter.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/AST/TemplateName.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/Basic/IdentifierTable.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/CodeCompletion/deuglify.cpp [new file with mode: 0644]
clang/unittests/AST/DeclPrinterTest.cpp
clang/unittests/AST/StmtPrinterTest.cpp
clang/unittests/AST/TypePrinterTest.cpp