Go to the documentation of this file.
14 #ifndef LLVM_CLANG_SEMA_TEMPLATEDEDUCTION_H
15 #define LLVM_CLANG_SEMA_TEMPLATEDEDUCTION_H
25 #include "llvm/ADT/Optional.h"
26 #include "llvm/ADT/SmallVector.h"
51 bool HasSFINAEDiagnostic =
false;
54 unsigned DeducedDepth;
58 unsigned ExplicitArgs = 0;
66 : Loc(Loc), DeducedDepth(DeducedDepth) {}
74 : Deduced(Info.Deduced), Loc(Info.Loc), DeducedDepth(Info.DeducedDepth),
75 ExplicitArgs(Info.ExplicitArgs) {}
103 assert(HasSFINAEDiagnostic);
104 PD.first = SuppressedDiagnostics.front().first;
105 PD.second.swap(SuppressedDiagnostics.front().second);
111 SuppressedDiagnostics.clear();
112 HasSFINAEDiagnostic =
false;
117 assert(HasSFINAEDiagnostic);
118 return SuppressedDiagnostics.front();
124 Deduced = NewDeduced;
125 ExplicitArgs = Deduced->
size();
131 Deduced = NewDeduced;
136 return HasSFINAEDiagnostic;
142 if (HasSFINAEDiagnostic)
144 SuppressedDiagnostics.clear();
145 SuppressedDiagnostics.emplace_back(Loc, std::move(PD));
146 HasSFINAEDiagnostic =
true;
152 if (HasSFINAEDiagnostic)
154 SuppressedDiagnostics.emplace_back(Loc, std::move(PD));
323 bool ForTakingAddress;
325 void destroyCandidates();
329 : Loc(Loc), ForTakingAddress(ForTakingAddress) {}
346 size_t size()
const {
return Candidates.size(); }
347 bool empty()
const {
return Candidates.empty(); }
352 Candidates.emplace_back();
353 return Candidates.back();
365 #endif // LLVM_CLANG_SEMA_TEMPLATEDEDUCTION_H
TemplateArgumentList * take()
Take ownership of the deduced template argument list.
unsigned CallArgIndex
The index of the function argument that caused a deduction failure.
Decl * Specialization
Specialization - The actual specialization that this candidate represents.
void NoteCandidates(Sema &S, SourceLocation Loc)
NoteCandidates - When no template specialization match is found, prints diagnostic messages containin...
TemplateSpecCandidateSet & operator=(const TemplateSpecCandidateSet &)=delete
Encodes a location in the source.
SourceLocation getLocation() const
TemplateSpecCandidate - This is a generalization of OverloadCandidate which keeps track of template a...
diag_iterator diag_begin() const
Returns an iterator at the beginning of the sequence of suppressed diagnostics.
void NoteCandidates(Sema &S, SourceLocation Loc) const
unsigned Result
A Sema::TemplateDeductionResult.
TemplateArgument FirstArg
The first template argument to which the template argument deduction failure refers.
TemplateDeductionInfo(ForBaseTag, const TemplateDeductionInfo &Info)
Create temporary template deduction info for speculatively deducing against a base class of an argume...
const PartialDiagnosticAt & peekSFINAEDiagnostic() const
Peek at the SFINAE diagnostic.
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
void Destroy()
Free any memory associated with this deduction failure.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
void addSuppressedDiagnostic(SourceLocation Loc, PartialDiagnostic PD)
Add a new diagnostic to the set of diagnostics.
TemplateSpecCandidateSet(SourceLocation Loc, bool ForTakingAddress=false)
A POD class for pairing a NamedDecl* with an access specifier.
A structure used to record information about a failed template argument deduction,...
TemplateParameter Param
The template parameter to which a template argument deduction failure refers.
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
Represents a template argument.
SmallVector< TemplateSpecCandidate, 16 >::iterator iterator
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
unsigned getDeducedDepth() const
The depth of template parameters for which deduction is being performed.
diag_iterator diag_end() const
Returns an iterator at the end of the sequence of suppressed diagnostics.
unsigned HasDiagnostic
Indicates whether a diagnostic is stored in Diagnostic.
This file provides AST data structures related to concepts.
void * Data
Opaque pointer containing additional data about this deduction failure.
const TemplateArgument * getFirstArg()
Return the first template argument this deduction failure refers to, if any.
void addSFINAEDiagnostic(SourceLocation Loc, PartialDiagnostic PD)
Set the diagnostic which caused the SFINAE failure.
void setExplicitArgs(TemplateArgumentList *NewDeduced)
Provide an initial template argument list that contains the explicitly-specified arguments.
void clear()
Clear out all of the candidates.
DeductionFailureInfo DeductionFailure
Template argument deduction info.
DeclAccessPair FoundDecl
The declaration that was looked up, together with its access.
const TemplateArgument * getSecondArg()
Return the second template argument this deduction failure refers to, if any.
void NoteDeductionFailure(Sema &S, bool ForTakingAddress)
Diagnose a template argument deduction failure.
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
ConstraintSatisfaction AssociatedConstraintsSatisfaction
The constraint satisfaction details resulting from the associated constraints satisfaction tests.
SmallVectorImpl< PartialDiagnosticAt >::const_iterator diag_iterator
Iterator over the set of suppressed diagnostics.
Decl - This represents one declaration (or definition), e.g.
Sema - This implements semantic analysis and AST building for C.
llvm::Optional< unsigned > getCallArgIndex()
Return the index of the call argument that this deduction failure refers to, if any.
SourceLocation getLocation() const
Returns the location at which template argument is occurring.
TemplateArgument SecondArg
The second template argument to which the template argument deduction failure refers.
A template argument list.
Provides information about an attempted template argument deduction, whose success or failure was des...
void reset(TemplateArgumentList *NewDeduced)
Provide a new template argument list that contains the results of template argument deduction.
SmallVector< DeducedPack *, 8 > PendingDeducedPacks
Information on packs that we're currently expanding.
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set.
TemplateDeductionInfo(SourceLocation Loc, unsigned DeducedDepth=0)
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
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.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
~TemplateSpecCandidateSet()
unsigned getNumExplicitArgs() const
Get the number of explicitly-specified arguments.
PartialDiagnosticAt * getSFINAEDiagnostic()
Retrieve the diagnostic which caused this deduction failure, if any.
void clearSFINAEDiagnostic()
Discard any SFINAE diagnostics.
TemplateDeductionInfo & operator=(const TemplateDeductionInfo &)=delete