Author: Yuanjing Hong Date: 2023-08-21T11:10:40+08:00 New Revision: dc10bd43a103d0e252c4fb4d30913f99b4f418fe
URL: https://github.com/llvm/llvm-project/commit/dc10bd43a103d0e252c4fb4d30913f99b4f418fe DIFF: https://github.com/llvm/llvm-project/commit/dc10bd43a103d0e252c4fb4d30913f99b4f418fe.diff LOG: [clangd] don't add inlay hint for dependent type in structured binding Currently clangd will display useless inlay hint for dependent type in structured binding, e.g. ``` template <class T> void foobar(T arg) { auto [a/*: <dependent type>*/, b/*: <dependent type>*/] = arg; } ``` Differential Revision: https://reviews.llvm.org/D157956 Added: Modified: clang-tools-extra/clangd/InlayHints.cpp clang-tools-extra/clangd/unittests/InlayHintTests.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/InlayHints.cpp b/clang-tools-extra/clangd/InlayHints.cpp index d403269f5a68f4..56f85ee155cb23 100644 --- a/clang-tools-extra/clangd/InlayHints.cpp +++ b/clang-tools-extra/clangd/InlayHints.cpp @@ -733,7 +733,8 @@ class InlayHintVisitor : public RecursiveASTVisitor<InlayHintVisitor> { // For structured bindings, print canonical types. This is important // because for bindings that use the tuple_element protocol, the // non-canonical types would be "tuple_element<I, A>::type". - if (auto Type = Binding->getType(); !Type.isNull()) + if (auto Type = Binding->getType(); + !Type.isNull() && !Type->isDependentType()) addTypeHint(Binding->getLocation(), Type.getCanonicalType(), /*Prefix=*/": "); } diff --git a/clang-tools-extra/clangd/unittests/InlayHintTests.cpp b/clang-tools-extra/clangd/unittests/InlayHintTests.cpp index 3c1e6c826ec259..1d12db3661c9eb 100644 --- a/clang-tools-extra/clangd/unittests/InlayHintTests.cpp +++ b/clang-tools-extra/clangd/unittests/InlayHintTests.cpp @@ -1353,6 +1353,11 @@ TEST(TypeHints, DependentType) { // FIXME: It would be nice to show "T" as the hint. auto $var2[[var2]] = arg; } + + template <typename T> + void bar(T arg) { + auto [a, b] = arg; + } )cpp"); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits