[clang] fa3b87f - [CodeComplete] Constructor overload candidates report as vector(int) instead of vector<string>(int)
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 15 06:42:30 PST 2019
Author: Sam McCall
Date: 2019-11-15T15:42:18+01:00
New Revision: fa3b87fbeb465c7ff9fd3c24b168d534d380af16
URL: https://github.com/llvm/llvm-project/commit/fa3b87fbeb465c7ff9fd3c24b168d534d380af16
DIFF: https://github.com/llvm/llvm-project/commit/fa3b87fbeb465c7ff9fd3c24b168d534d380af16.diff
LOG: [CodeComplete] Constructor overload candidates report as vector(int) instead of vector<string>(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<type-param-0-0>(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
Added:
Modified:
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/CodeCompletion/templates.cpp
Removed:
################################################################################
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<string>(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 <typename> struct X;
+template <typename T> struct X<T*> { X(double); };
+X<int*> 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<type-parameter-0-0 *>(<#double#>)
More information about the cfe-commits
mailing list