blob: 12fa3744538fbf46784aec8a4126af5c890ec000 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
//===--- template_specialization.cc - test input file for iwyu ------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// Tests that when we instantiate a specialized template, we attribute
// it to the right location.
#include "tests/cxx/template_specialization-d1.h"
#include "tests/cxx/direct.h"
template<typename T> class Foo;
// IWYU: Foo is...*template_specialization-i2.h
Foo<int> foo;
// Even though Foo<int> has a specialization, it doesn't matter
// because forward-declaring is ok.
Foo<int>* foo_ptr;
// Check we do the right thing when we're a template template arg, too.
// IWYU: Foo is...*template_specialization-i1.h
template <template<typename U> class T = Foo> struct TplTplStruct {
// TODO(csilvers): it's probably correct to say we need
// template_specialization-i1.h here, because if someone doesn't
// specify any tpl args when instantiating us, we'll create a
// Foo<int>, so as tpl authors we're responsible for the definition
// of Foo<int>. This is pretty unlikely to happen in practice.
T<int> u;
};
TplTplStruct<> tts;
// TODO(csilvers): This should find the -i2.h location (for Foo<int>),
// not -i1.h (for Foo<T>).
// IWYU: Foo is...*template_specialization-i1.h
TplTplStruct<Foo> tts2;
template<typename T>
struct Specialized;
template<>
// IWYU: IndirectClass is...*indirect.h
struct Specialized<int> : IndirectClass {};
/**** IWYU_SUMMARY
tests/cxx/template_specialization.cc should add these lines:
#include "tests/cxx/indirect.h"
#include "tests/cxx/template_specialization-i1.h"
#include "tests/cxx/template_specialization-i2.h"
tests/cxx/template_specialization.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
- #include "tests/cxx/template_specialization-d1.h" // lines XX-XX
- template <typename T> class Foo; // lines XX-XX
The full include-list for tests/cxx/template_specialization.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
#include "tests/cxx/template_specialization-i1.h" // for Foo
#include "tests/cxx/template_specialization-i2.h" // for Foo
template <typename T> struct Specialized; // lines XX-XX+1
***** IWYU_SUMMARY */
|