[PATCH] D72715: [clang][CodeComplete] Propogate printing policy to FunctionDecl
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 20 03:30:42 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1f946ee2faba: [clang][CodeComplete] Propogate printing policy to FunctionDecl (authored by kadircet).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72715/new/
https://reviews.llvm.org/D72715
Files:
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/CodeCompletion/ctor-signature.cpp
Index: clang/test/CodeCompletion/ctor-signature.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeCompletion/ctor-signature.cpp
@@ -0,0 +1,17 @@
+template <typename T>
+struct Foo {};
+template <typename T>
+struct Foo<T *> { Foo(T); };
+
+void foo() {
+ Foo<int>();
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:7:12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+ // CHECK-CC1: OVERLOAD: Foo()
+ // CHECK-CC1: OVERLOAD: Foo(<#const Foo<int> &#>)
+ // CHECK-CC1: OVERLOAD: Foo(<#Foo<int> &&#>
+ Foo<int *>(3);
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:12:14 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+ // CHECK-CC2: OVERLOAD: Foo(<#int#>)
+ // CHECK-CC2: OVERLOAD: Foo(<#const Foo<int *> &#>)
+ // CHECK-CC2: OVERLOAD: Foo(<#Foo<int *> &&#>
+}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===================================================================
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -37,6 +37,7 @@
#include "llvm/ADT/Twine.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
#include <list>
#include <map>
#include <string>
@@ -3705,8 +3706,11 @@
Result.addBriefComment(RC->getBriefText(S.getASTContext()));
}
AddResultTypeChunk(S.Context, Policy, FDecl, QualType(), Result);
- Result.AddTextChunk(
- Result.getAllocator().CopyString(FDecl->getNameAsString()));
+
+ std::string Name;
+ llvm::raw_string_ostream OS(Name);
+ FDecl->getDeclName().print(OS, Policy);
+ Result.AddTextChunk(Result.getAllocator().CopyString(OS.str()));
} else {
Result.AddResultTypeChunk(Result.getAllocator().CopyString(
Proto->getReturnType().getAsString(Policy)));
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2297,6 +2297,15 @@
AllOf(Named("TestClangc"), Deprecated())));
}
+TEST(SignatureHelpTest, PartialSpec) {
+ const auto Results = signatures(R"cpp(
+ template <typename T> struct Foo {};
+ template <typename T> struct Foo<T*> { Foo(T); };
+ Foo<int*> F(^);)cpp");
+ EXPECT_THAT(Results.signatures, Contains(Sig("Foo([[T]])")));
+ EXPECT_EQ(0, Results.activeParameter);
+}
+
TEST(SignatureHelpTest, InsideArgument) {
{
const auto Results = signatures(R"cpp(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72715.239058.patch
Type: text/x-patch
Size: 2593 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200120/16681e58/attachment.bin>
More information about the cfe-commits
mailing list