14#ifndef LLVM_CLANG_SEMA_TEMPLATEDEDUCTION_H
15#define LLVM_CLANG_SEMA_TEMPLATEDEDUCTION_H
25#include "llvm/ADT/SmallVector.h"
52 bool HasSFINAEDiagnostic =
false;
57 bool StrictPackMatch =
false;
60 unsigned DeducedDepth;
64 unsigned ExplicitArgs = 0;
72 : Loc(Loc), DeducedDepth(DeducedDepth) {}
80 : DeducedSugared(Info.DeducedSugared), Loc(Info.Loc),
81 DeducedDepth(Info.DeducedDepth), ExplicitArgs(Info.ExplicitArgs) {}
107 DeducedSugared =
nullptr;
112 DeducedCanonical =
nullptr;
118 assert(HasSFINAEDiagnostic);
119 PD.first = SuppressedDiagnostics.front().first;
120 PD.second.swap(SuppressedDiagnostics.front().second);
126 SuppressedDiagnostics.clear();
127 HasSFINAEDiagnostic =
false;
132 assert(HasSFINAEDiagnostic);
133 return SuppressedDiagnostics.front();
140 assert(NewDeducedSugared->
size() == NewDeducedCanonical->
size());
141 DeducedSugared = NewDeducedSugared;
142 DeducedCanonical = NewDeducedCanonical;
143 ExplicitArgs = DeducedSugared->
size();
150 DeducedSugared = NewDeducedSugared;
151 DeducedCanonical = NewDeducedCanonical;
156 return HasSFINAEDiagnostic;
162 if (HasSFINAEDiagnostic)
164 SuppressedDiagnostics.clear();
165 SuppressedDiagnostics.emplace_back(Loc, std::move(PD));
166 HasSFINAEDiagnostic =
true;
172 if (HasSFINAEDiagnostic)
174 SuppressedDiagnostics.emplace_back(Loc, std::move(PD));
354 bool ForTakingAddress;
356 void destroyCandidates();
360 : Loc(Loc), ForTakingAddress(ForTakingAddress) {}
377 size_t size()
const {
return Candidates.size(); }
378 bool empty()
const {
return Candidates.empty(); }
383 Candidates.emplace_back();
384 return Candidates.back();
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.
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.
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
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.
void setStrictPackMatch()
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.
bool hasStrictPackMatch() const
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
TemplateDeductionResult
Describes the result of template argument deduction.
A pack that we're currently deducing.
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.
unsigned HasDiagnostic
Indicates whether a diagnostic is stored in Diagnostic.
TemplateDeductionResult getResult() const
void Destroy()
Free any memory associated with this deduction failure.
char Diagnostic[sizeof(PartialDiagnosticAt)]
A diagnostic indicating why deduction failed.
UnsignedOrNone getCallArgIndex()
Return the index of the call argument that this deduction failure refers to, if any.
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)