[clang-tools-extra] r354272 - [clangd] Add tests for template specializations
Kadir Cetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 18 06:23:20 PST 2019
Author: kadircet
Date: Mon Feb 18 06:23:19 2019
New Revision: 354272
URL: http://llvm.org/viewvc/llvm-project?rev=354272&view=rev
Log:
[clangd] Add tests for template specializations
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D58190
Modified:
clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
Modified: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp?rev=354272&r1=354271&r2=354272&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp Mon Feb 18 06:23:19 2019
@@ -350,6 +350,58 @@ TEST(LocateSymbol, All) {
FF();
void f() { T^est a; }
)cpp",
+
+ R"cpp(// explicit template specialization
+ template <typename T>
+ struct Foo { void bar() {} };
+
+ template <>
+ struct [[Foo]]<int> { void bar() {} };
+
+ void foo() {
+ Foo<char> abc;
+ Fo^o<int> b;
+ }
+ )cpp",
+
+ R"cpp(// implicit template specialization
+ template <typename T>
+ struct [[Foo]] { void bar() {} };
+ template <>
+ struct Foo<int> { void bar() {} };
+ void foo() {
+ Fo^o<char> abc;
+ Foo<int> b;
+ }
+ )cpp",
+
+ R"cpp(// partial template specialization
+ template <typename T>
+ struct Foo { void bar() {} };
+ template <typename T>
+ struct [[Foo]]<T*> { void bar() {} };
+ ^Foo<int*> x;
+ )cpp",
+
+ R"cpp(// function template specializations
+ template <class T>
+ void foo(T) {}
+ template <>
+ void [[foo]](int) {}
+ void bar() {
+ fo^o(10);
+ }
+ )cpp",
+
+ R"cpp(// variable template decls
+ template <class T>
+ T var = T();
+
+ template <>
+ double [[var]]<int> = 10;
+
+ double y = va^r<int>;
+ )cpp",
};
for (const char *Test : Tests) {
Annotations T(Test);
More information about the cfe-commits
mailing list