ClassTemplateSpecializationDecl not within a ClassTemplateDecl represents an explicit instatiation of a template and so should be handled as if it were a normal CXXRecordDecl. Unfortunately, having an equivalent for FunctionTemplateDecl remains a TODO in ASTDumper's VisitFunctionTemplateDecl, with all the explicit instantiations just being emitted inside the FunctionTemplateDecl along with all the other specializations, meaning we can't easily support explicit function instantiations in update_cc_test_checks. Reviewed By: arichardson Differential Revision: https://reviews.llvm.org/D106243
51 lines
989 B
C++
51 lines
989 B
C++
// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
|
|
|
|
template <typename T>
|
|
struct Foo {
|
|
private:
|
|
T x;
|
|
|
|
public:
|
|
Foo(T x) : x(x) {}
|
|
~Foo() {}
|
|
|
|
T get() { return x; }
|
|
void set(T _x) { x = _x; }
|
|
};
|
|
|
|
template <typename T>
|
|
struct Bar {
|
|
private:
|
|
struct Foo<T> foo;
|
|
|
|
public:
|
|
Bar(T x) : foo(x) {}
|
|
~Bar() {}
|
|
|
|
T get() { return foo.get(); }
|
|
void set(T _x) { foo.set(_x); }
|
|
};
|
|
|
|
template <typename T>
|
|
struct Baz : Foo<T> {
|
|
public:
|
|
Baz(T x) : Foo<T>(x) {}
|
|
~Baz() {}
|
|
};
|
|
|
|
// These two specializations should generate lines for all of Foo's methods.
|
|
|
|
template struct Foo<char>;
|
|
|
|
template struct Foo<short>;
|
|
|
|
// This should not generate lines for the implicit specialization of Foo, but
|
|
// should generate lines for the explicit specialization of Bar.
|
|
|
|
template struct Bar<int>;
|
|
|
|
// This should not generate lines for the implicit specialization of Foo, but
|
|
// should generate lines for the explicit specialization of Baz.
|
|
|
|
template struct Baz<long>;
|