39#include "llvm/ADT/SmallBitVector.h"
40#include "llvm/ADT/SmallString.h"
41#include "llvm/ADT/StringExtras.h"
53 return SourceRange(Ps[0]->getTemplateLoc(), Ps[N-1]->getRAngleLoc());
61 for (
Scope *TempParamScope = S->getTemplateParamParent(); TempParamScope;
62 TempParamScope = TempParamScope->getParent()->getTemplateParamParent()) {
67 auto ParamsAtDepth = [&](
unsigned D) { Depth = std::max(Depth, D + 1); };
72 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(FSI)) {
73 if (!LSI->TemplateParams.empty()) {
74 ParamsAtDepth(LSI->AutoTemplateParameterDepth);
77 if (LSI->GLTemplateParameterList) {
78 ParamsAtDepth(LSI->GLTemplateParameterList->getDepth());
88 if (!Info.TemplateParams.empty()) {
89 ParamsAtDepth(Info.AutoTemplateParameterDepth);
104 bool AllowFunctionTemplates,
105 bool AllowDependent) {
108 if (isa<TemplateDecl>(D)) {
109 if (!AllowFunctionTemplates && isa<FunctionTemplateDecl>(D))
115 if (
const auto *
Record = dyn_cast<CXXRecordDecl>(D)) {
127 if (
Record->isInjectedClassName()) {
129 if (
Record->getDescribedClassTemplate())
130 return Record->getDescribedClassTemplate();
132 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(
Record))
133 return Spec->getSpecializedTemplate();
142 if (AllowDependent && isa<UnresolvedUsingValueDecl>(D))
149 bool AllowFunctionTemplates,
150 bool AllowDependent) {
161 bool AllowFunctionTemplates,
163 bool AllowNonTemplateFunctions) {
167 if (AllowNonTemplateFunctions &&
168 isa<FunctionDecl>((*I)->getUnderlyingDecl()))
177 bool hasTemplateKeyword,
180 bool EnteringContext,
182 bool &MemberOfUnknownSpecialization,
183 bool Disambiguation) {
187 MemberOfUnknownSpecialization =
false;
189 switch (Name.getKind()) {
196 Name.OperatorFunctionId.Operator);
235 bool AnyFunctionTemplates =
false;
238 if (isa<FunctionTemplateDecl>(FoundTemplate))
239 AnyFunctionTemplates =
true;
242 FoundUsingShadow = dyn_cast<UsingShadowDecl>(FoundD);
250 if (!D && !AnyFunctionTemplates) {
251 R.suppressDiagnostics();
268 unsigned ResultCount = R.
end() - R.
begin();
269 if (!D && ResultCount > 1) {
280 assert(D &&
"unambiguous result is not a template name");
283 if (isa<UnresolvedUsingValueDecl>(D)) {
285 MemberOfUnknownSpecialization =
true;
292 assert(!FoundUsingShadow || FoundUsingShadow->
getTargetDecl() == TD);
299 if (isa<FunctionTemplateDecl>(TD)) {
305 assert(isa<ClassTemplateDecl>(TD) || isa<TemplateTemplateParmDecl>(TD) ||
306 isa<TypeAliasTemplateDecl>(TD) || isa<VarTemplateDecl>(TD) ||
307 isa<BuiltinTemplateDecl>(TD) || isa<ConceptDecl>(TD));
322 bool MemberOfUnknownSpecialization =
false;
330 MemberOfUnknownSpecialization))
333 if (R.
empty())
return false;
367 Diag(IILoc, diag::err_template_kw_missing)
379 bool EnteringContext,
380 bool &MemberOfUnknownSpecialization,
383 bool AllowTypoCorrection) {
393 MemberOfUnknownSpecialization =
false;
395 bool IsDependent =
false;
396 if (!ObjectType.
isNull()) {
399 assert(SS.
isEmpty() &&
"ObjectType and scope specifier cannot coexist");
405 "Caller should have completed object type");
437 bool ObjectTypeSearchedInScope =
false;
438 bool AllowFunctionTemplatesInLookup =
true;
470 if (!ObjectType.
isNull()) {
474 AllowFunctionTemplatesInLookup =
false;
475 ObjectTypeSearchedInScope =
true;
498 if (AllFunctions || (Found.
empty() && !IsDependent)) {
510 if (Found.
empty() && !IsDependent && AllowTypoCorrection) {
518 FilterCCC.WantExpressionKeywords =
false;
519 FilterCCC.WantRemainingKeywords =
false;
520 FilterCCC.WantCXXNamedCasts =
true;
524 if (
auto *ND = Corrected.getFoundDecl())
529 }
else if (!Found.
empty()) {
532 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
533 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
534 Name.getAsString() == CorrectedStr;
536 << Name << LookupCtx << DroppedSpecifier
550 MemberOfUnknownSpecialization =
true;
556 if (ExampleLookupResult && RequiredTemplate) {
557 Diag(Found.
getNameLoc(), diag::err_template_kw_refers_to_non_template)
562 diag::note_template_kw_refers_to_non_template)
570 if (S && !ObjectType.
isNull() && !ObjectTypeSearchedInScope &&
587 if (FoundOuter.
empty()) {
605 diag::ext_nested_name_member_ref_lookup_ambiguous)
609 diag::note_ambig_member_ref_object_type)
612 diag::note_ambig_member_ref_scope);
635 bool MissingTemplateKeyword =
false;
638 if (
auto *DRE = dyn_cast<DeclRefExpr>(
TemplateName.get())) {
639 NameInfo = DRE->getNameInfo();
640 SS.
Adopt(DRE->getQualifierLoc());
642 Found = DRE->getFoundDecl();
643 }
else if (
auto *ME = dyn_cast<MemberExpr>(
TemplateName.get())) {
644 NameInfo = ME->getMemberNameInfo();
645 SS.
Adopt(ME->getQualifierLoc());
647 LookupCtx = ME->getBase()->getType()->getAsCXXRecordDecl();
648 Found = ME->getMemberDecl();
649 }
else if (
auto *DSDRE =
650 dyn_cast<DependentScopeDeclRefExpr>(
TemplateName.get())) {
651 NameInfo = DSDRE->getNameInfo();
652 SS.
Adopt(DSDRE->getQualifierLoc());
653 MissingTemplateKeyword =
true;
654 }
else if (
auto *DSME =
655 dyn_cast<CXXDependentScopeMemberExpr>(
TemplateName.get())) {
656 NameInfo = DSME->getMemberNameInfo();
657 SS.
Adopt(DSME->getQualifierLoc());
658 MissingTemplateKeyword =
true;
660 llvm_unreachable(
"unexpected kind of potential template name");
665 if (MissingTemplateKeyword) {
674 TemplateCandidateFilter(
Sema &S) : S(S) {
675 WantTypeSpecifiers =
false;
676 WantExpressionKeywords =
false;
677 WantRemainingKeywords =
false;
678 WantCXXNamedCasts =
true;
680 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
686 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
687 return std::make_unique<TemplateCandidateFilter>(*
this);
692 TemplateCandidateFilter CCC(*
this);
695 auto *ND = Corrected.getFoundDecl();
698 if (ND || Corrected.isKeyword()) {
700 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
701 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
702 Name.getAsString() == CorrectedStr;
704 PDiag(diag::err_non_template_in_member_template_id_suggest)
705 << Name << LookupCtx << DroppedSpecifier
709 PDiag(diag::err_non_template_in_template_id_suggest)
714 diag::note_non_template_in_template_id_found);
719 Diag(NameInfo.
getLoc(), diag::err_non_template_in_template_id)
722 Diag(Found->
getLocation(), diag::note_non_template_in_template_id_found);
732 bool isAddressOfOperand,
747 bool MightBeCxx11UnevalField =
753 IsEnum = isa_and_nonnull<EnumType>(NNS->getAsType());
755 if (!MightBeCxx11UnevalField && !isAddressOfOperand && !IsEnum &&
756 isa<CXXMethodDecl>(DC) &&
757 cast<CXXMethodDecl>(DC)->isImplicitObjectMemberFunction()) {
758 QualType ThisType = cast<CXXMethodDecl>(DC)->getThisType().getNonReferenceType();
762 NamedDecl *FirstQualifierInScope =
nullptr;
768 FirstQualifierInScope, NameInfo, TemplateArgs);
785 Context, QualifierLoc, TemplateKWLoc, NameInfo, TemplateArgs);
793 bool InstantiatedFromMember,
798 assert(isa<TagDecl>(Instantiation) || isa<FunctionDecl>(Instantiation) ||
799 isa<VarDecl>(Instantiation));
801 bool IsEntityBeingDefined =
false;
802 if (
const TagDecl *TD = dyn_cast_or_null<TagDecl>(PatternDef))
803 IsEntityBeingDefined = TD->isBeingDefined();
805 if (PatternDef && !IsEntityBeingDefined) {
820 if (!Complain || (PatternDef && PatternDef->
isInvalidDecl()))
824 if (
TagDecl *TD = dyn_cast<TagDecl>(Instantiation))
827 Diag(PointOfInstantiation,
828 diag::err_template_instantiate_within_definition)
834 }
else if (InstantiatedFromMember) {
835 if (isa<FunctionDecl>(Instantiation)) {
836 Diag(PointOfInstantiation,
837 diag::err_explicit_instantiation_undefined_member)
842 assert(isa<TagDecl>(Instantiation) &&
"Must be a TagDecl!");
843 Diag(PointOfInstantiation,
844 diag::err_implicit_instantiate_member_undefined)
849 if (isa<FunctionDecl>(Instantiation)) {
850 Diag(PointOfInstantiation,
851 diag::err_explicit_instantiation_undefined_func_template)
854 }
else if (isa<TagDecl>(Instantiation)) {
855 Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
860 assert(isa<VarDecl>(Instantiation) &&
"Must be a VarDecl!");
861 if (isa<VarTemplateSpecializationDecl>(Instantiation)) {
862 Diag(PointOfInstantiation,
863 diag::err_explicit_instantiation_undefined_var_template)
867 Diag(PointOfInstantiation,
868 diag::err_explicit_instantiation_undefined_member)
885 bool SupportedForCompatibility) {
898 ? diag::ext_template_param_shadow
899 : (SupportedForCompatibility ? diag::ext_compat_template_param_shadow
900 : diag::err_template_param_shadow);
901 const auto *ND = cast<NamedDecl>(PrevDecl);
902 Diag(Loc, DiagId) << ND->getDeclName();
910 if (
TemplateDecl *Temp = dyn_cast_or_null<TemplateDecl>(D)) {
911 D = Temp->getTemplatedDecl();
920 "Only template template arguments can be pack expansions here");
921 assert(
getAsTemplate().get().containsUnexpandedParameterPack() &&
922 "Template template argument pack expansion without packs");
924 Result.EllipsisLoc = EllipsisLoc;
959 llvm_unreachable(
"Unhandled parsed template argument");
966 for (
unsigned I = 0,
Last = TemplateArgsIn.size(); I !=
Last; ++I)
989 assert(TInfo &&
"template argument with no location");
997 EllipsisLoc = PET.getEllipsisLoc();
998 TL = PET.getPatternLoc();
1003 SS.
Adopt(ET.getQualifierLoc());
1004 TL = ET.getNamedTypeLoc();
1008 TemplateName Name = DTST.getTypePtr()->getTemplateName();
1014 DTST.getTemplateNameLoc());
1044 unsigned Depth,
unsigned Position,
1047 bool HasTypeConstraint) {
1048 assert(S->isTemplateParamScope() &&
1049 "Template type parameter not in template parameter scope!");
1051 bool IsParameterPack = EllipsisLoc.
isValid();
1054 KeyLoc, ParamNameLoc, Depth, Position,
1055 ParamName,
Typename, IsParameterPack,
1061 LSI->LocalPacks.push_back(Param);
1074 if (DefaultArg && IsParameterPack) {
1075 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1076 DefaultArg =
nullptr;
1084 assert(DefaultTInfo &&
"expected source information for type");
1111 return TemplateArgs;
1124 diag::err_type_constraint_non_type_concept);
1130 if (!WereArgsSpecified &&
1133 diag::err_type_constraint_missing_arguments)
1152 bool AllowUnexpandedPack) {
1169 if (EllipsisLoc.
isInvalid() && !AllowUnexpandedPack) {
1178 ConceptName, CD, USD ? cast<NamedDecl>(USD) : CD,
1180 ConstrainedParameter, EllipsisLoc);
1183template <
typename ArgumentLocAppender>
1198 Appender(ConstraintArgs);
1207 FoundDecl ? FoundDecl : NamedConcept, NamedConcept,
1210 return ImmediatelyDeclaredConstraint;
1226 ImmediatelyDeclaredConstraint.
get(), BO_LAnd,
1227 EllipsisLoc,
nullptr,
1247 *TemplateArgs) :
nullptr;
1252 *
this,
NS, NameInfo, NamedConcept, FoundDecl,
1255 ParamAsArgument, ConstrainedParameter->
getLocation(),
1258 for (const auto &ArgLoc : TemplateArgs->arguments())
1259 ConstraintArgs.addArgument(ArgLoc);
1262 if (ImmediatelyDeclaredConstraint.
isInvalid())
1272 ImmediatelyDeclaredConstraint.
get());
1283 diag::err_unsupported_placeholder_constraint)
1302 for (unsigned I = 0, C = TL.getNumArgs(); I != C; ++I)
1303 ConstraintArgs.addArgument(TL.getArgLoc(I));
1306 if (ImmediatelyDeclaredConstraint.
isInvalid() ||
1307 !ImmediatelyDeclaredConstraint.
isUsable())
1311 ImmediatelyDeclaredConstraint.
get());
1349 Diag(Loc, diag::err_template_nontype_parm_rvalue_ref) << T;
1359 Diag(Loc, diag::err_template_nontype_parm_bad_type) << T;
1367 Diag(Loc, diag::err_template_nontype_parm_not_structural) << T;
1374 for (
const FieldDecl *FD : RD->fields()) {
1376 Diag(FD->getLocation(), diag::note_not_structural_non_public) << T << 0;
1379 if (FD->isMutable()) {
1380 Diag(FD->getLocation(), diag::note_not_structural_mutable_field) << T;
1383 if (FD->getType()->isRValueReferenceType()) {
1384 Diag(FD->getLocation(), diag::note_not_structural_rvalue_ref_field)
1391 for (
const auto &BaseSpec : RD->bases()) {
1392 if (BaseSpec.getAccessSpecifier() !=
AS_public) {
1393 Diag(BaseSpec.getBaseTypeLoc(), diag::note_not_structural_non_public)
1404 for (
const FieldDecl *FD : RD->fields()) {
1407 SubLoc = FD->getLocation();
1415 for (
const auto &BaseSpec : RD->bases()) {
1418 SubLoc = BaseSpec.getBaseTypeLoc();
1426 assert(Kind != -1 &&
"couldn't find reason why type is not structural");
1427 Diag(SubLoc, diag::note_not_structural_subobject)
1428 << T << Kind << SubType;
1441 Diag(Loc, diag::err_variably_modified_nontype_template_param)
1494 Diag(Loc, diag::err_template_nontype_parm_bad_structural_type) << T;
1498 Diag(Loc, diag::warn_cxx17_compat_template_nontype_parm_type) << T;
1510 auto CheckValidDeclSpecifiers = [
this, &D] {
1524 Diag(Loc, diag::err_invalid_decl_specifier_in_nontype_parm)
1561 CheckValidDeclSpecifiers();
1564 if (isa<AutoType>(T))
1566 diag::warn_cxx14_compat_template_nontype_parm_auto_type)
1569 assert(S->isTemplateParamScope() &&
1570 "Non-type template parameter not in template parameter scope!");
1590 if (TL.isConstrained())
1599 LSI->LocalPacks.push_back(Param);
1613 if (
Default && IsParameterPack) {
1614 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1643 assert(S->isTemplateParamScope() &&
1644 "Template template parameter not in template parameter scope!");
1647 bool IsParameterPack = EllipsisLoc.
isValid();
1651 Depth, Position, IsParameterPack,
1657 LSI->LocalPacks.push_back(Param);
1668 if (Params->
size() == 0) {
1677 if (IsParameterPack && !
Default.isInvalid()) {
1678 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1693 Diag(DefaultArg.
getLocation(), diag::err_template_arg_not_valid_template)
1711class ConstraintRefersToContainingTemplateChecker
1712 :
public TreeTransform<ConstraintRefersToContainingTemplateChecker> {
1713 bool Result =
false;
1715 unsigned TemplateDepth = 0;
1719 void CheckIfContainingRecord(
const CXXRecordDecl *CheckingRD) {
1726 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
1727 if (CheckingRD == RD->getMostRecentDecl())
1732 assert(D->
getDepth() <= TemplateDepth &&
1733 "Nothing should reference a value below the actual template depth, "
1734 "depth is likely wrong");
1735 if (D->
getDepth() != TemplateDepth)
1746 ConstraintRefersToContainingTemplateChecker(
Sema &SemaRef,
1748 unsigned TemplateDepth)
1749 : inherited(SemaRef), Friend(Friend), TemplateDepth(TemplateDepth) {}
1750 bool getResult()
const {
return Result; }
1756 using inherited::TransformTemplateTypeParmType;
1760 "Nothing should reference a value below the actual template depth, "
1761 "depth is likely wrong");
1764 return inherited::TransformTemplateTypeParmType(
1776 if (
auto *TD = dyn_cast<TypedefNameDecl>(D))
1777 TransformType(TD->getUnderlyingType());
1778 else if (
auto *NTTPD = dyn_cast<NonTypeTemplateParmDecl>(D))
1779 CheckNonTypeTemplateParmDecl(NTTPD);
1780 else if (
auto *VD = dyn_cast<ValueDecl>(D))
1781 TransformType(VD->getType());
1782 else if (
auto *TD = dyn_cast<TemplateDecl>(D))
1783 TransformTemplateParameterList(TD->getTemplateParameters());
1784 else if (
auto *RD = dyn_cast<CXXRecordDecl>(D))
1785 CheckIfContainingRecord(RD);
1786 else if (isa<NamedDecl>(D)) {
1789 llvm_unreachable(
"Don't know how to handle this declaration type yet");
1797 const Expr *Constraint) {
1799 ConstraintRefersToContainingTemplateChecker Checker(*
this, Friend,
1801 Checker.TransformExpr(
const_cast<Expr *
>(Constraint));
1802 return Checker.getResult();
1815 Expr *RequiresClause) {
1817 Diag(ExportLoc, diag::warn_template_export_unsupported);
1823 Context, TemplateLoc, LAngleLoc,
1824 llvm::ArrayRef(Params.data(), Params.size()), RAngleLoc, RequiresClause);
1849 assert(TemplateParams && TemplateParams->
size() > 0 &&
1850 "No template parameters");
1851 assert(TUK !=
TUK_Reference &&
"Can only declare or define class templates");
1860 "can't build template of enumerated type");
1864 Diag(KWLoc, diag::err_template_unnamed_class);
1878 if (!SemanticContext) {
1883 ? diag::warn_template_qualified_friend_ignored
1884 : diag::err_template_qualified_declarator_no_match)
1927 PrevDecl = (*
Previous.begin())->getUnderlyingDecl();
1939 dyn_cast_or_null<ClassTemplateDecl>(PrevDecl);
1944 if (!PrevClassTemplate && PrevDecl && isa<CXXRecordDecl>(PrevDecl) &&
1945 cast<CXXRecordDecl>(PrevDecl)->isInjectedClassName()) {
1948 = cast<CXXRecordDecl>(PrevDecl)->getDescribedClassTemplate();
1949 if (!PrevClassTemplate && isa<ClassTemplateSpecializationDecl>(PrevDecl)) {
1951 = cast<ClassTemplateSpecializationDecl>(PrevDecl)
1952 ->getSpecializedTemplate();
1975 PrevDecl = PrevClassTemplate =
nullptr;
1976 SemanticContext = OutermostContext;
1990 PrevDecl = (*
Previous.begin())->getUnderlyingDecl();
1993 }
else if (PrevDecl &&
1996 PrevDecl = PrevClassTemplate =
nullptr;
1998 if (
auto *Shadow = dyn_cast_or_null<UsingShadowDecl>(
1999 PrevDecl ?
Previous.getRepresentativeDecl() :
nullptr)) {
2001 !(PrevClassTemplate &&
2004 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
2005 Diag(Shadow->getTargetDecl()->getLocation(),
2006 diag::note_using_decl_target);
2007 Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl) << 0;
2009 PrevDecl = PrevClassTemplate =
nullptr;
2013 if (PrevClassTemplate) {
2022 TemplateParams, PrevClassTemplate,
2035 Diag(KWLoc, diag::err_use_with_wrong_tag)
2051 auto *Tmpl = cast<CXXRecordDecl>(Hidden)->getDescribedClassTemplate();
2052 assert(Tmpl &&
"original definition of a class template is not a "
2057 Diag(NameLoc, diag::err_redefinition) << Name;
2058 Diag(Def->getLocation(), diag::note_previous_definition);
2065 }
else if (PrevDecl) {
2071 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
2085 (SS.
isSet() && SemanticContext && SemanticContext->
isRecord() &&
2097 Diag(NameLoc, TUK ==
TUK_Friend ? diag::err_friend_decl_does_not_match
2098 : diag::err_member_decl_does_not_match)
2099 << Name << SemanticContext <<
true << SS.
getRange();
2109 bool ShouldAddRedecl
2114 PrevClassTemplate && ShouldAddRedecl ?
2118 if (NumOuterTemplateParamLists > 0)
2121 llvm::ArrayRef(OuterTemplateParamLists, NumOuterTemplateParamLists));
2135 if (ShouldAddRedecl)
2140 if (ModulePrivateLoc.
isValid())
2146 assert(T->
isDependentType() &&
"Class template type is not dependent?");
2151 if (PrevClassTemplate &&
2169 if (PrevClassTemplate)
2204 if (PrevClassTemplate)
2223class ExtractTypeForDeductionGuide
2229 ExtractTypeForDeductionGuide(
2232 :
Base(SemaRef), MaterializedTypedefs(MaterializedTypedefs) {}
2237 ASTContext &Context = SemaRef.getASTContext();
2247 if (isa<TypeAliasDecl>(OrigDecl))
2252 assert(isa<TypedefDecl>(OrigDecl) &&
"Not a Type alias or typedef");
2257 MaterializedTypedefs.push_back(
Decl);
2276 auto DeductionGuideName =
2287 TInfo->
getType(), TInfo, LocEnd, Ctor);
2288 Guide->setImplicit(IsImplicit);
2289 Guide->setParams(Params);
2291 for (
auto *Param : Params)
2292 Param->setDeclContext(Guide);
2293 for (
auto *TD : MaterializedTypedefs)
2294 TD->setDeclContext(Guide);
2297 SemaRef.
Context, DC, Loc, DeductionGuideName, TemplateParams, Guide);
2298 GuideTemplate->setImplicit(IsImplicit);
2299 Guide->setDescribedFunctionTemplate(GuideTemplate);
2301 if (isa<CXXRecordDecl>(DC)) {
2307 return GuideTemplate;
2315 unsigned NewDepth,
unsigned NewIndex) {
2332 if (InstantiatedDefaultArg)
2333 NewTTP->setDefaultArgument(InstantiatedDefaultArg);
2339template <
typename NonTypeTemplateOrTemplateTemplateParmDecl>
2340NonTypeTemplateOrTemplateTemplateParmDecl *
2342 NonTypeTemplateOrTemplateTemplateParmDecl *OldParam,
2344 unsigned NewDepth) {
2347 auto *NewParam = cast<NonTypeTemplateOrTemplateTemplateParmDecl>(
2349 NewParam->setPosition(NewIndex);
2350 NewParam->setDepth(NewDepth);
2356struct ConvertConstructorToDeductionGuideTransform {
2357 ConvertConstructorToDeductionGuideTransform(
Sema &S,
2359 : SemaRef(S), Template(Template) {
2367 NestedPattern = Pattern;
2412 AllParams.reserve(TemplateParams->
size() + InnerParams->
size());
2413 AllParams.insert(AllParams.begin(),
2414 TemplateParams->
begin(), TemplateParams->
end());
2415 SubstArgs.reserve(InnerParams->
size());
2416 Depth1Args.reserve(InnerParams->
size());
2422 Args.
setKind(TemplateSubstitutionKind::Rewrite);
2427 NamedDecl *NewParam = transformTemplateParameter(Param, Args);
2435 if (NestedPattern) {
2437 OuterInstantiationArgs);
2438 Instantiator.setEvaluateConstraints(
false);
2440 NewParam = cast<NamedDecl>(Instantiator.Visit(NewParam));
2445 "Unexpected template parameter depth");
2447 AllParams.push_back(NewParam);
2453 Expr *RequiresClause =
nullptr;
2454 if (
Expr *InnerRC = InnerParams->getRequiresClause()) {
2456 Args.
setKind(TemplateSubstitutionKind::Rewrite);
2467 TemplateParams = TemplateParameterList::Create(
2468 SemaRef.
Context, InnerParams->getTemplateLoc(),
2469 InnerParams->getLAngleLoc(), AllParams, InnerParams->getRAngleLoc(),
2477 Args.
setKind(TemplateSubstitutionKind::Rewrite);
2488 assert(FPTL &&
"no prototype for constructor declaration");
2496 QualType NewType = transformFunctionProtoType(TLB, FPTL, Params, Args,
2497 MaterializedTypedefs);
2502 return buildDeductionGuide(
2505 true, MaterializedTypedefs);
2516 DeductionGuideName, EPI);
2519 TSI = SemaRef.
SubstType(TSI, OuterInstantiationArgs, Loc,
2520 DeductionGuideName);
2527 for (
auto T : ParamTypes) {
2530 TSI = SemaRef.
SubstType(TSI, OuterInstantiationArgs, Loc,
2536 FPTL.
setParam(Params.size(), NewParam);
2537 Params.push_back(NewParam);
2540 return buildDeductionGuide(
2551 if (
auto *TTP = dyn_cast<TemplateTypeParmDecl>(
TemplateParam))
2552 return transformTemplateTypeParam(
2553 SemaRef, DC, TTP, Args, TTP->
getDepth() - 1,
2554 Depth1IndexAdjustment + TTP->
getIndex());
2555 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(
TemplateParam))
2556 return transformTemplateParam(SemaRef, DC, TTP, Args,
2557 Depth1IndexAdjustment + TTP->
getIndex(),
2560 return transformTemplateParam(SemaRef, DC, NTTP, Args,
2561 Depth1IndexAdjustment + NTTP->getIndex(),
2562 NTTP->getDepth() - 1);
2565 QualType transformFunctionProtoType(
2576 transformFunctionTypeParam(OldParam, Args, MaterializedTypedefs);
2577 if (NestedPattern && NewParam)
2578 NewParam = transformFunctionTypeParam(NewParam, OuterInstantiationArgs,
2579 MaterializedTypedefs);
2582 ParamTypes.push_back(NewParam->
getType());
2583 Params.push_back(NewParam);
2605 ReturnType, ParamTypes, TL.
getBeginLoc(), DeductionGuideName, EPI);
2606 if (Result.isNull())
2615 for (
unsigned I = 0, E = NewTL.
getNumParams(); I != E; ++I)
2630 SemaRef.
SubstType(PackTL.getPatternLoc(), Args,
2632 if (!NewDI)
return nullptr;
2635 PackTL.getTypePtr()->getNumExpansions());
2646 NewDI = ExtractTypeForDeductionGuide(SemaRef, MaterializedTypedefs)
2656 NewDefArg =
new (SemaRef.
Context)
2664 auto NewType = NewDI->
getType();
2684 struct TemplateParamsReferencedFinder
2690 : TemplateParams(TemplateParams.begin(), TemplateParams.end()) {}
2703 if (TemplateParams.contains(ND))
2704 ReferencedTemplateParams.insert(ND);
2707 TemplateParamsReferencedFinder Finder(TemplateParams);
2708 Finder.TraverseTemplateArguments(DeducedArgs);
2711 for (
unsigned Index = 0; Index < TemplateParams.size(); ++Index) {
2712 if (Finder.ReferencedTemplateParams.contains(TemplateParams[Index]))
2713 Results.push_back(Index);
2721 assert(Name.getNameKind() ==
2723 "name must be a deduction guide name");
2724 auto Existing = DC->
lookup(Name);
2725 for (
auto *D : Existing)
2732void DeclareImplicitDeductionGuidesForTypeAlias(
2734 auto &Context = SemaRef.
Context;
2738 if (hasDeclaredDeductionGuides(
2744 ->getUnderlyingType()
2745 .getSingleStepDesugaredType(Context);
2752 Template = TST->getTemplateName().getAsTemplateDecl();
2753 AliasRhsTemplateArgs = TST->template_arguments();
2754 }
else if (
const auto *RT = RhsType->getAs<
RecordType>()) {
2758 if (
const auto *CTSD = llvm::dyn_cast<ClassTemplateSpecializationDecl>(
2759 RT->getAsCXXRecordDecl())) {
2760 Template = CTSD->getSpecializedTemplate();
2761 AliasRhsTemplateArgs = CTSD->getTemplateArgs().asArray();
2764 assert(
false &&
"unhandled RHS type of the alias");
2772 Guides.suppressDiagnostics();
2774 for (
auto *G : Guides) {
2784 FReturnType = InjectedCNT->getInjectedTST();
2788 assert(FReturnType &&
"expected to see a return type");
2821 AliasRhsTemplateArgs, TDeduceInfo, DeduceResults,
2828 for (
unsigned Index = 0; Index < DeduceResults.size(); ++Index) {
2829 if (
const auto &D = DeduceResults[Index]; !D.isNull())
2830 DeducedArgs.push_back(D);
2832 NonDeducedTemplateParamsInFIndex.push_back(Index);
2834 auto DeducedAliasTemplateParams =
2835 TemplateParamsReferencedInTemplateArgumentList(
2836 AliasTemplate->getTemplateParameters()->asArray(), DeducedArgs);
2844 if (BuildingDeductionGuides.isInvalid())
2860 auto TransformTemplateParameter =
2864 if (
auto *TTP = dyn_cast<TemplateTypeParmDecl>(
TemplateParam))
2865 return transformTemplateTypeParam(SemaRef, DC, TTP, Args,
2867 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(
TemplateParam))
2868 return transformTemplateParam(SemaRef, DC, TTP, Args, NewIndex,
2870 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(
TemplateParam))
2871 return transformTemplateParam(SemaRef, DC, NTTP, Args, NewIndex,
2876 for (
unsigned AliasTemplateParamIdx : DeducedAliasTemplateParams) {
2877 auto *TP =
AliasTemplate->getTemplateParameters()->getParam(
2878 AliasTemplateParamIdx);
2885 TransformTemplateParameter(
AliasTemplate->getDeclContext(), TP, Args,
2886 FPrimeTemplateParams.size());
2887 FPrimeTemplateParams.push_back(NewParam);
2891 TransformedDeducedAliasArgs[AliasTemplateParamIdx] = NewTemplateArgument;
2895 for (
unsigned FTemplateParamIdx : NonDeducedTemplateParamsInFIndex) {
2902 NamedDecl *NewParam = TransformTemplateParameter(
2904 FPrimeTemplateParams.push_back(NewParam);
2906 assert(TemplateArgsForBuildingFPrime[FTemplateParamIdx].isNull() &&
2907 "The argument must be null before setting");
2908 TemplateArgsForBuildingFPrime[FTemplateParamIdx] =
2913 Expr *RequiresClause =
nullptr;
2928 Context,
AliasTemplate->getTemplateParameters()->getTemplateLoc(),
2930 FPrimeTemplateParams,
2952 for (
unsigned Index = 0; Index < DeduceResults.size(); ++Index) {
2953 const auto &D = DeduceResults[Index];
2956 assert(!TemplateArgsForBuildingFPrime[Index].isNull() &&
2957 "template arguments for non-deduced template parameters should "
2965 assert(TemplateArgsForBuildingFPrime[Index].isNull() &&
2966 "InstantiatedArgs must be null before setting");
2967 TemplateArgsForBuildingFPrime[Index] = (Output.
getArgument());
2972 Context, TemplateArgsForBuildingFPrime);
2975 F, TemplateArgListForBuildingFPrime,
AliasTemplate->getLocation(),
2977 auto *GG = dyn_cast<CXXDeductionGuideDecl>(FPrime);
2978 buildDeductionGuide(SemaRef,
AliasTemplate, FPrimeTemplateParamList,
2979 GG->getCorrespondingConstructor(),
2980 GG->getExplicitSpecifier(), GG->getTypeSourceInfo(),
2996 DefRecord->getDescribedClassTemplate())
2997 Template = DescribedTemplate;
3004 ConvertConstructorToDeductionGuideTransform Transform(
3005 *
this, cast<ClassTemplateDecl>(Template));
3016 *
this, Loc, Template,
3018 if (BuildingDeductionGuides.isInvalid())
3022 Transform.NestedPattern ? Transform.NestedPattern : Transform.Template;
3025 auto *DG = cast<FunctionTemplateDecl>(
3026 Transform.buildSimpleDeductionGuide(ParamTypes));
3033 if (
auto *
AliasTemplate = llvm::dyn_cast<TypeAliasTemplateDecl>(Template)) {
3034 DeclareImplicitDeductionGuidesForTypeAlias(*
this,
AliasTemplate, Loc);
3039 if (
TemplateDecl *DescribedTemplate = DefRecord->getDescribedClassTemplate())
3040 Template = DescribedTemplate;
3047 ConvertConstructorToDeductionGuideTransform Transform(
3048 *
this, cast<ClassTemplateDecl>(Template));
3052 if (hasDeclaredDeductionGuides(Transform.DeductionGuideName, DC))
3061 *
this, Loc, Template,
3063 if (BuildingDeductionGuides.isInvalid())
3071 Transform.NestedPattern ? Transform.NestedPattern : Transform.Template;
3074 bool AddedAny =
false;
3076 D = D->getUnderlyingDecl();
3085 if (ProcessedCtors.count(D))
3088 auto *FTD = dyn_cast<FunctionTemplateDecl>(D);
3098 return !P || P->hasUnparsedDefaultArg();
3102 ProcessedCtors.insert(D);
3103 Transform.transformConstructor(FTD, CD);
3112 Transform.buildSimpleDeductionGuide(std::nullopt);
3116 cast<CXXDeductionGuideDecl>(
3117 cast<FunctionTemplateDecl>(
3118 Transform.buildSimpleDeductionGuide(Transform.DeducedType))
3119 ->getTemplatedDecl())
3150 diag::warn_cxx98_compat_template_parameter_default_in_function_template
3151 : diag::ext_template_parameter_default_in_function_template)
3160 S.
Diag(ParamLoc, diag::err_template_parameter_default_template_member)
3169 S.
Diag(ParamLoc, diag::err_template_parameter_default_friend_template)
3178 llvm_unreachable(
"Invalid TemplateParamListContext!");
3191 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
3196 if (TC->hasExplicitTemplateArgs())
3197 for (
auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
3205 if (!NTTP->isParameterPack() &&
3207 NTTP->getTypeSourceInfo(),
3215 = dyn_cast<TemplateTemplateParmDecl>(
P))
3263 bool SawDefaultArgument =
false;
3269 OldParam = OldParams->
begin();
3271 bool RemoveDefaultArguments =
false;
3273 NewParamEnd = NewParams->
end();
3274 NewParam != NewParamEnd; ++NewParam) {
3277 bool RedundantDefaultArg =
false;
3280 bool InconsistentDefaultArg =
false;
3282 std::string PrevModuleName;
3288 bool MissingDefaultArg =
false;
3291 bool SawParameterPack =
false;
3294 = dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
3296 if (NewTypeParm->hasDefaultArgument() &&
3298 NewTypeParm->getLocation(),
3299 NewTypeParm->getDefaultArgumentInfo()->getTypeLoc()
3301 NewTypeParm->removeDefaultArgument();
3305 = OldParams? cast<TemplateTypeParmDecl>(*OldParam) :
nullptr;
3306 if (NewTypeParm->isParameterPack()) {
3307 assert(!NewTypeParm->hasDefaultArgument() &&
3308 "Parameter packs can't have a default argument!");
3309 SawParameterPack =
true;
3311 NewTypeParm->hasDefaultArgument() &&
3314 NewDefaultLoc = NewTypeParm->getDefaultArgumentLoc();
3315 SawDefaultArgument =
true;
3318 RedundantDefaultArg =
true;
3319 else if (!
getASTContext().isSameDefaultTemplateArgument(OldTypeParm,
3321 InconsistentDefaultArg =
true;
3325 PreviousDefaultArgLoc = NewDefaultLoc;
3329 NewTypeParm->setInheritedDefaultArgument(
Context, OldTypeParm);
3331 }
else if (NewTypeParm->hasDefaultArgument()) {
3332 SawDefaultArgument =
true;
3333 PreviousDefaultArgLoc = NewTypeParm->getDefaultArgumentLoc();
3334 }
else if (SawDefaultArgument)
3335 MissingDefaultArg =
true;
3337 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
3339 if (!NewNonTypeParm->isParameterPack() &&
3341 NewNonTypeParm->getTypeSourceInfo(),
3348 if (NewNonTypeParm->hasDefaultArgument() &&
3350 NewNonTypeParm->getLocation(),
3351 NewNonTypeParm->getDefaultArgument()->getSourceRange())) {
3352 NewNonTypeParm->removeDefaultArgument();
3357 = OldParams? cast<NonTypeTemplateParmDecl>(*OldParam) :
nullptr;
3358 if (NewNonTypeParm->isParameterPack()) {
3359 assert(!NewNonTypeParm->hasDefaultArgument() &&
3360 "Parameter packs can't have a default argument!");
3361 if (!NewNonTypeParm->isPackExpansion())
3362 SawParameterPack =
true;
3364 NewNonTypeParm->hasDefaultArgument() &&
3367 NewDefaultLoc = NewNonTypeParm->getDefaultArgumentLoc();
3368 SawDefaultArgument =
true;
3370 RedundantDefaultArg =
true;
3372 OldNonTypeParm, NewNonTypeParm)) {
3373 InconsistentDefaultArg =
true;
3377 PreviousDefaultArgLoc = NewDefaultLoc;
3381 NewNonTypeParm->setInheritedDefaultArgument(
Context, OldNonTypeParm);
3383 }
else if (NewNonTypeParm->hasDefaultArgument()) {
3384 SawDefaultArgument =
true;
3385 PreviousDefaultArgLoc = NewNonTypeParm->getDefaultArgumentLoc();
3386 }
else if (SawDefaultArgument)
3387 MissingDefaultArg =
true;
3390 = cast<TemplateTemplateParmDecl>(*NewParam);
3407 = OldParams? cast<TemplateTemplateParmDecl>(*OldParam) :
nullptr;
3410 "Parameter packs can't have a default argument!");
3412 SawParameterPack =
true;
3413 }
else if (OldTemplateParm &&
3419 SawDefaultArgument =
true;
3421 RedundantDefaultArg =
true;
3423 OldTemplateParm, NewTemplateParm)) {
3424 InconsistentDefaultArg =
true;
3428 PreviousDefaultArgLoc = NewDefaultLoc;
3433 PreviousDefaultArgLoc
3436 SawDefaultArgument =
true;
3437 PreviousDefaultArgLoc
3439 }
else if (SawDefaultArgument)
3440 MissingDefaultArg =
true;
3446 if (SawParameterPack && (NewParam + 1) != NewParamEnd &&
3449 Diag((*NewParam)->getLocation(),
3450 diag::err_template_param_pack_must_be_last_template_parameter);
3467 if (RedundantDefaultArg) {
3468 Diag(NewDefaultLoc, diag::err_template_param_default_arg_redefinition);
3469 Diag(OldDefaultLoc, diag::note_template_param_prev_default_arg);
3471 }
else if (InconsistentDefaultArg) {
3475 diag::err_template_param_default_arg_inconsistent_redefinition);
3477 diag::note_template_param_prev_default_arg_in_other_module)
3480 }
else if (MissingDefaultArg &&
3488 Diag((*NewParam)->getLocation(),
3489 diag::err_template_param_default_arg_missing);
3490 Diag(PreviousDefaultArgLoc, diag::note_template_param_prev_default_arg);
3492 RemoveDefaultArguments =
true;
3503 if (RemoveDefaultArguments) {
3505 NewParamEnd = NewParams->
end();
3506 NewParam != NewParamEnd; ++NewParam) {
3508 TTP->removeDefaultArgument();
3510 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
3511 NTTP->removeDefaultArgument();
3513 cast<TemplateTemplateParmDecl>(*NewParam)->removeDefaultArgument();
3533 bool IgnoreNonTypeDependent;
3538 DependencyChecker(
unsigned Depth,
bool IgnoreNonTypeDependent)
3539 : Depth(Depth), IgnoreNonTypeDependent(IgnoreNonTypeDependent),
3543 : IgnoreNonTypeDependent(IgnoreNonTypeDependent), Match(
false) {
3546 Depth = PD->getDepth();
3548 dyn_cast<NonTypeTemplateParmDecl>(ND)) {
3549 Depth = PD->getDepth();
3551 Depth = cast<TemplateTemplateParmDecl>(ND)->getDepth();
3556 if (ParmDepth >= Depth) {
3564 bool TraverseStmt(
Stmt *S, DataRecursionQueue *Q =
nullptr) {
3569 if (
auto *E = dyn_cast_or_null<Expr>(S))
3570 if (IgnoreNonTypeDependent && !E->isTypeDependent())
3572 return super::TraverseStmt(S, Q);
3575 bool TraverseTypeLoc(
TypeLoc TL) {
3576 if (IgnoreNonTypeDependent && !TL.
isNull() &&
3579 return super::TraverseTypeLoc(TL);
3588 return IgnoreNonTypeDependent || !Matches(T->
getDepth());
3594 if (Matches(PD->getDepth()))
3596 return super::TraverseTemplateName(N);
3601 dyn_cast<NonTypeTemplateParmDecl>(E->
getDecl()))
3602 if (Matches(PD->getDepth(), E->
getExprLoc()))
3604 return super::VisitDeclRefExpr(E);
3626 if (!Params->
size())
3629 DependencyChecker Checker(Params,
false);
3630 Checker.TraverseType(T);
3631 return Checker.Match;
3641 if (
const Type *CurType = NNS->getAsType()) {
3690 bool &IsMemberSpecialization,
bool &
Invalid,
bool SuppressDiagnostic) {
3691 IsMemberSpecialization =
false;
3713 NestedTypes.push_back(T);
3719 = dyn_cast<ClassTemplateSpecializationDecl>(
Record)) {
3720 if (!isa<ClassTemplatePartialSpecializationDecl>(Spec) &&
3722 ExplicitSpecLoc = Spec->getLocation();
3725 }
else if (
Record->getTemplateSpecializationKind()
3727 ExplicitSpecLoc =
Record->getLocation();
3740 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
3786 std::reverse(NestedTypes.begin(), NestedTypes.end());
3794 bool SawNonEmptyTemplateParameterList =
false;
3796 auto CheckExplicitSpecialization = [&](
SourceRange Range,
bool Recovery) {
3797 if (SawNonEmptyTemplateParameterList) {
3798 if (!SuppressDiagnostic)
3799 Diag(DeclLoc, diag::err_specialize_member_of_template)
3800 << !Recovery << Range;
3802 IsMemberSpecialization =
false;
3809 auto DiagnoseMissingExplicitSpecialization = [&] (
SourceRange Range) {
3811 if (CheckExplicitSpecialization(Range,
true))
3816 if (!ParamLists.empty())
3817 ExpectedTemplateLoc = ParamLists[0]->getTemplateLoc();
3819 ExpectedTemplateLoc = DeclStartLoc;
3821 if (!SuppressDiagnostic)
3822 Diag(DeclLoc, diag::err_template_spec_needs_header)
3829 for (
unsigned TypeIdx = 0, NumTypes = NestedTypes.size(); TypeIdx != NumTypes;
3831 T = NestedTypes[TypeIdx];
3834 bool NeedEmptyTemplateHeader =
false;
3837 bool NeedNonemptyTemplateHeader =
false;
3850 = dyn_cast<ClassTemplatePartialSpecializationDecl>(
Record)) {
3851 ExpectedTemplateParams = Partial->getTemplateParameters();
3852 NeedNonemptyTemplateHeader =
true;
3853 }
else if (
Record->isDependentType()) {
3854 if (
Record->getDescribedClassTemplate()) {
3855 ExpectedTemplateParams =
Record->getDescribedClassTemplate()
3856 ->getTemplateParameters();
3857 NeedNonemptyTemplateHeader =
true;
3860 = dyn_cast<ClassTemplateSpecializationDecl>(
Record)) {
3866 NeedEmptyTemplateHeader =
true;
3869 }
else if (
Record->getTemplateSpecializationKind()) {
3870 if (
Record->getTemplateSpecializationKind()
3872 TypeIdx == NumTypes - 1)
3873 IsMemberSpecialization =
true;
3879 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
3881 NeedNonemptyTemplateHeader =
true;
3886 NeedNonemptyTemplateHeader =
false;
3896 if (
ParamIdx < ParamLists.size()) {
3897 if (ParamLists[
ParamIdx]->size() == 0) {
3898 if (CheckExplicitSpecialization(ParamLists[
ParamIdx]->getSourceRange(),
3902 SawNonEmptyTemplateParameterList =
true;
3905 if (NeedEmptyTemplateHeader) {
3908 if (TypeIdx == NumTypes - 1)
3909 IsMemberSpecialization =
true;
3911 if (
ParamIdx < ParamLists.size()) {
3912 if (ParamLists[
ParamIdx]->size() > 0) {
3914 if (!SuppressDiagnostic)
3916 diag::err_template_param_list_matches_nontemplate)
3919 ParamLists[
ParamIdx]->getRAngleLoc())
3931 if (DiagnoseMissingExplicitSpecialization(
3938 if (NeedNonemptyTemplateHeader) {
3944 if (
ParamIdx < ParamLists.size() &&
3946 ExpectedTemplateParams =
nullptr;
3951 if (
ParamIdx < ParamLists.size()) {
3953 if (ExpectedTemplateParams &&
3955 ExpectedTemplateParams,
3968 if (!SuppressDiagnostic)
3969 Diag(DeclLoc, diag::err_template_spec_needs_template_parameters)
3980 if (
ParamIdx >= ParamLists.size()) {
3981 if (TemplateId && !IsFriend) {
3997 if (
ParamIdx < ParamLists.size() - 1) {
3998 bool HasAnyExplicitSpecHeader =
false;
3999 bool AllExplicitSpecHeaders =
true;
4000 for (
unsigned I =
ParamIdx, E = ParamLists.size() - 1; I != E; ++I) {
4001 if (ParamLists[I]->size() == 0)
4002 HasAnyExplicitSpecHeader =
true;
4004 AllExplicitSpecHeaders =
false;
4007 if (!SuppressDiagnostic)
4009 AllExplicitSpecHeaders ? diag::ext_template_spec_extra_headers
4010 : diag::err_template_spec_extra_headers)
4012 ParamLists[ParamLists.size() - 2]->getRAngleLoc());
4017 if (ExplicitSpecLoc.
isValid() && HasAnyExplicitSpecHeader &&
4018 !SuppressDiagnostic)
4019 Diag(ExplicitSpecLoc,
4020 diag::note_explicit_template_spec_does_not_need_header)
4021 << NestedTypes.back();
4026 if (!AllExplicitSpecHeaders)
4037 if (ParamLists.back()->size() == 0 &&
4038 CheckExplicitSpecialization(ParamLists[
ParamIdx]->getSourceRange(),
4044 return ParamLists.back();
4048 if (
TemplateDecl *Template = Name.getAsTemplateDecl()) {
4050 << (isa<FunctionTemplateDecl>(Template)
4052 : isa<ClassTemplateDecl>(Template)
4054 : isa<VarTemplateDecl>(Template)
4056 : isa<TypeAliasTemplateDecl>(Template) ? 3 : 4)
4065 Diag((*I)->getLocation(), diag::note_template_declared_here)
4066 << 0 << (*I)->getDeclName();
4084 QualType OrigType = Converted[1].getAsType();
4088 SemaRef.
Diag(TemplateArgs[1].getLocation(),
4089 diag::err_integer_sequence_integral_element_type);
4104 OrigType, TemplateArgs[1].getLocation())));
4106 if (llvm::APSInt NumArgs = NumArgsArg.
getAsIntegral(); NumArgs >= 0) {
4108 for (llvm::APSInt I(NumArgs.getBitWidth(), NumArgs.isUnsigned());
4112 TA, OrigType, TemplateArgs[2].getLocation()));
4117 SemaRef.
Diag(TemplateArgs[2].getLocation(),
4118 diag::err_integer_sequence_negative_length);
4125 TemplateLoc, SyntheticTemplateArgs);
4132 assert(Converted.size() == 2 &&
4133 "__type_pack_element should be given an index and a parameter pack");
4141 assert(Index >= 0 &&
"the index used with __type_pack_element should be of "
4142 "type std::size_t, and hence be non-negative");
4144 if (Index >= Ts.pack_size()) {
4145 SemaRef.
Diag(TemplateArgs[0].getLocation(),
4146 diag::err_type_pack_element_out_of_bounds);
4151 int64_t N = Index.getExtValue();
4152 return Ts.getPackAsArray()[N].getAsType();
4154 llvm_unreachable(
"unexpected BuiltinTemplateDecl!");
4173 if (BinOp->getOpcode() == BO_LAnd) {
4180 Terms.push_back(Clause);
4189 if (!BinOp)
return Cond;
4191 if (BinOp->getOpcode() != BO_LOr)
return Cond;
4194 Expr *LHS = BinOp->getLHS();
4196 if (!InnerBinOp)
return Cond;
4198 if (InnerBinOp->getOpcode() != BO_EQ ||
4199 !isa<IntegerLiteral>(InnerBinOp->getRHS()))
4209 if (MacroName ==
"CONCEPT_REQUIRES" || MacroName ==
"CONCEPT_REQUIRES_")
4210 return BinOp->getRHS();
4220class FailedBooleanConditionPrinterHelper :
public PrinterHelper {
4225 bool handledStmt(
Stmt *E, raw_ostream &OS)
override {
4226 const auto *DR = dyn_cast<DeclRefExpr>(E);
4227 if (DR && DR->getQualifier()) {
4230 DR->getQualifier()->print(OS, Policy,
true);
4234 if (
const auto *IV = dyn_cast<VarTemplateSpecializationDecl>(VD)) {
4237 OS, IV->getTemplateArgs().asArray(), Policy,
4238 IV->getSpecializedTemplate()->getTemplateParameters());
4251std::pair<Expr *, std::string>
4260 Expr *FailedCond =
nullptr;
4261 for (
Expr *Term : Terms) {
4265 if (isa<CXXBoolLiteralExpr>(TermAsWritten) ||
4266 isa<IntegerLiteral>(TermAsWritten))
4275 if (Term->EvaluateAsBooleanCondition(Succeeded,
Context) &&
4277 FailedCond = TermAsWritten;
4284 std::string Description;
4286 llvm::raw_string_ostream Out(Description);
4289 FailedBooleanConditionPrinterHelper Helper(Policy);
4290 FailedCond->
printPretty(Out, &Helper, Policy, 0,
"\n",
nullptr);
4292 return { FailedCond, Description };
4299 = Name.getUnderlying().getAsDependentTemplateName();
4309 if (Name.getAsAssumedTemplateName() &&
4314 if (!Template || isa<FunctionTemplateDecl>(Template) ||
4315 isa<VarTemplateDecl>(Template) || isa<ConceptDecl>(Template)) {
4318 if (Name.getAsSubstTemplateTemplateParmPack())
4322 Diag(TemplateLoc, diag::err_template_id_not_a_type)
4332 SugaredConverted, CanonicalConverted,
4339 dyn_cast<TypeAliasTemplateDecl>(Template)) {
4358 std::optional<ContextRAII> SavedContext;
4360 SavedContext.emplace(*
this,
AliasTemplate->getDeclContext());
4365 if (CanonType.
isNull()) {
4371 if (*DeductionInfo &&
4372 (*DeductionInfo)->hasSFINAEDiagnostic() &&
4373 (*DeductionInfo)->peekSFINAEDiagnostic().second.getDiagID() ==
4374 diag::err_typename_nested_not_found_enable_if &&
4375 TemplateArgs[0].getArgument().getKind()
4378 std::string FailedDescription;
4379 std::tie(FailedCond, FailedDescription) =
4385 (*DeductionInfo)->takeSFINAEDiagnostic(OldDiag);
4389 (*DeductionInfo)->addSFINAEDiagnostic(
4391 PDiag(diag::err_typename_nested_not_found_requirement)
4392 << FailedDescription
4400 }
else if (
auto *BTD = dyn_cast<BuiltinTemplateDecl>(Template)) {
4402 TemplateLoc, TemplateArgs);
4403 }
else if (Name.isDependent() ||
4405 TemplateArgs, CanonicalConverted)) {
4414 Name, CanonicalConverted);
4422 if (isa<ClassTemplateDecl>(Template)) {
4425 if (Ctx->isFileContext())
break;
4433 if (!isa<ClassTemplatePartialSpecializationDecl>(
Record) &&
4434 !
Record->getDescribedClassTemplate())
4440 QualType Injected = cast<InjectedClassNameType>(ICNT)
4441 ->getInjectedSpecializationType();
4454 dyn_cast<ClassTemplateDecl>(Template)) {
4457 void *InsertPos =
nullptr;
4459 ClassTemplate->findSpecialization(CanonicalConverted, InsertPos);
4491 assert(isa<RecordType>(CanonType) &&
4492 "type of non-dependent specialization is not a RecordType");
4494 llvm_unreachable(
"Unhandled template kind");
4511 auto *ATN = Name.getAsAssumedTemplateName();
4512 assert(ATN &&
"not an assumed template name");
4513 II = ATN->getDeclName().getAsIdentifierInfo();
4529 assert(ATN &&
"not an assumed template name");
4537 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
4538 return std::make_unique<CandidateCallback>(*
this);
4562 bool IsCtorOrDtorName,
bool IsClassName,
4567 if (!IsCtorOrDtorName && !IsClassName && SS.
isSet()) {
4593 TemplateD, TemplateII, TemplateIILoc, LAngleLoc,
4594 TemplateArgsIn, RAngleLoc);
4601 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
4602 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
4605 ? diag::err_out_of_line_qualified_id_type_names_constructor
4606 : diag::ext_out_of_line_qualified_id_type_names_constructor)
4636 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
4653 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
4694 Keyword, DTN->getQualifier(), DTN->getIdentifier(),
4707 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
4718 Diag(TemplateLoc, diag::err_tag_reference_non_tag)
4720 Diag(TAT->getLocation(), diag::note_declared_at);
4732 assert(
Id &&
"templated class must have an identifier");
4736 Diag(TagLoc, diag::err_use_with_wrong_tag)
4751 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
4786 return TPT && !
Type.hasQualifiers() &&
4795 dyn_cast<NonTypeTemplateParmDecl>(DRE->
getDecl());
4801 dyn_cast_or_null<TemplateTemplateParmDecl>(
4805 llvm_unreachable(
"unexpected kind of template argument");
4810 if (Params->
size() != Args.size())
4813 unsigned Depth = Params->
getDepth();
4815 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
4834template<
typename PartialSpecDecl>
4836 if (Partial->getDeclContext()->isDependentContext())
4845 auto *Template = Partial->getSpecializedTemplate();
4846 S.
Diag(Partial->getLocation(),
4847 diag::ext_partial_spec_not_more_specialized_than_primary)
4848 << isa<VarTemplateDecl>(Template);
4857 diag::note_partial_spec_not_more_specialized_than_primary)
4864 Partial->getAssociatedConstraints(PartialAC);
4871 const llvm::SmallBitVector &DeducibleParams) {
4872 for (
unsigned I = 0, N = DeducibleParams.size(); I != N; ++I) {
4873 if (!DeducibleParams[I]) {
4886template<
typename PartialSpecDecl>
4888 PartialSpecDecl *Partial) {
4901 auto *TemplateParams = Partial->getTemplateParameters();
4902 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
4904 TemplateParams->getDepth(), DeducibleParams);
4906 if (!DeducibleParams.all()) {
4907 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
4908 S.
Diag(Partial->getLocation(), diag::ext_partial_specs_not_deducible)
4909 << isa<VarTemplatePartialSpecializationDecl>(Partial)
4910 << (NumNonDeducible > 1)
4912 Partial->getTemplateArgsAsWritten()->RAngleLoc);
4933 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
4935 for (
unsigned I = 0; I != TemplateParams->size(); ++I) {
4937 auto *Param = TemplateParams->getParam(I);
4939 DeducibleParams[I] =
true;
4942 if (!DeducibleParams.all()) {
4943 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
4944 Diag(TD->
getLocation(), diag::err_deduction_guide_template_not_deducible)
4945 << (NumNonDeducible > 1);
4956 "Variable template specialization is declared with a template id.");
4969 dyn_cast_or_null<VarTemplateDecl>(Name.getAsTemplateDecl());
4972 if (
auto *OTS = Name.getAsOverloadedTemplate())
4973 FnTemplate = *OTS->begin();
4975 FnTemplate = dyn_cast_or_null<FunctionTemplateDecl>(Name.getAsTemplateDecl());
4984 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
4995 false, SugaredConverted, CanonicalConverted,
5003 TemplateArgs.
size(),
5004 CanonicalConverted))
5009 if (!Name.isDependent() &&
5011 TemplateArgs, CanonicalConverted)) {
5012 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
5018 CanonicalConverted) &&
5025 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
5035 void *InsertPos =
nullptr;
5039 PrevDecl =
VarTemplate->findPartialSpecialization(
5040 CanonicalConverted, TemplateParams, InsertPos);
5042 PrevDecl =
VarTemplate->findSpecialization(CanonicalConverted, InsertPos);
5064 cast_or_null<VarTemplatePartialSpecializationDecl>(PrevDecl);
5069 CanonicalConverted, TemplateArgs);
5072 VarTemplate->AddPartialSpecialization(Partial, InsertPos);
5111 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
5115 diag::note_instantiation_required_here)
5146struct PartialSpecMatchResult {
5156 assert(Template &&
"A variable template id without template?");
5161 Template, TemplateNameLoc,
5163 SugaredConverted, CanonicalConverted,
5170 TemplateArgs, CanonicalConverted))
5175 void *InsertPos =
nullptr;
5189 bool AmbiguousPartialSpec =
false;
5204 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
5218 Matched.push_back(PartialSpecMatchResult());
5219 Matched.back().Partial = Partial;
5224 if (Matched.size() >= 1) {
5226 if (Matched.size() == 1) {
5239 PEnd = Matched.end();
5242 PointOfInstantiation) ==
5250 PEnd = Matched.end();
5253 P->Partial, Best->Partial,
5254 PointOfInstantiation) != Best->Partial) {
5255 AmbiguousPartialSpec =
true;
5262 InstantiationPattern = Best->Partial;
5263 PartialSpecArgs = Best->Args;
5275 Template, InstantiationPattern, PartialSpecArgs, TemplateArgs,
5276 CanonicalConverted, TemplateNameLoc );
5280 if (AmbiguousPartialSpec) {
5283 Diag(PointOfInstantiation, diag::err_partial_spec_ordering_ambiguous)
5288 Diag(
P.Partial->getLocation(), diag::note_partial_spec_match)
5295 dyn_cast<VarTemplatePartialSpecializationDecl>(InstantiationPattern))
5296 Decl->setInstantiationOf(D, PartialSpecArgs);
5300 assert(
Decl &&
"No variable template specialization?");
5311 if (
Decl.isInvalid())
5328 Diag(Loc, diag::err_template_missing_args)
5342 assert(NamedConcept &&
"A concept template id without a template?");
5346 NamedConcept, ConceptNameInfo.
getLoc(),
5348 false, SugaredConverted, CanonicalConverted,
5354 CanonicalConverted);
5356 bool AreArgsDependent =
5358 *TemplateArgs, CanonicalConverted);
5366 if (!AreArgsDependent &&
5376 TemplateKWLoc, ConceptNameInfo, FoundDecl, NamedConcept,
5379 Context, CL, CSD, AreArgsDependent ?
nullptr : &Satisfaction);
5398 assert(!R.
isAmbiguous() &&
"ambiguous lookup when building templateid");
5402 if (!TemplateArgs && !isa<FunctionTemplateDecl>(TD)) {
5407 bool KnownDependent =
false;
5416 KnownDependent =
true;
5431 R.
begin(), R.
end(), KnownDependent);
5443 assert(TemplateArgs || TemplateKWLoc.
isValid());
5450 bool MemberOfUnknownSpecialization;
5453 false, MemberOfUnknownSpecialization,
5466 auto DiagnoseTypeTemplateDecl = [&](
TemplateDecl *Temp,
5467 bool isTypeAliasTemplateDecl) {
5468 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_type_template)
5470 << isTypeAliasTemplateDecl;
5476 return DiagnoseTypeTemplateDecl(Temp,
false);
5479 return DiagnoseTypeTemplateDecl(Temp,
true);
5503 bool EnteringContext,
5505 bool AllowInjectedClassName) {
5506 if (TemplateKWLoc.
isValid() && S && !S->getTemplateParamParent())
5509 diag::warn_cxx98_compat_template_outside_of_template :
5510 diag::ext_template_outside_of_template)
5520 else if (ObjectType)
5539 bool MemberOfUnknownSpecialization;
5541 ObjectType, EnteringContext,
Result,
5542 MemberOfUnknownSpecialization);
5545 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
5546 if (!AllowInjectedClassName && SS.
isNotEmpty() && LookupRD &&
5548 Name.Identifier && LookupRD->getIdentifier() == Name.Identifier) {
5558 Diag(Name.getBeginLoc(),
5559 diag::ext_out_of_line_qualified_id_type_names_constructor)
5567 if (!MemberOfUnknownSpecialization) {
5582 RTK,
nullptr,
false) &&
5585 Diag(Name.getBeginLoc(), diag::err_no_member)
5588 Diag(Name.getBeginLoc(), diag::err_undeclared_use)
5596 switch (Name.getKind()) {
5604 Qualifier, Name.OperatorFunctionId.Operator));
5618 Diag(Name.getBeginLoc(),
5619 diag::err_template_kw_refers_to_dependent_non_template)
5621 << TemplateKWLoc.
isValid() << TemplateKWLoc;
5658 dyn_cast<DependentScopeDeclRefExpr>(Arg.
getAsExpr())) {
5659 SS.
Adopt(ArgExpr->getQualifierLoc());
5660 NameInfo = ArgExpr->getNameInfo();
5662 dyn_cast<CXXDependentScopeMemberExpr>(Arg.
getAsExpr())) {
5663 if (ArgExpr->isImplicitAccess()) {
5664 SS.
Adopt(ArgExpr->getQualifierLoc());
5665 NameInfo = ArgExpr->getMemberNameInfo();
5674 Result.getResultKind() ==
5676 assert(SS.
getScopeRep() &&
"dependent scope expr must has a scope!");
5680 ? diag::ext_ms_template_type_arg_missing_typename
5681 : diag::err_template_arg_must_be_type_suggest)
5713 SugaredConverted.push_back(Arg);
5714 CanonicalConverted.push_back(Arg);
5720 Diag(SR.
getBegin(), diag::err_template_arg_must_be_type) << SR;
5742 CanonicalConverted.push_back(
5787 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
5790 bool ForLambdaCallOperator =
false;
5791 if (
const auto *Rec = dyn_cast<CXXRecordDecl>(Template->
getDeclContext()))
5792 ForLambdaCallOperator = Rec->isLambda();
5794 !ForLambdaCallOperator);
5796 SemaRef.
SubstType(ArgType, TemplateArgLists,
5839 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
5881 SugaredConverted,
SourceRange(TemplateLoc, RAngleLoc));
5888 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
5916 HasDefaultArg =
false;
5922 HasDefaultArg =
true;
5924 *
this, Template, TemplateLoc, RAngleLoc, TypeParm, SugaredConverted,
5925 CanonicalConverted);
5933 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
5937 HasDefaultArg =
true;
5939 *
this, Template, TemplateLoc, RAngleLoc, NonTypeParm, SugaredConverted,
5940 CanonicalConverted);
5949 = cast<TemplateTemplateParmDecl>(Param);
5953 HasDefaultArg =
true;
5956 *
this, Template, TemplateLoc, RAngleLoc, TempTempParm, SugaredConverted,
5957 CanonicalConverted, QualifierLoc);
5978 QualLoc = ETLoc.getQualifierLoc();
5979 TLoc = ETLoc.getNamedTypeLoc();
5985 QualLoc, InjLoc.getNameLoc());
5993 dyn_cast<ClassTemplateSpecializationDecl>(RecLoc.getDecl()))
5996 QualLoc, RecLoc.getNameLoc());
6030 unsigned ArgumentPackIndex,
6037 CanonicalConverted);
6044 QualType NTTPType = NTTP->getType();
6045 if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack())
6046 NTTPType = NTTP->getExpansionType(ArgumentPackIndex);
6049 !isa<TemplateTemplateParmDecl>(Template) &&
6064 NTTPType =
SubstType(PET->getPattern(), MLTAL, NTTP->getLocation(),
6065 NTTP->getDeclName());
6067 NTTPType =
SubstType(NTTPType, MLTAL, NTTP->getLocation(),
6068 NTTP->getDeclName());
6075 NTTP->getLocation());
6082 llvm_unreachable(
"Should never see a NULL template argument here");
6089 CanonicalResult, CTAK);
6098 if (Res.
get() != E) {
6103 SugaredConverted.push_back(SugaredResult);
6104 CanonicalConverted.push_back(CanonicalResult);
6115 CanonicalConverted.push_back(
6158 SugaredConverted.push_back(SugaredResult);
6159 CanonicalConverted.push_back(CanonicalResult);
6186 Diag(SR.
getBegin(), diag::err_template_arg_nontype_ambig) << SR << T;
6188 Diag(SR.
getBegin(), diag::err_template_arg_must_be_expr) << SR;
6194 llvm_unreachable(
"Caller must expand template argument packs");
6225 Template, SugaredConverted,
true),
6244 llvm_unreachable(
"Should never see a NULL template argument here");
6252 CanonicalConverted.push_back(
6268 llvm_unreachable(
"non-type argument with template template parameter");
6271 llvm_unreachable(
"Caller must expand template argument packs");
6278template<
typename TemplateParmDecl>
6281 const TemplateParmDecl *D,
6286 ->getTemplateParameters()
6287 ->getParam(D->getIndex()));
6294 D->getDefaultArgumentLoc(), Modules,
6305 S.
Diag(Loc, diag::err_template_arg_list_different_arity)
6339 bool isTemplateTemplateParameter = isa<TemplateTemplateParmDecl>(Template);
6342 unsigned ArgIdx = 0, NumArgs = NewArgs.
size();
6345 ParamEnd = Params->
end();
6346 Param != ParamEnd; ) {
6350 if (*Expansions == SugaredArgumentPack.size()) {
6353 SugaredConverted.push_back(
6355 SugaredArgumentPack.clear();
6357 CanonicalConverted.push_back(
6359 CanonicalArgumentPack.clear();
6364 }
else if (ArgIdx == NumArgs && !PartialTemplateArgs) {
6366 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
6375 if (ArgIdx < NumArgs) {
6378 RAngleLoc, SugaredArgumentPack.size(),
6379 SugaredConverted, CanonicalConverted,
6383 CanonicalConverted.back().setIsDefaulted(
6386 CanonicalConverted, Params->
getDepth()));
6388 bool PackExpansionIntoNonPack =
6389 NewArgs[ArgIdx].getArgument().isPackExpansion() &&
6391 if (PackExpansionIntoNonPack && (isa<TypeAliasTemplateDecl>(Template) ||
6392 isa<ConceptDecl>(Template))) {
6398 Diag(NewArgs[ArgIdx].getLocation(),
6399 diag::err_template_expansion_into_fixed_list)
6400 << (isa<ConceptDecl>(Template) ? 1 : 0)
6401 << NewArgs[ArgIdx].getSourceRange();
6409 if ((*Param)->isTemplateParameterPack()) {
6414 SugaredArgumentPack.push_back(SugaredConverted.pop_back_val());
6415 CanonicalArgumentPack.push_back(CanonicalConverted.pop_back_val());
6424 if (PackExpansionIntoNonPack) {
6425 if (!SugaredArgumentPack.empty()) {
6428 SugaredConverted.insert(SugaredConverted.end(),
6429 SugaredArgumentPack.begin(),
6430 SugaredArgumentPack.end());
6431 SugaredArgumentPack.clear();
6433 CanonicalConverted.insert(CanonicalConverted.end(),
6434 CanonicalArgumentPack.begin(),
6435 CanonicalArgumentPack.end());
6436 CanonicalArgumentPack.clear();
6439 while (ArgIdx < NumArgs) {
6441 SugaredConverted.push_back(Arg);
6442 CanonicalConverted.push_back(
6454 if (PartialTemplateArgs) {
6455 if ((*Param)->isTemplateParameterPack() && !SugaredArgumentPack.empty()) {
6456 SugaredConverted.push_back(
6458 CanonicalConverted.push_back(
6466 if ((*Param)->isTemplateParameterPack()) {
6468 "Should have dealt with this already");
6473 if (Param + 1 != ParamEnd) {
6476 "Concept templates must have parameter packs at the end.");
6480 SugaredConverted.push_back(
6482 SugaredArgumentPack.clear();
6484 CanonicalConverted.push_back(
6486 CanonicalArgumentPack.clear();
6506 *
this, Template, TemplateLoc, RAngleLoc, TTP, SugaredConverted,
6507 CanonicalConverted);
6514 = dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
6520 *
this, Template, TemplateLoc, RAngleLoc, NTTP, SugaredConverted,
6521 CanonicalConverted);
6529 = cast<TemplateTemplateParmDecl>(*Param);
6537 *
this, Template, TemplateLoc, RAngleLoc, TempParm, SugaredConverted,
6538 CanonicalConverted, QualifierLoc);
6559 SugaredConverted, CanonicalConverted,
6563 CanonicalConverted.back().setIsDefaulted(
true);
6568 if (isTemplateTemplateParameter)
6582 while (ArgIdx < NumArgs &&
6583 NewArgs[ArgIdx].
getArgument().isPackExpansion()) {
6585 SugaredConverted.push_back(Arg);
6592 if (ArgIdx < NumArgs) {
6593 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
6604 if (UpdateArgsWithConversions)
6605 TemplateArgs = std::move(NewArgs);
6607 if (!PartialTemplateArgs) {
6614 if (
auto *TD = dyn_cast<TemplateDecl>(NewContext))
6616 auto *RD = dyn_cast<CXXRecordDecl>(NewContext);
6619 if (
const auto *Method =
6621 ThisQuals = Method->getMethodQualifiers();
6627 Template, NewContext,
false, CanonicalConverted,
6644 class UnnamedLocalNoLinkageFinder
6645 :
public TypeVisitor<UnnamedLocalNoLinkageFinder, bool>
6653 UnnamedLocalNoLinkageFinder(
Sema &S,
SourceRange SR) : S(S), SR(SR) { }
6659#define TYPE(Class, Parent) \
6660 bool Visit##Class##Type(const Class##Type *);
6661#define ABSTRACT_TYPE(Class, Parent) \
6662 bool Visit##Class##Type(const Class##Type *) { return false; }
6663#define NON_CANONICAL_TYPE(Class, Parent) \
6664 bool Visit##Class##Type(const Class##Type *) { return false; }
6665#include "clang/AST/TypeNodes.inc"
6667 bool VisitTagDecl(
const TagDecl *Tag);
6672bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(
const BuiltinType*) {
6676bool UnnamedLocalNoLinkageFinder::VisitComplexType(
const ComplexType* T) {
6680bool UnnamedLocalNoLinkageFinder::VisitPointerType(
const PointerType* T) {
6684bool UnnamedLocalNoLinkageFinder::VisitBlockPointerType(
6689bool UnnamedLocalNoLinkageFinder::VisitLValueReferenceType(
6694bool UnnamedLocalNoLinkageFinder::VisitRValueReferenceType(
6699bool UnnamedLocalNoLinkageFinder::VisitMemberPointerType(
6704bool UnnamedLocalNoLinkageFinder::VisitConstantArrayType(
6709bool UnnamedLocalNoLinkageFinder::VisitIncompleteArrayType(
6714bool UnnamedLocalNoLinkageFinder::VisitVariableArrayType(
6719bool UnnamedLocalNoLinkageFinder::VisitDependentSizedArrayType(
6724bool UnnamedLocalNoLinkageFinder::VisitDependentSizedExtVectorType(
6729bool UnnamedLocalNoLinkageFinder::VisitDependentSizedMatrixType(
6734bool UnnamedLocalNoLinkageFinder::VisitDependentAddressSpaceType(
6739bool UnnamedLocalNoLinkageFinder::VisitVectorType(
const VectorType* T) {
6743bool UnnamedLocalNoLinkageFinder::VisitDependentVectorType(
6748bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(
const ExtVectorType* T) {
6752bool UnnamedLocalNoLinkageFinder::VisitConstantMatrixType(
6757bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
6767bool UnnamedLocalNoLinkageFinder::VisitFunctionNoProtoType(
6772bool UnnamedLocalNoLinkageFinder::VisitUnresolvedUsingType(
6777bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(
const TypeOfExprType*) {
6781bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(
const TypeOfType* T) {
6785bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(
const DecltypeType*) {
6789bool UnnamedLocalNoLinkageFinder::VisitPackIndexingType(
6794bool UnnamedLocalNoLinkageFinder::VisitUnaryTransformType(
6799bool UnnamedLocalNoLinkageFinder::VisitAutoType(
const AutoType *T) {
6803bool UnnamedLocalNoLinkageFinder::VisitDeducedTemplateSpecializationType(
6808bool UnnamedLocalNoLinkageFinder::VisitRecordType(
const RecordType* T) {
6809 return VisitTagDecl(T->
getDecl());
6812bool UnnamedLocalNoLinkageFinder::VisitEnumType(
const EnumType* T) {
6813 return VisitTagDecl(T->
getDecl());
6816bool UnnamedLocalNoLinkageFinder::VisitTemplateTypeParmType(
6821bool UnnamedLocalNoLinkageFinder::VisitSubstTemplateTypeParmPackType(
6826bool UnnamedLocalNoLinkageFinder::VisitTemplateSpecializationType(
6831bool UnnamedLocalNoLinkageFinder::VisitInjectedClassNameType(
6833 return VisitTagDecl(T->
getDecl());
6836bool UnnamedLocalNoLinkageFinder::VisitDependentNameType(
6841bool UnnamedLocalNoLinkageFinder::VisitDependentTemplateSpecializationType(
6844 return VisitNestedNameSpecifier(Q);
6848bool UnnamedLocalNoLinkageFinder::VisitPackExpansionType(
6853bool UnnamedLocalNoLinkageFinder::VisitObjCObjectType(
const ObjCObjectType *) {
6857bool UnnamedLocalNoLinkageFinder::VisitObjCInterfaceType(
6862bool UnnamedLocalNoLinkageFinder::VisitObjCObjectPointerType(
6867bool UnnamedLocalNoLinkageFinder::VisitAtomicType(
const AtomicType* T) {
6871bool UnnamedLocalNoLinkageFinder::VisitPipeType(
const PipeType* T) {
6875bool UnnamedLocalNoLinkageFinder::VisitBitIntType(
const BitIntType *T) {
6879bool UnnamedLocalNoLinkageFinder::VisitDependentBitIntType(
6884bool UnnamedLocalNoLinkageFinder::VisitTagDecl(
const TagDecl *Tag) {
6886 S.
Diag(SR.getBegin(),
6888 diag::warn_cxx98_compat_template_arg_local_type :
6889 diag::ext_template_arg_local_type)
6895 S.
Diag(SR.getBegin(),
6897 diag::warn_cxx98_compat_template_arg_unnamed_type :
6898 diag::ext_template_arg_unnamed_type) << SR;
6906bool UnnamedLocalNoLinkageFinder::VisitNestedNameSpecifier(
6924 llvm_unreachable(
"Invalid NestedNameSpecifier::Kind!");
6933 assert(ArgInfo &&
"invalid TypeSourceInfo");
6939 return Diag(SR.
getBegin(), diag::err_variably_modified_template_arg) << Arg;
6941 return Diag(SR.
getBegin(), diag::err_template_arg_overload_type) << SR;
6952 UnnamedLocalNoLinkageFinder Finder(*
this, SR);
6953 (void)Finder.Visit(CanonArg);
6970 Decl *Entity =
nullptr) {
6976 if (Entity && Entity->hasAttr<DLLImportAttr>())
6981 "Incomplete parameter type in isNullPointerValueTemplateArgument!");
6994 EvalResult.
Diag = &Notes;
7002 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
7003 diag::note_invalid_subexpr_in_const_expr) {
7004 DiagLoc = Notes[0].first;
7008 S.
Diag(DiagLoc, diag::err_template_arg_not_address_constant)
7010 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
7011 S.
Diag(Notes[I].first, Notes[I].second);
7029 bool ObjCLifetimeConversion;
7032 ObjCLifetimeConversion))
7037 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
7056 std::string Code =
"static_cast<" + ParamType.
getAsString() +
">(";
7057 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_untyped_null_constant)
7076 bool ObjCLifetimeConversion;
7080 ObjCLifetimeConversion)) {
7085 if (!ParamRef->getPointeeType()->isFunctionType()) {
7095 unsigned ParamQuals = ParamRef->getPointeeType().getCVRQualifiers();
7098 if ((ParamQuals | ArgQuals) != ParamQuals) {
7100 diag::err_template_arg_ref_bind_ignores_quals)
7137 bool AddressTaken =
false;
7144 bool ExtWarnMSTemplateArg =
false;
7147 while (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(Arg)) {
7149 if (UnOpKind == UO_Deref)
7150 ExtWarnMSTemplateArg =
true;
7151 if (UnOpKind == UO_AddrOf || UnOpKind == UO_Deref) {
7154 FirstOpKind = UnOpKind;
7155 FirstOpLoc = UnOp->getOperatorLoc();
7161 if (ExtWarnMSTemplateArg)
7165 if (FirstOpKind == UO_AddrOf)
7166 AddressTaken =
true;
7170 assert(FirstOpKind == UO_Deref);
7193 bool ExtraParens =
false;
7195 if (!
Invalid && !ExtraParens) {
7198 ? diag::warn_cxx98_compat_template_arg_extra_parens
7199 : diag::ext_template_arg_extra_parens)
7204 Arg =
Parens->getSubExpr();
7208 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
7212 if (UnOp->getOpcode() == UO_AddrOf) {
7213 Arg = UnOp->getSubExpr();
7214 AddressTaken =
true;
7215 AddrOpLoc = UnOp->getOperatorLoc();
7220 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
7225 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Arg))
7226 Entity = DRE->getDecl();
7228 Entity = CUE->getGuidDecl();
7235 S.
Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
7238 CanonicalConverted =
7255 CanonicalConverted =
7268 if (isa<FieldDecl>(Entity) || isa<IndirectFieldDecl>(Entity)) {
7276 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Entity)) {
7277 if (!Method->isStatic()) {
7286 VarDecl *Var = dyn_cast<VarDecl>(Entity);
7287 MSGuidDecl *Guid = dyn_cast<MSGuidDecl>(Entity);
7290 if (!
Func && !Var && !Guid) {
7302 ? diag::warn_cxx98_compat_template_arg_object_internal
7303 : diag::ext_template_arg_object_internal)
7305 S.
Diag(Entity->
getLocation(), diag::note_template_arg_internal_object)
7310 S.
Diag(Entity->
getLocation(), diag::note_template_arg_internal_object)
7339 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
7345 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
7387 CanonicalConverted =
7403 Expr *Arg = ResultArg;
7404 bool ObjCLifetimeConversion;
7416 bool ExtraParens =
false;
7418 if (!
Invalid && !ExtraParens) {
7421 ? diag::warn_cxx98_compat_template_arg_extra_parens
7422 : diag::ext_template_arg_extra_parens)
7427 Arg =
Parens->getSubExpr();
7431 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
7436 if (UnOp->getOpcode() == UO_AddrOf) {
7437 DRE = dyn_cast<DeclRefExpr>(UnOp->getSubExpr());
7443 else if ((DRE = dyn_cast<DeclRefExpr>(Arg))) {
7446 if (isa<NonTypeTemplateParmDecl>(VD)) {
7449 CanonicalConverted =
7453 CanonicalConverted =
7472 S.
Diag(ResultArg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
7484 ObjCLifetimeConversion)) {
7491 S.
Diag(ResultArg->
getBeginLoc(), diag::err_template_arg_not_convertible)
7499 diag::err_template_arg_not_pointer_to_member_form)
7502 if (isa<FieldDecl>(DRE->
getDecl()) ||
7503 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
7504 isa<CXXMethodDecl>(DRE->
getDecl())) {
7505 assert((isa<FieldDecl>(DRE->
getDecl()) ||
7506 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
7507 cast<CXXMethodDecl>(DRE->
getDecl())
7508 ->isImplicitObjectMemberFunction()) &&
7509 "Only non-static member pointers can make it here");
7515 CanonicalConverted =
7520 CanonicalConverted =
7528 S.
Diag(Arg->
getBeginLoc(), diag::err_template_arg_not_pointer_to_member_form)
7557 auto *AT = dyn_cast<AutoType>(DeducedT);
7558 if (AT && AT->isDecltypeAuto()) {
7569 Expr *DeductionArg = Arg;
7570 if (
auto *PE = dyn_cast<PackExpansionExpr>(DeductionArg))
7571 DeductionArg = PE->getPattern();
7574 if (isa<DeducedTemplateSpecializationType>(DeducedT)) {
7578 DeductionArg->
getBeginLoc(),
false, DeductionArg);
7579 Expr *Inits[1] = {DeductionArg};
7602 diag::err_non_type_template_parm_type_deduction_failure)
7614 if (ParamType.
isNull()) {
7622 "non-type template parameter type cannot be qualified");
7648 Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
7659 auto *PE = dyn_cast<PackExpansionExpr>(Arg);
7661 Arg = PE->getPattern();
7673 PE->getNumExpansions());
7691 if (ParamType->
isRecordType() && isa<DeclRefExpr>(InnerArg) &&
7693 NamedDecl *ND = cast<DeclRefExpr>(InnerArg)->getDecl();
7694 if (
auto *TPO = dyn_cast<TemplateParamObjectDecl>(ND)) {
7697 CanonicalConverted =
7701 if (isa<NonTypeTemplateParmDecl>(ND)) {
7703 CanonicalConverted =
7714 bool IsConvertedConstantExpression =
true;
7715 if (isa<InitListExpr>(Arg) || ParamType->
isRecordType()) {
7718 Expr *Inits[1] = {Arg};
7732 IsConvertedConstantExpression =
false;
7741 if (IsConvertedConstantExpression) {
7754 CanonicalConverted =
7762 false, PreNarrowingValue);
7766 if (
Value.isLValue()) {
7779 isa<LifetimeExtendedTemporaryDecl, UnnamedGlobalConstantDecl>(VD))) {
7785 if (
Value.hasLValuePath() &&
Value.getLValuePath().size() == 1 && VD &&
7787 Value.getLValuePath()[0].getAsArrayIndex() == 0 &&
7792 return ArgResult.
get();
7797 if (!
Value.hasLValuePath() ||
Value.getLValuePath().size() ||
7798 Value.isLValueOnePastTheEnd()) {
7799 Diag(StartLoc, diag::err_non_type_template_arg_subobject)
7804 "null reference should not be a constant expression");
7806 "non-null value of type nullptr_t?");
7810 if (
Value.isAddrLabelDiff())
7811 return Diag(StartLoc, diag::err_non_type_template_arg_addr_label_diff);
7815 return ArgResult.
get();
7853 CanonicalConverted =
7863 IntegerType =
Enum->getDecl()->getIntegerType();
7869 CanonicalConverted =
7877 Arg = ArgResult.
get();
7890 Diag(Arg->
getBeginLoc(), diag::err_template_arg_not_integral_or_enumeral)
7899 TmplArgICEDiagnoser(
QualType T) : T(T) { }
7903 return S.
Diag(Loc, diag::err_template_arg_not_ice) << T;
7905 } Diagnoser(ArgType);
7941 CanonicalConverted =
7948 IntegerType =
Enum->getDecl()->getIntegerType();
7955 if (
Value.getBitWidth() != AllowedBits)
7959 llvm::APSInt OldValue =
Value;
7966 if (
Value.getBitWidth() != AllowedBits)
7972 (OldValue.isSigned() && OldValue.isNegative())) {
7980 unsigned RequiredBits;
7982 RequiredBits = OldValue.getActiveBits();
7983 else if (OldValue.isUnsigned())
7984 RequiredBits = OldValue.getActiveBits() + 1;
7986 RequiredBits = OldValue.getSignificantBits();
7987 if (RequiredBits > AllowedBits) {
7997 CanonicalConverted =
8047 *
this, Param, ParamType, Arg, SugaredConverted,
8048 CanonicalConverted))
8054 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
8065 "Only object pointers allowed here");
8068 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
8080 assert(ParamRefType->getPointeeType()->isIncompleteOrObjectType() &&
8081 "Only object references allowed here");
8085 ParamRefType->getPointeeType(),
8100 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
8109 CanonicalConverted =
8117 << Arg->
getType() << ParamType;
8125 Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
8139 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
8160 assert(Name.isDependent() &&
"Non-dependent template isn't a declaration?");
8179 if (!isa<ClassTemplateDecl>(Template) &&
8180 !isa<TemplateTemplateParmDecl>(Template) &&
8181 !isa<TypeAliasTemplateDecl>(Template) &&
8182 !isa<BuiltinTemplateDecl>(Template)) {
8183 assert(isa<FunctionTemplateDecl>(Template) &&
8184 "Only function templates are possible here");
8186 Diag(Template->
getLocation(), diag::note_template_arg_refers_here_func)
8221 if (ParamsAC.empty())
8226 bool IsParamAtLeastAsConstrained;
8228 IsParamAtLeastAsConstrained))
8230 if (!IsParamAtLeastAsConstrained) {
8232 diag::err_template_template_parameter_not_at_least_as_constrained)
8254 unsigned HereDiagID,
8255 unsigned ExternalDiagID) {
8260 llvm::raw_svector_ostream Out(Str);
8268 std::optional<SourceRange> ParamRange) {
8271 diag::note_template_decl_external);
8272 if (ParamRange && ParamRange->isValid()) {
8274 "Parameter range has location when Decl does not");
8281 diag::note_template_param_external);
8309 ? CK_NullToMemberPointer
8310 : CK_NullToPointer);
8313 "Only declaration template arguments permitted here");
8322 (isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD) ||
8323 isa<IndirectFieldDecl>(VD)));
8351 assert(isa<TemplateParamObjectDecl>(VD) &&
8352 "arg for class template param not a template parameter object");
8357 "unexpected type for decl template argument");
8362 "value kind mismatch for non-type template argument");
8382 "unexpected conversion required for non-type template argument");
8409 T = ET->getDecl()->getIntegerType();
8460 llvm_unreachable(
"unexpected template argument value");
8485 return MakeInitList(
8498 return MakeInitList(Elts);
8503 llvm_unreachable(
"Unexpected APValue kind.");
8519 llvm_unreachable(
"Unhandled APValue::ValueKind enum");
8531 llvm_unreachable(
"not a non-type template argument");
8549 llvm_unreachable(
"Unhandled TemplateArgument::ArgKind enum");
8556 const NamedDecl *OldInstFrom,
bool Complain,
8561 unsigned NextDiag = diag::err_template_param_different_kind;
8562 if (TemplateArgLoc.
isValid()) {
8563 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
8564 NextDiag = diag::note_template_param_different_kind;
8583 unsigned NextDiag = diag::err_template_parameter_pack_non_pack;
8584 if (TemplateArgLoc.
isValid()) {
8585 S.
Diag(TemplateArgLoc,
8586 diag::err_template_arg_template_params_mismatch);
8587 NextDiag = diag::note_template_parameter_pack_non_pack;
8590 unsigned ParamKind = isa<TemplateTypeParmDecl>(New)? 0
8591 : isa<NonTypeTemplateParmDecl>(New)? 1
8604 = dyn_cast<NonTypeTemplateParmDecl>(Old)) {
8612 (!OldNTTP->getType()->isDependentType() &&
8622 unsigned NextDiag = diag::err_template_nontype_parm_different_type;
8623 if (TemplateArgLoc.
isValid()) {
8624 S.
Diag(TemplateArgLoc,
8625 diag::err_template_arg_template_params_mismatch);
8626 NextDiag = diag::note_template_nontype_parm_different_type;
8631 S.
Diag(OldNTTP->getLocation(),
8632 diag::note_template_nontype_parm_prev_declaration)
8633 << OldNTTP->getType();
8644 dyn_cast<TemplateTemplateParmDecl>(Old)) {
8648 OldTTP->getTemplateParameters(), Complain,
8658 !isa<TemplateTemplateParmDecl>(Old)) {
8659 const Expr *NewC =
nullptr, *OldC =
nullptr;
8661 if (isa<TemplateTypeParmDecl>(New)) {
8662 if (
const auto *TC = cast<TemplateTypeParmDecl>(New)->getTypeConstraint())
8663 NewC = TC->getImmediatelyDeclaredConstraint();
8664 if (
const auto *TC = cast<TemplateTypeParmDecl>(Old)->getTypeConstraint())
8665 OldC = TC->getImmediatelyDeclaredConstraint();
8666 }
else if (isa<NonTypeTemplateParmDecl>(New)) {
8667 if (
const Expr *E = cast<NonTypeTemplateParmDecl>(New)
8668 ->getPlaceholderTypeConstraint())
8670 if (
const Expr *E = cast<NonTypeTemplateParmDecl>(Old)
8671 ->getPlaceholderTypeConstraint())
8674 llvm_unreachable(
"unexpected template parameter type");
8676 auto Diagnose = [&] {
8678 diag::err_template_different_type_constraint);
8680 diag::note_template_prev_declaration) << 0;
8683 if (!NewC != !OldC) {
8710 unsigned NextDiag = diag::err_template_param_list_different_arity;
8711 if (TemplateArgLoc.
isValid()) {
8712 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
8713 NextDiag = diag::note_template_param_list_different_arity;
8768 OldParmEnd = Old->
end();
8769 OldParm != OldParmEnd; ++OldParm) {
8771 !(*OldParm)->isTemplateParameterPack()) {
8772 if (NewParm == NewParmEnd) {
8781 OldInstFrom, Complain, Kind,
8796 for (; NewParm != NewParmEnd; ++NewParm) {
8798 OldInstFrom, Complain, Kind,
8805 if (NewParm != NewParmEnd) {
8820 diag::err_template_different_requires_clause);
8822 diag::note_template_prev_declaration) << 0;
8825 if (!NewRC != !OldRC) {
8854 S = S->getDeclParent();
8864 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
8884 if (RD->isLocalClass())
8886 diag::err_template_inside_local_class)
8894 diag::err_template_outside_namespace_or_class_scope)
8905 return Record->getTemplateSpecializationKind();
8907 return Function->getTemplateSpecializationKind();
8908 if (
VarDecl *Var = dyn_cast<VarDecl>(D))
8909 return Var->getTemplateSpecializationKind();
8946 if (isa<ClassTemplateDecl>(Specialized))
8948 else if (isa<VarTemplateDecl>(Specialized))
8950 else if (isa<FunctionTemplateDecl>(Specialized))
8952 else if (isa<CXXMethodDecl>(Specialized))
8954 else if (isa<VarDecl>(Specialized))
8956 else if (isa<RecordDecl>(Specialized))
8958 else if (isa<EnumDecl>(Specialized) && S.
getLangOpts().CPlusPlus11)
8961 S.
Diag(Loc, diag::err_template_spec_unknown_kind)
8971 S.
Diag(Loc, diag::err_template_spec_decl_function_scope)
8986 : DC->
Equals(SpecializedContext))) {
8987 if (isa<TranslationUnitDecl>(SpecializedContext))
8988 S.
Diag(Loc, diag::err_template_spec_redecl_global_scope)
8989 << EntityKind << Specialized;
8991 auto *ND = cast<NamedDecl>(SpecializedContext);
8992 int Diag = diag::err_template_spec_redecl_out_of_scope;
8994 Diag = diag::ext_ms_template_spec_redecl_out_of_scope;
8995 S.
Diag(Loc,
Diag) << EntityKind << Specialized
8996 << ND << isa<CXXRecordDecl>(ND);
8999 S.
Diag(Specialized->getLocation(), diag::note_specialized_entity);
9013 DependencyChecker Checker(Depth,
true);
9014 Checker.TraverseStmt(E);
9015 if (Checker.MatchLoc.isInvalid())
9017 return Checker.MatchLoc;
9023 DependencyChecker Checker(Depth,
true);
9024 Checker.TraverseTypeLoc(TL);
9025 if (Checker.MatchLoc.isInvalid())
9027 return Checker.MatchLoc;
9035 for (
unsigned I = 0; I != NumArgs; ++I) {
9038 S, TemplateNameLoc, Param, Args[I].pack_begin(),
9039 Args[I].pack_size(), IsDefaultArgument))
9052 ArgExpr = Expansion->getPattern();
9056 ArgExpr = ICE->getSubExpr();
9066 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ArgExpr))
9067 if (isa<NonTypeTemplateParmDecl>(DRE->getDecl()))
9087 if (ParamUseRange.
isValid()) {
9088 if (IsDefaultArgument) {
9089 S.
Diag(TemplateNameLoc,
9090 diag::err_dependent_non_type_arg_in_partial_spec);
9092 diag::note_dependent_non_type_default_arg_in_partial_spec)
9096 diag::err_dependent_non_type_arg_in_partial_spec)
9104 if (ParamUseRange.
isValid()) {
9106 diag::err_dependent_typed_non_type_arg_in_partial_spec)
9137 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
9139 = dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->
getParam(I));
9144 Param, &TemplateArgs[I],
9145 1, I >= NumExplicit))
9157 assert(TUK !=
TUK_Reference &&
"References are not specializations");
9162 ? TemplateParameterLists[0]->getTemplateLoc() : KWLoc;
9170 = dyn_cast_or_null<ClassTemplateDecl>(Name.getAsTemplateDecl());
9173 Diag(TemplateNameLoc, diag::err_not_class_template_specialization)
9174 << (Name.getAsTemplateDecl() &&
9175 isa<TemplateTemplateParmDecl>(Name.getAsTemplateDecl()));
9179 bool isMemberSpecialization =
false;
9180 bool isPartialSpecialization =
false;
9186 TemplateNameLoc, &TemplateId,
9198 KWLoc, TemplateNameLoc, SS, &TemplateId,
9199 TemplateParameterLists, TUK ==
TUK_Friend, isMemberSpecialization,
9208 if (TemplateParams && TemplateParams->
size() > 0) {
9209 isPartialSpecialization =
true;
9212 Diag(KWLoc, diag::err_partial_specialization_friend)
9220 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
9223 if (TTP->hasDefaultArgument()) {
9224 Diag(TTP->getDefaultArgumentLoc(),
9225 diag::err_default_arg_in_partial_spec);
9226 TTP->removeDefaultArgument();
9229 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
9230 if (
Expr *DefArg = NTTP->getDefaultArgument()) {
9231 Diag(NTTP->getDefaultArgumentLoc(),
9232 diag::err_default_arg_in_partial_spec)
9233 << DefArg->getSourceRange();
9234 NTTP->removeDefaultArgument();
9240 diag::err_default_arg_in_partial_spec)
9246 }
else if (TemplateParams) {
9248 Diag(KWLoc, diag::err_template_spec_friend)
9254 assert(TUK ==
TUK_Friend &&
"should have a 'template<>' for this decl");
9261 "Invalid enum tag in class template spec!");
9265 Diag(KWLoc, diag::err_use_with_wrong_tag)
9270 diag::note_previous_use);
9279 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
9281 isPartialSpecialization
9290 false, SugaredConverted, CanonicalConverted,
9296 if (isPartialSpecialization) {
9298 TemplateArgs.
size(),
9299 CanonicalConverted))
9304 if (!Name.isDependent() &&
9306 TemplateArgs, CanonicalConverted)) {
9307 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
9309 isPartialSpecialization =
false;
9313 void *InsertPos =
nullptr;
9316 if (isPartialSpecialization)
9318 CanonicalConverted, TemplateParams, InsertPos);
9320 PrevDecl =
ClassTemplate->findSpecialization(CanonicalConverted, InsertPos);
9329 isPartialSpecialization))
9334 if (isPartialSpecialization) {
9339 CanonicalConverted);
9352 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
9362 TemplateParameterLists.size() - 1,
9363 TemplateParameterLists.data());
9368 = cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl);
9372 TemplateNameLoc, TemplateParams,
ClassTemplate, CanonicalConverted,
9373 TemplateArgs, CanonType, PrevPartial);
9375 if (TemplateParameterLists.size() > 1 && SS.
isSet()) {
9377 Context, TemplateParameterLists.drop_back(1));
9381 ClassTemplate->AddPartialSpecialization(Partial, InsertPos);
9397 if (TemplateParameterLists.size() > 0) {
9399 TemplateParameterLists);
9408 CanonicalConverted);
9432 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
9436 diag::note_instantiation_required_here)
9474 if (ModulePrivateLoc.
isValid())
9476 << (isPartialSpecialization? 1 : 0)
9488 TemplateArgs, CanonType);
9539 Expr *ConstraintExpr) {
9544 diag::err_concept_decls_may_only_appear_in_global_namespace_scope);
9548 if (TemplateParameterLists.size() > 1) {
9549 Diag(NameLoc, diag::err_concept_extra_headers);
9555 if (Params->
size() == 0) {
9556 Diag(NameLoc, diag::err_concept_no_parameters);
9563 ParamEnd = Params->
end();
9564 ParamIt != ParamEnd; ++ParamIt) {
9565 Decl const *Param = *ParamIt;
9567 if (++ParamIt == ParamEnd)
9570 diag::err_template_param_pack_must_be_last_template_parameter);
9584 Diag(NameLoc, diag::err_concept_no_associated_constraints);
9595 bool AddToScope =
true;
9611 auto *OldConcept = dyn_cast<ConceptDecl>(
Previous.getRepresentativeDecl()->getUnderlyingDecl());
9613 auto *Old =
Previous.getRepresentativeDecl();
9623 Diag(NewDecl->
getLocation(), diag::err_redefinition_different_concept)
9649 if (MinGW || (isa<FunctionDecl>(D) &&
9650 cast<FunctionDecl>(D)->isFunctionTemplateSpecialization()))
9651 D->
dropAttrs<DLLImportAttr, DLLExportAttr>();
9654 FD->setInlineSpecified(
false);
9665 for (
Decl *Prev = D; Prev && !PrevDiagLoc.
isValid();
9666 Prev = Prev->getPreviousDecl()) {
9667 PrevDiagLoc = Prev->getLocation();
9669 assert(PrevDiagLoc.
isValid() &&
9670 "Explicit instantiation without point of instantiation?");
9702 bool &HasNoEffect) {
9703 HasNoEffect =
false;
9710 "previous declaration must be implicit!");
9723 if (PrevPointOfInstantiation.
isInvalid()) {
9737 PrevPointOfInstantiation.
isValid()) &&
9738 "Explicit instantiation without point of instantiation?");
9752 Diag(NewLoc, diag::err_specialization_after_instantiation)
9754 Diag(PrevPointOfInstantiation, diag::note_instantiation_required_here)
9759 llvm_unreachable(
"The switch over PrevTSK must be exhaustive.");
9789 diag::err_explicit_instantiation_declaration_after_definition);
9795 diag::note_explicit_instantiation_definition_here);
9799 llvm_unreachable(
"Unexpected TemplateSpecializationKind!");
9815 Diag(NewLoc, diag::warn_explicit_instantiation_after_specialization)
9818 diag::note_previous_template_specialization);
9849 ? diag::ext_explicit_instantiation_duplicate
9850 : diag::err_explicit_instantiation_duplicate)
9853 diag::note_previous_explicit_instantiation);
9859 llvm_unreachable(
"Missing specialization/instantiation case?");
9884 enum DiscardReason { NotAFunctionTemplate, NotAMemberOfEnclosing };
9888 if (!isa<FunctionTemplateDecl>(D)) {
9890 DiscardedCandidates.push_back(std::make_pair(NotAFunctionTemplate, D));
9897 DiscardedCandidates.push_back(std::make_pair(NotAMemberOfEnclosing, D));
9905 Diag(FD->
getLocation(), diag::err_dependent_function_template_spec_no_match)
9907 for (
auto &
P : DiscardedCandidates)
9908 Diag(
P.second->getLocation(),
9909 diag::note_dependent_function_template_spec_discard_reason)
9910 <<
P.first << IsFriend;
9915 ExplicitTemplateArgs);
9950 llvm::SmallDenseMap<FunctionDecl *, TemplateArgumentListInfo, 8>
9951 ConvertedTemplateArgs;
9972 dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl());
9973 if (OldMD && OldMD->
isConst()) {
9983 if (ExplicitTemplateArgs)
9984 Args = *ExplicitTemplateArgs;
9996 cast<FunctionTemplateDecl>(FunTmpl->getFirstDecl()),
9997 ExplicitTemplateArgs ? &Args :
nullptr, FT,
Specialization, Info);
10002 I.getPair(), FunTmpl->getTemplatedDecl(),
10018 I.getPair(), FunTmpl->getTemplatedDecl(),
10025 if (ExplicitTemplateArgs)
10034 if (QualifiedFriend && Candidates.
empty()) {
10040 if (
auto *OldFD = dyn_cast<FunctionDecl>(OldND->getUnderlyingDecl()))
10051 PDiag(diag::err_function_template_spec_ambiguous)
10052 << FD->
getDeclName() << (ExplicitTemplateArgs !=
nullptr),
10053 PDiag(diag::note_function_template_spec_matched));
10086 auto *SpecializationFPT =
10097 assert(SpecInfo &&
"Function template specialization info missing?");
10135 bool HasNoEffect =
false;
10161 "This must be the only existing declaration of this specialization");
10176 FD->setFunctionTemplateSpecialization(
10179 ExplicitTemplateArgs ? &ConvertedTemplateArgs[
Specialization] :
nullptr);
10212 assert(!isa<TemplateDecl>(
Member) &&
"Only for non-template members");
10215 NamedDecl *FoundInstantiation =
nullptr;
10225 NamedDecl *D = (*I)->getUnderlyingDecl();
10233 FoundInstantiation = *I;
10234 Instantiation = Method;
10235 InstantiatedFrom = Method->getInstantiatedFromMemberFunction();
10236 MSInfo = Method->getMemberSpecializationInfo();
10241 }
else if (isa<VarDecl>(
Member)) {
10244 (PrevVar = dyn_cast<VarDecl>(
Previous.getFoundDecl())))
10246 FoundInstantiation =
Previous.getRepresentativeDecl();
10247 Instantiation = PrevVar;
10251 }
else if (isa<RecordDecl>(
Member)) {
10254 (PrevRecord = dyn_cast<CXXRecordDecl>(
Previous.getFoundDecl()))) {
10255 FoundInstantiation =
Previous.getRepresentativeDecl();
10256 Instantiation = PrevRecord;
10260 }
else if (isa<EnumDecl>(
Member)) {
10263 (PrevEnum = dyn_cast<EnumDecl>(
Previous.getFoundDecl()))) {
10264 FoundInstantiation =
Previous.getRepresentativeDecl();
10265 Instantiation = PrevEnum;
10271 if (!Instantiation) {
10285 if (InstantiatedFrom && isa<CXXMethodDecl>(
Member)) {
10286 cast<CXXMethodDecl>(
Member)->setInstantiationOfMemberFunction(
10287 cast<CXXMethodDecl>(InstantiatedFrom),
10289 }
else if (InstantiatedFrom && isa<CXXRecordDecl>(
Member)) {
10290 cast<CXXRecordDecl>(
Member)->setInstantiationOfMemberClass(
10291 cast<CXXRecordDecl>(InstantiatedFrom),
10296 Previous.addDecl(FoundInstantiation);
10301 if (!InstantiatedFrom) {
10302 Diag(
Member->getLocation(), diag::err_spec_member_not_instantiated)
10314 assert(MSInfo &&
"Member specialization info missing?");
10316 bool HasNoEffect =
false;
10328 Instantiation,
Member->getLocation(),
10334 if (
auto *MemberFunction = dyn_cast<FunctionDecl>(
Member)) {
10335 FunctionDecl *InstantiationFunction = cast<FunctionDecl>(Instantiation);
10340 if (InstantiationFunction->
isDeleted()) {
10343 InstantiationFunction);
10349 MemberFunction->setInstantiationOfMemberFunction(
10351 }
else if (
auto *MemberVar = dyn_cast<VarDecl>(
Member)) {
10352 MemberVar->setInstantiationOfStaticDataMember(
10354 }
else if (
auto *MemberClass = dyn_cast<CXXRecordDecl>(
Member)) {
10355 MemberClass->setInstantiationOfMemberClass(
10357 }
else if (
auto *MemberEnum = dyn_cast<EnumDecl>(
Member)) {
10358 MemberEnum->setInstantiationOfMemberEnum(
10361 llvm_unreachable(
"unknown member specialization kind");
10367 Previous.addDecl(FoundInstantiation);
10376template<
typename DeclT>
10387 OrigD->setLocation(Loc);
10392 NamedDecl *Instantiation = cast<NamedDecl>(
Member->getCanonicalDecl());
10393 if (Instantiation ==
Member)
10396 if (
auto *
Function = dyn_cast<CXXMethodDecl>(Instantiation))
10398 else if (
auto *Var = dyn_cast<VarDecl>(Instantiation))
10400 else if (
auto *
Record = dyn_cast<CXXRecordDecl>(Instantiation))
10402 else if (
auto *
Enum = dyn_cast<EnumDecl>(Instantiation))
10405 llvm_unreachable(
"unknown member specialization kind");
10413 bool WasQualifiedName) {
10418 S.
Diag(InstLoc, diag::err_explicit_instantiation_in_class)
10431 if (WasQualifiedName) {
10432 if (CurContext->
Encloses(OrigContext))
10439 if (
NamespaceDecl *NS = dyn_cast<NamespaceDecl>(OrigContext)) {
10440 if (WasQualifiedName)
10443 diag::err_explicit_instantiation_out_of_scope :
10444 diag::warn_explicit_instantiation_out_of_scope_0x)
10449 diag::err_explicit_instantiation_unqualified_wrong_namespace :
10450 diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x)
10455 diag::err_explicit_instantiation_must_be_global :
10456 diag::warn_explicit_instantiation_must_be_global_0x)
10465 bool WasQualifiedName,
10472 S.
Diag(InstLoc, diag::err_explicit_instantiation_internal_linkage) << D;
10500 if (isa<TemplateSpecializationType>(T))
10510 auto *A = cast_or_null<InheritableAttr>(
getDLLAttr(Def));
10511 assert(A &&
"dllExportImportClassTemplateSpecialization called "
10512 "on Def without dllexport or dllimport");
10517 "delayed exports present at explicit instantiation");
10521 for (
auto &B : Def->
bases()) {
10522 if (
auto *BT = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
10523 B.getType()->getAsCXXRecordDecl()))
10544 "Invalid enum tag in class template explicit instantiation!");
10550 Diag(TemplateNameLoc, diag::err_tag_reference_non_tag)
10551 << TD << NTK << llvm::to_underlying(Kind);
10557 Kind,
false, KWLoc,
10559 Diag(KWLoc, diag::err_use_with_wrong_tag)
10564 diag::note_previous_use);
10581 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
10583 diag::warn_attribute_dllexport_explicit_instantiation_decl);
10584 Diag(AL.getLoc(), diag::note_attribute);
10589 if (
auto *A =
ClassTemplate->getTemplatedDecl()->getAttr<DLLExportAttr>()) {
10591 diag::warn_attribute_dllexport_explicit_instantiation_decl);
10592 Diag(A->getLocation(), diag::note_attribute);
10598 bool DLLImportExplicitInstantiationDef =
false;
10603 ClassTemplate->getTemplatedDecl()->getAttr<DLLImportAttr>();
10605 if (AL.getKind() == ParsedAttr::AT_DLLImport)
10607 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
10615 DLLImportExplicitInstantiationDef =
true;
10627 false, SugaredConverted, CanonicalConverted,
10633 void *InsertPos =
nullptr;
10635 ClassTemplate->findSpecialization(CanonicalConverted, InsertPos);
10645 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
10647 diag::warn_attribute_dllexport_explicit_instantiation_def);
10659 bool HasNoEffect =
false;
10662 PrevDecl, PrevDecl_TSK,
10679 PrevDecl =
nullptr;
10683 DLLImportExplicitInstantiationDef) {
10685 HasNoEffect =
false;
10700 if (
const auto *A = PrevDecl->
getAttr<MSInheritanceAttr>()) {
10702 Clone->setInherited(
true);
10708 if (!HasNoEffect && !PrevDecl) {
10732 bool PreviouslyDLLExported =
Specialization->hasAttr<DLLExportAttr>();
10757 = cast_or_null<ClassTemplateSpecializationDecl>(
10767 Def = cast_or_null<ClassTemplateSpecializationDecl>(
10775 DLLImportExplicitInstantiationDef)) {
10785 auto *A = cast<InheritableAttr>(
10787 A->setInherited(
true);
10795 bool NewlyDLLExported =
10796 !PreviouslyDLLExported &&
Specialization->hasAttr<DLLExportAttr>();
10813 "Def and Specialization should match for implicit instantiation");
10821 PrevDecl->
hasAttr<DLLExportAttr>()) {
10846 bool Owned =
false;
10847 bool IsDependent =
false;
10853 assert(!IsDependent &&
"explicit instantiation of dependent name not yet handled");
10858 TagDecl *Tag = cast<TagDecl>(TagD);
10859 assert(!Tag->
isEnum() &&
"shouldn't see enumerations here");
10867 Diag(TemplateLoc, diag::err_explicit_instantiation_nontemplate_type)
10869 Diag(
Record->getLocation(), diag::note_nontemplate_decl_here);
10880 Diag(TemplateLoc, diag::ext_explicit_instantiation_without_qualified_id)
10895 = cast_or_null<CXXRecordDecl>(
Record->getPreviousDecl());
10900 bool HasNoEffect =
false;
10901 assert(MSInfo &&
"No member specialization information?");
10913 = cast_or_null<CXXRecordDecl>(
Record->getDefinition());
10921 Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member)
10922 << 0 <<
Record->getDeclName() <<
Record->getDeclContext();
10932 RecordDef = cast_or_null<CXXRecordDecl>(
Record->getDefinition());
10963 diag::err_explicit_instantiation_requires_name)
10970 S = S->getDeclParent();
11002 diag::err_explicit_instantiation_inline :
11003 diag::warn_explicit_instantiation_inline_0x)
11009 diag::err_explicit_instantiation_constexpr);
11044 if (!PrevTemplate) {
11051 Diag((*P)->getLocation(), diag::note_explicit_instantiation_here);
11058 diag::err_explicit_instantiation_data_member_not_instantiated)
11074 diag::err_auto_not_allowed_var_inst);
11083 diag::err_explicit_instantiation_without_template_id)
11085 Diag(PrevTemplate->getLocation(),
11086 diag::note_explicit_instantiation_here);
11109 Prev = cast<VarDecl>(Res.
get());
11124 diag::ext_explicit_instantiation_without_qualified_id)
11132 bool HasNoEffect =
false;
11134 PrevTSK, POI, HasNoEffect))
11137 if (!HasNoEffect) {
11152 diag::err_invalid_var_template_spec_type)
11153 << 0 << PrevTemplate << R << Prev->
getType();
11154 Diag(PrevTemplate->getLocation(), diag::note_template_declared_here)
11155 << 2 << PrevTemplate->getDeclName();
11160 return (
Decl*)
nullptr;
11165 bool HasExplicitTemplateArgs =
false;
11169 HasExplicitTemplateArgs =
true;
11183 if (!HasExplicitTemplateArgs) {
11184 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Prev)) {
11188 if (Method->getPrimaryTemplate()) {
11189 TemplateMatches.
addDecl(Method,
P.getAccess());
11192 assert(!NonTemplateMatch &&
"Multiple NonTemplateMatches");
11193 NonTemplateMatch = Method;
11206 FunTmpl, (HasExplicitTemplateArgs ? &TemplateArgs :
nullptr), R,
11240 TemplateMatches.
begin(), TemplateMatches.
end(), FailedCandidates,
11242 PDiag(diag::err_explicit_instantiation_not_known) << Name,
11243 PDiag(diag::err_explicit_instantiation_ambiguous) << Name,
11244 PDiag(diag::note_explicit_instantiation_candidate));
11260 if (FPT->hasExceptionSpec()) {
11262 diag::err_mismatched_exception_spec_explicit_instantiation;
11264 DiagID = diag::ext_mismatched_exception_spec_explicit_instantiation;
11267 PDiag(diag::note_explicit_instantiation_here),
11278 diag::err_explicit_instantiation_member_function_not_instantiated)
11287 if (!PrevDecl &&
Specialization->isThisDeclarationADefinition())
11291 bool HasNoEffect =
false;
11302 return (
Decl*)
nullptr;
11313 if (
auto *RD = dyn_cast<CXXRecordDecl>(
Specialization->getDeclContext()))
11314 if (RD->getIdentifier() && RD->getIdentifier()->isStr(
"valarray") &&
11315 RD->isInStdNamespace())
11316 return (
Decl*)
nullptr;
11350 diag::ext_explicit_instantiation_without_qualified_id)
11360 return (
Decl*)
nullptr;
11368 assert(Name &&
"Expected a name in a dependent tag");
11377 Diag(NameLoc, diag::err_dependent_tag_decl)
11404 if (TypenameLoc.
isValid() && S && !S->getTemplateParamParent())
11407 diag::warn_cxx98_compat_typename_outside_of_template :
11408 diag::ext_typename_outside_of_template)
11418 TypenameLoc, QualifierLoc, II, IdLoc, &TSI,
11436 if (TypenameLoc.
isValid() && S && !S->getTemplateParamParent())
11439 diag::warn_cxx98_compat_typename_outside_of_template :
11440 diag::ext_typename_outside_of_template)
11448 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
11449 Diag(TemplateIILoc,
11450 diag::ext_out_of_line_qualified_id_type_names_constructor)
11452 << (TemplateKWLoc.
isValid() ? 1 : 0 );
11463 assert(DTN &&
"dependent template has non-dependent name?");
11467 DTN->getIdentifier(), TemplateArgs.
arguments());
11479 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
11496 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
11515 if (!II.
isStr(
"type"))
11524 if (!EnableIfTSTLoc || EnableIfTSTLoc.
getNumArgs() == 0)
11537 if (!EnableIfII || !EnableIfII->
isStr(
"enable_if"))
11565 bool DeducedTSTContext) {
11567 DeducedTSTContext);
11572 if (isa<DependentNameType>(T)) {
11596 SS.
Adopt(QualifierLoc);
11599 if (QualifierLoc) {
11626 unsigned DiagID = 0;
11627 Decl *Referenced =
nullptr;
11628 switch (
Result.getResultKind()) {
11633 Expr *Cond =
nullptr;
11634 if (Ctx &&
isEnableIf(QualifierLoc, II, CondRange, Cond)) {
11639 std::string FailedDescription;
11640 std::tie(FailedCond, FailedDescription) =
11644 diag::err_typename_nested_not_found_requirement)
11645 << FailedDescription
11651 diag::err_typename_nested_not_found_enable_if)
11652 << Ctx << CondRange;
11656 DiagID = Ctx ? diag::err_typename_nested_not_found
11657 : diag::err_unknown_typename;
11666 Diag(IILoc, diag::err_typename_refers_to_using_value_decl)
11667 << Name << Ctx << FullRange;
11669 = dyn_cast<UnresolvedUsingValueDecl>(
Result.getRepresentativeDecl())){
11671 Diag(Loc, diag::note_using_value_decl_missing_typename)
11701 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(Ctx);
11702 auto *FoundRD = dyn_cast<CXXRecordDecl>(
Type);
11704 FoundRD->isInjectedClassName() &&
11706 Diag(IILoc, diag::ext_out_of_line_qualified_id_type_names_constructor)
11723 if (!DeducedTSTContext) {
11728 Diag(IILoc, diag::err_dependent_deduced_tst)
11731 Diag(IILoc, diag::err_deduced_tst)
11743 DiagID = Ctx ? diag::err_typename_nested_not_type
11744 : diag::err_typename_not_type;
11745 Referenced =
Result.getFoundDecl();
11749 DiagID = Ctx ? diag::err_typename_nested_not_type
11750 : diag::err_typename_not_type;
11751 Referenced = *
Result.begin();
11763 Diag(IILoc, DiagID) << FullRange << Name << Ctx;
11765 Diag(IILoc, DiagID) << FullRange << Name;
11768 Ctx ? diag::note_typename_member_refers_here
11769 : diag::note_typename_refers_here)
11776 class CurrentInstantiationRebuilder
11784 CurrentInstantiationRebuilder(
Sema &SemaRef,
11788 Loc(Loc), Entity(Entity) { }
11795 bool AlreadyTransformed(
QualType T) {
11810 this->Entity = Entity;
11852 CurrentInstantiationRebuilder Rebuilder(*
this, Loc, Name);
11853 return Rebuilder.TransformType(T);
11857 CurrentInstantiationRebuilder Rebuilder(*
this, E->
getExprLoc(),
11859 return Rebuilder.TransformExpr(E);
11870 = Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
11882 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
11886 if (isa<TemplateTypeParmDecl>(Param))
11891 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
11893 TTP->getTemplateParameters()))
11937 unsigned NumArgs) {
11939 llvm::raw_svector_ostream Out(Str);
11941 if (!Params || Params->
size() == 0 || NumArgs == 0)
11942 return std::string();
11944 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
11954 Out <<
Id->getName();
11966 return std::string(Out.str());
11974 auto LPT = std::make_unique<LateParsedTemplate>();
11977 LPT->Toks.swap(Toks);
12024class ExplicitSpecializationVisibilityChecker {
12033 : S(S), Loc(Loc), Kind(Kind) {}
12036 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
12037 return checkImpl(FD);
12038 if (
auto *RD = dyn_cast<CXXRecordDecl>(ND))
12039 return checkImpl(RD);
12040 if (
auto *VD = dyn_cast<VarDecl>(ND))
12041 return checkImpl(VD);
12042 if (
auto *ED = dyn_cast<EnumDecl>(ND))
12043 return checkImpl(ED);
12047 void diagnose(
NamedDecl *D,
bool IsPartialSpec) {
12048 auto Kind = IsPartialSpec ? Sema::MissingImportKind::PartialSpecialization
12049 : Sema::MissingImportKind::ExplicitSpecialization;
12050 const bool Recover =
true;
12055 if (Modules.empty())
12061 bool CheckMemberSpecialization(
const NamedDecl *D) {
12062 return Kind == Sema::AcceptableKind::Visible
12067 bool CheckExplicitSpecialization(
const NamedDecl *D) {
12068 return Kind == Sema::AcceptableKind::Visible
12073 bool CheckDeclaration(
const NamedDecl *D) {
12090 template<
typename SpecDecl>
12091 void checkImpl(SpecDecl *Spec) {
12092 bool IsHiddenExplicitSpecialization =
false;
12094 IsHiddenExplicitSpecialization = Spec->getMemberSpecializationInfo()
12095 ? !CheckMemberSpecialization(Spec)
12096 : !CheckExplicitSpecialization(Spec);
12098 checkInstantiated(Spec);
12101 if (IsHiddenExplicitSpecialization)
12102 diagnose(Spec->getMostRecentDecl(),
false);
12111 auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(RD);
12115 auto From = SD->getSpecializedTemplateOrPartial();
12118 else if (
auto *TD =
12120 if (!CheckDeclaration(TD))
12121 diagnose(TD,
true);
12126 void checkInstantiated(
VarDecl *RD) {
12127 auto *SD = dyn_cast<VarTemplateSpecializationDecl>(RD);
12131 auto From = SD->getSpecializedTemplateOrPartial();
12134 else if (
auto *TD =
12136 if (!CheckDeclaration(TD))
12137 diagnose(TD,
true);
12142 void checkInstantiated(
EnumDecl *FD) {}
12144 template<
typename TemplDecl>
12145 void checkTemplate(TemplDecl *TD) {
12146 if (TD->isMemberSpecialization()) {
12147 if (!CheckMemberSpecialization(TD))
12148 diagnose(TD->getMostRecentDecl(),
false);
12158 ExplicitSpecializationVisibilityChecker(*
this, Loc,
12168 ExplicitSpecializationVisibilityChecker(*
this, Loc,
12180 if (
const auto *FD = dyn_cast<FunctionDecl>(N)) {
12188 if (!CSC.isInstantiationRecord() || CSC.PointOfInstantiation.isInvalid())
12190 return CSC.PointOfInstantiation;
Defines the clang::ASTContext interface.
Defines enum values for all the target-independent builtin functions.
static Decl::Kind getKind(const Decl *D)
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines the clang::LangOptions interface.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Record Record
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
MatchFinder::MatchResult MatchResult
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
static void SetNestedNameSpecifier(Sema &S, DeclaratorDecl *DD, Declarator &D)
static bool DependsOnTemplateParameters(QualType T, TemplateParameterList *Params)
Determines whether a given type depends on the given parameter list.
static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D)
Determine what kind of template specialization the given declaration is.
static Expr * BuildExpressionFromNonTypeTemplateArgumentValue(Sema &S, QualType T, const APValue &Val, SourceLocation Loc)
static TemplateArgumentLoc convertTypeTemplateArgumentToTemplate(ASTContext &Context, TypeLoc TLoc)
Convert a template-argument that we parsed as a type into a template, if possible.
static bool CheckTemplateSpecializationScope(Sema &S, NamedDecl *Specialized, NamedDecl *PrevDecl, SourceLocation Loc, bool IsPartialSpecialization)
Check whether a specialization is well-formed in the current context.
static bool ScopeSpecifierHasTemplateId(const CXXScopeSpec &SS)
Determine whether the given scope specifier has a template-id in it.
static SourceRange findTemplateParameterInType(unsigned Depth, Expr *E)
static Sema::SemaDiagnosticBuilder noteLocation(Sema &S, const NamedDecl &Decl, unsigned HereDiagID, unsigned ExternalDiagID)
static SourceRange getRangeOfTypeInNestedNameSpecifier(ASTContext &Context, QualType T, const CXXScopeSpec &SS)
static Expr * BuildExpressionFromIntegralTemplateArgumentValue(Sema &S, QualType OrigT, const llvm::APSInt &Int, SourceLocation Loc)
Construct a new expression that refers to the given integral template argument with the given source-...
static SourceRange findTemplateParameter(unsigned Depth, TypeLoc TL)
static NullPointerValueKind isNullPointerValueTemplateArgument(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *Arg, Decl *Entity=nullptr)
Determine whether the given template argument is a null pointer value of the appropriate type.
static ExprResult formImmediatelyDeclaredConstraint(Sema &S, NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, ConceptDecl *NamedConcept, NamedDecl *FoundDecl, SourceLocation LAngleLoc, SourceLocation RAngleLoc, QualType ConstrainedType, SourceLocation ParamNameLoc, ArgumentLocAppender Appender, SourceLocation EllipsisLoc)
static bool CheckNonTypeTemplatePartialSpecializationArgs(Sema &S, SourceLocation TemplateNameLoc, NonTypeTemplateParmDecl *Param, const TemplateArgument *Args, unsigned NumArgs, bool IsDefaultArgument)
Subroutine of Sema::CheckTemplatePartialSpecializationArgs that checks non-type template partial spec...
static void StripImplicitInstantiation(NamedDecl *D, bool MinGW)
Strips various properties off an implicit instantiation that has just been explicitly specialized.
static bool isEnableIf(NestedNameSpecifierLoc NNS, const IdentifierInfo &II, SourceRange &CondRange, Expr *&Cond)
Determine whether this failed name lookup should be treated as being disabled by a usage of std::enab...
static void DiagnoseTemplateParameterListArityMismatch(Sema &S, TemplateParameterList *New, TemplateParameterList *Old, Sema::TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc)
Diagnose a known arity mismatch when comparing template argument lists.
static bool isTemplateArgumentTemplateParameter(const TemplateArgument &Arg, unsigned Depth, unsigned Index)
static TemplateArgumentListInfo makeTemplateArgumentListInfo(Sema &S, TemplateIdAnnotation &TemplateId)
Convert the parser's template argument list representation into our form.
static bool CheckTemplateArgumentIsCompatibleWithParameter(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *ArgIn, Expr *Arg, QualType ArgType)
Checks whether the given template argument is compatible with its template parameter.
static bool CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *ArgIn, TemplateArgument &SugaredConverted, TemplateArgument &CanonicalConverted)
Checks whether the given template argument is the address of an object or function according to C++ [...
static void collectConjunctionTerms(Expr *Clause, SmallVectorImpl< Expr * > &Terms)
Collect all of the separable terms in the given condition, which might be a conjunction.
static void checkMoreSpecializedThanPrimary(Sema &S, PartialSpecDecl *Partial)
static bool CheckTemplateArgumentPointerToMember(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *&ResultArg, TemplateArgument &SugaredConverted, TemplateArgument &CanonicalConverted)
Checks whether the given template argument is a pointer to member constant according to C++ [temp....
static SourceLocation DiagLocForExplicitInstantiation(NamedDecl *D, SourceLocation PointOfInstantiation)
Compute the diagnostic location for an explicit instantiation.
static TemplateParameterList * GetTemplateParameterList(TemplateDecl *TD)
static bool isEnableIfAliasTemplate(TypeAliasTemplateDecl *AliasTemplate)
Determine whether this alias template is "enable_if_t".
static bool DiagnoseUnexpandedParameterPacks(Sema &S, TemplateTemplateParmDecl *TTP)
Check for unexpanded parameter packs within the template parameters of a template template parameter,...
static bool CheckExplicitInstantiationScope(Sema &S, NamedDecl *D, SourceLocation InstLoc, bool WasQualifiedName)
Check the scope of an explicit instantiation.
static TemplateArgumentLoc translateTemplateArgument(Sema &SemaRef, const ParsedTemplateArgument &Arg)
static bool isSameAsPrimaryTemplate(TemplateParameterList *Params, ArrayRef< TemplateArgument > Args)
static void checkTemplatePartialSpecialization(Sema &S, PartialSpecDecl *Partial)
static TypeSourceInfo * SubstDefaultTemplateArgument(Sema &SemaRef, TemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, TemplateTypeParmDecl *Param, ArrayRef< TemplateArgument > SugaredConverted, ArrayRef< TemplateArgument > CanonicalConverted)
Substitute template arguments into the default template argument for the given template type paramete...
static bool CheckExplicitInstantiation(Sema &S, NamedDecl *D, SourceLocation InstLoc, bool WasQualifiedName, TemplateSpecializationKind TSK)
Common checks for whether an explicit instantiation of D is valid.
static Expr * lookThroughRangesV3Condition(Preprocessor &PP, Expr *Cond)
static bool DiagnoseDefaultTemplateArgument(Sema &S, Sema::TemplateParamListContext TPC, SourceLocation ParamLoc, SourceRange DefArgRange)
Diagnose the presence of a default template argument on a template parameter, which is ill-formed in ...
static QualType checkBuiltinTemplateIdType(Sema &SemaRef, BuiltinTemplateDecl *BTD, ArrayRef< TemplateArgument > Converted, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
static void noteNonDeducibleParameters(Sema &S, TemplateParameterList *TemplateParams, const llvm::SmallBitVector &DeducibleParams)
static void completeMemberSpecializationImpl(Sema &S, DeclT *OrigD, SourceLocation Loc)
Complete the explicit specialization of a member of a class template by updating the instantiated mem...
static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc, TemplateDecl *TD, const TemplateParmDecl *D, TemplateArgumentListInfo &Args)
Diagnose a missing template argument.
static void maybeDiagnoseTemplateParameterShadow(Sema &SemaRef, Scope *S, SourceLocation Loc, IdentifierInfo *Name)
static bool MatchTemplateParameterKind(Sema &S, NamedDecl *New, const Sema::TemplateCompareNewDeclInfo &NewInstFrom, NamedDecl *Old, const NamedDecl *OldInstFrom, bool Complain, Sema::TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc)
Match two template parameters within template parameter lists.
static void dllExportImportClassTemplateSpecialization(Sema &S, ClassTemplateSpecializationDecl *Def)
Make a dllexport or dllimport attr on a class template specialization take effect.
Defines the clang::SourceLocation class and associated facilities.
Defines utilities for dealing with stack allocation and stack space.
static const TemplateArgument & getArgument(const TemplateArgument &A)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
const LValueBase getLValueBase() const
APSInt & getComplexIntImag()
ValueKind getKind() const
APFixedPoint & getFixedPoint()
const ValueDecl * getMemberPointerDecl() const
APValue & getVectorElt(unsigned I)
unsigned getVectorLength() const
bool isMemberPointer() const
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
@ Indeterminate
This object has an indeterminate value (C++ [basic.indet]).
@ None
There is no such object (it's outside its lifetime).
bool isNullPointer() const
APSInt & getComplexIntReal()
APFloat & getComplexFloatImag()
APFloat & getComplexFloatReal()
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
virtual void AssignInheritanceModel(CXXRecordDecl *RD)
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TranslationUnitDecl * getTranslationUnitDecl() const
unsigned getIntWidth(QualType T) const
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, ArrayRef< TemplateArgumentLoc > Args) const
bool hasSimilarType(QualType T1, QualType T2)
Determine if two types are similar, according to the C++ rules.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
DeclarationNameTable DeclarationNames
TemplateName getCanonicalTemplateName(const TemplateName &Name) const
Retrieves the "canonical" template name that refers to a given template.
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const
getInjectedClassNameType - Return the unique reference to the injected class name type for the specif...
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
const LangOptions & getLangOpts() const
TemplateArgument getInjectedTemplateArg(NamedDecl *ParamDecl)
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
QualType getCanonicalTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args) const
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
bool isSameEntity(const NamedDecl *X, const NamedDecl *Y) const
Determine whether the two declarations refer to the same entity.
TypeSourceInfo * getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &Args, QualType Canon=QualType()) const
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template apply.
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
const TargetInfo & getTargetInfo() const
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
QualType getUnconstrainedType(QualType T) const
Remove any type constraints from a template parameter type, for equivalence comparison of template pa...
QualType getTypedefType(const TypedefNameDecl *Decl, QualType Underlying=QualType()) const
Return the unique reference to the type for the specified typedef-name decl.
void setPrimaryMergedDecl(Decl *D, Decl *Primary)
TemplateName getAssumedTemplateName(DeclarationName Name) const
Retrieve a template name representing an unqualified-id that has been assumed to name a template for ...
QualType getElementType() const
A structure for storing the information associated with a name that has been assumed to be a template...
DeclarationName getDeclName() const
Get the name of the template.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Attr - This represents one attribute.
AutoTypeKeyword getAutoKeyword() const
const NestedNameSpecifierLoc getNestedNameSpecifierLoc() const
SourceLocation getRAngleLoc() const
ConceptDecl * getNamedConcept() const
SourceLocation getLAngleLoc() const
NamedDecl * getFoundDecl() const
DeclarationNameInfo getConceptNameInfo() const
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
A fixed int type of a specified bitwidth.
QualType getPointeeType() const
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
BuiltinTemplateKind getBuiltinTemplateKind() const
This class is used for builtin types like 'int'.
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, FPOptionsOverride FPO, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
static CXXBoolLiteralExpr * Create(const ASTContext &C, bool Val, QualType Ty, SourceLocation Loc)
Represents a C++ constructor within a class.
ExplicitSpecifier getExplicitSpecifier()
static CXXDeductionGuideDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation, CXXConstructorDecl *Ctor=nullptr, DeductionCandidate Kind=DeductionCandidate::Normal)
Represents a C++ member access expression where the actual member referenced could not be resolved be...
static CXXDependentScopeMemberExpr * Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Represents a static or instance method of a struct/union/class.
The null pointer literal (C++11 [lex.nullptr])
Represents a C++ struct/union/class.
CXXRecordDecl * getMostRecentDecl()
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
CXXRecordDecl * getDefinition() const
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
void setDescribedClassTemplate(ClassTemplateDecl *Template)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization,...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
CXXRecordDecl * getPreviousDecl()
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
char * location_data() const
Retrieve the data associated with the source-location information.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
SourceRange getRange() const
SourceLocation getBeginLoc() const
bool isSet() const
Deprecated.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isEmpty() const
No scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Declaration of a class template.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a class template node.
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template.
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
void setMemberSpecialization()
Note that this member template is a specialization.
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos, QualType CanonInjectedType, ClassTemplatePartialSpecializationDecl *PrevDecl)
Represents a class template specialization, which refers to a class template with a given set of temp...
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
Complex values, per C99 6.2.5p11.
QualType getElementType() const
Declaration of a C++20 concept.
Expr * getConstraintExpr() const
bool isTypeConcept() const
static ConceptDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, Expr *ConstraintExpr)
ConceptDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
static ConceptSpecializationExpr * Create(const ASTContext &C, ConceptReference *ConceptRef, ImplicitConceptSpecializationDecl *SpecDecl, const ConstraintSatisfaction *Satisfaction)
const TypeClass * getTypePtr() const
Represents the canonical version of C arrays with a specified constant size.
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
Represents a concrete matrix type with constant number of rows and columns.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isFileContext() const
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context,...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDecl(Decl *D)
Add the declaration D into this context.
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
bool isFunctionOrMethod() const
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
const LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
A reference to a declared variable, function, enum, etc.
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
Captures information about "declaration specifiers".
bool isVirtualSpecified() const
void ClearStorageClassSpecs()
bool isNoreturnSpecified() const
SourceLocation getStorageClassSpecLoc() const
SCS getStorageClassSpec() const
SourceLocation getBeginLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getNoreturnSpecLoc() const
SourceLocation getExplicitSpecLoc() const
TSCS getThreadStorageClassSpec() const
ParsedAttributes & getAttributes()
bool isInlineSpecified() const
SourceLocation getThreadStorageClassSpecLoc() const
SourceLocation getVirtualSpecLoc() const
SourceLocation getConstexprSpecLoc() const
SourceLocation getInlineSpecLoc() const
bool hasExplicitSpecifier() const
bool hasConstexprSpecifier() const
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
SourceLocation getEndLoc() const LLVM_READONLY
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
bool isParameterPack() const
Whether this declaration is a parameter pack.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
@ FOK_None
Not a friend object.
bool isTemplated() const
Determine whether this declaration is a templated entity (whether it is.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
unsigned getTemplateDepth() const
Determine the number of levels of template parameter surrounding this declaration.
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
static DeclContext * castToDeclContext(const Decl *)
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
bool isInvalidDecl() const
void setAccess(AccessSpecifier AS)
SourceLocation getLocation() const
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
SourceLocation getBeginLoc() const LLVM_READONLY
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
void setLexicalDeclContext(DeclContext *DC)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
std::string getAsString() const
Retrieve the human-readable string for this name.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
SourceLocation getBeginLoc() const LLVM_READONLY
void setTypeSourceInfo(TypeSourceInfo *TI)
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
SourceLocation getIdentifierLoc() const
SourceLocation getEllipsisLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
IdentifierInfo * getIdentifier() const
bool isInvalidType() const
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
Represents the type decltype(expr) (C++11).
Represents a C++17 deduced template specialization type.
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it has not been deduced.
Represents an extended address space qualifier where the input address space value is dependent.
QualType getPointeeType() const
void setNameLoc(SourceLocation Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Represents a qualified type name for which the type name is dependent.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
A qualified reference to a name whose declaration cannot yet be resolved.
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Represents an array type in C++ whose size is a value-dependent expression.
Represents an extended vector type where either the type or size is dependent.
QualType getElementType() const
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Represents a dependent template name that cannot be resolved prior to template instantiation.
bool isIdentifier() const
Determine whether this template name refers to an identifier.
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
unsigned getNumArgs() const
void setTemplateKeywordLoc(SourceLocation Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void setLAngleLoc(SourceLocation Loc)
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
void setTemplateNameLoc(SourceLocation Loc)
Represents a template specialization type whose template cannot be resolved, e.g.
NestedNameSpecifier * getQualifier() const
Represents a vector type where either the type or size is dependent.
QualType getElementType() const
void setElaboratedKeywordLoc(SourceLocation Loc)
TypeLoc getNamedTypeLoc() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
RAII object that enters a new expression evaluation context.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
EnumDecl * getDecl() const
Store information needed for an explicit specifier.
This represents one expression.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
@ NPC_NeverValueDependent
Specifies that the expression should never be value-dependent.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
ExtVectorType - Extended vector type.
Represents a member of a struct/union/class.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
static FixedPointLiteral * CreateFromRawInt(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l, unsigned Scale)
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList * > FriendTypeTPLists=std::nullopt)
Represents a function declaration or definition.
ConstexprSpecKind getConstexprKind() const
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
SourceLocation getPointOfInstantiation() const
Retrieve the (first) point of instantiation of a function template specialization or a member of a cl...
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isDeleted() const
Whether this function has been deleted.
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo *TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization.
void setLateTemplateParsed(bool ILT=true)
State that this templated function will be late parsed.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
void setDeletedAsWritten(bool D=true)
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Represents a prototype with parameter type info, e.g.
bool isVariadic() const
Whether this function prototype is variadic.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > getParamTypes() const
ArrayRef< QualType > param_types() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
bool isExplicitSpecialization() const
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
unsigned getNumParams() const
SourceLocation getLocalRangeEnd() const
void setLocalRangeBegin(SourceLocation L)
void setLParenLoc(SourceLocation Loc)
void setParam(unsigned i, ParmVarDecl *VD)
ArrayRef< ParmVarDecl * > getParams() const
void setRParenLoc(SourceLocation Loc)
void setLocalRangeEnd(SourceLocation L)
void setExceptionSpecRange(SourceRange R)
SourceLocation getLocalRangeBegin() const
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
QualType getReturnType() const
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef getName() const
Return the actual identifier string.
void AddDecl(NamedDecl *D)
AddDecl - Link the decl to its shadowed decl chain.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitConceptSpecializationDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation SL, ArrayRef< TemplateArgument > ConvertedArgs)
Represents a C array with an unspecified size.
const TypeClass * getTypePtr() const
Describes an C or C++ initializer list.
Describes the kind of initialization being performed, along with location information for tokens rela...
static InitializationKind CreateForInit(SourceLocation Loc, bool DirectInit, Expr *Init)
Create an initialization from an initializer (which, for direct initialization from a parenthesized l...
Describes the sequence of initializations required to initialize a given object or reference with a s...
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence.
Describes an entity that is being initialized.
static InitializedEntity InitializeTemplateParameter(QualType T, NonTypeTemplateParmDecl *Param)
Create the initialization entity for a template parameter.
Wrapper for source info for injected class names of class templates.
The injected class name of a C++ class template or class template partial specialization.
CXXRecordDecl * getDecl() const
QualType getInjectedSpecializationType() const
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
An lvalue reference type, per C++11 [dcl.ref].
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Represents a linkage specification.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
NamedDecl * getPartiallySubstitutedPack(const TemplateArgument **ExplicitArgs=nullptr, unsigned *NumExplicitArgs=nullptr) const
Retrieve the partially-substitued template parameter pack.
void InstantiatedLocal(const Decl *D, Decl *Inst)
A class for iterating through a result set and possibly filtering out results.
void erase()
Erase the last element returned from this iterator.
Represents the results of name lookup.
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
@ NotFound
No entity found met the criteria.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
@ Found
Name lookup found a single declaration that met the criteria.
bool wasNotFoundInCurrentInstantiation() const
Determine whether no result was found because we could not search into dependent base classes of the ...
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
void setTemplateNameLookup(bool TemplateName)
Sets whether this is a template-name lookup.
DeclClass * getAsSingle() const
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool empty() const
Return true if no decls were found.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Filter makeFilter()
Create a filter for this result set.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
bool isSuppressingAmbiguousDiagnostics() const
Determines whether this lookup is suppressing ambiguous lookup diagnostics.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
DeclarationName getLookupName() const
Gets the name to look up.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
QualType getElementType() const
Returns type of the elements being stored in the matrix.
A pointer to member type per C++ 8.3.3 - Pointers to members.
QualType getPointeeType() const
const Type * getClass() const
Provides information a specialization of a member of a class template, which may be a member function...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
Data structure that captures multiple levels of template argument lists for use in template instantia...
void addOuterRetainedLevel()
Add an outermost level that we are not substituting.
void addOuterTemplateArguments(Decl *AssociatedDecl, ArgList Args, bool Final)
Add a new outmost level to the multi-level template argument list.
void setKind(TemplateSubstitutionKind K)
void addOuterRetainedLevels(unsigned Num)
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
NamedDecl * getMostRecentDecl()
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined.
bool hasLinkage() const
Determine whether this declaration has linkage.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
@ TypeSpec
A type, stored as a Type*.
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Identifier
An identifier, stored as an IdentifierInfo*.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace, stored as a NamespaceDecl*.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
void setDefaultArgument(Expr *DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
unsigned getDepth() const
Get the nesting depth of the template parameter.
void setPlaceholderTypeConstraint(Expr *E)
Interfaces are the core concept in Objective-C for object oriented design.
Represents a pointer to an Objective C object.
Represents a class type in Objective C.
static OpaquePtr make(TemplateName P)
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
A structure for storing the information associated with an overloaded template name.
NamedDecl *const * iterator
Represents a C++11 pack expansion that produces a sequence of expressions.
Represents a pack expansion of types.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
ParenExpr - This represents a parethesized expression, e.g.
Represents a parameter to a function.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
unsigned getFunctionScopeDepth() const
ParsedAttr - Represents a syntactic attribute.
Represents the parsed form of a C++ template argument.
KindType getKind() const
Determine what kind of template argument we have.
SourceLocation getLocation() const
Retrieve the location of the template argument.
ParsedTemplateTy getAsTemplate() const
Retrieve the template template argument's template name.
ParsedTemplateArgument getTemplatePackExpansion(SourceLocation EllipsisLoc) const
Retrieve a pack expansion of the given template template argument.
ParsedType getAsType() const
Retrieve the template type argument's type.
@ Type
A template type parameter, stored as a type.
@ Template
A template template argument, stored as a template name.
@ NonType
A non-type template parameter, stored as an expression.
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that makes a template template argument into a pack expansion.
Expr * getAsExpr() const
Retrieve the non-type template argument's expression.
const CXXScopeSpec & getScopeSpec() const
Retrieve the nested-name-specifier that precedes the template name in a template template argument.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
StringRef getImmediateMacroName(SourceLocation Loc)
Retrieve the name of the immediate macro expansion.
A (possibly-)qualified type.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
void * getAsOpaquePtr() const
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
The collection of all-type qualifiers we support.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
void setObjCLifetime(ObjCLifetime type)
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
Wrapper for source info for record types.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
void setMemberSpecialization()
Note that this member template is a specialization.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
Scope - A scope is a transient data structure that is used while parsing the program.
unsigned getFlags() const
getFlags - Return the flags for this scope.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
@ TemplateParamScope
This is a scope that corresponds to the template parameters of a C++ template.
RAII object used to change the argument pack substitution index within a Sema object.
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Whether and why a template name is required in this lookup.
SourceLocation getTemplateKeywordLoc() const
bool hasTemplateKeyword() const
A generic diagnostic builder for errors which may or may not be deferred.
Abstract base class used for diagnosing integer constant expression violations.
Sema - This implements semantic analysis and AST building for C.
bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a reachable definition.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
VarTemplateSpecializationDecl * BuildVarTemplateInstantiation(VarTemplateDecl *VarTemplate, VarDecl *FromVar, const TemplateArgumentList *PartialSpecArgs, const TemplateArgumentListInfo &TemplateArgsInfo, SmallVectorImpl< TemplateArgument > &Converted, SourceLocation PointOfInstantiation, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *StartingScope=nullptr)
bool SubstTypeConstraint(TemplateTypeParmDecl *Inst, const TypeConstraint *TC, const MultiLevelTemplateArgumentList &TemplateArgs, bool EvaluateConstraint)
DeclResult ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, CXXScopeSpec &SS, TemplateIdAnnotation &TemplateId, const ParsedAttributesView &Attr, MultiTemplateParamsArg TemplateParameterLists, SkipBodyInfo *SkipBody=nullptr)
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
CUDAFunctionTarget IdentifyCUDATarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false) const
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S',...
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
LookupNameKind
Describes the kind of name lookup to perform.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
ExprResult ActOnConstantExpression(ExprResult Res)
TemplateName SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs)
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, NamedDecl *PrevMemberDecl, AccessSpecifier LexicalAS)
SetMemberAccessSpecifier - Set the access specifier of a member.
bool BuildTypeConstraint(const CXXScopeSpec &SS, TemplateIdAnnotation *TypeConstraint, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc, bool AllowUnexpandedPack)
bool isTemplateTemplateParameterAtLeastAsSpecializedAs(TemplateParameterList *PParam, TemplateDecl *AArg, SourceLocation Loc)
bool diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC, DeclarationName Name, SourceLocation Loc, TemplateIdAnnotation *TemplateId, bool IsMemberSpecialization)
Diagnose a declaration whose declarator-id has the given nested-name-specifier.
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
NamedDecl * ActOnTemplateTemplateParameter(Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params, SourceLocation EllipsisLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg)
ActOnTemplateTemplateParameter - Called when a C++ template template parameter (e....
bool ActOnTypeConstraint(const CXXScopeSpec &SS, TemplateIdAnnotation *TypeConstraint, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is visible.
bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info)
DiagnoseClassNameShadow - Implement C++ [class.mem]p13: If T is the name of a class,...
void NoteAllFoundTemplates(TemplateName Name)
bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation, NamedDecl *Instantiation, bool InstantiatedFromMember, const NamedDecl *Pattern, const NamedDecl *PatternDef, TemplateSpecializationKind TSK, bool Complain=true)
Determine whether we would be unable to instantiate this template (because it either has no definitio...
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
void InstantiateClassTemplateSpecializationMembers(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK)
Instantiate the definitions of all of the members of the given class template specialization,...
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
bool TemplateParameterListsAreEqual(const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New, const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
TemplateArgumentLoc SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, Decl *Param, ArrayRef< TemplateArgument > SugaredConverted, ArrayRef< TemplateArgument > CanonicalConverted, bool &HasDefaultArg)
If the given template parameter has a default template argument, substitute into that default templat...
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
DeclResult ActOnVarTemplateSpecialization(Scope *S, Declarator &D, TypeSourceInfo *DI, LookupResult &Previous, SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, StorageClass SC, bool IsPartialSpecialization)
ClassTemplatePartialSpecializationDecl * getMoreSpecializedPartialSpecialization(ClassTemplatePartialSpecializationDecl *PS1, ClassTemplatePartialSpecializationDecl *PS2, SourceLocation Loc)
Returns the more specialized class template partial specialization according to the rules of partial ...
FunctionDecl * InstantiateFunctionDeclaration(FunctionTemplateDecl *FTD, const TemplateArgumentList *Args, SourceLocation Loc, CodeSynthesisContext::SynthesisKind CSC=CodeSynthesisContext::ExplicitTemplateArgumentSubstitution)
Instantiate (or find existing instantiation of) a function template with a given set of template argu...
void referenceDLLExportedClassMethods()
static NamedDecl * getAsTemplateNameDecl(NamedDecl *D, bool AllowFunctionTemplates=true, bool AllowDependent=true)
Try to interpret the lookup result D as a template-name.
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
TemplateParameterList * MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, ArrayRef< TemplateParameterList * > ParamLists, bool IsFriend, bool &IsMemberSpecialization, bool &Invalid, bool SuppressDiagnostic=false)
Match the given template parameter lists to the given scope specifier, returning the template paramet...
void AddAlignmentAttributesForRecord(RecordDecl *RD)
AddAlignmentAttributesForRecord - Adds any needed alignment attributes to a the record decl,...
bool RequireStructuralType(QualType T, SourceLocation Loc)
Require the given type to be a structural type, and diagnose if it is not.
ExprResult EvaluateConvertedConstantExpression(Expr *E, QualType T, APValue &Value, CCEKind CCE, bool RequireInt, const APValue &PreNarrowingValue)
EvaluateConvertedConstantExpression - Evaluate an Expression That is a converted constant expression ...
FPOptionsOverride CurFPFeatureOverrides()
ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, bool isAddressOfOperand, const TemplateArgumentListInfo *TemplateArgs)
ActOnDependentIdExpression - Handle a dependent id-expression that was just parsed.
bool hasVisibleExplicitSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a visible declaration of D that is an explicit specialization declaration for a...
bool IsInsideALocalClassWithinATemplateFunction()
Decl * ActOnTemplateDeclarator(Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
LateParsedTemplateMapT LateParsedTemplateMap
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
@ CTAK_Deduced
The template argument was deduced via template argument deduction.
void CheckTemplatePartialSpecialization(ClassTemplatePartialSpecializationDecl *Partial)
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization, bool Disambiguation=false)
ParsedTemplateArgument ActOnTemplateTypeArgument(TypeResult ParsedType)
Convert a parsed type into a parsed template argument.
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
bool ConstraintExpressionDependsOnEnclosingTemplate(const FunctionDecl *Friend, unsigned TemplateDepth, const Expr *Constraint)
bool CheckTemplatePartialSpecializationArgs(SourceLocation Loc, TemplateDecl *PrimaryTemplate, unsigned NumExplicitArgs, ArrayRef< TemplateArgument > Args)
Check the non-type template arguments of a class template partial specialization according to C++ [te...
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
DiagnosticsEngine & getDiagnostics() const
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
ExprResult BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
void propagateDLLAttrToBaseClassTemplate(CXXRecordDecl *Class, Attr *ClassAttr, ClassTemplateSpecializationDecl *BaseTemplateSpec, SourceLocation BaseLoc)
Perform propagation of DLL attributes from a derived class to a templated base class for MS compatibi...
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over....
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
void checkSpecializationReachability(SourceLocation Loc, NamedDecl *Spec)
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
ASTContext & getASTContext() const
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd, TemplateSpecCandidateSet &FailedCandidates, SourceLocation Loc, const PartialDiagnostic &NoneDiag, const PartialDiagnostic &AmbigDiag, const PartialDiagnostic &CandidateDiag, bool Complain=true, QualType TargetType=QualType())
Retrieve the most specialized of the given function template specializations.
bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
IsIntegralPromotion - Determines whether the conversion from the expression From (whose potentially-a...
TypeSourceInfo * SubstType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, bool AllowDeducedTST=false)
Perform substitution on the type T with a given set of template arguments.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given variable from its template.
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
bool isAcceptableTagRedeclaration(const TagDecl *Previous, TagTypeKind NewTag, bool isDefinition, SourceLocation NewTagLoc, const IdentifierInfo *Name)
Determine whether a tag with a given kind is acceptable as a redeclaration of the given tag declarati...
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
unsigned NumSFINAEErrors
The number of SFINAE diagnostics that have been trapped.
TemplateParameterListEqualKind
Enumeration describing how template parameter lists are compared for equality.
@ TPL_TemplateTemplateParmMatch
We are matching the template parameter lists of two template template parameters as part of matching ...
@ TPL_TemplateTemplateArgumentMatch
We are matching the template parameter lists of a template template argument against the template par...
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
@ TPL_TemplateParamsEquivalent
We are determining whether the template-parameters are equivalent according to C++ [temp....
NamedDecl * ActOnTypeParameter(Scope *S, bool Typename, SourceLocation EllipsisLoc, SourceLocation KeyLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedType DefaultArg, bool HasTypeConstraint)
ActOnTypeParameter - Called when a C++ template type parameter (e.g., "typename T") has been parsed.
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
@ FoundFunctions
This is assumed to be a template name because lookup found one or more functions (but no function tem...
@ None
This is not assumed to be a template name.
@ FoundNothing
This is assumed to be a template name because lookup found nothing.
bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain=true)
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
FunctionTemplateDecl * DeclareImplicitDeductionGuideFromInitList(TemplateDecl *Template, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc)
ArrayRef< InventedTemplateParameterInfo > getInventedParameterInfos() const
void inferGslOwnerPointerAttribute(CXXRecordDecl *Record)
Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
FPOptions & getCurFPFeatures()
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
bool EnsureTemplateArgumentListConstraints(TemplateDecl *Template, const MultiLevelTemplateArgumentList &TemplateArgs, SourceRange TemplateIDRange)
Ensure that the given template arguments satisfy the constraints associated with the given template,...
@ UPPC_PartialSpecialization
Partial specialization.
@ UPPC_DefaultArgument
A default argument.
@ UPPC_ExplicitSpecialization
Explicit specialization.
@ UPPC_NonTypeTemplateParameterType
The type of a non-type template parameter.
@ UPPC_TypeConstraint
A type constraint.
const LangOptions & getLangOpts() const
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl, bool SupportedForCompatibility=false)
DiagnoseTemplateParameterShadow - Produce a diagnostic complaining that the template parameter 'PrevD...
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
bool RebuildTemplateParamsInCurrentInstantiation(TemplateParameterList *Params)
Rebuild the template parameters now that we know we're in a current instantiation.
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
void NoteTemplateLocation(const NamedDecl &Decl, std::optional< SourceRange > ParamRange={})
ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, std::optional< unsigned > NumExpansions)
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool hasVisibleMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a visible declaration of D that is a member specialization declaration (as oppo...
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
void checkClassLevelDLLAttribute(CXXRecordDecl *Class)
Check class-level dllimport/dllexport attribute.
bool CheckConstraintSatisfaction(const NamedDecl *Template, ArrayRef< const Expr * > ConstraintExprs, const MultiLevelTemplateArgumentList &TemplateArgLists, SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction)
Check whether the given list of constraint expressions are satisfied (as if in a 'conjunction') given...
const LangOptions & LangOpts
void InstantiateClassMembers(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK)
Instantiates the definitions of all of the member of the given class, which is an instantiation of a ...
std::pair< Expr *, std::string > findFailedBooleanCondition(Expr *Cond)
Find the failed Boolean condition within a given Boolean constant expression, and describe it with a ...
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc, TypeSourceInfo **TSI, bool DeducedTSTContext)
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
bool hasAnyAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true, bool AllowNonTemplateFunctions=false)
ExprResult BuildConvertedConstantExpression(Expr *From, QualType T, CCEKind CCE, NamedDecl *Dest=nullptr)
bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD, const TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given dependent function template specialization.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, const CXXScopeSpec &SS, QualType T, TagDecl *OwnedTagDecl=nullptr)
Retrieve a version of the type 'T' that is elaborated by Keyword, qualified by the nested-name-specif...
bool hasExplicitCallingConv(QualType T)
Decl * ActOnConceptDefinition(Scope *S, MultiTemplateParamsArg TemplateParameterLists, IdentifierInfo *Name, SourceLocation NameLoc, Expr *ConstraintExpr)
NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK)
Given a non-tag type declaration, returns an enum useful for indicating what kind of non-tag type thi...
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg, SmallVectorImpl< TemplateArgument > &SugaredConverted, SmallVectorImpl< TemplateArgument > &CanonicalConverted)
bool AreConstraintExpressionsEqual(const NamedDecl *Old, const Expr *OldConstr, const TemplateCompareNewDeclInfo &New, const Expr *NewConstr)
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
void AddPushedVisibilityAttribute(Decl *RD)
AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, add an appropriate visibility at...
std::optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic(NamedDecl *D1, ArrayRef< const Expr * > AC1, NamedDecl *D2, ArrayRef< const Expr * > AC2)
If D1 was not at least as constrained as D2, but would've been if a pair of atomic constraints involv...
ExprResult DefaultLvalueConversion(Expr *E)
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
void NoteOverloadCandidate(const NamedDecl *Found, const FunctionDecl *Fn, OverloadCandidateRewriteKind RewriteKind=OverloadCandidateRewriteKind(), QualType DestType=QualType(), bool TakingAddress=false)
bool hasReachableDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a reachable default argument.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
@ ForVisibleRedeclaration
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5.
DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false) const
If AllowLambda is true, treat lambda as function.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
bool CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, TemplateSpecializationKind ActOnExplicitInstantiationNewTSK, NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK, SourceLocation PrevPtOfInstantiation, bool &SuppressNew)
Diagnose cases where we have an explicit template specialization before/after an explicit template in...
bool CheckTypeConstraint(TemplateIdAnnotation *TypeConstraint)
TemplateNameKind ActOnTemplateName(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool AllowInjectedClassName=false)
Form a template name from a name that is syntactically required to name a template,...
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
void diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName, SourceLocation Less, SourceLocation Greater)
void DeclareImplicitDeductionGuides(TemplateDecl *Template, SourceLocation Loc)
Declare implicit deduction guides for a class template if we've not already done so.
ExprResult FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
bool CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param, TemplateParameterList *Params, TemplateArgumentLoc &Arg)
Check a template argument against its corresponding template template parameter.
DeclResult CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation TemplateNameLoc, const TemplateArgumentListInfo &TemplateArgs)
Get the specialization of the given variable template corresponding to the specified argument list,...
RedeclarationKind forRedeclarationInCurContext() const
Decl * SubstDecl(Decl *D, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs)
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
TypeResult ActOnTemplateIdType(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, IdentifierInfo *TemplateII, SourceLocation TemplateIILoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false, bool IsClassName=false, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No)
QualType CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI, SourceLocation Loc)
Check that the type of a non-type template parameter is well-formed.
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
void diagnoseMissingImport(SourceLocation Loc, const NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
void FilterAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true)
TypeSourceInfo * SubstAutoTypeSourceInfoDependent(TypeSourceInfo *TypeWithAuto)
bool IsAtLeastAsConstrained(NamedDecl *D1, MutableArrayRef< const Expr * > AC1, NamedDecl *D2, MutableArrayRef< const Expr * > AC2, bool &Result)
Check whether the given declaration's associated constraints are at least as constrained than another...
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams)
Check whether a template can be declared within this scope.
void AddMsStructLayoutForRecord(RecordDecl *RD)
AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
TemplateParameterList * SubstTemplateParams(TemplateParameterList *Params, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs, bool EvaluateConstraints=true)
SourceLocation getTopMostPointOfInstantiation(const NamedDecl *) const
Returns the top most location responsible for the definition of N.
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion.
void ActOnUndeclaredTypeTemplateName(Scope *S, TemplateTy &Name, TemplateNameKind &TNK, SourceLocation NameLoc, IdentifierInfo *&II)
Try to resolve an undeclared template name as a type template.
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
Perform semantic analysis for the given non-template member specialization.
TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS, const IdentifierInfo &II, SourceLocation IdLoc, ImplicitTypenameContext IsImplicitTypename=ImplicitTypenameContext::No)
Called when the parser has parsed a C++ typename specifier, e.g., "typename T::type".
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
bool InstantiateClass(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK, bool Complain=true)
Instantiate the definition of a class from a given pattern.
bool hasReachableMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a reachable declaration of D that is a member specialization declaration (as op...
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, ConceptDecl *NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, FunctionDecl *Function, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given function from its template.
@ CCEK_TemplateArg
Value of a non-type template parameter.
void InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
void MarkUnusedFileScopedDecl(const DeclaratorDecl *D)
If it's a file scoped decl that must warn if not used, keep track of it.
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs, SmallVectorImpl< TemplateArgument > &SugaredConverted, SmallVectorImpl< TemplateArgument > &CanonicalConverted, bool UpdateArgsWithConversions=true, bool *ConstraintsNotSatisfied=nullptr)
Check that the given template arguments can be provided to the given template, converting the argumen...
void inheritCUDATargetAttrs(FunctionDecl *FD, const FunctionTemplateDecl &TD)
Copies target attributes from the template TD to the function FD.
void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
Mark which template parameters are used in a given expression.
DeclResult ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS, TemplateTy Template, SourceLocation TemplateNameLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, const ParsedAttributesView &Attr)
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
QualType BuildDecltypeType(Expr *E, bool AsUnevaluated=true)
If AsUnevaluated is false, E is treated as though it were an evaluated context, such as when building...
ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, bool IsTemplateParamOrArg, OffsetOfKind OOK, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, SmallVectorImpl< TemplateArgument > &SugaredConverted, SmallVectorImpl< TemplateArgument > &CanonicalConverted, CheckTemplateArgumentKind CTAK)
Check that the given template argument corresponds to the given template parameter.
NestedNameSpecifierLoc SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const MultiLevelTemplateArgumentList &TemplateArgs)
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
bool LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType, bool EnteringContext, bool &MemberOfUnknownSpecialization, RequiredTemplateKind RequiredTemplate=SourceLocation(), AssumedTemplateKind *ATK=nullptr, bool AllowTypoCorrection=true)
void makeMergedDefinitionVisible(NamedDecl *ND)
Make a merged definition of an existing hidden definition ND visible at the specified location.
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
bool hasReachableExplicitSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a reachable declaration of D that is an explicit specialization declaration for...
bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name, SourceLocation NameLoc, CXXScopeSpec &SS, ParsedTemplateTy *Template=nullptr)
Determine whether a particular identifier might be the name in a C++1z deduction-guide declaration.
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
NamedDecl * ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, unsigned Depth, unsigned Position, SourceLocation EqualLoc, Expr *DefaultArg)
void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc)
void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D)
Common checks for a parameter-declaration that should apply to both function parameters and non-type ...
TemplateParamListContext
The context in which we are checking a template parameter list.
@ TPC_FriendFunctionTemplate
@ TPC_ClassTemplateMember
@ TPC_FriendClassTemplate
@ TPC_FriendFunctionTemplateDefinition
void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a templated declaration that would trigger an implicit instantiation.
void FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S, bool ConsiderLinkage, bool AllowInlineNamespace)
Filters out lookup results that don't fall within the given scope as determined by isDeclInScope.
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, ArrayRef< TemplateArgument > TemplateArgs, sema::TemplateDeductionInfo &Info)
Perform template argument deduction to determine whether the given template arguments match the given...
bool resolveAssumedTemplateNameAsType(Scope *S, TemplateName &Name, SourceLocation NameLoc, bool Diagnose=true)
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
Finds the scope corresponding to the given decl context, if it happens to be an enclosing scope.
ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs)
sema::LambdaScopeInfo * getEnclosingLambda() const
Get the innermost lambda enclosing the current location, if any.
void CheckConceptRedefinition(ConceptDecl *NewDecl, LookupResult &Previous, bool &AddToScope)
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC, SkipBodyInfo *SkipBody=nullptr)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
bool isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl *T, sema::TemplateDeductionInfo &Info)
void ProcessAPINotes(Decl *D)
Map any API notes provided for this declaration to attributes on the declaration.
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments.
bool CheckRedeclarationInModule(NamedDecl *New, NamedDecl *Old)
bool SubstTemplateArgument(const TemplateArgumentLoc &Input, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentLoc &Output)
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
unsigned getTemplateDepth(Scope *S) const
Determine the number of levels of enclosing template parameters.
TemplateDeductionResult DeduceAutoType(TypeLoc AutoTypeLoc, Expr *Initializer, QualType &Result, sema::TemplateDeductionInfo &Info, bool DependentDeduction=false, bool IgnoreConstraints=false, TemplateSpecCandidateSet *FailedTSC=nullptr)
Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
QualType adjustCCAndNoReturn(QualType ArgFunctionType, QualType FunctionType, bool AdjustExceptionSpec=false)
Adjust the type ArgFunctionType to match the calling convention, noreturn, and optionally the excepti...
void NoteTemplateParameterLocation(const NamedDecl &Decl)
IdentifierResolver IdResolver
ArrayRef< sema::FunctionScopeInfo * > getFunctionScopes() const
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD)
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
TypeResult ActOnTagTemplateIdType(TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc)
Parsed an elaborated-type-specifier that refers to a template-id, such as class T::template apply.
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(const NamedDecl *D, const DeclContext *DC=nullptr, bool Final=false, std::optional< ArrayRef< TemplateArgument > > Innermost=std::nullopt, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr, bool ForConstraintInstantiation=false, bool SkipForSpecialization=false)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
bool hasReachableDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is reachable.
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
bool DiagnoseUnexpandedParameterPacks(SourceLocation Loc, UnexpandedParameterPackContext UPPC, ArrayRef< UnexpandedParameterPack > Unexpanded)
Diagnose unexpanded parameter packs.
void warnOnReservedIdentifier(const NamedDecl *D)
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Represents the result of substituting a set of types for a template type parameter pack.
TemplateArgument getArgumentPack() const
Represents the result of substituting a type for a template type parameter.
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
Represents the declaration of a struct/union/class/enum.
StringRef getKindName() const
void startDefinition()
Starts the definition of this tag declaration.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type?
TagKind getTagKind() const
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
virtual bool shouldDLLImportComdatSymbols() const
Does this target aim for semantic compatibility with Microsoft C++ code using dllimport/export attrib...
A convenient class for passing around template argument information.
SourceLocation getRAngleLoc() const
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
SourceLocation getLAngleLoc() const
A template argument list.
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Location wrapper for a TemplateArgument.
SourceLocation getLocation() const
SourceLocation getTemplateEllipsisLoc() const
const TemplateArgument & getArgument() const
SourceLocation getTemplateNameLoc() const
TypeSourceInfo * getTypeSourceInfo() const
SourceRange getSourceRange() const LLVM_READONLY
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Expr * getSourceExpression() const
Represents a template argument.
QualType getStructuralValueType() const
Get the type of a StructuralValue.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
bool isNull() const
Determine whether this template argument has no value.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
void print(const PrintingPolicy &Policy, raw_ostream &Out, bool IncludeType) const
Print this template argument to the given output stream.
QualType getIntegralType() const
Retrieve the type of the integral value.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
The base class of all kinds of template declarations (e.g., class, function, etc.).
bool hasAssociatedConstraints() const
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
Get the total constraint-expression associated with this template, including constraint-expressions d...
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
bool isNull() const
Determine whether this template name is NULL.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
AssumedTemplateStorage * getAsAssumedTemplateName() const
Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...
UsingShadowDecl * getAsUsingShadowDecl() const
Retrieve the using shadow declaration through which the underlying template declaration is introduced...
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
SourceRange getSourceRange() const LLVM_READONLY
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
bool hasAssociatedConstraints() const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
NamedDecl *const * const_iterator
Iterates through the template parameters in this list.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
All associated constraints derived from this template parameter list, including the requires clause a...
static bool shouldIncludeTypeForArgument(const PrintingPolicy &Policy, const TemplateParameterList *TPL, unsigned Idx)
SourceLocation getTemplateLoc() const
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
void NoteCandidates(Sema &S, SourceLocation Loc)
NoteCandidates - When no template specialization match is found, prints diagnostic messages containin...
SourceLocation getLocation() const
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set.
unsigned getNumArgs() const
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
void setTemplateKeywordLoc(SourceLocation Loc)
TemplateArgumentLoc getArgLoc(unsigned i) const
void setTemplateNameLoc(SourceLocation Loc)
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
Represents a type template specialization; the template must be a class template, a type alias templa...
ArrayRef< TemplateArgument > template_arguments() const
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, ArrayRef< TemplateArgument > Converted)
Determine whether any of the given template arguments are dependent.
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
void setInheritedDefaultArgument(const ASTContext &C, TemplateTemplateParmDecl *Prev)
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
unsigned getDepth() const
Get the nesting depth of the template parameter.
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params)
void removeDefaultArgument()
Removes the default argument of this template parameter.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Declaration of a template type parameter.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
unsigned getIndex() const
Retrieve the index of the template parameter.
bool hasTypeConstraint() const
Determine whether this template parameter has a type-constraint.
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, std::optional< unsigned > NumExpanded=std::nullopt)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool isExpandedParameterPack() const
Whether this parameter is a template type parameter pack that has a known list of different type-cons...
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
bool isParameterPack() const
Returns whether this is a parameter pack.
unsigned getDepth() const
Retrieve the depth of the template parameter.
void setTypeConstraint(ConceptReference *CR, Expr *ImmediatelyDeclaredConstraint)
unsigned getNumExpansionParameters() const
Retrieves the number of parameters in an expanded parameter pack.
Wrapper for template type parameters.
TemplateTypeParmDecl * getDecl() const
TemplateTypeParmDecl * getDecl() const
unsigned getIndex() const
unsigned getDepth() const
Represents the declaration of a typedef-name via a C++11 alias-declaration.
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
Declaration of an alias template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Represents a declaration of a type.
const Type * getTypeForDecl() const
SourceLocation getBeginLoc() const LLVM_READONLY
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
QualType getType() const
Get the type for which this source info wrapper provides information.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
AutoTypeLoc getContainedAutoTypeLoc() const
Get the typeloc of an AutoType whose type will be deduced for a variable with an initializer of this ...
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
SourceLocation getBeginLoc() const
Get the begin source location.
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
QualType getUnmodifiedType() const
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier.
SourceLocation getNameLoc() const
void setNameLoc(SourceLocation Loc)
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
The base class of the type hierarchy.
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBooleanType() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
bool isRValueReferenceType() const
bool isVoidPointerType() const
bool isPointerType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() const
bool isScalarType() const
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
const Type * getArrayElementTypeNoTypeQual() const
If this is an array type, return the element type of the array, potentially with type qualifiers miss...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
bool isObjCObjectOrInterfaceType() const
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isLValueReferenceType() const
bool isBitIntType() const
bool isStructuralType() const
Determine if this type is a structural type, per C++20 [temp.param]p7.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isChar16Type() const
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
QualType getCanonicalTypeInternal() const
bool isMemberPointerType() const
bool isChar32Type() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool hasUnnamedOrLocalType() const
Whether this type is or contains a local or unnamed type.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isFunctionType() const
bool isVectorType() const
bool isWideCharType() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
bool isRecordType() const
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
Base class for declarations which introduce a typedef-name.
TypeSourceInfo * getTypeSourceInfo() const
QualType getUnderlyingType() const
Wrapper for source info for typedefs.
TypedefNameDecl * getTypedefNameDecl() const
Simple class containing the result of Sema::CorrectTypo.
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
DeclClass * getCorrectionDeclAs() const
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Represents a C++ unqualified-id that has been parsed.
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
void addDecl(NamedDecl *D)
The iterator over UnresolvedSets.
A set of unresolved declarations.
Represents the dependent type named by a dependently-scoped typename using declaration,...
Represents a dependent using declaration which was not marked with typename.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
Represents a variable declaration or definition.
TLSKind getTLSKind() const
bool isStaticDataMember() const
Determines whether this is a static data member.
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization,...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template,...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization,...
Declaration of a variable template.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
void setMemberSpecialization()
Note that this member template is a specialization.
static VarTemplatePartialSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos)
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
Represents a variable template specialization, which refers to a variable template with a given set o...
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
Represents a C array with a specified size that is not an integer-constant-expression.
Represents a GCC generic vector type.
QualType getElementType() const
Retains information about a function, method, or block that is currently being parsed.
Provides information about an attempted template argument deduction, whose success or failure was des...
TemplateArgumentList * takeCanonical()
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
TypeSpecifierType
Specifies the kind of type.
bool isa(CodeGen::Address addr)
@ Rewrite
We are substituting template parameters for (typically) other template parameters in order to rewrite...
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
@ IK_TemplateId
A template-id, e.g., f<int>.
@ IK_LiteralOperatorId
A user-defined literal name, e.g., operator "" _i.
@ IK_Identifier
An identifier.
@ IK_OperatorFunctionId
An overloaded operator name, e.g., operator+.
StorageClass
Storage classes.
@ CRK_None
Candidate is not a rewritten candidate.
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
@ Result
The result type of a method or function.
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
ActionResult< Expr * > ExprResult
TagTypeKind
The kind of a tag type.
@ Enum
The "enum" keyword.
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
@ BTK__type_pack_element
This names the __type_pack_element BuiltinTemplateDecl.
@ BTK__make_integer_seq
This names the __make_integer_seq BuiltinTemplateDecl.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
CastKind
CastKind - The kind of operation required for a conversion.
std::optional< unsigned > getExpandedPackSize(const NamedDecl *Param)
Check whether the template parameter is a pack expansion, and if so, determine the number of paramete...
SourceRange getTemplateParamsRange(TemplateParameterList const *const *Params, unsigned NumParams)
Retrieves the range of the given template parameter lists.
bool isSubstitutedDefaultArgument(ASTContext &Ctx, TemplateArgument Arg, const NamedDecl *Param, ArrayRef< TemplateArgument > Args, unsigned Depth)
Make a best-effort determination of whether the type T can be produced by substituting Args into the ...
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
@ TNK_Var_template
The name refers to a variable template whose specialization produces a variable.
@ TNK_Type_template
The name refers to a template whose specialization produces a type.
@ TNK_Dependent_template_name
The name refers to a dependent template name:
@ TNK_Function_template
The name refers to a function template or a set of overloaded functions that includes at least one fu...
@ TNK_Concept_template
The name refers to a concept.
@ TNK_Non_template
The name does not refer to a template.
@ TNK_Undeclared_template
Lookup for the name failed, but we're assuming it was a template name anyway.
ActionResult< ParsedType > TypeResult
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy, const TemplateParameterList *TPL=nullptr)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
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.
@ ConstraintsNotSatisfied
The deduced arguments did not satisfy the constraints associated with the template.
@ CUDATargetMismatch
CUDA Target attributes do not match.
@ Success
Template argument deduction was successful.
@ AlreadyDiagnosed
Some error which was already diagnosed.
ActionResult< Decl * > DeclResult
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
@ None
No keyword precedes the qualified type name.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
@ Parens
New-expression has a C++98 paren-delimited initializer.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
bool HasSideEffects
Whether the evaluated expression has side effects.
Extra information about a function prototype.
unsigned HasTrailingReturn
Describes how types, statements, expressions, and declarations should be printed.
unsigned PrintCanonicalTypes
Whether to print types as written or canonically.
unsigned TerseOutput
Provide a 'terse' output.
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
@ BuildingDeductionGuides
We are building deduction guides for a class.
A stack object to be created when performing template instantiation.
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
Location information for a TemplateArgument.
Information about a template-id annotation token.
unsigned NumArgs
NumArgs - The number of template arguments.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
Contains all information for a given match.