From fa3b87fbeb465c7ff9fd3c24b168d534d380af16 Mon Sep 17 00:00:00 2001 From: Sam McCall Date: Fri, 15 Nov 2019 14:52:04 +0100 Subject: [PATCH] [CodeComplete] Constructor overload candidates report as vector(int) instead of vector(int) Summary: This is shorter, shouldn't be confusing (is consistent with how they're declared), and avoids messy cases that are printed as myclass(int) in the case of partial specialization. Fixes part of https://github.com/clangd/clangd/issues/76 Reviewers: hokein, lh123 Subscribers: ilya-biryukov, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70307 --- clang/lib/Sema/SemaCodeComplete.cpp | 4 ++++ clang/test/CodeCompletion/templates.cpp | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index e4c4264d9dc2..ade6e46d1bca 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -3653,6 +3653,10 @@ CodeCompleteConsumer::OverloadCandidate::CreateSignatureString( unsigned CurrentArg, Sema &S, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments) const { PrintingPolicy Policy = getCompletionPrintingPolicy(S); + // Show signatures of constructors as they are declared: + // vector(int n) rather than vector(int n) + // This is less noisy without being less clear, and avoids tricky cases. + Policy.SuppressTemplateArgsInCXXConstructors = true; // FIXME: Set priority, availability appropriately. CodeCompletionBuilder Result(Allocator, CCTUInfo, 1, diff --git a/clang/test/CodeCompletion/templates.cpp b/clang/test/CodeCompletion/templates.cpp index 32a7b2125fec..f9811f446476 100644 --- a/clang/test/CodeCompletion/templates.cpp +++ b/clang/test/CodeCompletion/templates.cpp @@ -24,5 +24,12 @@ void f() { // CHECK-CC2: foo // CHECK-CC2: in_base // CHECK-CC2: stop - +} + +template struct X; +template struct X { X(double); }; +X x(42); +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:32:11 %s -o - | FileCheck -check-prefix=CHECK-CONSTRUCTOR %s +// CHECK-CONSTRUCTOR: OVERLOAD: X(<#double#>) +// (rather than X(<#double#>) -- 2.34.1