clang: include/clang/Sema/TemplateDeduction.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_CLANG_SEMA_TEMPLATEDEDUCTION_H
15#define LLVM_CLANG_SEMA_TEMPLATEDEDUCTION_H
16
25#include "llvm/ADT/SmallVector.h"
26#include
27#include
28#include
29#include
30
32
34struct DeducedPack;
35class Sema;
37
38namespace sema {
39
40
41
42
44
46
47
48
50
51
52 bool HasSFINAEDiagnostic = false;
53
54
55 unsigned DeducedDepth;
56
57
58
59 unsigned ExplicitArgs = 0;
60
61
62
64
65public:
67 : Loc(Loc), DeducedDepth(DeducedDepth) {}
70
72
73
75 : DeducedSugared(Info.DeducedSugared), Loc(Info.Loc),
76 DeducedDepth(Info.DeducedDepth), ExplicitArgs(Info.ExplicitArgs) {}
77
78
79
81 return Loc;
82 }
83
84
85
87 return DeducedDepth;
88 }
89
90
92 return ExplicitArgs;
93 }
94
95
98 DeducedSugared = nullptr;
100 }
103 DeducedCanonical = nullptr;
105 }
106
107
109 assert(HasSFINAEDiagnostic);
110 PD.first = SuppressedDiagnostics.front().first;
111 PD.second.swap(SuppressedDiagnostics.front().second);
113 }
114
115
117 SuppressedDiagnostics.clear();
118 HasSFINAEDiagnostic = false;
119 }
120
121
123 assert(HasSFINAEDiagnostic);
124 return SuppressedDiagnostics.front();
125 }
126
127
128
131 assert(NewDeducedSugared->size() == NewDeducedCanonical->size());
132 DeducedSugared = NewDeducedSugared;
133 DeducedCanonical = NewDeducedCanonical;
134 ExplicitArgs = DeducedSugared->size();
135 }
136
137
138
141 DeducedSugared = NewDeducedSugared;
142 DeducedCanonical = NewDeducedCanonical;
143 }
144
145
147 return HasSFINAEDiagnostic;
148 }
149
150
152
153 if (HasSFINAEDiagnostic)
154 return;
155 SuppressedDiagnostics.clear();
156 SuppressedDiagnostics.emplace_back(Loc, std::move(PD));
157 HasSFINAEDiagnostic = true;
158 }
159
160
163 if (HasSFINAEDiagnostic)
164 return;
165 SuppressedDiagnostics.emplace_back(Loc, std::move(PD));
166 }
167
168
170
171
172
174
175
176
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
216
217
218
219
220
221
222
223
224
225
226
227
228
230
231
232
233
234
235
237
238
239
240
241
242
244
245
246
247
249
250
251
253};
254
255}
256
257
258
260
262
263
265
266
267
269
270
272
273
274
276
277
278
280
281
282
284
285
286
288
289
290
292
293
294
296
297
299
302 }
303};
304
305
306
307
308
309
310
311
313
314
316
317
318
320
321
323
328 }
329
330
332};
333
334
335
336
337
341
342
343
344
345 bool ForTakingAddress;
346
347 void destroyCandidates();
348
349public:
351 : Loc(Loc), ForTakingAddress(ForTakingAddress) {}
356
358
359
360
362
364
367
368 size_t size() const { return Candidates.size(); }
369 bool empty() const { return Candidates.empty(); }
370
371
372
374 Candidates.emplace_back();
375 return Candidates.back();
376 }
377
379
382 }
383};
384
385}
386
387#endif
This file provides AST data structures related to concepts.
Defines the C++ template declaration subclasses.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::SourceLocation class and associated facilities.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
A POD class for pairing a NamedDecl* with an access specifier.
Decl - This represents one declaration (or definition), e.g.
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine a...
Sema - This implements semantic analysis and AST building for C.
Encodes a location in the source.
A template argument list.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Represents a template argument.
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
SmallVector< TemplateSpecCandidate, 16 >::iterator iterator
void NoteCandidates(Sema &S, SourceLocation Loc)
NoteCandidates - When no template specialization match is found, prints diagnostic messages containin...
TemplateSpecCandidateSet & operator=(const TemplateSpecCandidateSet &)=delete
void clear()
Clear out all of the candidates.
~TemplateSpecCandidateSet()
SourceLocation getLocation() const
TemplateSpecCandidateSet(const TemplateSpecCandidateSet &)=delete
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set.
TemplateSpecCandidateSet(SourceLocation Loc, bool ForTakingAddress=false)
void NoteCandidates(Sema &S, SourceLocation Loc) const
Provides information about an attempted template argument deduction, whose success or failure was des...
TemplateDeductionInfo & operator=(const TemplateDeductionInfo &)=delete
void setExplicitArgs(TemplateArgumentList *NewDeducedSugared, TemplateArgumentList *NewDeducedCanonical)
Provide an initial template argument list that contains the explicitly-specified arguments.
TemplateArgumentList * takeCanonical()
TemplateArgumentList * takeSugared()
Take ownership of the deduced template argument lists.
TemplateDeductionInfo(ForBaseTag, const TemplateDeductionInfo &Info)
Create temporary template deduction info for speculatively deducing against a base class of an argume...
unsigned getNumExplicitArgs() const
Get the number of explicitly-specified arguments.
SourceLocation getLocation() const
Returns the location at which template argument is occurring.
void addSuppressedDiagnostic(SourceLocation Loc, PartialDiagnostic PD)
Add a new diagnostic to the set of diagnostics.
void clearSFINAEDiagnostic()
Discard any SFINAE diagnostics.
TemplateArgument SecondArg
The second template argument to which the template argument deduction failure refers.
TemplateParameter Param
The template parameter to which a template argument deduction failure refers.
diag_iterator diag_end() const
Returns an iterator at the end of the sequence of suppressed diagnostics.
SmallVectorImpl< PartialDiagnosticAt >::const_iterator diag_iterator
Iterator over the set of suppressed diagnostics.
TemplateDeductionInfo(SourceLocation Loc, unsigned DeducedDepth=0)
void reset(TemplateArgumentList *NewDeducedSugared, TemplateArgumentList *NewDeducedCanonical)
Provide a new template argument list that contains the results of template argument deduction.
void addSFINAEDiagnostic(SourceLocation Loc, PartialDiagnostic PD)
Set the diagnostic which caused the SFINAE failure.
unsigned getDeducedDepth() const
The depth of template parameters for which deduction is being performed.
diag_iterator diag_begin() const
Returns an iterator at the beginning of the sequence of suppressed diagnostics.
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
bool AggregateDeductionCandidateHasMismatchedArity
SmallVector< DeducedPack *, 8 > PendingDeducedPacks
Information on packs that we're currently expanding.
TemplateArgument FirstArg
The first template argument to which the template argument deduction failure refers.
ConstraintSatisfaction AssociatedConstraintsSatisfaction
The constraint satisfaction details resulting from the associated constraints satisfaction tests.
const PartialDiagnosticAt & peekSFINAEDiagnostic() const
Peek at the SFINAE diagnostic.
TemplateDeductionInfo(const TemplateDeductionInfo &)=delete
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
unsigned CallArgIndex
The index of the function argument that caused a deduction failure.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
TemplateDeductionResult
Describes the result of template argument deduction.
A structure used to record information about a failed template argument deduction,...
void * Data
Opaque pointer containing additional data about this deduction failure.
const TemplateArgument * getSecondArg()
Return the second template argument this deduction failure refers to, if any.
unsigned Result
A Sema::TemplateDeductionResult.
PartialDiagnosticAt * getSFINAEDiagnostic()
Retrieve the diagnostic which caused this deduction failure, if any.
std::optional< unsigned > getCallArgIndex()
Return the index of the call argument that this deduction failure refers to, if any.
unsigned HasDiagnostic
Indicates whether a diagnostic is stored in Diagnostic.
TemplateDeductionResult getResult() const
void Destroy()
Free any memory associated with this deduction failure.
TemplateParameter getTemplateParameter()
Retrieve the template parameter this deduction failure refers to, if any.
TemplateArgumentList * getTemplateArgumentList()
Retrieve the template argument list associated with this deduction failure, if any.
const TemplateArgument * getFirstArg()
Return the first template argument this deduction failure refers to, if any.
TemplateSpecCandidate - This is a generalization of OverloadCandidate which keeps track of template a...
void NoteDeductionFailure(Sema &S, bool ForTakingAddress)
Diagnose a template argument deduction failure.
DeductionFailureInfo DeductionFailure
Template argument deduction info.
Decl * Specialization
Specialization - The actual specialization that this candidate represents.
DeclAccessPair FoundDecl
The declaration that was looked up, together with its access.
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)