[clang-tools-extra] r368403 - [clangd] Fixed printTemplateSpecializationArgs not printing partial variable specialization arguments.
Johan Vikstrom via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 9 00:35:16 PDT 2019
Author: jvikstrom
Date: Fri Aug 9 00:35:16 2019
New Revision: 368403
URL: http://llvm.org/viewvc/llvm-project?rev=368403&view=rev
Log:
[clangd] Fixed printTemplateSpecializationArgs not printing partial variable specialization arguments.
Summary:
printTemplateSpecializationArgs was not printing partial variable specialization args. This adds an additional If clause where we check if it's a VariableTemplatePartialSpecializationDecl and returns the ArgumentLocs if that's the case.
Also adds tests for printTemplateSpecializationArgs in ASTTests.cpp.
Reviewers: hokein, ilya-biryukov
Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D65926
Modified:
clang-tools-extra/trunk/clangd/AST.cpp
clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp
clang-tools-extra/trunk/clangd/unittests/PrintASTTests.cpp
Modified: clang-tools-extra/trunk/clangd/AST.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/AST.cpp?rev=368403&r1=368402&r2=368403&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/AST.cpp (original)
+++ clang-tools-extra/trunk/clangd/AST.cpp Fri Aug 9 00:35:16 2019
@@ -36,6 +36,10 @@ getTemplateSpecializationArgLocs(const N
llvm::dyn_cast<ClassTemplatePartialSpecializationDecl>(&ND)) {
if (auto *Args = Cls->getTemplateArgsAsWritten())
return Args->arguments();
+ } else if (auto *Var =
+ llvm::dyn_cast<VarTemplatePartialSpecializationDecl>(&ND)) {
+ if (auto *Args = Var->getTemplateArgsAsWritten())
+ return Args->arguments();
} else if (auto *Var = llvm::dyn_cast<VarTemplateSpecializationDecl>(&ND))
return Var->getTemplateArgsInfo().arguments();
// We return None for ClassTemplateSpecializationDecls because it does not
Modified: clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp?rev=368403&r1=368402&r2=368403&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp Fri Aug 9 00:35:16 2019
@@ -188,7 +188,7 @@ TEST(ClangdUnitTest,
AllOf(DeclNamed("foo"), WithTemplateArgs("")),
AllOf(DeclNamed("i"), WithTemplateArgs("")),
AllOf(DeclNamed("d"), WithTemplateArgs("")),
- AllOf(DeclNamed("foo"), WithTemplateArgs("<>")),
+ AllOf(DeclNamed("foo"), WithTemplateArgs("<T *>")),
AllOf(DeclNamed("foo"), WithTemplateArgs("<bool>"))}));
}
Modified: clang-tools-extra/trunk/clangd/unittests/PrintASTTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/PrintASTTests.cpp?rev=368403&r1=368402&r2=368403&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/unittests/PrintASTTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/PrintASTTests.cpp Fri Aug 9 00:35:16 2019
@@ -95,6 +95,15 @@ INSTANTIATE_TEST_CASE_P(ASTUtilsTests, A
struct Bar { friend class Foo<int>; };
template <> struct ^Foo<int> {};)cpp",
{"<int>"}},
+ {
+ R"cpp(
+ template<class T>
+ T S = T(10);
+ template <class T>
+ int ^S<T*> = 0;
+ template <>
+ int ^S<double> = 0;)cpp",
+ {"<T *>", "<double>"}},
})),);
} // namespace
} // namespace clangd
More information about the cfe-commits
mailing list