[PATCH] D58190: [clangd] Add tests for template specializations

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 18 06:23:01 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL354272: [clangd] Add tests for template specializations (authored by kadircet, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58190/new/

https://reviews.llvm.org/D58190

Files:
  clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp


Index: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
===================================================================
--- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
@@ -350,6 +350,58 @@
          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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58190.187238.patch
Type: text/x-patch
Size: 1635 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190218/9221efbc/attachment.bin>


More information about the cfe-commits mailing list