[clang-tools-extra] r330087 - [clangd] Fix label and snippet for funcs in the index
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 14 09:27:35 PDT 2018
Author: ibiryukov
Date: Sat Apr 14 09:27:35 2018
New Revision: 330087
URL: http://llvm.org/viewvc/llvm-project?rev=330087&view=rev
Log:
[clangd] Fix label and snippet for funcs in the index
This is a follow-up to r330004 to fix functions with required template args,
e.g. std::make_shared.
Modified:
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=330087&r1=330086&r2=330087&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Sat Apr 14 09:27:35 2018
@@ -27,16 +27,11 @@ namespace clang {
namespace clangd {
namespace {
-/// If \p ND is a template specialization, returns the primary template.
+/// If \p ND is a template specialization, returns the described template.
/// Otherwise, returns \p ND.
const NamedDecl &getTemplateOrThis(const NamedDecl &ND) {
- if (auto Cls = dyn_cast<CXXRecordDecl>(&ND)) {
- if (auto T = Cls->getDescribedTemplate())
- return *T;
- } else if (auto Func = dyn_cast<FunctionDecl>(&ND)) {
- if (auto T = Func->getPrimaryTemplate())
- return *T;
- }
+ if (auto T = ND.getDescribedTemplate())
+ return *T;
return ND;
}
Modified: clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp?rev=330087&r1=330086&r2=330087&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp Sat Apr 14 09:27:35 2018
@@ -201,8 +201,8 @@ template <class Ty>
class vector {
};
-template <class Ty>
-vector<Ty> make_vector(Ty* begin, Ty* end) {}
+template <class Ty, class Arg>
+vector<Ty> make_vector(Arg A) {}
)cpp";
FileIndex M;
@@ -222,9 +222,9 @@ vector<Ty> make_vector(Ty* begin, Ty* en
}
if (Sym.Name == "make_vector") {
- EXPECT_EQ(Sym.CompletionLabel, "make_vector(Ty *begin, Ty *end)");
+ EXPECT_EQ(Sym.CompletionLabel, "make_vector<class Ty>(Arg A)");
EXPECT_EQ(Sym.CompletionSnippetInsertText,
- "make_vector(${1:Ty *begin}, ${2:Ty *end})");
+ "make_vector<${1:class Ty}>(${2:Arg A})");
EXPECT_EQ(Sym.CompletionPlainInsertText, "make_vector");
SeenMakeVector = true;
}
More information about the cfe-commits
mailing list