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.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D140814 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 @@ -1364,7 +1364,6 @@ TEST(TypeHints, Decltype) { assertTypeHints(R"cpp( $a[[decltype(0)]] a; - // FIXME: will be nice to show `: int` instead $b[[decltype(a)]] b; const $c[[decltype(0)]] &c = b; @@ -1377,11 +1376,13 @@ template <class, class> struct Foo; using G = Foo<$g[[decltype(0)]], float>; + + auto $h[[h]] = $i[[decltype(0)]]{}; )cpp", - ExpectedHint{": int", "a"}, - ExpectedHint{": decltype(0)", "b"}, + ExpectedHint{": int", "a"}, ExpectedHint{": int", "b"}, ExpectedHint{": int", "c"}, ExpectedHint{": int", "e"}, - ExpectedHint{": int", "f"}, ExpectedHint{": int", "g"}); + ExpectedHint{": int", "f"}, ExpectedHint{": int", "g"}, + ExpectedHint{": int", "h"}, ExpectedHint{": int", "i"}); } TEST(DesignatorHints, Basic) { Index: clang-tools-extra/clangd/InlayHints.cpp =================================================================== --- clang-tools-extra/clangd/InlayHints.cpp +++ clang-tools-extra/clangd/InlayHints.cpp @@ -663,7 +663,14 @@ } void addTypeHint(SourceRange R, QualType T, llvm::StringRef Prefix) { + // print the underlying type for `decltype(expr)` + if (T->isDecltypeType()) + TypeHintPolicy.PrintCanonicalTypes = true; + else if (const AutoType *AT = T->getContainedAutoType(); + AT && AT->getDeducedType()->isDecltypeType()) + TypeHintPolicy.PrintCanonicalTypes = true; addTypeHint(R, T, Prefix, TypeHintPolicy); + TypeHintPolicy.PrintCanonicalTypes = false; } void addTypeHint(SourceRange R, QualType T, llvm::StringRef Prefix,
Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/InlayHintTests.cpp +++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp @@ -1364,7 +1364,6 @@ TEST(TypeHints, Decltype) { assertTypeHints(R"cpp( $a[[decltype(0)]] a; - // FIXME: will be nice to show `: int` instead $b[[decltype(a)]] b; const $c[[decltype(0)]] &c = b; @@ -1377,11 +1376,13 @@ template <class, class> struct Foo; using G = Foo<$g[[decltype(0)]], float>; + + auto $h[[h]] = $i[[decltype(0)]]{}; )cpp", - ExpectedHint{": int", "a"}, - ExpectedHint{": decltype(0)", "b"}, + ExpectedHint{": int", "a"}, ExpectedHint{": int", "b"}, ExpectedHint{": int", "c"}, ExpectedHint{": int", "e"}, - ExpectedHint{": int", "f"}, ExpectedHint{": int", "g"}); + ExpectedHint{": int", "f"}, ExpectedHint{": int", "g"}, + ExpectedHint{": int", "h"}, ExpectedHint{": int", "i"}); } TEST(DesignatorHints, Basic) { Index: clang-tools-extra/clangd/InlayHints.cpp =================================================================== --- clang-tools-extra/clangd/InlayHints.cpp +++ clang-tools-extra/clangd/InlayHints.cpp @@ -663,7 +663,14 @@ } void addTypeHint(SourceRange R, QualType T, llvm::StringRef Prefix) { + // print the underlying type for `decltype(expr)` + if (T->isDecltypeType()) + TypeHintPolicy.PrintCanonicalTypes = true; + else if (const AutoType *AT = T->getContainedAutoType(); + AT && AT->getDeducedType()->isDecltypeType()) + TypeHintPolicy.PrintCanonicalTypes = true; addTypeHint(R, T, Prefix, TypeHintPolicy); + TypeHintPolicy.PrintCanonicalTypes = false; } void addTypeHint(SourceRange R, QualType T, llvm::StringRef Prefix,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits