[clang-tools-extra] r339665 - [clangd] Show non-instantiated decls in signatureHelp
Galina Kistanova via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 15 21:37:53 PDT 2018
Hello Ilya,
This commit has broken the ABI test builder - lab.llvm.org:8011/builders/
clang-x86_64-linux-abi-test/builds/30676
Could you take care of this, please?
Thanks
Galina
. . .
FAILED: tools/clang/tools/extra/unittests/clangd/CMakeFiles/ClangdTests.dir/CodeCompleteTests.cpp.o
/usr/bin/c++ -DGTEST_HAS_RTTI=0 -DGTEST_HAS_TR1_TUPLE=0
-DGTEST_LANG_CXX11=1 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-Itools/clang/tools/extra/unittests/clangd
-I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/unittests/clangd
-I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/include
-Itools/clang/include -Iinclude
-I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/include
-I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd
-I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/utils/unittest/googletest/include
-I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/utils/unittest/googlemock/include
-fPIC -fvisibility-inlines-hidden -std=c++11 -Wall -Wextra
-Wno-unused-parameter -Wwrite-strings -Wcast-qual
-Wno-missing-field-initializers -pedantic -Wno-long-long
-Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual
-fno-strict-aliasing -O3 -UNDEBUG -Wno-variadic-macros
-fno-exceptions -fno-rtti -MD -MT
tools/clang/tools/extra/unittests/clangd/CMakeFiles/ClangdTests.dir/CodeCompleteTests.cpp.o
-MF tools/clang/tools/extra/unittests/clangd/CMakeFiles/ClangdTests.dir/CodeCompleteTests.cpp.o.d
-o tools/clang/tools/extra/unittests/clangd/CMakeFiles/ClangdTests.dir/CodeCompleteTests.cpp.o
-c /home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/unittests/clangd/CodeCompleteTests.cpp
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/unittests/clangd/CodeCompleteTests.cpp:1541:26:
error: unterminated raw string
EXPECT_THAT(signatures(R"cpp(
^
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/unittests/clangd/CodeCompleteTests.cpp:1548:7:
warning: missing terminating " character [enabled by default]
)cpp")
^
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/unittests/clangd/CodeCompleteTests.cpp:1541:3:
error: stray ‘R’ in program
EXPECT_THAT(signatures(R"cpp(
^
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/unittests/clangd/CodeCompleteTests.cpp:1541:3:
error: missing terminating " character
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/unittests/clangd/CodeCompleteTests.cpp:1552:26:
error: unterminated raw string
EXPECT_THAT(signatures(R"cpp(
^
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/unittests/clangd/CodeCompleteTests.cpp:1558:10:
warning: missing terminating " character [enabled by default]
})cpp")
^
etc...
On Tue, Aug 14, 2018 at 2:36 AM, Ilya Biryukov via cfe-commits <
cfe-commits at lists.llvm.org> wrote:
> Author: ibiryukov
> Date: Tue Aug 14 02:36:32 2018
> New Revision: 339665
>
> URL: http://llvm.org/viewvc/llvm-project?rev=339665&view=rev
> Log:
> [clangd] Show non-instantiated decls in signatureHelp
>
> Summary:
> To avoid producing very verbose output in substitutions involving
> typedefs, e.g.
> T -> std::vector<std::string>::iterator
> gets turned into an unreadable mess when printed out for libstdc++,
> result contains internal types (std::__Vector_iterator<...>) and
> expanded well-defined typedefs (std::basic_string<char>).
>
> Until we improve the presentation code in clang, going with
> non-instantiated decls looks like a better UX trade-off.
>
> Reviewers: hokein, ioeric, kadircet
>
> Reviewed By: hokein
>
> Subscribers: MaskRay, jkorous, arphaman, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D50645
>
> Modified:
> clang-tools-extra/trunk/clangd/CodeComplete.cpp
> clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
>
> Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clangd/CodeComplete.cpp?rev=339665&r1=339664&r2=339665&view=diff
> ============================================================
> ==================
> --- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
> +++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Tue Aug 14 02:36:32
> 2018
> @@ -714,7 +714,15 @@ public:
> "too many arguments");
> SigHelp.activeParameter = static_cast<int>(CurrentArg);
> for (unsigned I = 0; I < NumCandidates; ++I) {
> - const auto &Candidate = Candidates[I];
> + OverloadCandidate Candidate = Candidates[I];
> + // We want to avoid showing instantiated signatures, because they
> may be
> + // long in some cases (e.g. when 'T' is substituted with
> 'std::string', we
> + // would get 'std::basic_string<char>').
> + if (auto *Func = Candidate.getFunction()) {
> + if (auto *Pattern = Func->getTemplateInstantiationPattern())
> + Candidate = OverloadCandidate(Pattern);
> + }
> +
> const auto *CCS = Candidate.CreateSignatureString(
> CurrentArg, S, *Allocator, CCTUInfo, true);
> assert(CCS && "Expected the CodeCompletionString to be non-null");
>
> Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/unittests/clangd/CodeCompleteTests.cpp?rev=
> 339665&r1=339664&r2=339665&view=diff
> ============================================================
> ==================
> --- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
> (original)
> +++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Tue
> Aug 14 02:36:32 2018
> @@ -1537,6 +1537,59 @@ TEST(SignatureHelpTest, OverloadsOrderin
> EXPECT_EQ(0, Results.activeParameter);
> }
>
> +TEST(SignatureHelpTest, InstantiatedSignatures) {
> + EXPECT_THAT(signatures(R"cpp(
> + template <class T>
> + void foo(T, T, T);
> +
> + int main() {
> + foo<int>(^);
> + }
> + )cpp")
> + .signatures,
> + ElementsAre(Sig("foo(T, T, T) -> void", {"T", "T", "T"})));
> +
> + EXPECT_THAT(signatures(R"cpp(
> + template <class T>
> + void foo(T, T, T);
> +
> + int main() {
> + foo(10, ^);
> + })cpp")
> + .signatures,
> + ElementsAre(Sig("foo(T, T, T) -> void", {"T", "T", "T"})));
> +
> + EXPECT_THAT(signatures(R"cpp(
> + template <class ...T>
> + void foo(T...);
> +
> + int main() {
> + foo<int>(^);
> + }
> + )cpp")
> + .signatures,
> + ElementsAre(Sig("foo(T...) -> void", {"T..."})));
> +
> + // It is debatable whether we should substitute the outer template
> parameter
> + // ('T') in that case. Currently we don't substitute it in signature
> help, but
> + // do substitute in code complete.
> + // FIXME: make code complete and signature help consistent, figure out
> which
> + // way is better.
> + EXPECT_THAT(signatures(R"cpp(
> + template <class T>
> + struct X {
> + template <class U>
> + void foo(T, U);
> + };
> +
> + int main() {
> + X<int>().foo<double>(^)
> + }
> + )cpp")
> + .signatures,
> + ElementsAre(Sig("foo(T, U) -> void", {"T", "U"})));
> +}
> +
> } // namespace
> } // namespace clangd
> } // namespace clang
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180815/2aada8dc/attachment-0001.html>
More information about the cfe-commits
mailing list