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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
//===------- explicit_instantiation2.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.
//
//===----------------------------------------------------------------------===//
#include "explicit_instantiation-template_direct.h"
#include "explicit_instantiation2-template_helpers.h"
#include "explicit_instantiation2-template_short_direct.h"
// These tests verify that a dependent explicit instantiation declaration is
// always required when the main template is also needed, but not otherwise.
//
// Positive scenarios:
// 1a/1b: Implicit instantiation before and after an explicit instantiation
// definition (2), as it affects the semantics.
// 2: Explicit instantiation definition.
// 3: Full use in a template, provided as an explicit parameter.
// 4: Fwd-decl use in a template, provided as an explicit parameter.
// 5: Full use in a template, provided as an default parameter.
// 7: Full use in a template, provided as a template template parameter.
// 8: Fwd-decl use in a template, provided as a template template parameter.
//
// Negative scenarios, where the dependent template specialization is not
// required, or it does not provide an explicit instantiation:
// 6: Fwd-decl use in a template, provided as a default parameter.
// 9: Implicit instantiation of Template<int>
// 10: Specialization of Template<T>
// IWYU: Template is...*explicit_instantiation-template.h
// IWYU: Template is...*template_short.h.*for explicit instantiation
Template<short> t1a; // 1a
// IWYU: Template is...*explicit_instantiation-template.h
// IWYU: Template is...*template_short.h.*for explicit instantiation
template class Template<short>; // 2
// IWYU: Template is...*explicit_instantiation-template.h
// IWYU: Template is...*template_short.h.*for explicit instantiation
Template<short> t1b; // 1b
// IWYU: Template is...*explicit_instantiation-template.h
// IWYU: Template is...*template_short.h.*for explicit instantiation
FullUseArg<
// IWYU: Template needs a declaration...*
Template<short>>
// IWYU: Template is...*explicit_instantiation-template.h
t3; // 3
// IWYU: Template is...*template_short.h.*for explicit instantiation
FwdDeclUseArg<
// IWYU: Template needs a declaration...*
Template<short>>
t4; // 4
// IWYU: Template is...*explicit_instantiation-template.h
// IWYU: Template is...*template_short.h.*for explicit instantiation
TemplateAsDefaultFull<> t5; // 5
TemplateAsDefaultFwd<> t6; // 6
// IWYU: Template is...*template_short.h.*for explicit instantiation
TemplateTemplateArgShortFull<
// IWYU: Template is...*explicit_instantiation-template.h
Template>
t7; // 7
TemplateTemplateArgShortFwd<
// IWYU: Template is...*explicit_instantiation-template.h
Template>
t8; // 8
// IWYU: Template is...*explicit_instantiation-template.h
Template<int> t9; // 9
// IWYU: Template needs a declaration...*
template <> class Template<char> {};
TemplateAsDefaultFull<char> t10; // 10
/**** IWYU_SUMMARY
tests/cxx/explicit_instantiation2.cc should add these lines:
#include "explicit_instantiation-template.h"
#include "explicit_instantiation2-template_short.h"
tests/cxx/explicit_instantiation2.cc should remove these lines:
- #include "explicit_instantiation-template_direct.h" // lines XX-XX
- #include "explicit_instantiation2-template_short_direct.h" // lines XX-XX
The full include-list for tests/cxx/explicit_instantiation2.cc:
#include "explicit_instantiation-template.h" // for Template
#include "explicit_instantiation2-template_helpers.h" // for FullUseArg, FwdDeclUseArg, TemplateAsDefaultFull, TemplateAsDefaultFwd, TemplateTemplateArgShortFull, TemplateTemplateArgShortFwd
#include "explicit_instantiation2-template_short.h" // for Template
***** IWYU_SUMMARY */
|