40 #include "llvm/ADT/BitVector.h"
41 #include "llvm/ADT/SmallBitVector.h"
42 #include "llvm/ADT/SmallString.h"
43 #include "llvm/ADT/StringExtras.h"
47 using namespace clang;
55 return SourceRange(Ps[0]->getTemplateLoc(), Ps[N-1]->getRAngleLoc());
63 for (
Scope *TempParamScope = S->getTemplateParamParent(); TempParamScope;
64 TempParamScope = TempParamScope->getParent()->getTemplateParamParent()) {
74 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(FSI)) {
75 if (!LSI->TemplateParams.empty()) {
76 ParamsAtDepth(LSI->AutoTemplateParameterDepth);
79 if (LSI->GLTemplateParameterList) {
80 ParamsAtDepth(LSI->GLTemplateParameterList->getDepth());
89 getInventedParameterInfos()) {
90 if (!Info.TemplateParams.empty()) {
91 ParamsAtDepth(Info.AutoTemplateParameterDepth);
106 bool AllowFunctionTemplates,
107 bool AllowDependent) {
108 D =
D->getUnderlyingDecl();
110 if (isa<TemplateDecl>(
D)) {
111 if (!AllowFunctionTemplates && isa<FunctionTemplateDecl>(
D))
117 if (
const auto *
Record = dyn_cast<CXXRecordDecl>(
D)) {
129 if (
Record->isInjectedClassName()) {
131 if (
Record->getDescribedClassTemplate())
132 return Record->getDescribedClassTemplate();
134 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(
Record))
135 return Spec->getSpecializedTemplate();
144 if (AllowDependent && isa<UnresolvedUsingValueDecl>(
D))
151 bool AllowFunctionTemplates,
152 bool AllowDependent) {
156 if (!getAsTemplateNameDecl(Orig, AllowFunctionTemplates, AllowDependent))
163 bool AllowFunctionTemplates,
165 bool AllowNonTemplateFunctions) {
167 if (getAsTemplateNameDecl(*I, AllowFunctionTemplates, AllowDependent))
169 if (AllowNonTemplateFunctions &&
170 isa<FunctionDecl>((*I)->getUnderlyingDecl()))
179 bool hasTemplateKeyword,
182 bool EnteringContext,
184 bool &MemberOfUnknownSpecialization,
185 bool Disambiguation) {
186 assert(getLangOpts().
CPlusPlus &&
"No template names in C!");
189 MemberOfUnknownSpecialization =
false;
191 switch (Name.getKind()) {
198 Name.OperatorFunctionId.Operator);
212 LookupResult R(*
this, TName, Name.getBeginLoc(), LookupOrdinaryName);
213 if (LookupTemplateName(R, S, SS, ObjectType, EnteringContext,
225 return AssumedTemplate == AssumedTemplateKind::FoundNothing
238 bool AnyFunctionTemplates =
false;
240 if (
NamedDecl *FoundTemplate = getAsTemplateNameDecl(FoundD)) {
241 if (isa<FunctionTemplateDecl>(FoundTemplate))
242 AnyFunctionTemplates =
true;
245 FoundUsingShadow = dyn_cast<UsingShadowDecl>(FoundD);
253 if (!
D && !AnyFunctionTemplates) {
254 R.suppressDiagnostics();
261 FilterAcceptableTemplateNames(R);
271 unsigned ResultCount = R.
end() - R.
begin();
272 if (!
D && ResultCount > 1) {
282 D = getAsTemplateNameDecl(*R.
begin());
283 assert(
D &&
"unambiguous result is not a template name");
286 if (isa<UnresolvedUsingValueDecl>(
D)) {
288 MemberOfUnknownSpecialization =
true;
295 assert(!FoundUsingShadow || FoundUsingShadow->
getTargetDecl() == TD);
302 if (isa<FunctionTemplateDecl>(TD)) {
308 assert(isa<ClassTemplateDecl>(TD) || isa<TemplateTemplateParmDecl>(TD) ||
309 isa<TypeAliasTemplateDecl>(TD) || isa<VarTemplateDecl>(TD) ||
310 isa<BuiltinTemplateDecl>(TD) || isa<ConceptDecl>(TD));
318 TemplateResult = TemplateTy::make(Template);
329 if (LookupTemplateName(R, S, SS,
QualType(),
333 if (R.
empty())
return false;
349 *Template = TemplateTy::make(Name);
363 if (!SS || !SS->
isSet() || !isDependentScopeSpecifier(*SS) ||
364 computeDeclContext(*SS))
370 Diag(IILoc, diag::err_template_kw_missing)
380 QualType ObjectType,
bool EnteringContext,
383 bool AllowTypoCorrection) {
390 Found.setTemplateNameLookup(
true);
394 bool IsDependent =
false;
395 if (!ObjectType.
isNull()) {
398 assert(SS.
isEmpty() &&
"ObjectType and scope specifier cannot coexist");
399 LookupCtx = computeDeclContext(ObjectType);
404 "Caller should have completed object type");
428 LookupCtx = computeDeclContext(SS, EnteringContext);
429 IsDependent = !LookupCtx && isDependentScopeSpecifier(SS);
432 if (LookupCtx && RequireCompleteDeclContext(SS, LookupCtx))
436 bool ObjectTypeSearchedInScope =
false;
437 bool AllowFunctionTemplatesInLookup =
true;
443 LookupQualifiedName(
Found, LookupCtx);
453 IsDependent |=
Found.wasNotFoundInCurrentInstantiation();
467 LookupName(
Found, S);
469 if (!ObjectType.
isNull()) {
473 AllowFunctionTemplatesInLookup =
false;
474 ObjectTypeSearchedInScope =
true;
477 IsDependent |=
Found.wasNotFoundInCurrentInstantiation();
480 if (
Found.isAmbiguous())
494 getLangOpts().CPlusPlus20 && llvm::all_of(
Found, [](
NamedDecl *ND) {
497 if (AllFunctions || (
Found.empty() && !IsDependent)) {
501 *ATK = (
Found.empty() &&
Found.getLookupName().isIdentifier())
502 ? AssumedTemplateKind::FoundNothing
503 : AssumedTemplateKind::FoundFunctions;
509 if (
Found.empty() && !IsDependent && AllowTypoCorrection) {
517 FilterCCC.WantExpressionKeywords =
false;
518 FilterCCC.WantRemainingKeywords =
false;
519 FilterCCC.WantCXXNamedCasts =
true;
521 CorrectTypo(
Found.getLookupNameInfo(),
Found.getLookupKind(), S,
522 &SS, FilterCCC, CTK_ErrorRecovery, LookupCtx)) {
523 if (
auto *ND = Corrected.getFoundDecl())
525 FilterAcceptableTemplateNames(
Found);
526 if (
Found.isAmbiguous()) {
528 }
else if (!
Found.empty()) {
529 Found.setLookupName(Corrected.getCorrection());
531 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
532 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
533 Name.getAsString() == CorrectedStr;
534 diagnoseTypo(Corrected, PDiag(diag::err_no_member_template_suggest)
535 << Name << LookupCtx << DroppedSpecifier
538 diagnoseTypo(Corrected, PDiag(diag::err_no_template_suggest) << Name);
545 Found.empty() ? nullptr :
Found.getRepresentativeDecl();
546 FilterAcceptableTemplateNames(
Found, AllowFunctionTemplatesInLookup);
549 Found.setNotFoundInCurrentInstantiation();
555 if (ExampleLookupResult && RequiredTemplate) {
556 Diag(
Found.getNameLoc(), diag::err_template_kw_refers_to_non_template)
561 diag::note_template_kw_refers_to_non_template)
562 <<
Found.getLookupName();
569 if (S && !ObjectType.
isNull() && !ObjectTypeSearchedInScope &&
580 LookupName(FoundOuter, S);
583 FilterAcceptableTemplateNames(FoundOuter,
false);
586 if (FoundOuter.
empty()) {
596 }
else if (!
Found.isSuppressingAmbiguousDiagnostics()) {
600 if (!
Found.isSingleResult() ||
601 getAsTemplateNameDecl(
Found.getFoundDecl())->getCanonicalDecl() !=
604 diag::ext_nested_name_member_ref_lookup_ambiguous)
605 <<
Found.getLookupName()
607 Diag(
Found.getRepresentativeDecl()->getLocation(),
608 diag::note_ambig_member_ref_object_type)
611 diag::note_ambig_member_ref_scope);
634 bool MissingTemplateKeyword =
false;
637 if (
auto *DRE = dyn_cast<DeclRefExpr>(
TemplateName.get())) {
638 NameInfo = DRE->getNameInfo();
639 SS.
Adopt(DRE->getQualifierLoc());
640 LookupKind = LookupOrdinaryName;
641 Found = DRE->getFoundDecl();
642 }
else if (
auto *ME = dyn_cast<MemberExpr>(
TemplateName.get())) {
643 NameInfo = ME->getMemberNameInfo();
644 SS.
Adopt(ME->getQualifierLoc());
645 LookupKind = LookupMemberName;
646 LookupCtx = ME->getBase()->getType()->getAsCXXRecordDecl();
647 Found = ME->getMemberDecl();
648 }
else if (
auto *DSDRE =
649 dyn_cast<DependentScopeDeclRefExpr>(
TemplateName.get())) {
650 NameInfo = DSDRE->getNameInfo();
651 SS.
Adopt(DSDRE->getQualifierLoc());
652 MissingTemplateKeyword =
true;
653 }
else if (
auto *DSME =
654 dyn_cast<CXXDependentScopeMemberExpr>(
TemplateName.get())) {
655 NameInfo = DSME->getMemberNameInfo();
656 SS.
Adopt(DSME->getQualifierLoc());
657 MissingTemplateKeyword =
true;
659 llvm_unreachable(
"unexpected kind of potential template name");
664 if (MissingTemplateKeyword) {
673 TemplateCandidateFilter(
Sema &S) : S(S) {
674 WantTypeSpecifiers =
false;
675 WantExpressionKeywords =
false;
676 WantRemainingKeywords =
false;
677 WantCXXNamedCasts =
true;
679 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
685 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
686 return std::make_unique<TemplateCandidateFilter>(*
this);
691 TemplateCandidateFilter CCC(*
this);
692 if (
TypoCorrection Corrected = CorrectTypo(NameInfo, LookupKind, S, &SS, CCC,
693 CTK_ErrorRecovery, LookupCtx)) {
694 auto *ND = Corrected.getFoundDecl();
696 ND = getAsTemplateNameDecl(ND);
697 if (ND || Corrected.isKeyword()) {
699 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
700 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
701 Name.getAsString() == CorrectedStr;
702 diagnoseTypo(Corrected,
703 PDiag(diag::err_non_template_in_member_template_id_suggest)
704 << Name << LookupCtx << DroppedSpecifier
707 diagnoseTypo(Corrected,
708 PDiag(diag::err_non_template_in_template_id_suggest)
713 diag::note_non_template_in_template_id_found);
718 Diag(NameInfo.
getLoc(), diag::err_non_template_in_template_id)
721 Diag(
Found->getLocation(), diag::note_non_template_in_template_id_found);
728 bool isAddressOfOperand,
735 QualType ThisType = getCurrentThisType();
740 Context,
nullptr, ThisType,
744 nullptr, NameInfo, TemplateArgs);
746 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
756 return CreateRecoveryExpr(
767 bool InstantiatedFromMember,
772 assert(isa<TagDecl>(Instantiation) || isa<FunctionDecl>(Instantiation) ||
773 isa<VarDecl>(Instantiation));
775 bool IsEntityBeingDefined =
false;
776 if (
const TagDecl *TD = dyn_cast_or_null<TagDecl>(PatternDef))
777 IsEntityBeingDefined = TD->isBeingDefined();
779 if (PatternDef && !IsEntityBeingDefined) {
781 if (!hasReachableDefinition(
const_cast<NamedDecl *
>(PatternDef),
785 bool Recover = Complain && !isSFINAEContext();
787 diagnoseMissingImport(PointOfInstantiation, SuggestedDef,
794 if (!Complain || (PatternDef && PatternDef->
isInvalidDecl()))
798 if (
TagDecl *TD = dyn_cast<TagDecl>(Instantiation))
801 Diag(PointOfInstantiation,
802 diag::err_template_instantiate_within_definition)
808 }
else if (InstantiatedFromMember) {
809 if (isa<FunctionDecl>(Instantiation)) {
810 Diag(PointOfInstantiation,
811 diag::err_explicit_instantiation_undefined_member)
816 assert(isa<TagDecl>(Instantiation) &&
"Must be a TagDecl!");
817 Diag(PointOfInstantiation,
818 diag::err_implicit_instantiate_member_undefined)
823 if (isa<FunctionDecl>(Instantiation)) {
824 Diag(PointOfInstantiation,
825 diag::err_explicit_instantiation_undefined_func_template)
828 }
else if (isa<TagDecl>(Instantiation)) {
829 Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
832 NoteTemplateLocation(*Pattern);
834 assert(isa<VarDecl>(Instantiation) &&
"Must be a VarDecl!");
835 if (isa<VarTemplateSpecializationDecl>(Instantiation)) {
836 Diag(PointOfInstantiation,
837 diag::err_explicit_instantiation_undefined_var_template)
841 Diag(PointOfInstantiation,
842 diag::err_explicit_instantiation_undefined_member)
859 bool SupportedForCompatibility) {
871 getLangOpts().MSVCCompat
872 ? diag::ext_template_param_shadow
873 : (SupportedForCompatibility ? diag::ext_compat_template_param_shadow
874 : diag::err_template_param_shadow);
875 const auto *ND = cast<NamedDecl>(PrevDecl);
876 Diag(
Loc, DiagId) << ND->getDeclName();
877 NoteTemplateParameterLocation(*ND);
881 if (
TemplateDecl *Temp = dyn_cast_or_null<TemplateDecl>(
D)) {
882 D = Temp->getTemplatedDecl();
890 assert(
Kind == Template &&
891 "Only template template arguments can be pack expansions here");
892 assert(getAsTemplate().get().containsUnexpandedParameterPack() &&
893 "Template template argument pack expansion without packs");
895 Result.EllipsisLoc = EllipsisLoc;
930 llvm_unreachable(
"Unhandled parsed template argument");
935 for (
unsigned I = 0,
Last = TemplateArgsIn.size(); I !=
Last; ++I)
955 assert(TInfo &&
"template argument with no location");
963 EllipsisLoc = PET.getEllipsisLoc();
964 TL = PET.getPatternLoc();
969 SS.
Adopt(ET.getQualifierLoc());
970 TL = ET.getNamedTypeLoc();
974 TemplateName Name = DTST.getTypePtr()->getTemplateName();
976 DTST.getTemplateNameLoc());
978 Result = Result.getTemplatePackExpansion(EllipsisLoc);
997 unsigned Depth,
unsigned Position,
1000 bool HasTypeConstraint) {
1001 assert(S->isTemplateParamScope() &&
1002 "Template type parameter not in template parameter scope!");
1004 bool IsParameterPack = EllipsisLoc.
isValid();
1007 KeyLoc, ParamNameLoc,
Depth, Position,
1008 ParamName,
Typename, IsParameterPack,
1013 if (
auto *LSI = getEnclosingLambda())
1014 LSI->LocalPacks.push_back(Param);
1021 IdResolver.AddDecl(Param);
1027 if (DefaultArg && IsParameterPack) {
1028 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1029 DefaultArg =
nullptr;
1035 GetTypeFromParser(DefaultArg, &DefaultTInfo);
1037 assert(DefaultTInfo &&
"expected source information for type");
1040 if (DiagnoseUnexpandedParameterPack(ParamNameLoc, DefaultTInfo,
1041 UPPC_DefaultArgument))
1045 if (CheckTemplateArgument(DefaultTInfo)) {
1065 return TemplateArgs;
1078 diag::err_type_constraint_non_type_concept);
1087 if (!WereArgsSpecified &&
1090 diag::err_type_constraint_missing_arguments)
1101 return BuildTypeConstraint(SS, TypeConstr, ConstrainedParameter, EllipsisLoc,
1109 bool AllowUnexpandedPack) {
1111 if (CheckTypeConstraint(TypeConstr))
1126 if (EllipsisLoc.
isInvalid() && !AllowUnexpandedPack) {
1128 if (DiagnoseUnexpandedParameterPack(Arg, UPPC_TypeConstraint))
1133 return AttachTypeConstraint(
1135 ConceptName, CD, USD ? cast<NamedDecl>(USD) : CD,
1137 ConstrainedParameter, EllipsisLoc);
1140 template <
typename ArgumentLocAppender>
1155 Appender(ConstraintArgs);
1164 FoundDecl ? FoundDecl : NamedConcept, NamedConcept,
1167 return ImmediatelyDeclaredConstraint;
1183 ImmediatelyDeclaredConstraint.
get(), BO_LAnd,
1184 EllipsisLoc,
nullptr,
1200 *TemplateArgs) :
nullptr;
1205 *
this, NS, NameInfo, NamedConcept, FoundDecl,
1208 ParamAsArgument, ConstrainedParameter->
getLocation(),
1211 for (const auto &ArgLoc : TemplateArgs->arguments())
1212 ConstraintArgs.addArgument(ArgLoc);
1215 if (ImmediatelyDeclaredConstraint.
isInvalid())
1225 ImmediatelyDeclaredConstraint.
get());
1236 diag::err_unsupported_placeholder_constraint)
1245 BuildDeclRefExpr(OrigConstrainedParm, OrigConstrainedParm->
getType(),
1255 for (unsigned I = 0, C = TL.getNumArgs(); I != C; ++I)
1256 ConstraintArgs.addArgument(TL.getArgLoc(I));
1259 if (ImmediatelyDeclaredConstraint.
isInvalid() ||
1260 !ImmediatelyDeclaredConstraint.
isUsable())
1264 ImmediatelyDeclaredConstraint.
get());
1276 TSI = SubstAutoTypeSourceInfoDependent(TSI);
1279 return CheckNonTypeTemplateParameterType(TSI->
getType(),
Loc);
1286 if (RequireCompleteType(
Loc,
T, diag::err_template_nontype_parm_incomplete))
1294 Diag(
Loc, diag::err_template_nontype_parm_rvalue_ref) <<
T;
1304 Diag(
Loc, diag::err_template_nontype_parm_bad_type) <<
T;
1309 if (RequireLiteralType(
Loc,
T, diag::err_template_nontype_parm_not_literal))
1312 Diag(
Loc, diag::err_template_nontype_parm_not_structural) <<
T;
1319 for (
const FieldDecl *FD : RD->fields()) {
1321 Diag(FD->getLocation(), diag::note_not_structural_non_public) <<
T << 0;
1324 if (FD->isMutable()) {
1325 Diag(FD->getLocation(), diag::note_not_structural_mutable_field) <<
T;
1328 if (FD->getType()->isRValueReferenceType()) {
1329 Diag(FD->getLocation(), diag::note_not_structural_rvalue_ref_field)
1336 for (
const auto &BaseSpec : RD->bases()) {
1337 if (BaseSpec.getAccessSpecifier() !=
AS_public) {
1338 Diag(BaseSpec.getBaseTypeLoc(), diag::note_not_structural_non_public)
1349 for (
const FieldDecl *FD : RD->fields()) {
1352 SubLoc = FD->getLocation();
1360 for (
const auto &BaseSpec : RD->bases()) {
1363 SubLoc = BaseSpec.getBaseTypeLoc();
1371 assert(
Kind != -1 &&
"couldn't find reason why type is not structural");
1372 Diag(SubLoc, diag::note_not_structural_subobject)
1373 <<
T <<
Kind << SubType;
1386 Diag(
Loc, diag::err_variably_modified_nontype_template_param)
1410 return T.getUnqualifiedType();
1428 return T.getUnqualifiedType();
1432 if (RequireStructuralType(
T,
Loc))
1439 Diag(
Loc, diag::err_template_nontype_parm_bad_structural_type) <<
T;
1443 Diag(
Loc, diag::warn_cxx17_compat_template_nontype_parm_type) <<
T;
1444 return T.getUnqualifiedType();
1455 auto CheckValidDeclSpecifiers = [
this, &
D] {
1469 Diag(
Loc, diag::err_invalid_decl_specifier_in_nontype_parm)
1506 CheckValidDeclSpecifiers();
1509 if (isa<AutoType>(
T))
1510 Diag(
D.getIdentifierLoc(),
1511 diag::warn_cxx14_compat_template_nontype_parm_auto_type)
1514 assert(S->isTemplateParamScope() &&
1515 "Non-type template parameter not in template parameter scope!");
1516 bool Invalid =
false;
1518 QualType T = CheckNonTypeTemplateParameterType(TInfo,
D.getIdentifierLoc());
1524 CheckFunctionOrTemplateParamDeclarator(S,
D);
1527 bool IsParameterPack =
D.hasEllipsis();
1530 D.getIdentifierLoc(),
Depth, Position, ParamName,
T, IsParameterPack,
1535 if (TL.isConstrained())
1536 if (AttachTypeConstraint(TL, Param, Param,
D.getEllipsisLoc()))
1543 if (
auto *LSI = getEnclosingLambda())
1544 LSI->LocalPacks.push_back(Param);
1552 IdResolver.AddDecl(Param);
1558 if (
Default && IsParameterPack) {
1559 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1566 if (DiagnoseUnexpandedParameterPack(
Default, UPPC_DefaultArgument))
1582 assert(S->isTemplateParamScope() &&
1583 "Template template parameter not in template parameter scope!");
1586 bool IsParameterPack = EllipsisLoc.
isValid();
1589 NameLoc.
isInvalid() ? TmpLoc : NameLoc,
Depth, Position, IsParameterPack,
1594 if (
auto *LSI = getEnclosingLambda())
1595 LSI->LocalPacks.push_back(Param);
1603 IdResolver.AddDecl(Param);
1606 if (Params->
size() == 0) {
1615 if (IsParameterPack && !
Default.isInvalid()) {
1616 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1631 Diag(DefaultArg.
getLocation(), diag::err_template_arg_not_valid_template)
1637 if (DiagnoseUnexpandedParameterPack(DefaultArg.
getLocation(),
1639 UPPC_DefaultArgument))
1649 class ConstraintRefersToContainingTemplateChecker
1650 :
public TreeTransform<ConstraintRefersToContainingTemplateChecker> {
1651 bool Result =
false;
1653 unsigned TemplateDepth = 0;
1657 void CheckIfContainingRecord(
const CXXRecordDecl *CheckingRD) {
1663 DC && !DC->isFileContext(); DC = DC->getParent())
1664 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
1665 if (CheckingRD == RD->getMostRecentDecl())
1670 assert(
D->getDepth() <= TemplateDepth &&
1671 "Nothing should reference a value below the actual template depth, "
1672 "depth is likely wrong");
1673 if (
D->getDepth() != TemplateDepth)
1678 TransformType(
D->getType());
1684 ConstraintRefersToContainingTemplateChecker(
Sema &SemaRef,
1686 unsigned TemplateDepth)
1687 : inherited(SemaRef),
Friend(
Friend), TemplateDepth(TemplateDepth) {}
1688 bool getResult()
const {
return Result; }
1694 using inherited::TransformTemplateTypeParmType;
1698 "Nothing should reference a value below the actual template depth, "
1699 "depth is likely wrong");
1702 return inherited::TransformTemplateTypeParmType(
1714 if (
auto *TD = dyn_cast<TypedefNameDecl>(
D))
1715 TransformType(TD->getUnderlyingType());
1716 else if (
auto *NTTPD = dyn_cast<NonTypeTemplateParmDecl>(
D))
1717 CheckNonTypeTemplateParmDecl(NTTPD);
1718 else if (
auto *VD = dyn_cast<ValueDecl>(
D))
1719 TransformType(VD->getType());
1720 else if (
auto *TD = dyn_cast<TemplateDecl>(
D))
1721 TransformTemplateParameterList(TD->getTemplateParameters());
1722 else if (
auto *RD = dyn_cast<CXXRecordDecl>(
D))
1723 CheckIfContainingRecord(RD);
1724 else if (isa<NamedDecl>(
D)) {
1727 llvm_unreachable(
"Don't know how to handle this declaration type yet");
1735 const Expr *Constraint) {
1736 assert(
Friend->getFriendObjectKind() &&
"Only works on a friend");
1737 ConstraintRefersToContainingTemplateChecker Checker(*
this,
Friend,
1739 Checker.TransformExpr(
const_cast<Expr *
>(Constraint));
1740 return Checker.getResult();
1750 Expr *RequiresClause) {
1752 Diag(ExportLoc, diag::warn_template_export_unsupported);
1755 warnOnReservedIdentifier(
P);
1758 Context, TemplateLoc, LAngleLoc,
1759 llvm::ArrayRef(Params.data(), Params.size()), RAngleLoc, RequiresClause);
1794 return cast<TemplateDecl>(
D)->getTemplateParameters();
1804 assert(TemplateParams && TemplateParams->
size() > 0 &&
1805 "No template parameters");
1807 "Can only declare or define class templates");
1808 bool Invalid =
false;
1811 if (CheckTemplateDeclScope(S, TemplateParams))
1816 "can't build template of enumerated type");
1820 Diag(KWLoc, diag::err_template_unnamed_class);
1831 : LookupOrdinaryName,
1832 forRedeclarationInCurContext());
1834 SemanticContext = computeDeclContext(SS,
true);
1835 if (!SemanticContext) {
1840 ? diag::warn_template_qualified_friend_ignored
1841 : diag::err_template_qualified_declarator_no_match)
1846 if (RequireCompleteDeclContext(SS, SemanticContext))
1854 if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams))
1859 diagnoseQualifiedDeclaration(SS, SemanticContext, Name, NameLoc,
1863 LookupQualifiedName(
Previous, SemanticContext);
1865 SemanticContext = CurContext;
1872 DiagnoseClassNameShadow(SemanticContext,
1884 PrevDecl = (*
Previous.begin())->getUnderlyingDecl();
1888 DiagnoseTemplateParameterShadow(NameLoc, PrevDecl);
1896 dyn_cast_or_null<ClassTemplateDecl>(PrevDecl);
1901 if (!PrevClassTemplate && isa_and_nonnull<CXXRecordDecl>(PrevDecl) &&
1902 cast<CXXRecordDecl>(PrevDecl)->isInjectedClassName()) {
1905 = cast<CXXRecordDecl>(PrevDecl)->getDescribedClassTemplate();
1906 if (!PrevClassTemplate && isa<ClassTemplateSpecializationDecl>(PrevDecl)) {
1908 = cast<ClassTemplateSpecializationDecl>(PrevDecl)
1909 ->getSpecializedTemplate();
1932 PrevDecl = PrevClassTemplate =
nullptr;
1933 SemanticContext = OutermostContext;
1937 Previous.clear(LookupOrdinaryName);
1941 LookupQualifiedName(
Previous, LookupContext);
1947 PrevDecl = (*
Previous.begin())->getUnderlyingDecl();
1950 }
else if (PrevDecl && !isDeclInScope(
Previous.getRepresentativeDecl(),
1951 SemanticContext, S, SS.
isValid()))
1952 PrevDecl = PrevClassTemplate =
nullptr;
1954 if (
auto *Shadow = dyn_cast_or_null<UsingShadowDecl>(
1955 PrevDecl ?
Previous.getRepresentativeDecl() :
nullptr)) {
1957 !(PrevClassTemplate &&
1960 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
1961 Diag(Shadow->getTargetDecl()->getLocation(),
1962 diag::note_using_decl_target);
1963 Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl) << 0;
1965 PrevDecl = PrevClassTemplate =
nullptr;
1969 if (PrevClassTemplate) {
1974 !TemplateParameterListsAreEqual(
1978 TemplateParams, PrevClassTemplate,
1989 if (!isAcceptableTagRedeclaration(
1991 Diag(KWLoc, diag::err_use_with_wrong_tag)
2004 if (SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
2007 auto *Tmpl = cast<CXXRecordDecl>(Hidden)->getDescribedClassTemplate();
2008 assert(Tmpl &&
"original definition of a class template is not a "
2010 makeMergedDefinitionVisible(Hidden);
2011 makeMergedDefinitionVisible(Tmpl);
2013 Diag(NameLoc, diag::err_redefinition) << Name;
2014 Diag(Def->getLocation(), diag::note_previous_definition);
2021 }
else if (PrevDecl) {
2027 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
2037 CheckTemplateParameterList(
2039 PrevClassTemplate ? GetTemplateParameterList(PrevClassTemplate)
2041 (SS.
isSet() && SemanticContext && SemanticContext->
isRecord() &&
2043 ? TPC_ClassTemplateMember
2045 : TPC_ClassTemplate,
2052 if (!SS.
isInvalid() && !Invalid && !PrevClassTemplate) {
2054 ? diag::err_friend_decl_does_not_match
2055 : diag::err_member_decl_does_not_match)
2056 << Name << SemanticContext <<
true << SS.
getRange();
2066 bool ShouldAddRedecl =
2071 PrevClassTemplate && ShouldAddRedecl ?
2075 if (NumOuterTemplateParamLists > 0)
2078 llvm::ArrayRef(OuterTemplateParamLists, NumOuterTemplateParamLists));
2083 AddAlignmentAttributesForRecord(NewClass);
2084 AddMsStructLayoutForRecord(NewClass);
2092 if (ShouldAddRedecl)
2097 if (ModulePrivateLoc.
isValid())
2108 if (PrevClassTemplate &&
2115 SetMemberAccessSpecifier(NewTemplate, PrevClassTemplate, AS);
2124 ProcessDeclAttributeList(S, NewClass,
Attr);
2127 if (PrevClassTemplate)
2130 AddPushedVisibilityAttribute(NewClass);
2131 inferGslOwnerPointerAttribute(NewClass);
2132 inferNullableClassAttribute(NewClass);
2139 PushOnScopeChains(NewTemplate, Outer);
2149 if (!CurContext->isDependentContext()) {
2152 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
2153 PushOnScopeChains(NewTemplate, EnclosingScope,
2158 Context, CurContext, NewClass->
getLocation(), NewTemplate, FriendLoc);
2160 CurContext->addDecl(
Friend);
2163 if (PrevClassTemplate)
2164 CheckRedeclarationInModule(NewTemplate, PrevClassTemplate);
2171 ActOnDocumentableDecl(NewTemplate);
2204 diag::warn_cxx98_compat_template_parameter_default_in_function_template
2205 : diag::ext_template_parameter_default_in_function_template)
2214 S.
Diag(ParamLoc, diag::err_template_parameter_default_template_member)
2223 S.
Diag(ParamLoc, diag::err_template_parameter_default_friend_template)
2232 llvm_unreachable(
"Invalid TemplateParamListContext!");
2245 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
2250 if (TC->hasExplicitTemplateArgs())
2251 for (
auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
2259 if (!NTTP->isParameterPack() &&
2261 NTTP->getTypeSourceInfo(),
2269 = dyn_cast<TemplateTemplateParmDecl>(
P))
2281 bool Invalid =
false;
2289 bool SawDefaultArgument =
false;
2295 OldParam = OldParams->
begin();
2297 bool RemoveDefaultArguments =
false;
2299 NewParamEnd = NewParams->
end();
2300 NewParam != NewParamEnd; ++NewParam) {
2303 bool RedundantDefaultArg =
false;
2306 bool InconsistentDefaultArg =
false;
2308 std::string PrevModuleName;
2314 bool MissingDefaultArg =
false;
2317 bool SawParameterPack =
false;
2320 = dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
2322 if (NewTypeParm->hasDefaultArgument() &&
2324 *
this, TPC, NewTypeParm->getLocation(),
2325 NewTypeParm->getDefaultArgument().getSourceRange()))
2326 NewTypeParm->removeDefaultArgument();
2330 = OldParams? cast<TemplateTypeParmDecl>(*OldParam) :
nullptr;
2331 if (NewTypeParm->isParameterPack()) {
2332 assert(!NewTypeParm->hasDefaultArgument() &&
2333 "Parameter packs can't have a default argument!");
2334 SawParameterPack =
true;
2335 }
else if (OldTypeParm && hasVisibleDefaultArgument(OldTypeParm) &&
2339 NewDefaultLoc = NewTypeParm->getDefaultArgumentLoc();
2340 SawDefaultArgument =
true;
2343 RedundantDefaultArg =
true;
2344 else if (!getASTContext().isSameDefaultTemplateArgument(OldTypeParm,
2346 InconsistentDefaultArg =
true;
2350 PreviousDefaultArgLoc = NewDefaultLoc;
2354 NewTypeParm->setInheritedDefaultArgument(Context, OldTypeParm);
2356 }
else if (NewTypeParm->hasDefaultArgument()) {
2357 SawDefaultArgument =
true;
2358 PreviousDefaultArgLoc = NewTypeParm->getDefaultArgumentLoc();
2359 }
else if (SawDefaultArgument)
2360 MissingDefaultArg =
true;
2362 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
2364 if (!NewNonTypeParm->isParameterPack() &&
2365 DiagnoseUnexpandedParameterPack(NewNonTypeParm->getLocation(),
2366 NewNonTypeParm->getTypeSourceInfo(),
2367 UPPC_NonTypeTemplateParameterType)) {
2373 if (NewNonTypeParm->hasDefaultArgument() &&
2375 *
this, TPC, NewNonTypeParm->getLocation(),
2376 NewNonTypeParm->getDefaultArgument().getSourceRange())) {
2377 NewNonTypeParm->removeDefaultArgument();
2382 = OldParams? cast<NonTypeTemplateParmDecl>(*OldParam) :
nullptr;
2383 if (NewNonTypeParm->isParameterPack()) {
2384 assert(!NewNonTypeParm->hasDefaultArgument() &&
2385 "Parameter packs can't have a default argument!");
2386 if (!NewNonTypeParm->isPackExpansion())
2387 SawParameterPack =
true;
2388 }
else if (OldNonTypeParm && hasVisibleDefaultArgument(OldNonTypeParm) &&
2392 NewDefaultLoc = NewNonTypeParm->getDefaultArgumentLoc();
2393 SawDefaultArgument =
true;
2395 RedundantDefaultArg =
true;
2396 else if (!getASTContext().isSameDefaultTemplateArgument(
2397 OldNonTypeParm, NewNonTypeParm)) {
2398 InconsistentDefaultArg =
true;
2402 PreviousDefaultArgLoc = NewDefaultLoc;
2406 NewNonTypeParm->setInheritedDefaultArgument(Context, OldNonTypeParm);
2408 }
else if (NewNonTypeParm->hasDefaultArgument()) {
2409 SawDefaultArgument =
true;
2410 PreviousDefaultArgLoc = NewNonTypeParm->getDefaultArgumentLoc();
2411 }
else if (SawDefaultArgument)
2412 MissingDefaultArg =
true;
2415 = cast<TemplateTemplateParmDecl>(*NewParam);
2432 = OldParams? cast<TemplateTemplateParmDecl>(*OldParam) :
nullptr;
2435 "Parameter packs can't have a default argument!");
2437 SawParameterPack =
true;
2438 }
else if (OldTemplateParm &&
2439 hasVisibleDefaultArgument(OldTemplateParm) &&
2444 SawDefaultArgument =
true;
2446 RedundantDefaultArg =
true;
2447 else if (!getASTContext().isSameDefaultTemplateArgument(
2448 OldTemplateParm, NewTemplateParm)) {
2449 InconsistentDefaultArg =
true;
2453 PreviousDefaultArgLoc = NewDefaultLoc;
2458 PreviousDefaultArgLoc
2461 SawDefaultArgument =
true;
2462 PreviousDefaultArgLoc
2464 }
else if (SawDefaultArgument)
2465 MissingDefaultArg =
true;
2471 if (SawParameterPack && (NewParam + 1) != NewParamEnd &&
2472 (TPC == TPC_ClassTemplate || TPC == TPC_VarTemplate ||
2473 TPC == TPC_TypeAliasTemplate)) {
2474 Diag((*NewParam)->getLocation(),
2475 diag::err_template_param_pack_must_be_last_template_parameter);
2492 if (RedundantDefaultArg) {
2493 Diag(NewDefaultLoc, diag::err_template_param_default_arg_redefinition);
2494 Diag(OldDefaultLoc, diag::note_template_param_prev_default_arg);
2496 }
else if (InconsistentDefaultArg) {
2500 diag::err_template_param_default_arg_inconsistent_redefinition);
2502 diag::note_template_param_prev_default_arg_in_other_module)
2505 }
else if (MissingDefaultArg &&
2506 (TPC == TPC_ClassTemplate || TPC == TPC_FriendClassTemplate ||
2507 TPC == TPC_VarTemplate || TPC == TPC_TypeAliasTemplate)) {
2513 Diag((*NewParam)->getLocation(),
2514 diag::err_template_param_default_arg_missing);
2515 Diag(PreviousDefaultArgLoc, diag::note_template_param_prev_default_arg);
2517 RemoveDefaultArguments =
true;
2528 if (RemoveDefaultArguments) {
2530 NewParamEnd = NewParams->
end();
2531 NewParam != NewParamEnd; ++NewParam) {
2533 TTP->removeDefaultArgument();
2535 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
2536 NTTP->removeDefaultArgument();
2538 cast<TemplateTemplateParmDecl>(*NewParam)->removeDefaultArgument();
2558 bool IgnoreNonTypeDependent;
2563 DependencyChecker(
unsigned Depth,
bool IgnoreNonTypeDependent)
2564 :
Depth(
Depth), IgnoreNonTypeDependent(IgnoreNonTypeDependent),
2568 : IgnoreNonTypeDependent(IgnoreNonTypeDependent), Match(
false) {
2571 Depth = PD->getDepth();
2573 dyn_cast<NonTypeTemplateParmDecl>(ND)) {
2574 Depth = PD->getDepth();
2576 Depth = cast<TemplateTemplateParmDecl>(ND)->getDepth();
2581 if (ParmDepth >=
Depth) {
2589 bool TraverseStmt(
Stmt *S, DataRecursionQueue *Q =
nullptr) {
2594 if (
auto *
E = dyn_cast_or_null<Expr>(S))
2597 return super::TraverseStmt(S, Q);
2600 bool TraverseTypeLoc(
TypeLoc TL) {
2601 if (IgnoreNonTypeDependent && !TL.
isNull() &&
2604 return super::TraverseTypeLoc(TL);
2613 return IgnoreNonTypeDependent || !Matches(
T->getDepth());
2619 if (Matches(PD->getDepth()))
2621 return super::TraverseTemplateName(N);
2626 dyn_cast<NonTypeTemplateParmDecl>(
E->getDecl()))
2629 return super::VisitDeclRefExpr(
E);
2633 return TraverseType(
T->getReplacementType());
2638 return TraverseTemplateArgument(
T->getArgumentPack());
2642 return TraverseType(
T->getInjectedSpecializationType());
2651 if (!Params->
size())
2654 DependencyChecker Checker(Params,
false);
2655 Checker.TraverseType(
T);
2656 return Checker.Match;
2666 if (
const Type *CurType = NNS->getAsType()) {
2682 bool &IsMemberSpecialization,
bool &Invalid,
bool SuppressDiagnostic) {
2683 IsMemberSpecialization =
false;
2693 = dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS,
true)))
2704 while (!
T.isNull()) {
2705 NestedTypes.push_back(
T);
2711 = dyn_cast<ClassTemplateSpecializationDecl>(
Record)) {
2712 if (!isa<ClassTemplatePartialSpecializationDecl>(Spec) &&
2714 ExplicitSpecLoc = Spec->getLocation();
2717 }
else if (
Record->getTemplateSpecializationKind()
2719 ExplicitSpecLoc =
Record->getLocation();
2732 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
2733 if (
TypeDecl *
Parent = dyn_cast<TypeDecl>(Template->getDeclContext()))
2778 std::reverse(NestedTypes.begin(), NestedTypes.end());
2786 bool SawNonEmptyTemplateParameterList =
false;
2789 if (SawNonEmptyTemplateParameterList) {
2790 if (!SuppressDiagnostic)
2791 Diag(DeclLoc, diag::err_specialize_member_of_template)
2792 << !Recovery <<
Range;
2794 IsMemberSpecialization =
false;
2803 if (CheckExplicitSpecialization(
Range,
true))
2808 if (!ParamLists.empty())
2809 ExpectedTemplateLoc = ParamLists[0]->getTemplateLoc();
2811 ExpectedTemplateLoc = DeclStartLoc;
2813 if (!SuppressDiagnostic)
2814 Diag(DeclLoc, diag::err_template_spec_needs_header)
2821 for (
unsigned TypeIdx = 0, NumTypes = NestedTypes.size(); TypeIdx != NumTypes;
2823 T = NestedTypes[TypeIdx];
2826 bool NeedEmptyTemplateHeader =
false;
2829 bool NeedNonemptyTemplateHeader =
false;
2842 = dyn_cast<ClassTemplatePartialSpecializationDecl>(
Record)) {
2843 ExpectedTemplateParams = Partial->getTemplateParameters();
2844 NeedNonemptyTemplateHeader =
true;
2845 }
else if (
Record->isDependentType()) {
2846 if (
Record->getDescribedClassTemplate()) {
2847 ExpectedTemplateParams =
Record->getDescribedClassTemplate()
2848 ->getTemplateParameters();
2849 NeedNonemptyTemplateHeader =
true;
2852 = dyn_cast<ClassTemplateSpecializationDecl>(
Record)) {
2858 NeedEmptyTemplateHeader =
true;
2861 }
else if (
Record->getTemplateSpecializationKind()) {
2862 if (
Record->getTemplateSpecializationKind()
2864 TypeIdx == NumTypes - 1)
2865 IsMemberSpecialization =
true;
2871 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
2872 ExpectedTemplateParams = Template->getTemplateParameters();
2873 NeedNonemptyTemplateHeader =
true;
2878 NeedNonemptyTemplateHeader =
false;
2888 if (
ParamIdx < ParamLists.size()) {
2889 if (ParamLists[
ParamIdx]->size() == 0) {
2894 SawNonEmptyTemplateParameterList =
true;
2897 if (NeedEmptyTemplateHeader) {
2900 if (TypeIdx == NumTypes - 1)
2901 IsMemberSpecialization =
true;
2903 if (
ParamIdx < ParamLists.size()) {
2904 if (ParamLists[
ParamIdx]->size() > 0) {
2906 if (!SuppressDiagnostic)
2908 diag::err_template_param_list_matches_nontemplate)
2911 ParamLists[
ParamIdx]->getRAngleLoc())
2923 if (DiagnoseMissingExplicitSpecialization(
2930 if (NeedNonemptyTemplateHeader) {
2936 if (
ParamIdx < ParamLists.size() &&
2938 ExpectedTemplateParams =
nullptr;
2943 if (
ParamIdx < ParamLists.size()) {
2945 if (ExpectedTemplateParams &&
2946 !TemplateParameterListsAreEqual(ParamLists[
ParamIdx],
2947 ExpectedTemplateParams,
2948 !SuppressDiagnostic, TPL_TemplateMatch))
2952 CheckTemplateParameterList(ParamLists[
ParamIdx],
nullptr,
2953 TPC_ClassTemplateMember))
2960 if (!SuppressDiagnostic)
2961 Diag(DeclLoc, diag::err_template_spec_needs_template_parameters)
2972 if (
ParamIdx >= ParamLists.size()) {
2973 if (TemplateId && !IsFriend) {
2989 if (
ParamIdx < ParamLists.size() - 1) {
2990 bool HasAnyExplicitSpecHeader =
false;
2991 bool AllExplicitSpecHeaders =
true;
2992 for (
unsigned I =
ParamIdx,
E = ParamLists.size() - 1; I !=
E; ++I) {
2993 if (ParamLists[I]->size() == 0)
2994 HasAnyExplicitSpecHeader =
true;
2996 AllExplicitSpecHeaders =
false;
2999 if (!SuppressDiagnostic)
3001 AllExplicitSpecHeaders ? diag::ext_template_spec_extra_headers
3002 : diag::err_template_spec_extra_headers)
3004 ParamLists[ParamLists.size() - 2]->getRAngleLoc());
3009 if (ExplicitSpecLoc.
isValid() && HasAnyExplicitSpecHeader &&
3010 !SuppressDiagnostic)
3011 Diag(ExplicitSpecLoc,
3012 diag::note_explicit_template_spec_does_not_need_header)
3013 << NestedTypes.back();
3018 if (!AllExplicitSpecHeaders)
3029 if (ParamLists.back()->size() == 0 &&
3036 return ParamLists.back();
3040 if (
TemplateDecl *Template = Name.getAsTemplateDecl()) {
3041 Diag(Template->getLocation(), diag::note_template_declared_here)
3042 << (isa<FunctionTemplateDecl>(Template)
3044 : isa<ClassTemplateDecl>(Template)
3046 : isa<VarTemplateDecl>(Template)
3048 : isa<TypeAliasTemplateDecl>(Template) ? 3 : 4)
3049 << Template->getDeclName();
3057 Diag((*I)->getLocation(), diag::note_template_declared_here)
3058 << 0 << (*I)->getDeclName();
3076 QualType OrigType = Converted[1].getAsType();
3080 SemaRef.
Diag(TemplateArgs[1].getLocation(),
3081 diag::err_integer_sequence_integral_element_type);
3096 OrigType, TemplateArgs[1].getLocation())));
3100 for (
llvm::APSInt I(NumArgs.getBitWidth(), NumArgs.isUnsigned());
3104 TA, OrigType, TemplateArgs[2].getLocation()));
3109 SemaRef.
Diag(TemplateArgs[2].getLocation(),
3110 diag::err_integer_sequence_negative_length);
3117 TemplateLoc, SyntheticTemplateArgs);
3124 assert(Converted.size() == 2 &&
3125 "__type_pack_element should be given an index and a parameter pack");
3133 assert(Index >= 0 &&
"the index used with __type_pack_element should be of "
3134 "type std::size_t, and hence be non-negative");
3136 if (Index >= Ts.pack_size()) {
3137 SemaRef.
Diag(TemplateArgs[0].getLocation(),
3138 diag::err_type_pack_element_out_of_bounds);
3143 int64_t N = Index.getExtValue();
3144 return Ts.getPackAsArray()[N].getAsType();
3146 llvm_unreachable(
"unexpected BuiltinTemplateDecl!");
3165 if (BinOp->getOpcode() == BO_LAnd) {
3172 Terms.push_back(Clause);
3181 if (!BinOp)
return Cond;
3183 if (BinOp->getOpcode() != BO_LOr)
return Cond;
3186 Expr *LHS = BinOp->getLHS();
3188 if (!InnerBinOp)
return Cond;
3190 if (InnerBinOp->getOpcode() != BO_EQ ||
3191 !isa<IntegerLiteral>(InnerBinOp->getRHS()))
3201 if (MacroName ==
"CONCEPT_REQUIRES" || MacroName ==
"CONCEPT_REQUIRES_")
3202 return BinOp->getRHS();
3212 class FailedBooleanConditionPrinterHelper :
public PrinterHelper {
3217 bool handledStmt(
Stmt *
E, raw_ostream &OS)
override {
3218 const auto *DR = dyn_cast<DeclRefExpr>(
E);
3219 if (DR && DR->getQualifier()) {
3222 DR->getQualifier()->print(OS, Policy,
true);
3226 if (
const auto *IV = dyn_cast<VarTemplateSpecializationDecl>(VD)) {
3229 OS, IV->getTemplateArgs().asArray(), Policy,
3230 IV->getSpecializedTemplate()->getTemplateParameters());
3243 std::pair<Expr *, std::string>
3252 Expr *FailedCond =
nullptr;
3253 for (
Expr *Term : Terms) {
3257 if (isa<CXXBoolLiteralExpr>(TermAsWritten) ||
3258 isa<IntegerLiteral>(TermAsWritten))
3267 if (Term->EvaluateAsBooleanCondition(Succeeded, Context) &&
3269 FailedCond = TermAsWritten;
3276 std::string Description;
3278 llvm::raw_string_ostream Out(Description);
3281 FailedBooleanConditionPrinterHelper Helper(Policy);
3282 FailedCond->
printPretty(Out, &Helper, Policy, 0,
"\n",
nullptr);
3284 return { FailedCond, Description };
3291 = Name.getUnderlying().getAsDependentTemplateName();
3301 if (Name.getAsAssumedTemplateName() &&
3302 resolveAssumedTemplateNameAsType(
nullptr, Name, TemplateLoc))
3306 if (!Template || isa<FunctionTemplateDecl>(Template) ||
3307 isa<VarTemplateDecl>(Template) || isa<ConceptDecl>(Template)) {
3310 if (Name.getAsSubstTemplateTemplateParmPack())
3314 Diag(TemplateLoc, diag::err_template_id_not_a_type)
3316 NoteAllFoundTemplates(Name);
3323 if (CheckTemplateArgumentList(Template, TemplateLoc, TemplateArgs,
false,
3324 SugaredConverted, CanonicalConverted,
3331 dyn_cast<TypeAliasTemplateDecl>(Template)) {
3346 Template, SugaredConverted,
3347 !getLangOpts().RetainSubstTemplateTypeParmTypeAstNodes);
3363 std::optional<ContextRAII> SavedContext;
3365 SavedContext.emplace(*
this,
AliasTemplate->getDeclContext());
3370 if (CanonType.
isNull()) {
3375 if (
auto DeductionInfo = isSFINAEContext()) {
3376 if (*DeductionInfo &&
3377 (*DeductionInfo)->hasSFINAEDiagnostic() &&
3378 (*DeductionInfo)->peekSFINAEDiagnostic().second.getDiagID() ==
3379 diag::err_typename_nested_not_found_enable_if &&
3380 TemplateArgs[0].getArgument().getKind()
3383 std::string FailedDescription;
3384 std::tie(FailedCond, FailedDescription) =
3385 findFailedBooleanCondition(TemplateArgs[0].getSourceExpression());
3390 (*DeductionInfo)->takeSFINAEDiagnostic(OldDiag);
3394 (*DeductionInfo)->addSFINAEDiagnostic(
3396 PDiag(diag::err_typename_nested_not_found_requirement)
3397 << FailedDescription
3405 }
else if (
auto *BTD = dyn_cast<BuiltinTemplateDecl>(Template)) {
3407 TemplateLoc, TemplateArgs);
3408 }
else if (Name.isDependent() ||
3410 TemplateArgs, CanonicalConverted)) {
3419 Name, CanonicalConverted);
3427 if (isa<ClassTemplateDecl>(Template)) {
3430 if (Ctx->isFileContext())
break;
3438 if (!isa<ClassTemplatePartialSpecializationDecl>(
Record) &&
3439 !
Record->getDescribedClassTemplate())
3445 QualType Injected = cast<InjectedClassNameType>(ICNT)
3446 ->getInjectedSpecializationType();
3459 dyn_cast<ClassTemplateDecl>(Template)) {
3462 void *InsertPos =
nullptr;
3464 ClassTemplate->findSpecialization(CanonicalConverted, InsertPos);
3470 Context, ClassTemplate->getTemplatedDecl()->getTagKind(),
3471 ClassTemplate->getDeclContext(),
3472 ClassTemplate->getTemplatedDecl()->getBeginLoc(),
3473 ClassTemplate->getLocation(), ClassTemplate, CanonicalConverted,
3475 ClassTemplate->AddSpecialization(
Decl, InsertPos);
3476 if (ClassTemplate->isOutOfLine())
3481 ClassTemplate->getTemplatedDecl()->hasAttrs()) {
3487 InstantiateAttrsForDecl(TemplateArgLists,
3488 ClassTemplate->getTemplatedDecl(),
Decl);
3493 (void)DiagnoseUseOfDecl(
Decl, TemplateLoc);
3496 assert(isa<RecordType>(CanonType) &&
3497 "type of non-dependent specialization is not a RecordType");
3499 llvm_unreachable(
"Unhandled template kind");
3516 auto *ATN = Name.getAsAssumedTemplateName();
3517 assert(ATN &&
"not an assumed template name");
3518 II = ATN->getDeclName().getAsIdentifierInfo();
3520 if (!resolveAssumedTemplateNameAsType(S, Name, NameLoc,
false)) {
3522 ParsedName = TemplateTy::make(Name);
3534 assert(ATN &&
"not an assumed template name");
3542 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
3543 return std::make_unique<CandidateCallback>(*
this);
3549 FilterCCC, CTK_ErrorRecovery);
3551 diagnoseTypo(Corrected, PDiag(diag::err_no_template_suggest)
3567 bool IsCtorOrDtorName,
bool IsClassName,
3572 if (!IsCtorOrDtorName && !IsClassName && SS.
isSet()) {
3573 DeclContext *LookupCtx = computeDeclContext(SS,
false);
3581 if (!LookupCtx && isDependentScopeSpecifier(SS)) {
3597 return ActOnTypenameType(
nullptr,
SourceLocation(), SS, TemplateKWLoc,
3598 TemplateD, TemplateII, TemplateIILoc, LAngleLoc,
3599 TemplateArgsIn, RAngleLoc);
3606 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
3607 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
3610 ? diag::err_out_of_line_qualified_id_type_names_constructor
3611 : diag::ext_out_of_line_qualified_id_type_names_constructor)
3619 resolveAssumedTemplateNameAsType(S, Template, TemplateIILoc))
3624 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
3641 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
3646 QualType SpecTy = CheckTemplateIdType(Template, TemplateIILoc, TemplateArgs);
3658 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
3689 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
3699 Keyword, DTN->getQualifier(), DTN->getIdentifier(),
3712 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
3723 Diag(TemplateLoc, diag::err_tag_reference_non_tag)
3724 << TAT << NTK_TypeAliasTemplate << llvm::to_underlying(TagKind);
3725 Diag(TAT->getLocation(), diag::note_declared_at);
3728 QualType Result = CheckTemplateIdType(Template, TemplateLoc, TemplateArgs);
3729 if (Result.isNull())
3737 assert(
Id &&
"templated class must have an identifier");
3741 Diag(TagLoc, diag::err_use_with_wrong_tag)
3756 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
3791 return TPT && !
Type.hasQualifiers() &&
3800 dyn_cast<NonTypeTemplateParmDecl>(DRE->
getDecl());
3806 dyn_cast_or_null<TemplateTemplateParmDecl>(
3810 llvm_unreachable(
"unexpected kind of template argument");
3815 if (Params->
size() != Args.size())
3820 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
3839 template<
typename PartialSpecDecl>
3841 if (Partial->getDeclContext()->isDependentContext())
3850 auto *Template = Partial->getSpecializedTemplate();
3851 S.
Diag(Partial->getLocation(),
3852 diag::ext_partial_spec_not_more_specialized_than_primary)
3853 << isa<VarTemplateDecl>(Template);
3862 diag::note_partial_spec_not_more_specialized_than_primary)
3868 Template->getAssociatedConstraints(TemplateAC);
3869 Partial->getAssociatedConstraints(PartialAC);
3876 const llvm::SmallBitVector &DeducibleParams) {
3877 for (
unsigned I = 0, N = DeducibleParams.size(); I != N; ++I) {
3878 if (!DeducibleParams[I]) {
3891 template<
typename PartialSpecDecl>
3893 PartialSpecDecl *Partial) {
3906 auto *TemplateParams = Partial->getTemplateParameters();
3907 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
3909 TemplateParams->getDepth(), DeducibleParams);
3911 if (!DeducibleParams.all()) {
3912 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
3913 S.
Diag(Partial->getLocation(), diag::ext_partial_specs_not_deducible)
3914 << isa<VarTemplatePartialSpecializationDecl>(Partial)
3915 << (NumNonDeducible > 1)
3917 Partial->getTemplateArgsAsWritten()->RAngleLoc);
3938 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
3939 MarkDeducedTemplateParameters(TD, DeducibleParams);
3940 for (
unsigned I = 0; I != TemplateParams->size(); ++I) {
3942 auto *Param = TemplateParams->getParam(I);
3943 if (Param->isParameterPack() || hasVisibleDefaultArgument(Param))
3944 DeducibleParams[I] =
true;
3947 if (!DeducibleParams.all()) {
3948 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
3949 Diag(TD->
getLocation(), diag::err_deduction_guide_template_not_deducible)
3950 << (NumNonDeducible > 1);
3961 "Variable template specialization is declared with a template id.");
3974 dyn_cast_or_null<VarTemplateDecl>(Name.getAsTemplateDecl());
3977 if (
auto *OTS = Name.getAsOverloadedTemplate())
3978 FnTemplate = *OTS->begin();
3980 FnTemplate = dyn_cast_or_null<FunctionTemplateDecl>(Name.getAsTemplateDecl());
3982 return Diag(
D.getIdentifierLoc(), diag::err_var_spec_no_template_but_method)
3984 return Diag(
D.getIdentifierLoc(), diag::err_var_spec_no_template)
3989 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
3990 if (DiagnoseUnexpandedParameterPack(TemplateArgs[I],
3992 ? UPPC_PartialSpecialization
3993 : UPPC_ExplicitSpecialization))
3999 if (CheckTemplateArgumentList(VarTemplate, TemplateNameLoc, TemplateArgs,
4000 false, SugaredConverted, CanonicalConverted,
4007 if (CheckTemplatePartialSpecializationArgs(TemplateNameLoc, VarTemplate,
4008 TemplateArgs.
size(),
4009 CanonicalConverted))
4014 if (!Name.isDependent() &&
4016 TemplateArgs, CanonicalConverted)) {
4017 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
4023 CanonicalConverted) &&
4030 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
4032 << (SC !=
SC_Extern && !CurContext->isRecord())
4040 void *InsertPos =
nullptr;
4045 CanonicalConverted, TemplateParams, InsertPos);
4069 cast_or_null<VarTemplatePartialSpecializationDecl>(PrevDecl);
4073 TemplateNameLoc, TemplateParams, VarTemplate, DI->
getType(), DI, SC,
4074 CanonicalConverted);
4086 CheckTemplatePartialSpecialization(Partial);
4091 Context, VarTemplate->
getDeclContext(), TemplateKWLoc, TemplateNameLoc,
4092 VarTemplate, DI->
getType(), DI, SC, CanonicalConverted);
4117 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
4121 diag::note_instantiation_required_here)
4151 struct PartialSpecMatchResult {
4161 assert(Template &&
"A variable template id without template?");
4165 if (CheckTemplateArgumentList(
4166 Template, TemplateNameLoc,
4168 SugaredConverted, CanonicalConverted,
4175 TemplateArgs, CanonicalConverted))
4180 void *InsertPos =
nullptr;
4183 checkSpecializationReachability(TemplateNameLoc, Spec);
4194 bool AmbiguousPartialSpec =
false;
4209 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
4223 Matched.push_back(PartialSpecMatchResult());
4224 Matched.back().Partial = Partial;
4229 if (Matched.size() >= 1) {
4231 if (Matched.size() == 1) {
4244 PEnd = Matched.end();
4246 if (getMoreSpecializedPartialSpecialization(
P->Partial, Best->Partial,
4247 PointOfInstantiation) ==
4255 PEnd = Matched.end();
4257 if (
P != Best && getMoreSpecializedPartialSpecialization(
4258 P->Partial, Best->Partial,
4259 PointOfInstantiation) != Best->Partial) {
4260 AmbiguousPartialSpec =
true;
4267 InstantiationPattern = Best->Partial;
4268 PartialSpecArgs = Best->Args;
4280 Template, InstantiationPattern, PartialSpecArgs, TemplateArgs,
4281 CanonicalConverted, TemplateNameLoc );
4285 if (AmbiguousPartialSpec) {
4288 Diag(PointOfInstantiation, diag::err_partial_spec_ordering_ambiguous)
4293 Diag(
P.Partial->getLocation(), diag::note_partial_spec_match)
4294 << getTemplateArgumentBindingsText(
P.Partial->getTemplateParameters(),
4300 dyn_cast<VarTemplatePartialSpecializationDecl>(InstantiationPattern))
4301 Decl->setInstantiationOf(
D, PartialSpecArgs);
4303 checkSpecializationReachability(TemplateNameLoc,
Decl);
4305 assert(
Decl &&
"No variable template specialization?");
4316 if (
Decl.isInvalid())
4328 return BuildDeclarationNameExpr(SS, NameInfo, Var, FoundD, TemplateArgs);
4333 Diag(
Loc, diag::err_template_missing_args)
4334 << (
int)getTemplateNameKindForDiagnostics(Name) << Name;
4336 NoteTemplateLocation(*TD, TD->getTemplateParameters()->getSourceRange());
4341 bool TemplateKeyword,
4346 diagnoseMissingTemplateArguments(Name,
Loc);
4356 assert(NamedConcept &&
"A concept template id without a template?");
4359 if (CheckTemplateArgumentList(
4360 NamedConcept, ConceptNameInfo.
getLoc(),
4362 false, SugaredConverted, CanonicalConverted,
4366 DiagnoseUseOfDecl(NamedConcept, ConceptNameInfo.
getLoc());
4370 CanonicalConverted);
4372 bool AreArgsDependent =
4374 *TemplateArgs, CanonicalConverted);
4380 *
this, ExpressionEvaluationContext::Unevaluated, CSD};
4382 if (!AreArgsDependent &&
4392 TemplateKWLoc, ConceptNameInfo, FoundDecl, NamedConcept,
4395 Context, CL, CSD, AreArgsDependent ?
nullptr : &Satisfaction);
4414 assert(!R.
isAmbiguous() &&
"ambiguous lookup when building templateid");
4418 if (!TemplateArgs && !isa<FunctionTemplateDecl>(TD)) {
4419 diagnoseMissingTemplateArguments(
4424 bool KnownDependent =
false;
4433 KnownDependent =
true;
4448 R.
begin(), R.
end(), KnownDependent,
4465 assert(TemplateArgs || TemplateKWLoc.
isValid());
4468 if (LookupTemplateName(R,
nullptr, SS,
QualType(),
4469 false, TemplateKWLoc))
4476 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
4486 if (isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
4487 return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc, R, TemplateArgs,
4490 return BuildTemplateIdExpr(SS, TemplateKWLoc, R,
false, TemplateArgs);
4498 bool EnteringContext,
4500 bool AllowInjectedClassName) {
4501 if (TemplateKWLoc.
isValid() && S && !S->getTemplateParamParent())
4504 diag::warn_cxx98_compat_template_outside_of_template :
4505 diag::ext_template_outside_of_template)
4514 LookupCtx = computeDeclContext(SS, EnteringContext);
4515 else if (ObjectType)
4516 LookupCtx = computeDeclContext(GetTypeFromParser(ObjectType));
4534 bool MemberOfUnknownSpecialization;
4536 ObjectType, EnteringContext, Result,
4537 MemberOfUnknownSpecialization);
4540 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
4541 if (!AllowInjectedClassName && SS.
isNotEmpty() && LookupRD &&
4543 Name.Identifier && LookupRD->getIdentifier() == Name.Identifier) {
4553 Diag(Name.getBeginLoc(),
4554 diag::ext_out_of_line_qualified_id_type_names_constructor)
4562 if (!MemberOfUnknownSpecialization) {
4569 LookupOrdinaryName);
4574 : TemplateNameIsRequired;
4575 if (!LookupTemplateName(R, S, SS, ObjectType.
get(), EnteringContext, RTK,
4579 Diag(Name.getBeginLoc(), diag::err_no_member)
4582 Diag(Name.getBeginLoc(), diag::err_undeclared_use)
4590 switch (Name.getKind()) {
4592 Result = TemplateTy::make(
4598 Qualifier, Name.OperatorFunctionId.Operator));
4612 Diag(Name.getBeginLoc(),
4613 diag::err_template_kw_refers_to_dependent_non_template)
4614 << GetNameFromUnqualifiedId(Name).getName() << Name.getSourceRange()
4615 << TemplateKWLoc.
isValid() << TemplateKWLoc;
4642 diagnoseMissingTemplateArguments(Name, SR.
getEnd());
4652 dyn_cast<DependentScopeDeclRefExpr>(Arg.
getAsExpr())) {
4653 SS.
Adopt(ArgExpr->getQualifierLoc());
4654 NameInfo = ArgExpr->getNameInfo();
4656 dyn_cast<CXXDependentScopeMemberExpr>(Arg.
getAsExpr())) {
4657 if (ArgExpr->isImplicitAccess()) {
4658 SS.
Adopt(ArgExpr->getQualifierLoc());
4659 NameInfo = ArgExpr->getMemberNameInfo();
4664 LookupResult Result(*
this, NameInfo, LookupOrdinaryName);
4665 LookupParsedName(Result, CurScope, &SS,
QualType());
4667 if (Result.getAsSingle<
TypeDecl>() ||
4668 Result.wasNotFoundInCurrentInstantiation()) {
4669 assert(SS.
getScopeRep() &&
"dependent scope expr must has a scope!");
4672 Diag(
Loc, getLangOpts().MSVCCompat
4673 ? diag::ext_ms_template_type_arg_missing_typename
4674 : diag::err_template_arg_must_be_type_suggest)
4676 NoteTemplateParameterLocation(*Param);
4704 CodeSynthesisContexts.back().Kind ==
4706 SugaredConverted.push_back(Arg);
4707 CanonicalConverted.push_back(Arg);
4713 Diag(SR.
getBegin(), diag::err_template_arg_must_be_type) << SR;
4714 NoteTemplateParameterLocation(*Param);
4720 if (CheckTemplateArgument(TSI))
4726 if (getLangOpts().ObjCAutoRefCount &&
4735 CanonicalConverted.push_back(
4784 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4787 bool ForLambdaCallOperator =
false;
4788 if (
const auto *Rec = dyn_cast<CXXRecordDecl>(Template->
getDeclContext()))
4789 ForLambdaCallOperator = Rec->isLambda();
4791 !ForLambdaCallOperator);
4839 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4846 TemplateArgLists, Output);
4882 SugaredConverted,
SourceRange(TemplateLoc, RAngleLoc));
4889 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4914 HasDefaultArg =
false;
4917 if (!hasReachableDefaultArgument(TypeParm))
4920 HasDefaultArg =
true;
4923 TypeParm, SugaredConverted,
4924 CanonicalConverted, Output))
4930 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
4931 if (!hasReachableDefaultArgument(NonTypeParm))
4934 HasDefaultArg =
true;
4937 NonTypeParm, SugaredConverted,
4938 CanonicalConverted, Output))
4944 = cast<TemplateTemplateParmDecl>(Param);
4945 if (!hasReachableDefaultArgument(TempTempParm))
4948 HasDefaultArg =
true;
4951 *
this, Template, TemplateLoc, RAngleLoc, TempTempParm, SugaredConverted,
4952 CanonicalConverted, QualifierLoc);
4973 QualLoc = ETLoc.getQualifierLoc();
4974 TLoc = ETLoc.getNamedTypeLoc();
4980 QualLoc, InjLoc.getNameLoc());
4988 dyn_cast<ClassTemplateSpecializationDecl>(RecLoc.getDecl()))
4991 QualLoc, RecLoc.getNameLoc());
4999 unsigned ArgumentPackIndex,
5005 return CheckTemplateTypeArgument(TTP, Arg, SugaredConverted,
5006 CanonicalConverted);
5013 QualType NTTPType = NTTP->getType();
5014 if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack())
5015 NTTPType = NTTP->getExpansionType(ArgumentPackIndex);
5018 !isa<TemplateTemplateParmDecl>(Template) &&
5033 NTTPType = SubstType(PET->getPattern(), MLTAL, NTTP->getLocation(),
5034 NTTP->getDeclName());
5036 NTTPType = SubstType(NTTPType, MLTAL, NTTP->getLocation(),
5037 NTTP->getDeclName());
5043 NTTPType = CheckNonTypeTemplateParameterType(NTTPType,
5044 NTTP->getLocation());
5051 llvm_unreachable(
"Should never see a NULL template argument here");
5056 unsigned CurSFINAEErrors = NumSFINAEErrors;
5057 ExprResult Res = CheckTemplateArgument(NTTP, NTTPType,
E, SugaredResult,
5058 CanonicalResult, CTAK);
5062 if (CurSFINAEErrors < NumSFINAEErrors)
5067 if (Res.
get() !=
E) {
5072 SugaredConverted.push_back(SugaredResult);
5073 CanonicalConverted.push_back(CanonicalResult);
5084 CanonicalConverted.push_back(
5122 E = CheckTemplateArgument(NTTP, NTTPType,
E.get(), SugaredResult,
5123 CanonicalResult, CTAK_Specified);
5127 SugaredConverted.push_back(SugaredResult);
5128 CanonicalConverted.push_back(CanonicalResult);
5137 NoteTemplateParameterLocation(*Param);
5155 Diag(SR.
getBegin(), diag::err_template_arg_nontype_ambig) << SR <<
T;
5157 Diag(SR.
getBegin(), diag::err_template_arg_must_be_expr) << SR;
5158 NoteTemplateParameterLocation(*Param);
5163 llvm_unreachable(
"Caller must expand template argument packs");
5192 SubstTemplateParams(Params, CurContext,
5194 Template, SugaredConverted,
true),
5213 llvm_unreachable(
"Should never see a NULL template argument here");
5217 if (CheckTemplateTemplateArgument(TempParm, Params, Arg,
5218 CTAK != CTAK_Specified))
5222 CanonicalConverted.push_back(
5231 << getLangOpts().CPlusPlus11;
5238 llvm_unreachable(
"non-type argument with template template parameter");
5241 llvm_unreachable(
"Caller must expand template argument packs");
5248 template<
typename TemplateParmDecl>
5251 const TemplateParmDecl *
D,
5256 ->getTemplateParameters()
5257 ->getParam(
D->getIndex()));
5264 D->getDefaultArgumentLoc(), Modules,
5275 S.
Diag(
Loc, diag::err_template_arg_list_different_arity)
5290 bool UpdateArgsWithConversions,
bool *ConstraintsNotSatisfied,
5291 bool PartialOrderingTTP) {
5310 bool isTemplateTemplateParameter = isa<TemplateTemplateParmDecl>(Template);
5313 unsigned ArgIdx = 0, NumArgs = NewArgs.
size();
5316 ParamEnd = Params->
end();
5317 Param != ParamEnd; ) {
5321 if (*Expansions == SugaredArgumentPack.size()) {
5324 SugaredConverted.push_back(
5326 SugaredArgumentPack.clear();
5328 CanonicalConverted.push_back(
5330 CanonicalArgumentPack.clear();
5335 }
else if (ArgIdx == NumArgs && !PartialTemplateArgs) {
5337 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
5346 if (ArgIdx < NumArgs) {
5348 if (CheckTemplateArgument(*Param, NewArgs[ArgIdx], Template, TemplateLoc,
5349 RAngleLoc, SugaredArgumentPack.size(),
5350 SugaredConverted, CanonicalConverted,
5354 CanonicalConverted.back().setIsDefaulted(
5357 CanonicalConverted, Params->
getDepth()));
5359 bool PackExpansionIntoNonPack =
5360 NewArgs[ArgIdx].getArgument().isPackExpansion() &&
5366 if (PackExpansionIntoNonPack && !PartialOrderingTTP &&
5367 (isa<TypeAliasTemplateDecl>(Template) ||
5368 isa<ConceptDecl>(Template))) {
5374 Diag(NewArgs[ArgIdx].getLocation(),
5375 diag::err_template_expansion_into_fixed_list)
5376 << (isa<ConceptDecl>(Template) ? 1 : 0)
5378 NoteTemplateParameterLocation(**Param);
5385 if ((*Param)->isTemplateParameterPack()) {
5390 SugaredArgumentPack.push_back(SugaredConverted.pop_back_val());
5391 CanonicalArgumentPack.push_back(CanonicalConverted.pop_back_val());
5400 if (PackExpansionIntoNonPack) {
5401 if (!SugaredArgumentPack.empty()) {
5404 SugaredConverted.insert(SugaredConverted.end(),
5405 SugaredArgumentPack.begin(),
5406 SugaredArgumentPack.end());
5407 SugaredArgumentPack.clear();
5409 CanonicalConverted.insert(CanonicalConverted.end(),
5410 CanonicalArgumentPack.begin(),
5411 CanonicalArgumentPack.end());
5412 CanonicalArgumentPack.clear();
5415 while (ArgIdx < NumArgs) {
5417 SugaredConverted.push_back(Arg);
5418 CanonicalConverted.push_back(
5430 if (PartialTemplateArgs) {
5431 if ((*Param)->isTemplateParameterPack() && !SugaredArgumentPack.empty()) {
5432 SugaredConverted.push_back(
5434 CanonicalConverted.push_back(
5442 if ((*Param)->isTemplateParameterPack()) {
5444 "Should have dealt with this already");
5449 if (Param + 1 != ParamEnd) {
5452 "Concept templates must have parameter packs at the end.");
5456 SugaredConverted.push_back(
5458 SugaredArgumentPack.clear();
5460 CanonicalConverted.push_back(
5462 CanonicalArgumentPack.clear();
5477 if (!hasReachableDefaultArgument(TTP))
5482 TTP, SugaredConverted,
5483 CanonicalConverted, Arg))
5486 = dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
5487 if (!hasReachableDefaultArgument(NTTP))
5492 NTTP, SugaredConverted,
5493 CanonicalConverted, Arg))
5497 = cast<TemplateTemplateParmDecl>(*Param);
5499 if (!hasReachableDefaultArgument(TempParm))
5505 *
this, Template, TemplateLoc, RAngleLoc, TempParm, SugaredConverted,
5506 CanonicalConverted, QualifierLoc);
5526 if (CheckTemplateArgument(*Param, Arg, Template, TemplateLoc, RAngleLoc, 0,
5527 SugaredConverted, CanonicalConverted,
5531 CanonicalConverted.back().setIsDefaulted(
true);
5536 if (isTemplateTemplateParameter)
5548 if (ArgIdx < NumArgs && CurrentInstantiationScope &&
5549 CurrentInstantiationScope->getPartiallySubstitutedPack()) {
5550 while (ArgIdx < NumArgs &&
5551 NewArgs[ArgIdx].
getArgument().isPackExpansion()) {
5553 SugaredConverted.push_back(Arg);
5560 if (ArgIdx < NumArgs) {
5561 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
5572 if (UpdateArgsWithConversions)
5573 TemplateArgs = std::move(NewArgs);
5575 if (!PartialTemplateArgs) {
5582 if (
auto *TD = dyn_cast<TemplateDecl>(NewContext))
5584 auto *RD = dyn_cast<CXXRecordDecl>(NewContext);
5587 if (
const auto *Method =
5589 ThisQuals = Method->getMethodQualifiers();
5595 Template, NewContext,
false, CanonicalConverted,
5599 if (EnsureTemplateArgumentListConstraints(
5612 class UnnamedLocalNoLinkageFinder
5613 :
public TypeVisitor<UnnamedLocalNoLinkageFinder, bool>
5621 UnnamedLocalNoLinkageFinder(
Sema &S,
SourceRange SR) : S(S), SR(SR) { }
5624 return T.isNull() ?
false : inherited::Visit(
T.getTypePtr());
5627 #define TYPE(Class, Parent) \
5628 bool Visit##Class##Type(const Class##Type *);
5629 #define ABSTRACT_TYPE(Class, Parent) \
5630 bool Visit##Class##Type(const Class##Type *) { return false; }
5631 #define NON_CANONICAL_TYPE(Class, Parent) \
5632 bool Visit##Class##Type(const Class##Type *) { return false; }
5633 #include "clang/AST/TypeNodes.inc"
5635 bool VisitTagDecl(
const TagDecl *Tag);
5640 bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(
const BuiltinType*) {
5644 bool UnnamedLocalNoLinkageFinder::VisitComplexType(
const ComplexType*
T) {
5645 return Visit(
T->getElementType());
5648 bool UnnamedLocalNoLinkageFinder::VisitPointerType(
const PointerType*
T) {
5652 bool UnnamedLocalNoLinkageFinder::VisitBlockPointerType(
5657 bool UnnamedLocalNoLinkageFinder::VisitLValueReferenceType(
5662 bool UnnamedLocalNoLinkageFinder::VisitRValueReferenceType(
5667 bool UnnamedLocalNoLinkageFinder::VisitMemberPointerType(
5672 bool UnnamedLocalNoLinkageFinder::VisitConstantArrayType(
5674 return Visit(
T->getElementType());
5677 bool UnnamedLocalNoLinkageFinder::VisitIncompleteArrayType(
5679 return Visit(
T->getElementType());
5682 bool UnnamedLocalNoLinkageFinder::VisitVariableArrayType(
5684 return Visit(
T->getElementType());
5687 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedArrayType(
5689 return Visit(
T->getElementType());
5692 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedExtVectorType(
5694 return Visit(
T->getElementType());
5697 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedMatrixType(
5699 return Visit(
T->getElementType());
5702 bool UnnamedLocalNoLinkageFinder::VisitDependentAddressSpaceType(
5707 bool UnnamedLocalNoLinkageFinder::VisitVectorType(
const VectorType*
T) {
5708 return Visit(
T->getElementType());
5711 bool UnnamedLocalNoLinkageFinder::VisitDependentVectorType(
5713 return Visit(
T->getElementType());
5716 bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(
const ExtVectorType*
T) {
5717 return Visit(
T->getElementType());
5720 bool UnnamedLocalNoLinkageFinder::VisitConstantMatrixType(
5722 return Visit(
T->getElementType());
5725 bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
5735 bool UnnamedLocalNoLinkageFinder::VisitFunctionNoProtoType(
5740 bool UnnamedLocalNoLinkageFinder::VisitUnresolvedUsingType(
5745 bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(
const TypeOfExprType*) {
5749 bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(
const TypeOfType*
T) {
5750 return Visit(
T->getUnmodifiedType());
5753 bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(
const DecltypeType*) {
5757 bool UnnamedLocalNoLinkageFinder::VisitPackIndexingType(
5762 bool UnnamedLocalNoLinkageFinder::VisitUnaryTransformType(
5767 bool UnnamedLocalNoLinkageFinder::VisitAutoType(
const AutoType *
T) {
5768 return Visit(
T->getDeducedType());
5771 bool UnnamedLocalNoLinkageFinder::VisitDeducedTemplateSpecializationType(
5773 return Visit(
T->getDeducedType());
5776 bool UnnamedLocalNoLinkageFinder::VisitRecordType(
const RecordType*
T) {
5777 return VisitTagDecl(
T->getDecl());
5780 bool UnnamedLocalNoLinkageFinder::VisitEnumType(
const EnumType*
T) {
5781 return VisitTagDecl(
T->getDecl());
5784 bool UnnamedLocalNoLinkageFinder::VisitTemplateTypeParmType(
5789 bool UnnamedLocalNoLinkageFinder::VisitSubstTemplateTypeParmPackType(
5794 bool UnnamedLocalNoLinkageFinder::VisitTemplateSpecializationType(
5799 bool UnnamedLocalNoLinkageFinder::VisitInjectedClassNameType(
5801 return VisitTagDecl(
T->getDecl());
5804 bool UnnamedLocalNoLinkageFinder::VisitDependentNameType(
5806 return VisitNestedNameSpecifier(
T->getQualifier());
5809 bool UnnamedLocalNoLinkageFinder::VisitDependentTemplateSpecializationType(
5811 if (
auto *Q =
T->getQualifier())
5812 return VisitNestedNameSpecifier(Q);
5816 bool UnnamedLocalNoLinkageFinder::VisitPackExpansionType(
5818 return Visit(
T->getPattern());
5821 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectType(
const ObjCObjectType *) {
5825 bool UnnamedLocalNoLinkageFinder::VisitObjCInterfaceType(
5830 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectPointerType(
5835 bool UnnamedLocalNoLinkageFinder::VisitAtomicType(
const AtomicType*
T) {
5836 return Visit(
T->getValueType());
5839 bool UnnamedLocalNoLinkageFinder::VisitPipeType(
const PipeType*
T) {
5843 bool UnnamedLocalNoLinkageFinder::VisitBitIntType(
const BitIntType *
T) {
5847 bool UnnamedLocalNoLinkageFinder::VisitArrayParameterType(
5849 return VisitConstantArrayType(
T);
5852 bool UnnamedLocalNoLinkageFinder::VisitDependentBitIntType(
5857 bool UnnamedLocalNoLinkageFinder::VisitTagDecl(
const TagDecl *Tag) {
5858 if (
Tag->getDeclContext()->isFunctionOrMethod()) {
5859 S.
Diag(SR.getBegin(),
5861 diag::warn_cxx98_compat_template_arg_local_type :
5862 diag::ext_template_arg_local_type)
5867 if (!
Tag->hasNameForLinkage()) {
5868 S.
Diag(SR.getBegin(),
5870 diag::warn_cxx98_compat_template_arg_unnamed_type :
5871 diag::ext_template_arg_unnamed_type) << SR;
5872 S.
Diag(
Tag->getLocation(), diag::note_template_unnamed_type_here);
5879 bool UnnamedLocalNoLinkageFinder::VisitNestedNameSpecifier(
5897 llvm_unreachable(
"Invalid NestedNameSpecifier::Kind!");
5901 assert(ArgInfo &&
"invalid TypeSourceInfo");
5907 return Diag(SR.
getBegin(), diag::err_variably_modified_template_arg) << Arg;
5909 return Diag(SR.
getBegin(), diag::err_template_arg_overload_type) << SR;
5920 UnnamedLocalNoLinkageFinder Finder(*
this, SR);
5921 (void)Finder.Visit(CanonArg);
5938 Decl *Entity =
nullptr) {
5944 if (Entity && Entity->hasAttr<DLLImportAttr>())
5949 "Incomplete parameter type in isNullPointerValueTemplateArgument!");
5962 EvalResult.
Diag = &Notes;
5970 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
5971 diag::note_invalid_subexpr_in_const_expr) {
5972 DiagLoc = Notes[0].first;
5976 S.
Diag(DiagLoc, diag::err_template_arg_not_address_constant)
5978 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
5979 S.
Diag(Notes[I].first, Notes[I].second);
5997 bool ObjCLifetimeConversion;
6000 ObjCLifetimeConversion))
6005 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
6024 std::string Code =
"static_cast<" + ParamType.
getAsString() +
">(";
6025 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_untyped_null_constant)
6044 bool ObjCLifetimeConversion;
6048 ObjCLifetimeConversion)) {
6053 if (!ParamRef->getPointeeType()->isFunctionType()) {
6063 unsigned ParamQuals = ParamRef->getPointeeType().getCVRQualifiers();
6066 if ((ParamQuals | ArgQuals) != ParamQuals) {
6068 diag::err_template_arg_ref_bind_ignores_quals)
6101 bool Invalid =
false;
6105 bool AddressTaken =
false;
6112 bool ExtWarnMSTemplateArg =
false;
6115 while (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(Arg)) {
6117 if (UnOpKind == UO_Deref)
6118 ExtWarnMSTemplateArg =
true;
6119 if (UnOpKind == UO_AddrOf || UnOpKind == UO_Deref) {
6122 FirstOpKind = UnOpKind;
6123 FirstOpLoc = UnOp->getOperatorLoc();
6129 if (ExtWarnMSTemplateArg)
6133 if (FirstOpKind == UO_AddrOf)
6134 AddressTaken =
true;
6138 assert(FirstOpKind == UO_Deref);
6161 bool ExtraParens =
false;
6163 if (!Invalid && !ExtraParens) {
6166 ? diag::warn_cxx98_compat_template_arg_extra_parens
6167 : diag::ext_template_arg_extra_parens)
6172 Arg =
Parens->getSubExpr();
6176 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6180 if (UnOp->getOpcode() == UO_AddrOf) {
6181 Arg = UnOp->getSubExpr();
6182 AddressTaken =
true;
6183 AddrOpLoc = UnOp->getOperatorLoc();
6188 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6193 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Arg))
6194 Entity = DRE->getDecl();
6196 Entity = CUE->getGuidDecl();
6203 S.
Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
6206 CanonicalConverted =
6223 CanonicalConverted =
6236 if (isa<FieldDecl>(Entity) || isa<IndirectFieldDecl>(Entity)) {
6244 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Entity)) {
6245 if (!Method->isStatic()) {
6254 VarDecl *Var = dyn_cast<VarDecl>(Entity);
6255 MSGuidDecl *Guid = dyn_cast<MSGuidDecl>(Entity);
6258 if (!
Func && !Var && !Guid) {
6270 ? diag::warn_cxx98_compat_template_arg_object_internal
6271 : diag::ext_template_arg_object_internal)
6273 S.
Diag(Entity->
getLocation(), diag::note_template_arg_internal_object)
6278 S.
Diag(Entity->
getLocation(), diag::note_template_arg_internal_object)
6307 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
6313 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
6355 CanonicalConverted =
6369 bool Invalid =
false;
6371 Expr *Arg = ResultArg;
6372 bool ObjCLifetimeConversion;
6384 bool ExtraParens =
false;
6386 if (!Invalid && !ExtraParens) {
6389 ? diag::warn_cxx98_compat_template_arg_extra_parens
6390 : diag::ext_template_arg_extra_parens)
6395 Arg =
Parens->getSubExpr();
6399 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6404 if (UnOp->getOpcode() == UO_AddrOf) {
6405 DRE = dyn_cast<DeclRefExpr>(UnOp->getSubExpr());
6411 else if ((DRE = dyn_cast<DeclRefExpr>(Arg))) {
6414 if (isa<NonTypeTemplateParmDecl>(VD)) {
6417 CanonicalConverted =
6421 CanonicalConverted =
6440 S.
Diag(ResultArg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
6452 ObjCLifetimeConversion)) {
6459 S.
Diag(ResultArg->
getBeginLoc(), diag::err_template_arg_not_convertible)
6467 diag::err_template_arg_not_pointer_to_member_form)
6470 if (isa<FieldDecl>(DRE->
getDecl()) ||
6471 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
6472 isa<CXXMethodDecl>(DRE->
getDecl())) {
6473 assert((isa<FieldDecl>(DRE->
getDecl()) ||
6474 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
6475 cast<CXXMethodDecl>(DRE->
getDecl())
6476 ->isImplicitObjectMemberFunction()) &&
6477 "Only non-static member pointers can make it here");
6483 CanonicalConverted =
6488 CanonicalConverted =
6496 S.
Diag(Arg->
getBeginLoc(), diag::err_template_arg_not_pointer_to_member_form)
6518 auto *AT = dyn_cast<AutoType>(DeducedT);
6519 if (AT && AT->isDecltypeAuto()) {
6530 Expr *DeductionArg = Arg;
6531 if (
auto *PE = dyn_cast<PackExpansionExpr>(DeductionArg))
6532 DeductionArg = PE->getPattern();
6535 if (isa<DeducedTemplateSpecializationType>(DeducedT)) {
6539 DeductionArg->
getBeginLoc(),
false, DeductionArg);
6540 Expr *Inits[1] = {DeductionArg};
6542 DeduceTemplateSpecializationFromInitializer(TSI, Entity,
Kind, Inits);
6550 DeduceAutoType(TSI->
getTypeLoc(), DeductionArg, ParamType, Info,
6563 diag::err_non_type_template_parm_type_deduction_failure)
6566 NoteTemplateParameterLocation(*Param);
6574 ParamType = CheckNonTypeTemplateParameterType(ParamType, Arg->
getExprLoc());
6575 if (ParamType.
isNull()) {
6576 NoteTemplateParameterLocation(*Param);
6583 "non-type template parameter type cannot be qualified");
6586 if (CTAK == CTAK_Deduced &&
6609 Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
6612 NoteTemplateParameterLocation(*Param);
6620 auto *PE = dyn_cast<PackExpansionExpr>(Arg);
6622 Arg = PE->getPattern();
6634 PE->getNumExpansions());
6652 if (ParamType->
isRecordType() && isa<DeclRefExpr>(InnerArg) &&
6654 NamedDecl *ND = cast<DeclRefExpr>(InnerArg)->getDecl();
6655 if (
auto *TPO = dyn_cast<TemplateParamObjectDecl>(ND)) {
6658 CanonicalConverted =
6662 if (isa<NonTypeTemplateParmDecl>(ND)) {
6664 CanonicalConverted =
6675 bool IsConvertedConstantExpression =
true;
6676 if (isa<InitListExpr>(Arg) || ParamType->
isRecordType()) {
6679 Expr *Inits[1] = {Arg};
6684 if (Result.isInvalid() || !Result.get())
6686 Result = ActOnConstantExpression(Result.get());
6687 if (Result.isInvalid() || !Result.get())
6689 Arg = ActOnFinishFullExpr(Result.get(), Arg->
getBeginLoc(),
6693 IsConvertedConstantExpression =
false;
6702 if (IsConvertedConstantExpression) {
6704 CCEK_TemplateArg, Param);
6715 CanonicalConverted =
6721 ArgResult = EvaluateConvertedConstantExpression(
6722 ArgResult.
get(), ParamType,
Value, CCEK_TemplateArg,
6723 false, PreNarrowingValue);
6727 if (
Value.isLValue()) {
6740 isa<LifetimeExtendedTemporaryDecl, UnnamedGlobalConstantDecl>(VD))) {
6746 if (
Value.hasLValuePath() &&
Value.getLValuePath().size() == 1 && VD &&
6748 Value.getLValuePath()[0].getAsArrayIndex() == 0 &&
6753 return ArgResult.
get();
6758 if (!
Value.hasLValuePath() ||
Value.getLValuePath().size() ||
6759 Value.isLValueOnePastTheEnd()) {
6760 Diag(StartLoc, diag::err_non_type_template_arg_subobject)
6761 <<
Value.getAsString(Context, ParamType);
6765 "null reference should not be a constant expression");
6767 "non-null value of type nullptr_t?");
6771 if (
Value.isAddrLabelDiff())
6772 return Diag(StartLoc, diag::err_non_type_template_arg_addr_label_diff);
6776 return ArgResult.
get();
6814 CanonicalConverted =
6824 IntegerType = Enum->getDecl()->getIntegerType();
6830 CanonicalConverted =
6835 ExprResult ArgResult = DefaultLvalueConversion(Arg);
6838 Arg = ArgResult.
get();
6851 Diag(Arg->
getBeginLoc(), diag::err_template_arg_not_integral_or_enumeral)
6853 NoteTemplateParameterLocation(*Param);
6864 return S.
Diag(
Loc, diag::err_template_arg_not_ice) <<
T;
6866 } Diagnoser(ArgType);
6868 Arg = VerifyIntegerConstantExpression(Arg, &
Value, Diagnoser).get();
6882 Arg = ImpCastExprToType(Arg, ParamType, CK_IntegralToBoolean).get();
6883 }
else if (IsIntegralPromotion(Arg, ArgType, ParamType) ||
6886 Arg = ImpCastExprToType(Arg, ParamType, CK_IntegralCast).get();
6891 NoteTemplateParameterLocation(*Param);
6902 CanonicalConverted =
6909 IntegerType = Enum->getDecl()->getIntegerType();
6915 unsigned AllowedBits = Context.
getTypeSize(IntegerType);
6916 if (
Value.getBitWidth() != AllowedBits)
6927 if (
Value.getBitWidth() != AllowedBits)
6933 (OldValue.isSigned() && OldValue.isNegative())) {
6937 NoteTemplateParameterLocation(*Param);
6941 unsigned RequiredBits;
6943 RequiredBits = OldValue.getActiveBits();
6944 else if (OldValue.isUnsigned())
6945 RequiredBits = OldValue.getActiveBits() + 1;
6947 RequiredBits = OldValue.getSignificantBits();
6948 if (RequiredBits > AllowedBits) {
6952 NoteTemplateParameterLocation(*Param);
6958 CanonicalConverted =
6991 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg, ParamType,
6997 ExprResult Res = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
7008 *
this, Param, ParamType, Arg, SugaredConverted,
7009 CanonicalConverted))
7015 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
7026 "Only object pointers allowed here");
7029 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
7041 assert(ParamRefType->getPointeeType()->isIncompleteOrObjectType() &&
7042 "Only object references allowed here");
7045 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg,
7046 ParamRefType->getPointeeType(),
7051 ExprResult Res = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
7061 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
7070 CanonicalConverted =
7078 << Arg->
getType() << ParamType;
7079 NoteTemplateParameterLocation(*Param);
7086 Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
7100 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
7117 assert(Name.isDependent() &&
"Non-dependent template isn't a declaration?");
7136 if (!isa<ClassTemplateDecl>(Template) &&
7137 !isa<TemplateTemplateParmDecl>(Template) &&
7138 !isa<TypeAliasTemplateDecl>(Template) &&
7139 !isa<BuiltinTemplateDecl>(Template)) {
7140 assert(isa<FunctionTemplateDecl>(Template) &&
7141 "Only function templates are possible here");
7143 Diag(Template->
getLocation(), diag::note_template_arg_refers_here_func)
7150 if (getLangOpts().RelaxedTemplateTemplateArgs) {
7155 if (TemplateParameterListsAreEqual(
7157 TPL_TemplateTemplateArgumentMatch, Arg.
getLocation()) &&
7164 if (isTemplateTemplateParameterAtLeastAsSpecializedAs(
7165 Params, Template, Arg.
getLocation(), IsDeduced)) {
7175 if (ParamsAC.empty())
7180 bool IsParamAtLeastAsConstrained;
7181 if (IsAtLeastAsConstrained(Param, ParamsAC, Template, TemplateAC,
7182 IsParamAtLeastAsConstrained))
7184 if (!IsParamAtLeastAsConstrained) {
7186 diag::err_template_template_parameter_not_at_least_as_constrained)
7191 MaybeEmitAmbiguousAtomicConstraintsDiagnostic(Param, ParamsAC, Template,
7203 TPL_TemplateTemplateArgumentMatch,
7208 unsigned HereDiagID,
7209 unsigned ExternalDiagID) {
7214 llvm::raw_svector_ostream Out(Str);
7222 std::optional<SourceRange> ParamRange) {
7225 diag::note_template_decl_external);
7226 if (ParamRange && ParamRange->isValid()) {
7228 "Parameter range has location when Decl does not");
7235 diag::note_template_param_external);
7254 return ImpCastExprToType(
7258 ? CK_NullToMemberPointer
7259 : CK_NullToPointer);
7262 "Only declaration template arguments permitted here");
7271 (isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD) ||
7272 isa<IndirectFieldDecl>(VD)));
7281 ExprResult RefExpr = BuildDeclarationNameExpr(
7291 RefExpr = DefaultFunctionArrayConversion(RefExpr.
get());
7296 RefExpr = CreateBuiltinUnaryOp(
Loc, UO_AddrOf, RefExpr.
get());
7300 assert(isa<TemplateParamObjectDecl>(VD) &&
7301 "arg for class template param not a template parameter object");
7306 "unexpected type for decl template argument");
7308 dyn_cast_if_present<NonTypeTemplateParmDecl>(
TemplateParam)) {
7309 QualType TemplateParamType = NTTP->getType();
7323 "value kind mismatch for non-type template argument");
7332 IsFunctionConversion(RefExpr.
get()->
getType(), DestExprType, Ignored)) {
7343 "unexpected conversion required for non-type template argument");
7345 RefExpr = ImpCastExprToType(RefExpr.
get(), DestExprType, CK,
7370 T = ET->getDecl()->getIntegerType();
7421 llvm_unreachable(
"unexpected template argument value");
7446 return MakeInitList(
7459 return MakeInitList(Elts);
7464 llvm_unreachable(
"Unexpected APValue kind.");
7480 llvm_unreachable(
"Unhandled APValue::ValueKind enum");
7492 llvm_unreachable(
"not a non-type template argument");
7499 return BuildExpressionFromDeclTemplateArgument(
7510 llvm_unreachable(
"Unhandled TemplateArgument::ArgKind enum");
7517 const NamedDecl *OldInstFrom,
bool Complain,
7522 unsigned NextDiag = diag::err_template_param_different_kind;
7523 if (TemplateArgLoc.
isValid()) {
7524 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
7525 NextDiag = diag::note_template_param_different_kind;
7544 unsigned NextDiag = diag::err_template_parameter_pack_non_pack;
7545 if (TemplateArgLoc.
isValid()) {
7546 S.
Diag(TemplateArgLoc,
7547 diag::err_template_arg_template_params_mismatch);
7548 NextDiag = diag::note_template_parameter_pack_non_pack;
7551 unsigned ParamKind = isa<TemplateTypeParmDecl>(New)? 0
7552 : isa<NonTypeTemplateParmDecl>(New)? 1
7565 = dyn_cast<NonTypeTemplateParmDecl>(Old)) {
7573 (!OldNTTP->getType()->isDependentType() &&
7583 unsigned NextDiag = diag::err_template_nontype_parm_different_type;
7584 if (TemplateArgLoc.
isValid()) {
7585 S.
Diag(TemplateArgLoc,
7586 diag::err_template_arg_template_params_mismatch);
7587 NextDiag = diag::note_template_nontype_parm_different_type;
7592 S.
Diag(OldNTTP->getLocation(),
7593 diag::note_template_nontype_parm_prev_declaration)
7594 << OldNTTP->getType();
7605 dyn_cast<TemplateTemplateParmDecl>(Old)) {
7609 OldTTP->getTemplateParameters(), Complain,
7619 !isa<TemplateTemplateParmDecl>(Old)) {
7620 const Expr *NewC =
nullptr, *OldC =
nullptr;
7622 if (isa<TemplateTypeParmDecl>(New)) {
7623 if (
const auto *TC = cast<TemplateTypeParmDecl>(New)->getTypeConstraint())
7624 NewC = TC->getImmediatelyDeclaredConstraint();
7625 if (
const auto *TC = cast<TemplateTypeParmDecl>(Old)->getTypeConstraint())
7626 OldC = TC->getImmediatelyDeclaredConstraint();
7627 }
else if (isa<NonTypeTemplateParmDecl>(New)) {
7628 if (
const Expr *
E = cast<NonTypeTemplateParmDecl>(New)
7629 ->getPlaceholderTypeConstraint())
7631 if (
const Expr *
E = cast<NonTypeTemplateParmDecl>(Old)
7632 ->getPlaceholderTypeConstraint())
7635 llvm_unreachable(
"unexpected template parameter type");
7637 auto Diagnose = [&] {
7639 diag::err_template_different_type_constraint);
7641 diag::note_template_prev_declaration) << 0;
7644 if (!NewC != !OldC) {
7671 unsigned NextDiag = diag::err_template_param_list_different_arity;
7672 if (TemplateArgLoc.
isValid()) {
7673 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
7674 NextDiag = diag::note_template_param_list_different_arity;
7689 if (Old->
size() != New->
size() &&
Kind != TPL_TemplateTemplateArgumentMatch) {
7706 OldParmEnd = Old->
end();
7707 OldParm != OldParmEnd; ++OldParm) {
7708 if (
Kind != TPL_TemplateTemplateArgumentMatch ||
7709 !(*OldParm)->isTemplateParameterPack()) {
7710 if (NewParm == NewParmEnd) {
7719 OldInstFrom, Complain,
Kind,
7734 for (; NewParm != NewParmEnd; ++NewParm) {
7736 OldInstFrom, Complain,
Kind,
7743 if (NewParm != NewParmEnd) {
7751 if (
Kind != TPL_TemplateTemplateArgumentMatch &&
7752 Kind != TPL_TemplateParamsEquivalent) {
7756 auto Diagnose = [&] {
7758 diag::err_template_different_requires_clause);
7760 diag::note_template_prev_declaration) << 0;
7763 if (!NewRC != !OldRC) {
7770 if (!AreConstraintExpressionsEqual(OldInstFrom, OldRC, NewInstFrom,
7788 S = S->getDeclParent();
7798 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
7818 if (RD->isLocalClass())
7820 diag::err_template_inside_local_class)
7828 diag::err_template_outside_namespace_or_class_scope)
7839 return Record->getTemplateSpecializationKind();
7841 return Function->getTemplateSpecializationKind();
7842 if (
VarDecl *Var = dyn_cast<VarDecl>(
D))
7843 return Var->getTemplateSpecializationKind();
7880 if (isa<ClassTemplateDecl>(Specialized))
7882 else if (isa<VarTemplateDecl>(Specialized))
7884 else if (isa<FunctionTemplateDecl>(Specialized))
7886 else if (isa<CXXMethodDecl>(Specialized))
7888 else if (isa<VarDecl>(Specialized))
7890 else if (isa<RecordDecl>(Specialized))
7892 else if (isa<EnumDecl>(Specialized) && S.
getLangOpts().CPlusPlus11)
7895 S.
Diag(
Loc, diag::err_template_spec_unknown_kind)
7905 S.
Diag(
Loc, diag::err_template_spec_decl_function_scope)
7920 : DC->
Equals(SpecializedContext))) {
7921 if (isa<TranslationUnitDecl>(SpecializedContext))
7922 S.
Diag(
Loc, diag::err_template_spec_redecl_global_scope)
7923 << EntityKind << Specialized;
7925 auto *ND = cast<NamedDecl>(SpecializedContext);
7926 int Diag = diag::err_template_spec_redecl_out_of_scope;
7928 Diag = diag::ext_ms_template_spec_redecl_out_of_scope;
7930 << ND << isa<CXXRecordDecl>(ND);
7933 S.
Diag(Specialized->getLocation(), diag::note_specialized_entity);
7947 DependencyChecker Checker(
Depth,
true);
7948 Checker.TraverseStmt(
E);
7949 if (Checker.MatchLoc.isInvalid())
7951 return Checker.MatchLoc;
7957 DependencyChecker Checker(
Depth,
true);
7958 Checker.TraverseTypeLoc(TL);
7959 if (Checker.MatchLoc.isInvalid())
7961 return Checker.MatchLoc;
7969 for (
unsigned I = 0; I != NumArgs; ++I) {
7972 S, TemplateNameLoc, Param, Args[I].pack_begin(),
7973 Args[I].pack_size(), IsDefaultArgument))
7986 ArgExpr = Expansion->getPattern();
7990 ArgExpr = ICE->getSubExpr();
8000 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ArgExpr))
8001 if (isa<NonTypeTemplateParmDecl>(DRE->getDecl()))
8021 if (ParamUseRange.
isValid()) {
8022 if (IsDefaultArgument) {
8023 S.
Diag(TemplateNameLoc,
8024 diag::err_dependent_non_type_arg_in_partial_spec);
8026 diag::note_dependent_non_type_default_arg_in_partial_spec)
8030 diag::err_dependent_non_type_arg_in_partial_spec)
8038 if (ParamUseRange.
isValid()) {
8040 diag::err_dependent_typed_non_type_arg_in_partial_spec)
8060 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
8062 = dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->
getParam(I));
8067 Param, &TemplateArgs[I],
8068 1, I >= NumExplicit))
8089 = dyn_cast_or_null<ClassTemplateDecl>(Name.getAsTemplateDecl());
8091 if (!ClassTemplate) {
8092 Diag(TemplateNameLoc, diag::err_not_class_template_specialization)
8093 << (Name.getAsTemplateDecl() &&
8094 isa<TemplateTemplateParmDecl>(Name.getAsTemplateDecl()));
8098 bool isMemberSpecialization =
false;
8099 bool isPartialSpecialization =
false;
8103 diagnoseQualifiedDeclaration(SS, ClassTemplate->
getDeclContext(),
8105 TemplateNameLoc, &TemplateId,
8114 bool Invalid =
false;
8116 MatchTemplateParametersToScopeSpecifier(
8117 KWLoc, TemplateNameLoc, SS, &TemplateId, TemplateParameterLists,
8123 if (TemplateParams && CheckTemplateDeclScope(S, TemplateParams))
8126 if (TemplateParams && TemplateParams->
size() > 0) {
8127 isPartialSpecialization =
true;
8130 Diag(KWLoc, diag::err_partial_specialization_friend)
8138 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
8141 if (TTP->hasDefaultArgument()) {
8142 Diag(TTP->getDefaultArgumentLoc(),
8143 diag::err_default_arg_in_partial_spec);
8144 TTP->removeDefaultArgument();
8147 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
8148 if (NTTP->hasDefaultArgument()) {
8149 Diag(NTTP->getDefaultArgumentLoc(),
8150 diag::err_default_arg_in_partial_spec)
8151 << NTTP->getDefaultArgument().getSourceRange();
8152 NTTP->removeDefaultArgument();
8158 diag::err_default_arg_in_partial_spec)
8164 }
else if (TemplateParams) {
8166 Diag(KWLoc, diag::err_template_spec_friend)
8173 "should have a 'template<>' for this decl");
8180 "Invalid enum tag in class template spec!");
8184 Diag(KWLoc, diag::err_use_with_wrong_tag)
8189 diag::note_previous_use);
8198 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
8199 if (DiagnoseUnexpandedParameterPack(TemplateArgs[I],
8200 isPartialSpecialization
8201 ? UPPC_PartialSpecialization
8202 : UPPC_ExplicitSpecialization))
8208 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc, TemplateArgs,
8209 false, SugaredConverted, CanonicalConverted,
8215 if (isPartialSpecialization) {
8216 if (CheckTemplatePartialSpecializationArgs(TemplateNameLoc, ClassTemplate,
8217 TemplateArgs.
size(),
8218 CanonicalConverted))
8223 if (!Name.isDependent() &&
8225 TemplateArgs, CanonicalConverted)) {
8226 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
8228 isPartialSpecialization =
false;
8233 void *InsertPos =
nullptr;
8236 if (isPartialSpecialization)
8238 CanonicalConverted, TemplateParams, InsertPos);
8249 isPartialSpecialization))
8254 if (isPartialSpecialization) {
8259 CanonicalConverted);
8272 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
8275 return CheckClassTemplate(S, TagSpec, TUK, KWLoc, SS,
8282 TemplateParameterLists.size() - 1,
8283 TemplateParameterLists.data());
8288 = cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl);
8292 TemplateNameLoc, TemplateParams, ClassTemplate, CanonicalConverted,
8293 CanonType, PrevPartial);
8296 if (TemplateParameterLists.size() > 1 && SS.
isSet()) {
8298 Context, TemplateParameterLists.drop_back(1));
8310 CheckTemplatePartialSpecialization(Partial);
8316 ClassTemplate, CanonicalConverted, PrevDecl);
8319 if (TemplateParameterLists.size() > 0) {
8321 TemplateParameterLists);
8327 if (CurContext->isDependentContext()) {
8330 CanonicalConverted);
8354 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
8358 diag::note_instantiation_required_here)
8373 if (Def && SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
8376 makeMergedDefinitionVisible(Hidden);
8396 if (ModulePrivateLoc.
isValid())
8398 << (isPartialSpecialization? 1 : 0)
8424 Name, TemplateNameLoc, TemplateArgs, CanonType);
8430 CurContext->addDecl(
Friend);
8448 Decl *NewDecl = HandleDeclarator(S,
D, TemplateParameterLists);
8449 ActOnDocumentableDecl(NewDecl);
8460 diag::err_concept_decls_may_only_appear_in_global_namespace_scope);
8464 if (TemplateParameterLists.size() > 1) {
8465 Diag(NameLoc, diag::err_concept_extra_headers);
8471 if (Params->
size() == 0) {
8472 Diag(NameLoc, diag::err_concept_no_parameters);
8479 ParamEnd = Params->
end();
8480 ParamIt != ParamEnd; ++ParamIt) {
8481 Decl const *Param = *ParamIt;
8483 if (++ParamIt == ParamEnd)
8486 diag::err_template_param_pack_must_be_last_template_parameter);
8497 Diag(NameLoc, diag::err_concept_no_associated_constraints);
8503 forRedeclarationInCurContext());
8505 FilterLookupForScope(
Previous, CurContext, S,
false,
8512 PushOnScopeChains(NewDecl, S,
true);
8534 Expr *ConstraintExpr,
8536 assert(!C->hasDefinition() &&
"Concept already defined");
8537 if (DiagnoseUnexpandedParameterPack(ConstraintExpr))
8539 C->setDefinition(ConstraintExpr);
8540 ProcessDeclAttributeList(S, C, Attrs);
8545 forRedeclarationInCurContext());
8547 FilterLookupForScope(
Previous, CurContext, S,
false,
8550 bool AddToScope =
true;
8551 CheckConceptRedefinition(C,
Previous, AddToScope);
8553 ActOnDocumentableDecl(C);
8554 if (!WasAlreadyAdded && AddToScope)
8555 PushOnScopeChains(C, S);
8567 auto *OldConcept = dyn_cast<ConceptDecl>(
Previous.getRepresentativeDecl()->getUnderlyingDecl());
8569 auto *Old =
Previous.getRepresentativeDecl();
8572 notePreviousDefinition(Old, NewDecl->
getLocation());
8577 bool IsSame = Context.
isSameEntity(NewDecl, OldConcept);
8579 Diag(NewDecl->
getLocation(), diag::err_redefinition_different_concept)
8581 notePreviousDefinition(OldConcept, NewDecl->
getLocation());
8585 if (hasReachableDefinition(OldConcept) &&
8586 IsRedefinitionInModule(NewDecl, OldConcept)) {
8589 notePreviousDefinition(OldConcept, NewDecl->
getLocation());
8604 if (!Concept->isInvalidDecl() && !Concept->hasDefinition()) {
8605 Diag(
Loc, diag::err_recursive_concept) << Concept;
8606 Diag(Concept->getLocation(), diag::note_declared_at);
8615 if (MinGW || (isa<FunctionDecl>(
D) &&
8616 cast<FunctionDecl>(
D)->isFunctionTemplateSpecialization()))
8617 D->
dropAttrs<DLLImportAttr, DLLExportAttr>();
8620 FD->setInlineSpecified(
false);
8632 Prev = Prev->getPreviousDecl()) {
8633 PrevDiagLoc = Prev->getLocation();
8635 assert(PrevDiagLoc.
isValid() &&
8636 "Explicit instantiation without point of instantiation?");
8646 bool &HasNoEffect) {
8647 HasNoEffect =
false;
8654 "previous declaration must be implicit!");
8667 if (PrevPointOfInstantiation.
isInvalid()) {
8681 PrevPointOfInstantiation.
isValid()) &&
8682 "Explicit instantiation without point of instantiation?");
8696 Diag(NewLoc, diag::err_specialization_after_instantiation)
8698 Diag(PrevPointOfInstantiation, diag::note_instantiation_required_here)
8703 llvm_unreachable(
"The switch over PrevTSK must be exhaustive.");
8733 diag::err_explicit_instantiation_declaration_after_definition);
8739 diag::note_explicit_instantiation_definition_here);
8743 llvm_unreachable(
"Unexpected TemplateSpecializationKind!");
8759 Diag(NewLoc, diag::warn_explicit_instantiation_after_specialization)
8762 diag::note_previous_template_specialization);
8792 Diag(NewLoc, (getLangOpts().MSVCCompat)
8793 ? diag::ext_explicit_instantiation_duplicate
8794 : diag::err_explicit_instantiation_duplicate)
8797 diag::note_previous_explicit_instantiation);
8803 llvm_unreachable(
"Missing specialization/instantiation case?");
8813 enum DiscardReason { NotAFunctionTemplate, NotAMemberOfEnclosing };
8817 if (!isa<FunctionTemplateDecl>(
D)) {
8819 DiscardedCandidates.push_back(std::make_pair(NotAFunctionTemplate,
D));
8826 DiscardedCandidates.push_back(std::make_pair(NotAMemberOfEnclosing,
D));
8834 Diag(FD->
getLocation(), diag::err_dependent_function_template_spec_no_match)
8836 for (
auto &
P : DiscardedCandidates)
8837 Diag(
P.second->getLocation(),
8838 diag::note_dependent_function_template_spec_discard_reason)
8839 <<
P.first << IsFriend;
8844 ExplicitTemplateArgs);
8857 llvm::SmallDenseMap<FunctionDecl *, TemplateArgumentListInfo, 8>
8858 ConvertedTemplateArgs;
8881 if (
auto *NewMD = dyn_cast<CXXMethodDecl>(FD);
8882 !getLangOpts().CPlusPlus14 && NewMD && NewMD->isConstexpr() &&
8883 !isa<CXXConstructorDecl, CXXDestructorDecl>(NewMD)) {
8884 auto *OldMD = dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl());
8885 if (OldMD && OldMD->isConst()) {
8895 if (ExplicitTemplateArgs)
8896 Args = *ExplicitTemplateArgs;
8908 cast<FunctionTemplateDecl>(FunTmpl->getFirstDecl()),
8909 ExplicitTemplateArgs ? &Args :
nullptr, FT,
Specialization, Info);
8914 I.getPair(), FunTmpl->getTemplatedDecl(),
8925 if (LangOpts.CUDA &&
8928 CUDA().IdentifyTarget(FD,
true)) {
8930 I.getPair(), FunTmpl->getTemplatedDecl(),
8937 if (ExplicitTemplateArgs)
8946 if (QualifiedFriend && Candidates.
empty()) {
8952 if (
auto *OldFD = dyn_cast<FunctionDecl>(OldND->getUnderlyingDecl()))
8962 PDiag(diag::err_function_template_spec_no_match) << FD->
getDeclName(),
8963 PDiag(diag::err_function_template_spec_ambiguous)
8964 << FD->
getDeclName() << (ExplicitTemplateArgs !=
nullptr),
8965 PDiag(diag::note_function_template_spec_matched));
8967 if (Result == Candidates.
end())
8998 auto *SpecializationFPT =
9002 if (getLangOpts().CPlusPlus17 &&
9004 !ResolveExceptionSpec(FD->
getLocation(), SpecializationFPT))
9009 assert(SpecInfo &&
"Function template specialization info missing?");
9047 bool HasNoEffect =
false;
9049 CheckSpecializationInstantiationRedecl(FD->
getLocation(),
9073 "This must be the only existing declaration of this specialization");
9087 Context,
Specialization->getTemplateSpecializationArgs()->asArray());
9088 FD->setFunctionTemplateSpecialization(
9091 ExplicitTemplateArgs ? &ConvertedTemplateArgs[
Specialization] :
nullptr);
9110 assert(!
Member->isTemplateDecl() && !
Member->getDescribedTemplate() &&
9111 "Only for non-template members");
9114 NamedDecl *FoundInstantiation =
nullptr;
9124 auto *Method = dyn_cast<CXXMethodDecl>(Candidate->getUnderlyingDecl());
9130 if (!hasExplicitCallingConv(Adjusted))
9131 Adjusted = adjustCCAndNoReturn(Adjusted, Method->getType());
9137 if (!Context.
hasSameType(Adjusted, Method->getType()))
9142 Method->getTrailingRequiresClause() &&
9143 (CheckFunctionConstraints(Method, Satisfaction,
9146 !Satisfaction.IsSatisfied))
9149 Candidates.
addDecl(Candidate);
9153 if (Candidates.
empty())
9162 auto *Method = cast<CXXMethodDecl>(I->getUnderlyingDecl());
9164 getMoreConstrainedFunction(Method, BestMethod) == Method) {
9166 BestMethod = Method;
9170 FoundInstantiation = *Best;
9171 Instantiation = BestMethod;
9176 bool Ambiguous =
false;
9179 auto *Method = cast<CXXMethodDecl>(I->getUnderlyingDecl());
9181 getMoreConstrainedFunction(Method, BestMethod) != BestMethod) {
9188 Diag(
Member->getLocation(), diag::err_function_member_spec_ambiguous)
9189 <<
Member << (InstantiatedFrom ? InstantiatedFrom : Instantiation);
9190 for (
NamedDecl *Candidate : Candidates) {
9191 Candidate = Candidate->getUnderlyingDecl();
9192 Diag(Candidate->getLocation(), diag::note_function_member_spec_matched)
9197 }
else if (isa<VarDecl>(
Member)) {
9200 (PrevVar = dyn_cast<VarDecl>(
Previous.getFoundDecl())))
9202 FoundInstantiation =
Previous.getRepresentativeDecl();
9203 Instantiation = PrevVar;
9207 }
else if (isa<RecordDecl>(
Member)) {
9210 (PrevRecord = dyn_cast<CXXRecordDecl>(
Previous.getFoundDecl()))) {
9211 FoundInstantiation =
Previous.getRepresentativeDecl();
9212 Instantiation = PrevRecord;
9216 }
else if (isa<EnumDecl>(
Member)) {
9219 (PrevEnum = dyn_cast<EnumDecl>(
Previous.getFoundDecl()))) {
9220 FoundInstantiation =
Previous.getRepresentativeDecl();
9221 Instantiation = PrevEnum;
9227 if (!Instantiation) {
9241 if (InstantiatedFrom && isa<CXXMethodDecl>(
Member)) {
9242 cast<CXXMethodDecl>(
Member)->setInstantiationOfMemberFunction(
9243 cast<CXXMethodDecl>(InstantiatedFrom),
9245 }
else if (InstantiatedFrom && isa<CXXRecordDecl>(
Member)) {
9246 cast<CXXRecordDecl>(
Member)->setInstantiationOfMemberClass(
9247 cast<CXXRecordDecl>(InstantiatedFrom),
9252 Previous.addDecl(FoundInstantiation);
9257 if (!InstantiatedFrom) {
9258 Diag(
Member->getLocation(), diag::err_spec_member_not_instantiated)
9270 assert(MSInfo &&
"Member specialization info missing?");
9272 bool HasNoEffect =
false;
9273 if (CheckSpecializationInstantiationRedecl(
Member->getLocation(),
9284 Instantiation,
Member->getLocation(),
9290 if (
auto *MemberFunction = dyn_cast<FunctionDecl>(
Member)) {
9291 FunctionDecl *InstantiationFunction = cast<FunctionDecl>(Instantiation);
9296 if (InstantiationFunction->
isDeleted()) {
9299 InstantiationFunction);
9305 MemberFunction->setInstantiationOfMemberFunction(
9307 }
else if (
auto *MemberVar = dyn_cast<VarDecl>(
Member)) {
9308 MemberVar->setInstantiationOfStaticDataMember(
9310 }
else if (
auto *MemberClass = dyn_cast<CXXRecordDecl>(
Member)) {
9311 MemberClass->setInstantiationOfMemberClass(
9313 }
else if (
auto *MemberEnum = dyn_cast<EnumDecl>(
Member)) {
9314 MemberEnum->setInstantiationOfMemberEnum(
9317 llvm_unreachable(
"unknown member specialization kind");
9323 Previous.addDecl(FoundInstantiation);
9332 template<
typename DeclT>
9343 OrigD->setLocation(
Loc);
9348 NamedDecl *Instantiation = cast<NamedDecl>(
Member->getCanonicalDecl());
9349 if (Instantiation ==
Member)
9352 if (
auto *
Function = dyn_cast<CXXMethodDecl>(Instantiation))
9354 else if (
auto *Var = dyn_cast<VarDecl>(Instantiation))
9356 else if (
auto *
Record = dyn_cast<CXXRecordDecl>(Instantiation))
9358 else if (
auto *Enum = dyn_cast<EnumDecl>(Instantiation))
9361 llvm_unreachable(
"unknown member specialization kind");
9369 bool WasQualifiedName) {
9374 S.
Diag(InstLoc, diag::err_explicit_instantiation_in_class)
9387 if (WasQualifiedName) {
9388 if (CurContext->
Encloses(OrigContext))
9395 if (
NamespaceDecl *NS = dyn_cast<NamespaceDecl>(OrigContext)) {
9396 if (WasQualifiedName)
9399 diag::err_explicit_instantiation_out_of_scope :
9400 diag::warn_explicit_instantiation_out_of_scope_0x)
9405 diag::err_explicit_instantiation_unqualified_wrong_namespace :
9406 diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x)
9411 diag::err_explicit_instantiation_must_be_global :
9412 diag::warn_explicit_instantiation_must_be_global_0x)
9421 bool WasQualifiedName,
9428 S.
Diag(InstLoc, diag::err_explicit_instantiation_internal_linkage) <<
D;
9456 if (isa<TemplateSpecializationType>(
T))
9466 auto *A = cast_or_null<InheritableAttr>(
getDLLAttr(Def));
9467 assert(A &&
"dllExportImportClassTemplateSpecialization called "
9468 "on Def without dllexport or dllimport");
9473 "delayed exports present at explicit instantiation");
9477 for (
auto &B : Def->
bases()) {
9478 if (
auto *BT = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
9479 B.getType()->getAsCXXRecordDecl()))
9499 "Invalid enum tag in class template explicit instantiation!");
9503 if (!ClassTemplate) {
9505 Diag(TemplateNameLoc, diag::err_tag_reference_non_tag)
9506 << TD << NTK << llvm::to_underlying(
Kind);
9514 Diag(KWLoc, diag::err_use_with_wrong_tag)
9519 diag::note_previous_use);
9536 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
9538 diag::warn_attribute_dllexport_explicit_instantiation_decl);
9539 Diag(AL.getLoc(), diag::note_attribute);
9546 diag::warn_attribute_dllexport_explicit_instantiation_decl);
9547 Diag(A->getLocation(), diag::note_attribute);
9553 bool DLLImportExplicitInstantiationDef =
false;
9560 if (AL.getKind() == ParsedAttr::AT_DLLImport)
9562 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
9570 DLLImportExplicitInstantiationDef =
true;
9576 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
9581 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc, TemplateArgs,
9582 false, SugaredConverted, CanonicalConverted,
9588 void *InsertPos =
nullptr;
9600 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
9602 diag::warn_attribute_dllexport_explicit_instantiation_def);
9614 bool HasNoEffect =
false;
9616 if (CheckSpecializationInstantiationRedecl(TemplateNameLoc, TSK,
9617 PrevDecl, PrevDecl_TSK,
9638 DLLImportExplicitInstantiationDef) {
9640 HasNoEffect =
false;
9649 ClassTemplate, CanonicalConverted, PrevDecl);
9655 if (
const auto *A = PrevDecl->
getAttr<MSInheritanceAttr>()) {
9656 auto *Clone = A->clone(getASTContext());
9657 Clone->setInherited(
true);
9663 if (!HasNoEffect && !PrevDecl) {
9676 bool PreviouslyDLLExported =
Specialization->hasAttr<DLLExportAttr>();
9701 = cast_or_null<ClassTemplateSpecializationDecl>(
9704 InstantiateClassTemplateSpecialization(TemplateNameLoc,
Specialization, TSK);
9711 Def = cast_or_null<ClassTemplateSpecializationDecl>(
9719 DLLImportExplicitInstantiationDef)) {
9728 auto *A = cast<InheritableAttr>(
9730 A->setInherited(
true);
9738 bool NewlyDLLExported =
9739 !PreviouslyDLLExported &&
Specialization->hasAttr<DLLExportAttr>();
9755 "Def and Specialization should match for implicit instantiation");
9763 PrevDecl->
hasAttr<DLLExportAttr>()) {
9770 InstantiateClassTemplateSpecializationMembers(TemplateNameLoc, Def, TSK);
9788 bool IsDependent =
false;
9796 assert(!IsDependent &&
"explicit instantiation of dependent name not yet handled");
9801 TagDecl *Tag = cast<TagDecl>(TagD);
9802 assert(!Tag->isEnum() &&
"shouldn't see enumerations here");
9804 if (Tag->isInvalidDecl())
9810 Diag(TemplateLoc, diag::err_explicit_instantiation_nontemplate_type)
9812 Diag(
Record->getLocation(), diag::note_nontemplate_decl_here);
9823 Diag(TemplateLoc, diag::ext_explicit_instantiation_without_qualified_id)
9838 = cast_or_null<CXXRecordDecl>(
Record->getPreviousDecl());
9843 bool HasNoEffect =
false;
9844 assert(MSInfo &&
"No member specialization information?");
9845 if (CheckSpecializationInstantiationRedecl(TemplateLoc, TSK,
9856 = cast_or_null<CXXRecordDecl>(
Record->getDefinition());
9864 Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member)
9865 << 0 <<
Record->getDeclName() <<
Record->getDeclContext();
9870 if (InstantiateClass(NameLoc,
Record, Def,
9871 getTemplateInstantiationArgs(
Record),
9875 RecordDef = cast_or_null<CXXRecordDecl>(
Record->getDefinition());
9882 InstantiateClassMembers(NameLoc, RecordDef,
9883 getTemplateInstantiationArgs(
Record), TSK);
9886 MarkVTableUsed(NameLoc, RecordDef,
true);
9904 if (!
D.isInvalidType())
9906 diag::err_explicit_instantiation_requires_name)
9913 S = S->getDeclParent();
9925 Diag(
D.getIdentifierLoc(), diag::err_explicit_instantiation_of_typedef)
9928 }
else if (
D.getDeclSpec().getStorageClassSpec()
9931 Diag(
D.getIdentifierLoc(), diag::err_explicit_instantiation_storage_class)
9934 D.getMutableDeclSpec().ClearStorageClassSpecs();
9942 if (
D.getDeclSpec().isInlineSpecified())
9943 Diag(
D.getDeclSpec().getInlineSpecLoc(),
9945 diag::err_explicit_instantiation_inline :
9946 diag::warn_explicit_instantiation_inline_0x)
9951 Diag(
D.getDeclSpec().getConstexprSpecLoc(),
9952 diag::err_explicit_instantiation_constexpr);
9971 LookupParsedName(
Previous, S, &
D.getCXXScopeSpec(),
9988 if (!PrevTemplate) {
9991 Diag(
D.getIdentifierLoc(), diag::err_explicit_instantiation_not_known)
9995 Diag((*P)->getLocation(), diag::note_explicit_instantiation_here);
10001 Diag(
D.getIdentifierLoc(),
10002 diag::err_explicit_instantiation_data_member_not_instantiated)
10017 Diag(
T->getTypeLoc().getBeginLoc(),
10018 diag::err_auto_not_allowed_var_inst);
10026 Diag(
D.getIdentifierLoc(),
10027 diag::err_explicit_instantiation_without_template_id)
10029 Diag(PrevTemplate->getLocation(),
10030 diag::note_explicit_instantiation_here);
10038 DeclResult Res = CheckVarTemplateId(PrevTemplate, TemplateLoc,
10039 D.getIdentifierLoc(), TemplateArgs);
10047 Diag(
D.getIdentifierLoc(), diag::err_explicit_instantiation_dependent);
10053 Prev = cast<VarDecl>(Res.
get());
10067 Diag(
D.getIdentifierLoc(),
10068 diag::ext_explicit_instantiation_without_qualified_id)
10069 << Prev <<
D.getCXXScopeSpec().getRange();
10076 bool HasNoEffect =
false;
10077 if (CheckSpecializationInstantiationRedecl(
D.getIdentifierLoc(), TSK, Prev,
10078 PrevTSK, POI, HasNoEffect))
10081 if (!HasNoEffect) {
10084 if (
auto *VTSD = dyn_cast<VarTemplatePartialSpecializationDecl>(Prev)) {
10085 VTSD->setExternKeywordLoc(ExternLoc);
10086 VTSD->setTemplateKeywordLoc(TemplateLoc);
10090 ProcessDeclAttributeList(S, Prev,
D.getDeclSpec().getAttributes());
10095 InstantiateVariableDefinition(
D.getIdentifierLoc(), Prev);
10100 Diag(
T->getTypeLoc().getBeginLoc(),
10101 diag::err_invalid_var_template_spec_type)
10102 << 0 << PrevTemplate << R << Prev->
getType();
10103 Diag(PrevTemplate->getLocation(), diag::note_template_declared_here)
10104 << 2 << PrevTemplate->getDeclName();
10109 return (
Decl*)
nullptr;
10114 bool HasExplicitTemplateArgs =
false;
10118 HasExplicitTemplateArgs =
true;
10132 if (!HasExplicitTemplateArgs) {
10133 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Prev)) {
10134 QualType Adjusted = adjustCCAndNoReturn(R, Method->getType(),
10137 if (Method->getPrimaryTemplate()) {
10138 TemplateMatches.
addDecl(Method,
P.getAccess());
10141 assert(!NonTemplateMatch &&
"Multiple NonTemplateMatches");
10142 NonTemplateMatch = Method;
10155 FunTmpl, (HasExplicitTemplateArgs ? &TemplateArgs :
nullptr), R,
10171 if (LangOpts.CUDA &&
10174 CUDA().IdentifyTarget(
D.getDeclSpec().getAttributes())) {
10189 TemplateMatches.
begin(), TemplateMatches.
end(), FailedCandidates,
10190 D.getIdentifierLoc(),
10191 PDiag(diag::err_explicit_instantiation_not_known) << Name,
10192 PDiag(diag::err_explicit_instantiation_ambiguous) << Name,
10193 PDiag(diag::note_explicit_instantiation_candidate));
10195 if (Result == TemplateMatches.
end())
10209 if (FPT->hasExceptionSpec()) {
10211 diag::err_mismatched_exception_spec_explicit_instantiation;
10212 if (getLangOpts().MicrosoftExt)
10213 DiagID = diag::ext_mismatched_exception_spec_explicit_instantiation;
10214 bool Result = CheckEquivalentExceptionSpec(
10216 PDiag(diag::note_explicit_instantiation_here),
10221 if (!getLangOpts().MicrosoftExt && Result)
10226 Diag(
D.getIdentifierLoc(),
10227 diag::err_explicit_instantiation_member_function_not_instantiated)
10236 if (!PrevDecl &&
Specialization->isThisDeclarationADefinition())
10240 bool HasNoEffect =
false;
10241 if (CheckSpecializationInstantiationRedecl(
D.getIdentifierLoc(), TSK,
10251 return (
Decl*)
nullptr;
10262 if (
auto *RD = dyn_cast<CXXRecordDecl>(
Specialization->getDeclContext()))
10263 if (RD->getIdentifier() && RD->getIdentifier()->isStr(
"valarray") &&
10264 RD->isInStdNamespace())
10265 return (
Decl*)
nullptr;
10268 ProcessDeclAttributeList(S,
Specialization,
D.getDeclSpec().getAttributes());
10278 Specialization->setTemplateSpecializationKind(TSK,
D.getIdentifierLoc());
10296 D.getCXXScopeSpec().isSet() &&
10298 Diag(
D.getIdentifierLoc(),
10299 diag::ext_explicit_instantiation_without_qualified_id)
10306 D.getIdentifierLoc(),
D.getCXXScopeSpec().isSet(), TSK);
10309 return (
Decl*)
nullptr;
10318 assert(Name &&
"Expected a name in a dependent tag");
10327 Diag(NameLoc, diag::err_dependent_tag_decl)
10354 if (TypenameLoc.
isValid() && S && !S->getTemplateParamParent())
10357 diag::warn_cxx98_compat_typename_outside_of_template :
10358 diag::ext_typename_outside_of_template)
10364 CheckTypenameType((TypenameLoc.
isValid() ||
10368 TypenameLoc, QualifierLoc, II, IdLoc, &TSI,
10372 return CreateParsedType(
T, TSI);
10382 if (TypenameLoc.
isValid() && S && !S->getTemplateParamParent())
10385 diag::warn_cxx98_compat_typename_outside_of_template :
10386 diag::ext_typename_outside_of_template)
10393 dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS,
false));
10394 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
10395 Diag(TemplateIILoc,
10396 diag::ext_out_of_line_qualified_id_type_names_constructor)
10398 << (TemplateKWLoc.
isValid() ? 1 : 0 );
10404 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
10409 assert(DTN &&
"dependent template has non-dependent name?");
10412 if (!DTN->isIdentifier()) {
10413 Diag(TemplateIILoc, diag::err_template_id_not_a_type) << Template;
10414 NoteAllFoundTemplates(Template);
10420 DTN->getIdentifier(), TemplateArgs.
arguments());
10432 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
10434 return CreateParsedType(
T, Builder.getTypeSourceInfo(Context,
T));
10437 QualType T = CheckTemplateIdType(Template, TemplateIILoc, TemplateArgs);
10449 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
10459 return CreateParsedType(
T, TSI);
10467 if (!II.
isStr(
"type"))
10476 if (!EnableIfTSTLoc || EnableIfTSTLoc.
getNumArgs() == 0)
10489 if (!EnableIfII || !EnableIfII->
isStr(
"enable_if"))
10517 bool DeducedTSTContext) {
10518 QualType T = CheckTypenameType(Keyword, KeywordLoc, QualifierLoc, II, IILoc,
10519 DeducedTSTContext);
10524 if (isa<DependentNameType>(
T)) {
10548 SS.
Adopt(QualifierLoc);
10551 if (QualifierLoc) {
10552 Ctx = computeDeclContext(SS);
10568 if (RequireCompleteDeclContext(SS, Ctx))
10573 LookupResult Result(*
this, Name, IILoc, LookupOrdinaryName);
10575 LookupQualifiedName(Result, Ctx, SS);
10577 LookupName(Result, CurScope);
10578 unsigned DiagID = 0;
10579 Decl *Referenced =
nullptr;
10580 switch (Result.getResultKind()) {
10585 Expr *Cond =
nullptr;
10586 if (Ctx &&
isEnableIf(QualifierLoc, II, CondRange, Cond)) {
10591 std::string FailedDescription;
10592 std::tie(FailedCond, FailedDescription) =
10593 findFailedBooleanCondition(Cond);
10596 diag::err_typename_nested_not_found_requirement)
10597 << FailedDescription
10603 diag::err_typename_nested_not_found_enable_if)
10604 << Ctx << CondRange;
10608 DiagID = Ctx ? diag::err_typename_nested_not_found
10609 : diag::err_unknown_typename;
10618 Diag(IILoc, diag::err_typename_refers_to_using_value_decl)
10619 << Name << Ctx << FullRange;
10621 = dyn_cast<UnresolvedUsingValueDecl>(Result.getRepresentativeDecl())){
10623 Diag(
Loc, diag::note_using_value_decl_missing_typename)
10638 if (
TypeDecl *
Type = dyn_cast<TypeDecl>(Result.getFoundDecl())) {
10653 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(Ctx);
10654 auto *FoundRD = dyn_cast<CXXRecordDecl>(
Type);
10656 FoundRD->isInjectedClassName() &&
10658 Diag(IILoc, diag::ext_out_of_line_qualified_id_type_names_constructor)
10663 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
10675 if (!DeducedTSTContext) {
10680 Diag(IILoc, diag::err_dependent_deduced_tst)
10683 Diag(IILoc, diag::err_deduced_tst)
10685 NoteTemplateLocation(*TD);
10695 DiagID = Ctx ? diag::err_typename_nested_not_type
10696 : diag::err_typename_not_type;
10697 Referenced = Result.getFoundDecl();
10701 DiagID = Ctx ? diag::err_typename_nested_not_type
10702 : diag::err_typename_not_type;
10703 Referenced = *Result.begin();
10715 Diag(IILoc, DiagID) << FullRange << Name << Ctx;
10717 Diag(IILoc, DiagID) << FullRange << Name;
10720 Ctx ? diag::note_typename_member_refers_here
10721 : diag::note_typename_refers_here)
10728 class CurrentInstantiationRebuilder
10736 CurrentInstantiationRebuilder(
Sema &SemaRef,
10740 Loc(
Loc), Entity(Entity) { }
10762 this->Entity = Entity;
10778 CurrentInstantiationRebuilder Rebuilder(*
this,
Loc, Name);
10779 return Rebuilder.TransformType(
T);
10783 CurrentInstantiationRebuilder Rebuilder(*
this,
E->
getExprLoc(),
10785 return Rebuilder.TransformExpr(
E);
10796 = Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
10806 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
10810 if (isa<TemplateTypeParmDecl>(Param))
10815 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
10816 if (RebuildTemplateParamsInCurrentInstantiation(
10817 TTP->getTemplateParameters()))
10838 NewTSI = SubstAutoTypeSourceInfoDependent(NewTSI);
10853 return getTemplateArgumentBindingsText(Params, Args.
data(), Args.
size());
10859 unsigned NumArgs) {
10861 llvm::raw_svector_ostream Out(Str);
10863 if (!Params || Params->
size() == 0 || NumArgs == 0)
10864 return std::string();
10866 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
10876 Out <<
Id->getName();
10882 Args[I].
print(getPrintingPolicy(), Out,
10884 getPrintingPolicy(), Params, I));
10888 return std::string(Out.str());
10896 auto LPT = std::make_unique<LateParsedTemplate>();
10899 LPT->Toks.swap(Toks);
10901 LPT->FPO = getCurFPFeatures();
10902 LateParsedTemplateMap.insert(std::make_pair(FD, std::move(LPT)));
10917 if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(CurContext)) {
10946 class ExplicitSpecializationVisibilityChecker {
10958 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
10959 return checkImpl(FD);
10960 if (
auto *RD = dyn_cast<CXXRecordDecl>(ND))
10961 return checkImpl(RD);
10962 if (
auto *VD = dyn_cast<VarDecl>(ND))
10963 return checkImpl(VD);
10964 if (
auto *ED = dyn_cast<EnumDecl>(ND))
10965 return checkImpl(ED);
10969 void diagnose(
NamedDecl *
D,
bool IsPartialSpec) {
10972 const bool Recover =
true;
10977 if (Modules.empty())
10983 bool CheckMemberSpecialization(
const NamedDecl *
D) {
10989 bool CheckExplicitSpecialization(
const NamedDecl *
D) {
11012 template<
typename SpecDecl>
11013 void checkImpl(SpecDecl *Spec) {
11014 bool IsHiddenExplicitSpecialization =
false;
11016 IsHiddenExplicitSpecialization = Spec->getMemberSpecializationInfo()
11017 ? !CheckMemberSpecialization(Spec)
11018 : !CheckExplicitSpecialization(Spec);
11020 checkInstantiated(Spec);
11023 if (IsHiddenExplicitSpecialization)
11024 diagnose(Spec->getMostRecentDecl(),
false);
11033 auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(RD);
11037 auto From = SD->getSpecializedTemplateOrPartial();
11040 else if (
auto *TD =
11042 if (!CheckDeclaration(TD))
11043 diagnose(TD,
true);
11048 void checkInstantiated(
VarDecl *RD) {
11049 auto *SD = dyn_cast<VarTemplateSpecializationDecl>(RD);
11053 auto From = SD->getSpecializedTemplateOrPartial();
11056 else if (
auto *TD =
11058 if (!CheckDeclaration(TD))
11059 diagnose(TD,
true);
11064 void checkInstantiated(
EnumDecl *FD) {}
11066 template<
typename TemplDecl>
11067 void checkTemplate(TemplDecl *TD) {
11068 if (TD->isMemberSpecialization()) {
11069 if (!CheckMemberSpecialization(TD))
11070 diagnose(TD->getMostRecentDecl(),
false);
11077 if (!getLangOpts().Modules)
11080 ExplicitSpecializationVisibilityChecker(*
this,
Loc,
11087 if (!getLangOpts().CPlusPlusModules)
11088 return checkSpecializationVisibility(
Loc, Spec);
11090 ExplicitSpecializationVisibilityChecker(*
this,
Loc,
11096 if (!getLangOpts().
CPlusPlus || CodeSynthesisContexts.empty())
11098 if (
const auto *FD = dyn_cast<FunctionDecl>(N)) {
11106 if (!CSC.isInstantiationRecord() || CSC.PointOfInstantiation.isInvalid())
11108 return CSC.PointOfInstantiation;
Defines the clang::ASTContext interface.
Defines enum values for all the target-independent builtin functions.
enum clang::sema::@1659::IndirectLocalPathEntry::EntryKind Kind
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
@ ForVisibleRedeclaration
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
static void ProcessAPINotes(Sema &S, Decl *D, const api_notes::CommonEntityInfo &Info, VersionedInfoMetadata Metadata)
This file declares semantic analysis for CUDA constructs.
static bool CheckConstraintSatisfaction(Sema &S, const NamedDecl *Template, ArrayRef< const Expr * > ConstraintExprs, llvm::SmallVectorImpl< Expr * > &Converted, const MultiLevelTemplateArgumentList &TemplateArgsLists, SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction)
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt, NamedDecl *Dest)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From, QualType T, Sema::CCEKind CCE, NamedDecl *Dest, APValue &PreNarrowingValue)
BuildConvertedConstantExpression - Check that the expression From is a converted constant expression ...
static TemplateDeductionResult DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, ArrayRef< TemplateArgument > Ps, ArrayRef< TemplateArgument > As, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, bool NumberOfArgumentsMustMatch, PackFold PackFold=PackFold::ParameterToArgument)
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 * lookThroughRangesV3Condition(Preprocessor &PP, Expr *Cond)
static void maybeDiagnoseTemplateParameterShadow(Sema &SemaRef, Scope *S, SourceLocation Loc, const IdentifierInfo *Name)
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 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 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 bool SubstDefaultTemplateArgument(Sema &SemaRef, TemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, TemplateTypeParmDecl *Param, ArrayRef< TemplateArgument > SugaredConverted, ArrayRef< TemplateArgument > CanonicalConverted, TemplateArgumentLoc &Output)
Substitute template arguments into the default template argument for the given template type paramete...
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 bool RemoveLookupResult(LookupResult &R, NamedDecl *C)
static Expr * BuildExpressionFromNonTypeTemplateArgumentValue(Sema &S, QualType T, const APValue &Val, SourceLocation Loc)
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 bool CheckExplicitInstantiation(Sema &S, NamedDecl *D, SourceLocation InstLoc, bool WasQualifiedName, TemplateSpecializationKind TSK)
Common checks for whether an explicit instantiation of D is valid.
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 void SetNestedNameSpecifier(Sema &S, TagDecl *T, const CXXScopeSpec &SS)
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 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)
__DEVICE__ int max(int __a, int __b)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
const LValueBase getLValueBase() const
ValueKind getKind() const
APFixedPoint & getFixedPoint()
APSInt & getComplexIntReal()
const ValueDecl * getMemberPointerDecl() const
unsigned getVectorLength() const
APSInt & getComplexIntImag()
APFloat & getComplexFloatImag()
bool isMemberPointer() const
APFloat & getComplexFloatReal()
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
APValue & getVectorElt(unsigned I)
@ Indeterminate
This object has an indeterminate value (C++ [basic.indet]).
@ None
There is no such object (it's outside its lifetime).
bool isNullPointer() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
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.
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
const LangOptions & getLangOpts() const
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.
CanQualType UnresolvedTemplateTy
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...
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 ...
TranslationUnitDecl * getTranslationUnitDecl() const
Represents a constant array type that does not decay to a pointer when used as a function parameter.
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.
Attr - This represents one attribute.
ConceptDecl * getNamedConcept() const
AutoTypeKeyword getAutoKeyword() const
const NestedNameSpecifierLoc getNestedNameSpecifierLoc() const
SourceLocation getRAngleLoc() const
NamedDecl * getFoundDecl() const
SourceLocation getLAngleLoc() const
DeclarationNameInfo getConceptNameInfo() const
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
bool isDecltypeAuto() const
A fixed int type of a specified bitwidth.
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++ 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...
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...
CXXRecordDecl * getPreviousDecl()
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 * getDefinition() const
Represents a C++ nested-name-specifier or a global scope specifier.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
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.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
char * location_data() const
Retrieve the data associated with the source-location information.
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.
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a class template node.
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template.
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, QualType CanonInjectedType, ClassTemplatePartialSpecializationDecl *PrevDecl)
void setMemberSpecialization()
Note that this member template is a specialization.
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)
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
Complex values, per C99 6.2.5p11.
Declaration of a C++20 concept.
ConceptDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isTypeConcept() const
Expr * getConstraintExpr() const
static ConceptDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, Expr *ConstraintExpr=nullptr)
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...
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...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
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.
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
bool isNoreturnSpecified() const
SourceLocation getStorageClassSpecLoc() const
SCS getStorageClassSpec() const
SourceLocation getNoreturnSpecLoc() const
SourceLocation getExplicitSpecLoc() const
TSCS getThreadStorageClassSpec() const
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.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
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.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
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.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
bool isInvalidDecl() const
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
void setAccess(AccessSpecifier AS)
SourceLocation getLocation() const
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
AccessSpecifier getAccess() const
SourceLocation getBeginLoc() const LLVM_READONLY
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
void setLexicalDeclContext(DeclContext *DC)
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
DeclContext * getDeclContext()
The name of a declaration.
std::string getAsString() const
Retrieve the human-readable string for this name.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
void setTypeSourceInfo(TypeSourceInfo *TI)
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
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...
Represents an extended address space qualifier where the input address space value is dependent.
void setNameLoc(SourceLocation Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Represents a qualified type name for which the type name is dependent.
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.
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.
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
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.
Represents a vector type where either the type or size is dependent.
void setElaboratedKeywordLoc(SourceLocation Loc)
TypeLoc getNamedTypeLoc() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
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.
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, SourceLocation EllipsisLoc={}, 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...
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization,...
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.
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, StringLiteral *Message=nullptr)
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization,...
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.
ArrayRef< QualType > getParamTypes() const
ArrayRef< QualType > param_types() const
ExtProtoInfo getExtProtoInfo() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
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.
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.
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.
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...
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.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
@ 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
bool empty() const
Return true if no decls were found.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
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.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
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.
A pointer to member type per C++ 8.3.3 - Pointers to members.
QualType getPointeeType() 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...
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
void addOuterTemplateArguments(Decl *AssociatedDecl, ArgList Args, bool Final)
Add a new outmost level to the multi-level template argument list.
void addOuterRetainedLevels(unsigned Num)
This represents a decl that may have a name.
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.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
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.
NamedDecl * getMostRecentDecl()
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>::".
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
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.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, const IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
const Type * getAsType() const
Retrieve the type stored in 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*.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, const IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
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.
unsigned getDepth() const
Get the nesting depth of the template parameter.
void setPlaceholderTypeConstraint(Expr *E)
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
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.
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.
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
ParenExpr - This represents a parenthesized expression, e.g.
ParsedAttr - Represents a syntactic attribute.
Represents the parsed form of a C++ template argument.
Expr * getAsExpr() const
Retrieve the non-type template argument's expression.
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.
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.
void * getAsOpaquePtr() const
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.
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...
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
void setMemberSpecialization()
Note that this member template is a specialization.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first 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.
A generic diagnostic builder for errors which may or may not be deferred.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
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
Abstract base class used for diagnosing integer constant expression violations.
Sema - This implements semantic analysis and AST building for C.
DeclResult ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, CXXScopeSpec &SS, TemplateIdAnnotation &TemplateId, const ParsedAttributesView &Attr, MultiTemplateParamsArg TemplateParameterLists, SkipBodyInfo *SkipBody=nullptr)
ConceptDecl * ActOnStartConceptDefinition(Scope *S, MultiTemplateParamsArg TemplateParameterLists, const IdentifierInfo *Name, SourceLocation NameLoc)
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
LookupNameKind
Describes the kind of name lookup to perform.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
TemplateName SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs)
bool LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType, bool EnteringContext, RequiredTemplateKind RequiredTemplate=SourceLocation(), AssumedTemplateKind *ATK=nullptr, bool AllowTypoCorrection=true)
bool BuildTypeConstraint(const CXXScopeSpec &SS, TemplateIdAnnotation *TypeConstraint, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc, bool AllowUnexpandedPack)
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...
TypeResult ActOnTemplateIdType(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, const IdentifierInfo *TemplateII, SourceLocation TemplateIILoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false, bool IsClassName=false, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No)
NamedDecl * ActOnTemplateTemplateParameter(Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params, bool Typename, 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.
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...
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, const IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
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)
void referenceDLLExportedClassMethods()
static NamedDecl * getAsTemplateNameDecl(NamedDecl *D, bool AllowFunctionTemplates=true, bool AllowDependent=true)
Try to interpret the lookup result D as a template-name.
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...
bool RequireStructuralType(QualType T, SourceLocation Loc)
Require the given type to be a structural type, and diagnose if it is not.
ConceptDecl * ActOnFinishConceptDefinition(Scope *S, ConceptDecl *C, Expr *ConstraintExpr, const ParsedAttributesView &Attrs)
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)
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
bool CheckConceptUseInDefinition(ConceptDecl *Concept, SourceLocation Loc)
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
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...
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...
void checkSpecializationReachability(SourceLocation Loc, NamedDecl *Spec)
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
bool CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param, TemplateParameterList *Params, TemplateArgumentLoc &Arg, bool IsDeduced)
Check a template argument against its corresponding template template parameter.
TemplateParameterList * GetTemplateParameterList(TemplateDecl *TD)
Returns the template parameter list with all default template argument information.
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
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.
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
@ UPPC_NonTypeTemplateParameterType
The type of a non-type template parameter.
@ UPPC_TypeConstraint
A type constraint.
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl, bool SupportedForCompatibility=false)
DiagnoseTemplateParameterShadow - Produce a diagnostic complaining that the template parameter 'PrevD...
bool RebuildTemplateParamsInCurrentInstantiation(TemplateParameterList *Params)
Rebuild the template parameters now that we know we're in a current instantiation.
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...
void checkClassLevelDLLAttribute(CXXRecordDecl *Class)
Check class-level dllimport/dllexport attribute.
std::pair< Expr *, std::string > findFailedBooleanCondition(Expr *Cond)
Find the failed Boolean condition within a given Boolean constant expression, and describe it with a ...
const LangOptions & getLangOpts() const
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs, SmallVectorImpl< TemplateArgument > &SugaredConverted, SmallVectorImpl< TemplateArgument > &CanonicalConverted, bool UpdateArgsWithConversions=true, bool *ConstraintsNotSatisfied=nullptr, bool PartialOrderingTTP=false)
Check that the given template arguments can be provided to the given template, converting the argumen...
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.
bool hasAnyAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true, bool AllowNonTemplateFunctions=false)
bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD, const TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given dependent function template specialization.
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)
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)
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...
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.
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
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,...
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
void diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName, SourceLocation Less, SourceLocation Greater)
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,...
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)
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams)
Check whether a template can be declared within this scope.
SourceLocation getTopMostPointOfInstantiation(const NamedDecl *) const
Returns the top most location responsible for the definition of N.
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)
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.
bool SubstTemplateArgument(const TemplateArgumentLoc &Input, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentLoc &Output, SourceLocation Loc={}, const DeclarationName &Entity={})
ASTContext & getASTContext() const
ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, bool IsAddressOfOperand)
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...
ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
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 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)
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.
bool resolveAssumedTemplateNameAsType(Scope *S, TemplateName &Name, SourceLocation NameLoc, bool Diagnose=true)
ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs)
void CheckConceptRedefinition(ConceptDecl *NewDecl, LookupResult &Previous, bool &AddToScope)
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)
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments.
unsigned getTemplateDepth(Scope *S) const
Determine the number of levels of enclosing template parameters.
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
DiagnosticsEngine & getDiagnostics() const
void NoteTemplateParameterLocation(const NamedDecl &Decl)
void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD)
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.
bool hasReachableDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is reachable.
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.
Represents the result of substituting a type for a template type parameter.
Represents the declaration of a struct/union/class/enum.
StringRef getKindName() const
void startDefinition()
Starts the definition of this tag declaration.
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
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.
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Location wrapper for a TemplateArgument.
SourceLocation getLocation() const
TypeSourceInfo * getTypeSourceInfo() const
SourceLocation getTemplateEllipsisLoc() const
SourceLocation getTemplateNameLoc() const
SourceRange getSourceRange() const LLVM_READONLY
NestedNameSpecifierLoc getTemplateQualifierLoc() const
const TemplateArgument & getArgument() const
Expr * getSourceExpression() const
Represents a template argument.
QualType getStructuralValueType() const
Get the type of a StructuralValue.
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
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.
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
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.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
QualType getIntegralType() const
Retrieve the type of the integral value.
@ 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.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
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,...
The base class of all kinds of template declarations (e.g., class, function, etc.).
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
bool hasAssociatedConstraints() const
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.
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.
NamedDecl *const * const_iterator
Iterates through the template parameters in this list.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
NamedDecl * getParam(unsigned Idx)
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)
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
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...
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.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
void setInheritedDefaultArgument(const ASTContext &C, TemplateTemplateParmDecl *Prev)
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
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...
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, bool Typename, 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.
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, 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 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)
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter.
Wrapper for template type parameters.
TemplateTypeParmDecl * getDecl() const
unsigned getIndex() const
unsigned getDepth() const
Represents the declaration of a typedef-name via a C++11 alias-declaration.
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.
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 ...
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),...
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
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
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
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
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 isPointerOrReferenceType() const
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
QualType getUnderlyingType() 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.
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, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
void addDecl(NamedDecl *D)
The iterator over UnresolvedSets.
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,...
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.
void AddPartialSpecialization(VarTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
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...
static VarTemplatePartialSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
void setMemberSpecialization()
Note that this member template is a specialization.
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.
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
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.
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...
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
TemplateArgumentList * takeSugared()
Take ownership of the deduced template argument lists.
Defines the clang::TargetInfo interface.
constexpr XRayInstrMask None
std::string toString(const til::SExpr *E)
The JSON file list parser is used to communicate input to InstallAPI.
TypeSpecifierType
Specifies the kind of type.
bool isa(CodeGen::Address addr)
@ 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+.
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
StorageClass
Storage classes.
@ CRK_None
Candidate is not a rewritten candidate.
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
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.
SourceRange getTemplateParamsRange(TemplateParameterList const *const *Params, unsigned NumParams)
Retrieves the range of the given template parameter lists.
std::optional< unsigned > getExpandedPackSize(const NamedDecl *Param)
Check whether the template parameter is a pack expansion, and if so, determine the number of paramete...
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.
const FunctionProtoType * T
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.
@ 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.
SourceLocation getEndLoc() const LLVM_READONLY
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.
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.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
const IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
unsigned NumArgs
NumArgs - The number of template arguments.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
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.
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
Contains all information for a given match.