v1nh1shungry created this revision. v1nh1shungry added a reviewer: nridge. Herald added subscribers: kadircet, arphaman. Herald added a project: All. v1nh1shungry requested review of this revision. Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov. Herald added a project: clang-tools-extra.
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; } Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D157956 Files: clang-tools-extra/clangd/InlayHints.cpp clang-tools-extra/clangd/unittests/InlayHintTests.cpp Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/InlayHintTests.cpp +++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp @@ -1333,6 +1333,11 @@ // 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"); } Index: clang-tools-extra/clangd/InlayHints.cpp =================================================================== --- clang-tools-extra/clangd/InlayHints.cpp +++ clang-tools-extra/clangd/InlayHints.cpp @@ -676,7 +676,8 @@ // 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=*/": "); }
Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/InlayHintTests.cpp +++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp @@ -1333,6 +1333,11 @@ // 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"); } Index: clang-tools-extra/clangd/InlayHints.cpp =================================================================== --- clang-tools-extra/clangd/InlayHints.cpp +++ clang-tools-extra/clangd/InlayHints.cpp @@ -676,7 +676,8 @@ // 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=*/": "); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits