[PATCH] D150635: [clangd] Implement end-definition-comment inlay hints
Younan Zhang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 16 02:19:35 PDT 2023
zyounan added a comment.
Sorry for chiming in. Left a few nit comments and I hope you don't mind. :)
================
Comment at: clang-tools-extra/clangd/InlayHints.cpp:772
+ Label = printName(AST, D);
+ } else {
+ // We handle type and namespace decls together.
----------------
Question: Should we restrict the type here? What will happen if `D` was something unexpected like a `TypedefDecl`? Would it fall into the logic that makes `Label` result to `<anonymous>`?
================
Comment at: clang-tools-extra/clangd/InlayHints.cpp:777-781
+ else if (isa<EnumDecl>(D)) {
+ Label += "enum ";
+ if (cast<EnumDecl>(D).isScopedUsingClassTag()) {
+ Label += "class ";
+ }
----------------
Perhaps duplicate the logic from [[ https://clang.llvm.org/doxygen/DeclPrinter_8cpp_source.html#l00529 | DeclPrinter::VisitEnumDecl ]]? For `enum struct`, printing `enum` only might confuse users.
================
Comment at: clang-tools-extra/clangd/InlayHints.cpp:783-788
+ if (RecordD->isStruct())
+ Label += "struct ";
+ else if (RecordD->isClass())
+ Label += "class ";
+ else if (RecordD->isUnion())
+ Label += "union ";
----------------
nit: How about using [[ https://clang.llvm.org/doxygen/Decl_8h_source.html#l03645 | tagDecl::getKindName() ]]?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150635/new/
https://reviews.llvm.org/D150635
More information about the cfe-commits
mailing list