33 #include "llvm/ADT/SmallBitVector.h" 34 #include "llvm/ADT/SmallString.h" 35 #include "llvm/ADT/StringExtras.h" 38 using namespace clang;
46 return SourceRange(Ps[0]->getTemplateLoc(), Ps[N-1]->getRAngleLoc());
56 bool AllowFunctionTemplates,
57 bool AllowDependent) {
60 if (isa<TemplateDecl>(D)) {
61 if (!AllowFunctionTemplates && isa<FunctionTemplateDecl>(D))
79 if (Record->isInjectedClassName()) {
80 Record = cast<CXXRecordDecl>(Record->getDeclContext());
81 if (Record->getDescribedClassTemplate())
82 return Record->getDescribedClassTemplate();
85 = dyn_cast<ClassTemplateSpecializationDecl>(Record))
86 return Spec->getSpecializedTemplate();
95 if (AllowDependent && isa<UnresolvedUsingValueDecl>(D))
102 bool AllowFunctionTemplates,
103 bool AllowDependent) {
107 if (!getAsTemplateNameDecl(Orig, AllowFunctionTemplates, AllowDependent))
114 bool AllowFunctionTemplates,
116 bool AllowNonTemplateFunctions) {
118 if (getAsTemplateNameDecl(*I, AllowFunctionTemplates, AllowDependent))
120 if (AllowNonTemplateFunctions &&
121 isa<FunctionDecl>((*I)->getUnderlyingDecl()))
130 bool hasTemplateKeyword,
133 bool EnteringContext,
135 bool &MemberOfUnknownSpecialization) {
136 assert(getLangOpts().
CPlusPlus &&
"No template names in C!");
139 MemberOfUnknownSpecialization =
false;
163 if (LookupTemplateName(R, S, SS, ObjectType, EnteringContext,
173 return AssumedTemplate == AssumedTemplateKind::FoundNothing
182 if (R.isAmbiguous()) {
185 bool AnyFunctionTemplates =
false;
187 if (
NamedDecl *FoundTemplate = getAsTemplateNameDecl(FoundD)) {
188 if (isa<FunctionTemplateDecl>(FoundTemplate))
189 AnyFunctionTemplates =
true;
199 if (!D && !AnyFunctionTemplates) {
200 R.suppressDiagnostics();
207 FilterAcceptableTemplateNames(R);
217 unsigned ResultCount = R.end() - R.begin();
218 if (!D && ResultCount > 1) {
225 R.suppressDiagnostics();
228 D = getAsTemplateNameDecl(*R.begin());
229 assert(D &&
"unambiguous result is not a template name");
232 if (isa<UnresolvedUsingValueDecl>(D)) {
234 MemberOfUnknownSpecialization =
true;
243 hasTemplateKeyword, TD);
248 if (isa<FunctionTemplateDecl>(TD)) {
252 R.suppressDiagnostics();
254 assert(isa<ClassTemplateDecl>(TD) || isa<TemplateTemplateParmDecl>(TD) ||
255 isa<TypeAliasTemplateDecl>(TD) || isa<VarTemplateDecl>(TD) ||
256 isa<BuiltinTemplateDecl>(TD) || isa<ConceptDecl>(TD));
264 TemplateResult = TemplateTy::make(Template);
272 bool MemberOfUnknownSpecialization =
false;
278 if (LookupTemplateName(R, S, SS,
QualType(),
280 MemberOfUnknownSpecialization))
283 if (R.
empty())
return false;
310 if (!SS || !SS->
isSet() || !isDependentScopeSpecifier(*SS) ||
311 computeDeclContext(*SS))
317 Diag(IILoc, diag::err_template_kw_missing)
329 bool EnteringContext,
330 bool &MemberOfUnknownSpecialization,
339 MemberOfUnknownSpecialization =
false;
341 bool IsDependent =
false;
342 if (!ObjectType.
isNull()) {
345 assert(!SS.
isSet() &&
"ObjectType and scope specifier cannot coexist");
346 LookupCtx = computeDeclContext(ObjectType);
350 "Caller should have completed object type");
371 }
else if (SS.
isSet()) {
374 LookupCtx = computeDeclContext(SS, EnteringContext);
375 IsDependent = !LookupCtx;
378 if (LookupCtx && RequireCompleteDeclContext(SS, LookupCtx))
382 bool ObjectTypeSearchedInScope =
false;
383 bool AllowFunctionTemplatesInLookup =
true;
389 LookupQualifiedName(Found, LookupCtx);
413 LookupName(Found, S);
415 if (!ObjectType.
isNull()) {
419 AllowFunctionTemplatesInLookup =
false;
420 ObjectTypeSearchedInScope =
true;
439 getLangOpts().CPlusPlus2a &&
441 return isa<FunctionDecl>(ND->getUnderlyingDecl());
443 if (AllFunctions || (Found.
empty() && !IsDependent)) {
448 ? AssumedTemplateKind::FoundNothing
449 : AssumedTemplateKind::FoundFunctions;
455 if (Found.
empty() && !IsDependent) {
462 FilterCCC.WantExpressionKeywords =
false;
463 FilterCCC.WantRemainingKeywords =
false;
464 FilterCCC.WantCXXNamedCasts =
true;
467 &SS, FilterCCC, CTK_ErrorRecovery, LookupCtx)) {
468 if (
auto *ND = Corrected.getFoundDecl())
470 FilterAcceptableTemplateNames(Found);
473 }
else if (!Found.
empty()) {
476 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
477 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
479 diagnoseTypo(Corrected, PDiag(diag::err_no_member_template_suggest)
480 << Name << LookupCtx << DroppedSpecifier
483 diagnoseTypo(Corrected, PDiag(diag::err_no_template_suggest) << Name);
491 FilterAcceptableTemplateNames(Found, AllowFunctionTemplatesInLookup);
494 MemberOfUnknownSpecialization =
true;
500 if (ExampleLookupResult && TemplateKWLoc.
isValid()) {
501 Diag(Found.
getNameLoc(), diag::err_template_kw_refers_to_non_template)
504 diag::note_template_kw_refers_to_non_template)
512 if (S && !ObjectType.
isNull() && !ObjectTypeSearchedInScope &&
513 !getLangOpts().CPlusPlus11) {
523 LookupName(FoundOuter, S);
526 FilterAcceptableTemplateNames(FoundOuter,
false);
529 if (FoundOuter.empty()) {
532 }
else if (FoundOuter.isAmbiguous() || !FoundOuter.isSingleResult() ||
534 getAsTemplateNameDecl(FoundOuter.getFoundDecl()))) {
547 diag::ext_nested_name_member_ref_lookup_ambiguous)
551 diag::note_ambig_member_ref_object_type)
553 Diag(FoundOuter.getFoundDecl()->getLocation(),
554 diag::note_ambig_member_ref_scope);
577 bool MissingTemplateKeyword =
false;
580 if (
auto *DRE = dyn_cast<DeclRefExpr>(TemplateName.
get())) {
581 NameInfo = DRE->getNameInfo();
582 SS.
Adopt(DRE->getQualifierLoc());
583 LookupKind = LookupOrdinaryName;
584 Found = DRE->getFoundDecl();
585 }
else if (
auto *ME = dyn_cast<MemberExpr>(TemplateName.
get())) {
586 NameInfo = ME->getMemberNameInfo();
587 SS.
Adopt(ME->getQualifierLoc());
588 LookupKind = LookupMemberName;
589 LookupCtx = ME->getBase()->getType()->getAsCXXRecordDecl();
590 Found = ME->getMemberDecl();
591 }
else if (
auto *DSDRE =
592 dyn_cast<DependentScopeDeclRefExpr>(TemplateName.
get())) {
593 NameInfo = DSDRE->getNameInfo();
594 SS.
Adopt(DSDRE->getQualifierLoc());
595 MissingTemplateKeyword =
true;
596 }
else if (
auto *DSME =
597 dyn_cast<CXXDependentScopeMemberExpr>(TemplateName.
get())) {
598 NameInfo = DSME->getMemberNameInfo();
599 SS.
Adopt(DSME->getQualifierLoc());
600 MissingTemplateKeyword =
true;
602 llvm_unreachable(
"unexpected kind of potential template name");
607 if (MissingTemplateKeyword) {
616 TemplateCandidateFilter(
Sema &S) : S(S) {
617 WantTypeSpecifiers =
false;
618 WantExpressionKeywords =
false;
619 WantRemainingKeywords =
false;
620 WantCXXNamedCasts =
true;
622 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
628 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
629 return std::make_unique<TemplateCandidateFilter>(*this);
634 TemplateCandidateFilter CCC(*
this);
635 if (
TypoCorrection Corrected = CorrectTypo(NameInfo, LookupKind, S, &SS, CCC,
636 CTK_ErrorRecovery, LookupCtx)) {
637 auto *ND = Corrected.getFoundDecl();
639 ND = getAsTemplateNameDecl(ND);
640 if (ND || Corrected.isKeyword()) {
642 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
643 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
645 diagnoseTypo(Corrected,
646 PDiag(diag::err_non_template_in_member_template_id_suggest)
647 << Name << LookupCtx << DroppedSpecifier
650 diagnoseTypo(Corrected,
651 PDiag(diag::err_non_template_in_template_id_suggest)
656 diag::note_non_template_in_template_id_found);
661 Diag(NameInfo.
getLoc(), diag::err_non_template_in_template_id)
664 Diag(Found->
getLocation(), diag::note_non_template_in_template_id_found);
674 bool isAddressOfOperand,
689 bool MightBeCxx11UnevalField =
690 getLangOpts().CPlusPlus11 && isUnevaluatedContext();
695 IsEnum = dyn_cast_or_null<EnumType>(NNS->getAsType());
697 if (!MightBeCxx11UnevalField && !isAddressOfOperand && !IsEnum &&
698 isa<CXXMethodDecl>(DC) && cast<CXXMethodDecl>(DC)->isInstance()) {
699 QualType ThisType = cast<CXXMethodDecl>(DC)->getThisType();
703 NamedDecl *FirstQualifierInScope =
nullptr;
706 Context,
nullptr, ThisType,
true,
708 FirstQualifierInScope, NameInfo, TemplateArgs);
711 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
725 Context, QualifierLoc, TemplateKWLoc, NameInfo, TemplateArgs);
733 bool InstantiatedFromMember,
738 assert(isa<TagDecl>(Instantiation) || isa<FunctionDecl>(Instantiation) ||
739 isa<VarDecl>(Instantiation));
741 bool IsEntityBeingDefined =
false;
742 if (
const TagDecl *TD = dyn_cast_or_null<TagDecl>(PatternDef))
743 IsEntityBeingDefined = TD->isBeingDefined();
745 if (PatternDef && !IsEntityBeingDefined) {
747 if (!hasVisibleDefinition(const_cast<NamedDecl*>(PatternDef), &SuggestedDef,
750 bool Recover = Complain && !isSFINAEContext();
752 diagnoseMissingImport(PointOfInstantiation, SuggestedDef,
759 if (!Complain || (PatternDef && PatternDef->
isInvalidDecl()))
764 if (
TagDecl *TD = dyn_cast<TagDecl>(Instantiation))
767 Diag(PointOfInstantiation,
768 diag::err_template_instantiate_within_definition)
774 }
else if (InstantiatedFromMember) {
775 if (isa<FunctionDecl>(Instantiation)) {
776 Diag(PointOfInstantiation,
777 diag::err_explicit_instantiation_undefined_member)
780 Note = diag::note_explicit_instantiation_here;
782 assert(isa<TagDecl>(Instantiation) &&
"Must be a TagDecl!");
783 Diag(PointOfInstantiation,
784 diag::err_implicit_instantiate_member_undefined)
786 Note = diag::note_member_declared_at;
789 if (isa<FunctionDecl>(Instantiation)) {
790 Diag(PointOfInstantiation,
791 diag::err_explicit_instantiation_undefined_func_template)
793 Note = diag::note_explicit_instantiation_here;
794 }
else if (isa<TagDecl>(Instantiation)) {
795 Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
798 Note = diag::note_template_decl_here;
800 assert(isa<VarDecl>(Instantiation) &&
"Must be a VarDecl!");
801 if (isa<VarTemplateSpecializationDecl>(Instantiation)) {
802 Diag(PointOfInstantiation,
803 diag::err_explicit_instantiation_undefined_var_template)
807 Diag(PointOfInstantiation,
808 diag::err_explicit_instantiation_undefined_member)
811 Note = diag::note_explicit_instantiation_here;
838 unsigned DiagId = getLangOpts().MSVCCompat ? diag::ext_template_param_shadow
839 : diag::err_template_param_shadow;
840 Diag(Loc, DiagId) << cast<NamedDecl>(PrevDecl)->getDeclName();
848 if (
TemplateDecl *Temp = dyn_cast_or_null<TemplateDecl>(D)) {
849 D = Temp->getTemplatedDecl();
857 assert(
Kind == Template &&
858 "Only template template arguments can be pack expansions here");
859 assert(getAsTemplate().
get().containsUnexpandedParameterPack() &&
860 "Template template argument pack expansion without packs");
862 Result.EllipsisLoc = EllipsisLoc;
898 llvm_unreachable(
"Unhandled parsed template argument");
905 for (
unsigned I = 0,
Last = TemplateArgsIn.size(); I !=
Last; ++I)
925 QualType T = GetTypeFromParser(ParsedType.
get(), &TInfo);
928 assert(TInfo &&
"template argument with no location");
936 EllipsisLoc = PET.getEllipsisLoc();
937 TL = PET.getPatternLoc();
942 SS.
Adopt(ET.getQualifierLoc());
943 TL = ET.getNamedTypeLoc();
947 TemplateName Name = DTST.getTypePtr()->getTemplateName();
953 DTST.getTemplateNameLoc());
955 Result = Result.getTemplatePackExpansion(EllipsisLoc);
965 ParsedType.
get().getAsOpaquePtr(),
983 unsigned Depth,
unsigned Position,
986 bool HasTypeConstraint) {
988 "Template type parameter not in template parameter scope!");
990 bool IsParameterPack = EllipsisLoc.
isValid();
993 KeyLoc, ParamNameLoc,
Depth, Position,
994 ParamName, Typename, IsParameterPack,
999 if (
auto *LSI = getEnclosingLambda())
1000 LSI->LocalPacks.push_back(Param);
1007 IdResolver.AddDecl(Param);
1013 if (DefaultArg && IsParameterPack) {
1014 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1015 DefaultArg =
nullptr;
1021 GetTypeFromParser(DefaultArg, &DefaultTInfo);
1023 assert(DefaultTInfo &&
"expected source information for type");
1026 if (DiagnoseUnexpandedParameterPack(ParamNameLoc, DefaultTInfo,
1027 UPPC_DefaultArgument))
1031 if (CheckTemplateArgument(Param, DefaultTInfo)) {
1050 return TemplateArgs;
1065 diag::err_type_constraint_non_type_concept);
1071 if (!WereArgsSpecified &&
1074 diag::err_type_constraint_missing_arguments) << CD;
1083 return AttachTypeConstraint(
1088 ConstrainedParameter, EllipsisLoc);
1091 template<
typename ArgumentLocAppender>
1106 Appender(ConstraintArgs);
1115 NamedConcept, NamedConcept, &ConstraintArgs);
1117 return ImmediatelyDeclaredConstraint;
1129 ImmediatelyDeclaredConstraint.
get(), BO_LAnd,
1130 EllipsisLoc,
nullptr,
1150 *TemplateArgs) :
nullptr;
1156 *
this, NS, NameInfo, NamedConcept,
1159 ParamAsArgument, ConstrainedParameter->
getLocation(),
1162 for (
const auto &ArgLoc : TemplateArgs->
arguments())
1163 ConstraintArgs.addArgument(ArgLoc);
1165 if (ImmediatelyDeclaredConstraint.isInvalid())
1170 NamedConcept, ArgsAsWritten,
1171 ImmediatelyDeclaredConstraint.get());
1180 diag::err_unsupported_placeholder_constraint)
1196 for (
unsigned I = 0, C = TL.
getNumArgs(); I != C; ++I)
1197 ConstraintArgs.addArgument(TL.
getArgLoc(I));
1199 if (ImmediatelyDeclaredConstraint.
isInvalid() ||
1200 !ImmediatelyDeclaredConstraint.
isUsable())
1220 TSI = SubstAutoTypeSourceInfo(TSI, Context.
DependentTy);
1223 return CheckNonTypeTemplateParameterType(TSI->
getType(), Loc);
1231 Diag(Loc, diag::err_variably_modified_nontype_template_param)
1275 Diag(Loc, diag::err_template_nontype_parm_bad_type)
1289 auto CheckValidDeclSpecifiers = [
this, &D] {
1303 Diag(Loc, diag::err_invalid_decl_specifier_in_nontype_parm)
1340 CheckValidDeclSpecifiers();
1344 diag::warn_cxx14_compat_template_nontype_parm_auto_type)
1349 "Non-type template parameter not in template parameter scope!");
1350 bool Invalid =
false;
1358 CheckFunctionOrTemplateParamDeclarator(S, D);
1369 if (TL.isConstrained())
1377 if (
auto *LSI = getEnclosingLambda())
1378 LSI->LocalPacks.push_back(Param);
1386 IdResolver.AddDecl(Param);
1392 if (Default && IsParameterPack) {
1393 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1400 if (DiagnoseUnexpandedParameterPack(Default, UPPC_DefaultArgument))
1405 CheckTemplateArgument(Param, Param->
getType(), Default, Converted);
1410 Default = DefaultRes.
get();
1432 "Template template parameter not in template parameter scope!");
1435 bool IsParameterPack = EllipsisLoc.
isValid();
1439 Depth, Position, IsParameterPack,
1444 if (
auto *LSI = getEnclosingLambda())
1445 LSI->LocalPacks.push_back(Param);
1453 IdResolver.AddDecl(Param);
1456 if (Params->
size() == 0) {
1465 if (IsParameterPack && !Default.
isInvalid()) {
1466 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1481 Diag(DefaultArg.
getLocation(), diag::err_template_arg_not_valid_template)
1487 if (DiagnoseUnexpandedParameterPack(DefaultArg.
getLocation(),
1489 UPPC_DefaultArgument))
1508 Expr *RequiresClause) {
1510 Diag(ExportLoc, diag::warn_template_export_unsupported);
1513 Context, TemplateLoc, LAngleLoc,
1514 llvm::makeArrayRef(Params.data(), Params.size()),
1515 RAngleLoc, RequiresClause);
1531 assert(TemplateParams && TemplateParams->
size() > 0 &&
1532 "No template parameters");
1533 assert(TUK != TUK_Reference &&
"Can only declare or define class templates");
1534 bool Invalid =
false;
1537 if (CheckTemplateDeclScope(S, TemplateParams))
1541 assert(Kind !=
TTK_Enum &&
"can't build template of enumerated type");
1545 Diag(KWLoc, diag::err_template_unnamed_class);
1554 (SS.
isEmpty() && TUK == TUK_Friend)
1555 ? LookupTagName : LookupOrdinaryName,
1556 forRedeclarationInCurContext());
1558 SemanticContext = computeDeclContext(SS,
true);
1559 if (!SemanticContext) {
1563 Diag(NameLoc, TUK == TUK_Friend
1564 ? diag::warn_template_qualified_friend_ignored
1565 : diag::err_template_qualified_declarator_no_match)
1567 return TUK != TUK_Friend;
1570 if (RequireCompleteDeclContext(SS, SemanticContext))
1578 if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams))
1580 }
else if (TUK != TUK_Friend && TUK != TUK_Reference)
1581 diagnoseQualifiedDeclaration(SS, SemanticContext, Name, NameLoc,
false);
1583 LookupQualifiedName(
Previous, SemanticContext);
1585 SemanticContext = CurContext;
1591 if (TUK != TUK_Friend &&
1592 DiagnoseClassNameShadow(SemanticContext,
1604 PrevDecl = (*
Previous.begin())->getUnderlyingDecl();
1608 DiagnoseTemplateParameterShadow(NameLoc, PrevDecl);
1616 dyn_cast_or_null<ClassTemplateDecl>(PrevDecl);
1621 if (!PrevClassTemplate && PrevDecl && isa<CXXRecordDecl>(PrevDecl) &&
1622 cast<CXXRecordDecl>(PrevDecl)->isInjectedClassName()) {
1625 = cast<CXXRecordDecl>(PrevDecl)->getDescribedClassTemplate();
1626 if (!PrevClassTemplate && isa<ClassTemplateSpecializationDecl>(PrevDecl)) {
1628 = cast<ClassTemplateSpecializationDecl>(PrevDecl)
1629 ->getSpecializedTemplate();
1633 if (TUK == TUK_Friend) {
1652 PrevDecl = PrevClassTemplate =
nullptr;
1653 SemanticContext = OutermostContext;
1657 Previous.clear(LookupOrdinaryName);
1661 LookupQualifiedName(
Previous, LookupContext);
1667 PrevDecl = (*
Previous.begin())->getUnderlyingDecl();
1670 }
else if (PrevDecl &&
1671 !isDeclInScope(
Previous.getRepresentativeDecl(), SemanticContext,
1673 PrevDecl = PrevClassTemplate =
nullptr;
1675 if (
auto *Shadow = dyn_cast_or_null<UsingShadowDecl>(
1676 PrevDecl ?
Previous.getRepresentativeDecl() :
nullptr)) {
1678 !(PrevClassTemplate &&
1681 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
1682 Diag(Shadow->getTargetDecl()->getLocation(),
1683 diag::note_using_decl_target);
1684 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl) << 0;
1686 PrevDecl = PrevClassTemplate =
nullptr;
1690 if (PrevClassTemplate) {
1694 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
1695 !TemplateParameterListsAreEqual(TemplateParams,
1707 if (!isAcceptableTagRedeclaration(PrevRecordDecl, Kind,
1708 TUK == TUK_Definition, KWLoc, Name)) {
1709 Diag(KWLoc, diag::err_use_with_wrong_tag)
1717 if (TUK == TUK_Definition) {
1722 if (SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
1725 auto *Tmpl = cast<CXXRecordDecl>(Hidden)->getDescribedClassTemplate();
1726 assert(Tmpl &&
"original definition of a class template is not a " 1728 makeMergedDefinitionVisible(Hidden);
1729 makeMergedDefinitionVisible(Tmpl);
1731 Diag(NameLoc, diag::err_redefinition) << Name;
1732 Diag(Def->getLocation(), diag::note_previous_definition);
1739 }
else if (PrevDecl) {
1745 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
1754 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
1755 CheckTemplateParameterList(
1760 (SS.
isSet() && SemanticContext && SemanticContext->
isRecord() &&
1762 ? TPC_ClassTemplateMember
1763 : TUK == TUK_Friend ? TPC_FriendClassTemplate : TPC_ClassTemplate,
1770 if (!SS.
isInvalid() && !Invalid && !PrevClassTemplate) {
1771 Diag(NameLoc, TUK == TUK_Friend ? diag::err_friend_decl_does_not_match
1772 : diag::err_member_decl_does_not_match)
1773 << Name << SemanticContext <<
true << SS.
getRange();
1783 bool ShouldAddRedecl
1784 = !(TUK == TUK_Friend && CurContext->isDependentContext());
1788 PrevClassTemplate && ShouldAddRedecl ?
1792 if (NumOuterTemplateParamLists > 0)
1794 Context, llvm::makeArrayRef(OuterTemplateParamLists,
1795 NumOuterTemplateParamLists));
1799 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip)) {
1800 AddAlignmentAttributesForRecord(NewClass);
1801 AddMsStructLayoutForRecord(NewClass);
1809 if (ShouldAddRedecl)
1814 if (ModulePrivateLoc.
isValid())
1820 assert(T->
isDependentType() &&
"Class template type is not dependent?");
1825 if (PrevClassTemplate &&
1831 SetMemberAccessSpecifier(NewTemplate, PrevClassTemplate, AS);
1837 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip))
1840 ProcessDeclAttributeList(S, NewClass, Attr);
1842 if (PrevClassTemplate)
1845 AddPushedVisibilityAttribute(NewClass);
1846 inferGslOwnerPointerAttribute(NewClass);
1848 if (TUK != TUK_Friend) {
1853 PushOnScopeChains(NewTemplate, Outer);
1863 if (!CurContext->isDependentContext()) {
1866 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
1867 PushOnScopeChains(NewTemplate, EnclosingScope,
1872 Context, CurContext, NewClass->
getLocation(), NewTemplate, FriendLoc);
1874 CurContext->addDecl(Friend);
1877 if (PrevClassTemplate)
1878 CheckRedeclarationModuleOwnership(NewTemplate, PrevClassTemplate);
1885 ActOnDocumentableDecl(NewTemplate);
1896 class ExtractTypeForDeductionGuide
1900 ExtractTypeForDeductionGuide(
Sema &SemaRef) : Base(SemaRef) {}
1905 return TransformType(
1913 struct ConvertConstructorToDeductionGuideTransform {
1914 ConvertConstructorToDeductionGuideTransform(
Sema &S,
1916 : SemaRef(S), Template(Template) {}
1950 AllParams.reserve(TemplateParams->
size() + InnerParams->
size());
1951 AllParams.insert(AllParams.begin(),
1952 TemplateParams->
begin(), TemplateParams->
end());
1953 SubstArgs.reserve(InnerParams->
size());
1961 NamedDecl *NewParam = transformTemplateParameter(Param, Args);
1964 AllParams.push_back(NewParam);
1969 SemaRef.
Context, InnerParams->getTemplateLoc(),
1970 InnerParams->getLAngleLoc(), AllParams, InnerParams->getRAngleLoc(),
1980 Args.addOuterRetainedLevel();
1985 assert(FPTL &&
"no prototype for constructor declaration");
1992 QualType NewType = transformFunctionProtoType(TLB, FPTL, Params, Args);
2010 DeductionGuideName, EPI);
2018 for (
auto T : ParamTypes) {
2020 SemaRef.
Context, DC, Loc, Loc,
nullptr, T,
2023 FPTL.
setParam(Params.size(), NewParam);
2024 Params.push_back(NewParam);
2037 if (
auto *TTP = dyn_cast<TemplateTypeParmDecl>(TemplateParam)) {
2041 SemaRef.
Context, DC, TTP->getBeginLoc(), TTP->getLocation(),
2042 0, Depth1IndexAdjustment + TTP->getIndex(),
2043 TTP->getIdentifier(), TTP->wasDeclaredWithTypename(),
2044 TTP->isParameterPack(), TTP->hasTypeConstraint(),
2045 TTP->isExpandedParameterPack() ?
2047 if (
const auto *TC = TTP->getTypeConstraint()) {
2049 const auto *ArgsAsWritten = TC->getTemplateArgsAsWritten();
2050 if (!ArgsAsWritten ||
2051 SemaRef.
Subst(ArgsAsWritten->getTemplateArgs(),
2052 ArgsAsWritten->NumTemplateArgs, TransformedArgs,
2055 TC->getNestedNameSpecifierLoc(), TC->getConceptNameInfo(),
2056 TC->getNamedConcept(), ArgsAsWritten ? &TransformedArgs :
nullptr,
2058 NewTTP->isParameterPack()
2059 ? cast<CXXFoldExpr>(TC->getImmediatelyDeclaredConstraint())
2063 if (TTP->hasDefaultArgument()) {
2065 SemaRef.
SubstType(TTP->getDefaultArgumentInfo(), Args,
2066 TTP->getDefaultArgumentLoc(), TTP->getDeclName());
2067 if (InstantiatedDefaultArg)
2068 NewTTP->setDefaultArgument(InstantiatedDefaultArg);
2075 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(TemplateParam))
2076 return transformTemplateParameterImpl(TTP, Args);
2078 return transformTemplateParameterImpl(
2079 cast<NonTypeTemplateParmDecl>(TemplateParam), Args);
2081 template<
typename TemplateParmDecl>
2083 transformTemplateParameterImpl(TemplateParmDecl *OldParam,
2088 cast<TemplateParmDecl>(SemaRef.
SubstDecl(OldParam, DC, Args));
2089 assert(NewParam->getDepth() == 0 &&
"unexpected template param depth");
2090 NewParam->setPosition(NewParam->getPosition() + Depth1IndexAdjustment);
2103 ParmVarDecl *NewParam = transformFunctionTypeParam(OldParam, Args);
2106 ParamTypes.push_back(NewParam->
getType());
2107 Params.push_back(NewParam);
2129 ReturnType, ParamTypes, TL.
getBeginLoc(), DeductionGuideName, EPI);
2139 for (
unsigned I = 0, E = NewTL.
getNumParams(); I != E; ++I)
2154 SemaRef.
SubstType(PackTL.getPatternLoc(), Args,
2156 if (!NewDI)
return nullptr;
2159 PackTL.getTypePtr()->getNumExpansions());
2170 NewDI = ExtractTypeForDeductionGuide(SemaRef).transform(NewDI);
2206 TInfo->
getType(), TInfo, LocEnd);
2208 Guide->setParams(Params);
2210 for (
auto *Param : Params)
2211 Param->setDeclContext(Guide);
2214 SemaRef.
Context, DC, Loc, DeductionGuideName, TemplateParams, Guide);
2215 GuideTemplate->setImplicit();
2216 Guide->setDescribedFunctionTemplate(GuideTemplate);
2218 if (isa<CXXRecordDecl>(DC)) {
2224 return GuideTemplate;
2233 TemplateDecl *DescribedTemplate = DefRecord->getDescribedClassTemplate();
2234 Template = DescribedTemplate ? DescribedTemplate : Template;
2241 ConvertConstructorToDeductionGuideTransform Transform(
2242 *
this, cast<ClassTemplateDecl>(Template));
2243 if (!isCompleteType(Loc, Transform.DeducedType))
2248 auto Existing = DC->
lookup(Transform.DeductionGuideName);
2249 for (
auto *D : Existing)
2250 if (D->isImplicit())
2261 if (BuildingDeductionGuides.
isInvalid())
2268 bool AddedAny =
false;
2269 for (
NamedDecl *D : LookupConstructors(Transform.Primary)) {
2270 D = D->getUnderlyingDecl();
2271 if (D->isInvalidDecl() || D->isImplicit())
2273 D = cast<NamedDecl>(D->getCanonicalDecl());
2277 dyn_cast_or_null<CXXConstructorDecl>(FTD ? FTD->getTemplatedDecl() : D);
2280 if (!CD || (!FTD && CD->isFunctionTemplateSpecialization()))
2283 Transform.transformConstructor(FTD, CD);
2292 Transform.buildSimpleDeductionGuide(None);
2296 cast<CXXDeductionGuideDecl>(
2297 cast<FunctionTemplateDecl>(
2298 Transform.buildSimpleDeductionGuide(Transform.DeducedType))
2299 ->getTemplatedDecl())
2300 ->setIsCopyDeductionCandidate();
2328 diag::warn_cxx98_compat_template_parameter_default_in_function_template
2329 : diag::ext_template_parameter_default_in_function_template)
2338 S.
Diag(ParamLoc, diag::err_template_parameter_default_template_member)
2347 S.
Diag(ParamLoc, diag::err_template_parameter_default_friend_template)
2356 llvm_unreachable(
"Invalid TemplateParamListContext!");
2369 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
2374 if (TC->hasExplicitTemplateArgs())
2375 for (
auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
2383 if (!NTTP->isParameterPack() &&
2385 NTTP->getTypeSourceInfo(),
2393 = dyn_cast<TemplateTemplateParmDecl>(P))
2433 bool Invalid =
false;
2441 bool SawDefaultArgument =
false;
2447 OldParam = OldParams->
begin();
2449 bool RemoveDefaultArguments =
false;
2451 NewParamEnd = NewParams->
end();
2452 NewParam != NewParamEnd; ++NewParam) {
2454 bool RedundantDefaultArg =
false;
2459 bool MissingDefaultArg =
false;
2462 bool SawParameterPack =
false;
2465 = dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
2467 if (NewTypeParm->hasDefaultArgument() &&
2469 NewTypeParm->getLocation(),
2470 NewTypeParm->getDefaultArgumentInfo()->getTypeLoc()
2472 NewTypeParm->removeDefaultArgument();
2476 = OldParams? cast<TemplateTypeParmDecl>(*OldParam) :
nullptr;
2477 if (NewTypeParm->isParameterPack()) {
2478 assert(!NewTypeParm->hasDefaultArgument() &&
2479 "Parameter packs can't have a default argument!");
2480 SawParameterPack =
true;
2482 NewTypeParm->hasDefaultArgument() &&
2485 NewDefaultLoc = NewTypeParm->getDefaultArgumentLoc();
2486 SawDefaultArgument =
true;
2487 RedundantDefaultArg =
true;
2488 PreviousDefaultArgLoc = NewDefaultLoc;
2492 NewTypeParm->setInheritedDefaultArgument(Context, OldTypeParm);
2494 }
else if (NewTypeParm->hasDefaultArgument()) {
2495 SawDefaultArgument =
true;
2496 PreviousDefaultArgLoc = NewTypeParm->getDefaultArgumentLoc();
2497 }
else if (SawDefaultArgument)
2498 MissingDefaultArg =
true;
2500 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
2502 if (!NewNonTypeParm->isParameterPack() &&
2503 DiagnoseUnexpandedParameterPack(NewNonTypeParm->getLocation(),
2504 NewNonTypeParm->getTypeSourceInfo(),
2505 UPPC_NonTypeTemplateParameterType)) {
2511 if (NewNonTypeParm->hasDefaultArgument() &&
2513 NewNonTypeParm->getLocation(),
2514 NewNonTypeParm->getDefaultArgument()->getSourceRange())) {
2515 NewNonTypeParm->removeDefaultArgument();
2520 = OldParams? cast<NonTypeTemplateParmDecl>(*OldParam) :
nullptr;
2521 if (NewNonTypeParm->isParameterPack()) {
2522 assert(!NewNonTypeParm->hasDefaultArgument() &&
2523 "Parameter packs can't have a default argument!");
2524 if (!NewNonTypeParm->isPackExpansion())
2525 SawParameterPack =
true;
2527 NewNonTypeParm->hasDefaultArgument() &&
2530 NewDefaultLoc = NewNonTypeParm->getDefaultArgumentLoc();
2531 SawDefaultArgument =
true;
2532 RedundantDefaultArg =
true;
2533 PreviousDefaultArgLoc = NewDefaultLoc;
2537 NewNonTypeParm->setInheritedDefaultArgument(Context, OldNonTypeParm);
2539 }
else if (NewNonTypeParm->hasDefaultArgument()) {
2540 SawDefaultArgument =
true;
2541 PreviousDefaultArgLoc = NewNonTypeParm->getDefaultArgumentLoc();
2542 }
else if (SawDefaultArgument)
2543 MissingDefaultArg =
true;
2546 = cast<TemplateTemplateParmDecl>(*NewParam);
2563 = OldParams? cast<TemplateTemplateParmDecl>(*OldParam) :
nullptr;
2566 "Parameter packs can't have a default argument!");
2568 SawParameterPack =
true;
2569 }
else if (OldTemplateParm &&
2575 SawDefaultArgument =
true;
2576 RedundantDefaultArg =
true;
2577 PreviousDefaultArgLoc = NewDefaultLoc;
2582 PreviousDefaultArgLoc
2585 SawDefaultArgument =
true;
2586 PreviousDefaultArgLoc
2588 }
else if (SawDefaultArgument)
2589 MissingDefaultArg =
true;
2595 if (SawParameterPack && (NewParam + 1) != NewParamEnd &&
2596 (TPC == TPC_ClassTemplate || TPC == TPC_VarTemplate ||
2597 TPC == TPC_TypeAliasTemplate)) {
2598 Diag((*NewParam)->getLocation(),
2599 diag::err_template_param_pack_must_be_last_template_parameter);
2603 if (RedundantDefaultArg) {
2607 Diag(NewDefaultLoc, diag::err_template_param_default_arg_redefinition);
2608 Diag(OldDefaultLoc, diag::note_template_param_prev_default_arg);
2610 }
else if (MissingDefaultArg && TPC != TPC_FunctionTemplate) {
2616 Diag((*NewParam)->getLocation(),
2617 diag::err_template_param_default_arg_missing);
2618 Diag(PreviousDefaultArgLoc, diag::note_template_param_prev_default_arg);
2620 RemoveDefaultArguments =
true;
2631 if (RemoveDefaultArguments) {
2633 NewParamEnd = NewParams->
end();
2634 NewParam != NewParamEnd; ++NewParam) {
2636 TTP->removeDefaultArgument();
2638 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
2639 NTTP->removeDefaultArgument();
2641 cast<TemplateTemplateParmDecl>(*NewParam)->removeDefaultArgument();
2661 bool IgnoreNonTypeDependent;
2666 DependencyChecker(
unsigned Depth,
bool IgnoreNonTypeDependent)
2667 :
Depth(Depth), IgnoreNonTypeDependent(IgnoreNonTypeDependent),
2671 : IgnoreNonTypeDependent(IgnoreNonTypeDependent), Match(
false) {
2674 Depth = PD->getDepth();
2676 dyn_cast<NonTypeTemplateParmDecl>(ND)) {
2677 Depth = PD->getDepth();
2679 Depth = cast<TemplateTemplateParmDecl>(ND)->getDepth();
2684 if (ParmDepth >= Depth) {
2692 bool TraverseStmt(
Stmt *S, DataRecursionQueue *Q =
nullptr) {
2697 if (
auto *E = dyn_cast_or_null<Expr>(S))
2698 if (IgnoreNonTypeDependent && !E->isTypeDependent())
2700 return super::TraverseStmt(S, Q);
2703 bool TraverseTypeLoc(
TypeLoc TL) {
2704 if (IgnoreNonTypeDependent && !TL.
isNull() &&
2707 return super::TraverseTypeLoc(TL);
2716 return IgnoreNonTypeDependent || !Matches(T->
getDepth());
2722 if (Matches(PD->getDepth()))
2724 return super::TraverseTemplateName(N);
2729 dyn_cast<NonTypeTemplateParmDecl>(E->
getDecl()))
2730 if (Matches(PD->getDepth(), E->
getExprLoc()))
2732 return super::VisitDeclRefExpr(E);
2754 if (!Params->
size())
2757 DependencyChecker Checker(Params,
false);
2758 Checker.TraverseType(T);
2759 return Checker.Match;
2769 if (
const Type *CurType = NNS->getAsType()) {
2775 NNSLoc = NNSLoc.getPrefix();
2818 bool &IsMemberSpecialization,
bool &Invalid,
bool SuppressDiagnostic) {
2819 IsMemberSpecialization =
false;
2829 = dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS,
true)))
2841 NestedTypes.push_back(T);
2847 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
2848 if (!isa<ClassTemplatePartialSpecializationDecl>(Spec) &&
2850 ExplicitSpecLoc = Spec->getLocation();
2853 }
else if (Record->getTemplateSpecializationKind()
2855 ExplicitSpecLoc = Record->getLocation();
2868 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
2869 if (
TypeDecl *
Parent = dyn_cast<TypeDecl>(Template->getDeclContext()))
2914 std::reverse(NestedTypes.begin(), NestedTypes.end());
2922 bool SawNonEmptyTemplateParameterList =
false;
2924 auto CheckExplicitSpecialization = [&](
SourceRange Range,
bool Recovery) {
2925 if (SawNonEmptyTemplateParameterList) {
2926 if (!SuppressDiagnostic)
2927 Diag(DeclLoc, diag::err_specialize_member_of_template)
2928 << !Recovery << Range;
2930 IsMemberSpecialization =
false;
2937 auto DiagnoseMissingExplicitSpecialization = [&] (
SourceRange Range) {
2939 if (CheckExplicitSpecialization(Range,
true))
2944 if (!ParamLists.empty())
2945 ExpectedTemplateLoc = ParamLists[0]->getTemplateLoc();
2947 ExpectedTemplateLoc = DeclStartLoc;
2949 if (!SuppressDiagnostic)
2950 Diag(DeclLoc, diag::err_template_spec_needs_header)
2957 for (
unsigned TypeIdx = 0, NumTypes = NestedTypes.size(); TypeIdx != NumTypes;
2959 T = NestedTypes[TypeIdx];
2962 bool NeedEmptyTemplateHeader =
false;
2965 bool NeedNonemptyTemplateHeader =
false;
2978 = dyn_cast<ClassTemplatePartialSpecializationDecl>(Record)) {
2979 ExpectedTemplateParams = Partial->getTemplateParameters();
2980 NeedNonemptyTemplateHeader =
true;
2981 }
else if (Record->isDependentType()) {
2982 if (Record->getDescribedClassTemplate()) {
2983 ExpectedTemplateParams = Record->getDescribedClassTemplate()
2984 ->getTemplateParameters();
2985 NeedNonemptyTemplateHeader =
true;
2988 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
2994 NeedEmptyTemplateHeader =
true;
2997 }
else if (Record->getTemplateSpecializationKind()) {
2998 if (Record->getTemplateSpecializationKind()
3000 TypeIdx == NumTypes - 1)
3001 IsMemberSpecialization =
true;
3007 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
3008 ExpectedTemplateParams = Template->getTemplateParameters();
3009 NeedNonemptyTemplateHeader =
true;
3014 NeedNonemptyTemplateHeader =
false;
3024 if (ParamIdx < ParamLists.size()) {
3025 if (ParamLists[ParamIdx]->size() == 0) {
3026 if (CheckExplicitSpecialization(ParamLists[ParamIdx]->
getSourceRange(),
3030 SawNonEmptyTemplateParameterList =
true;
3033 if (NeedEmptyTemplateHeader) {
3036 if (TypeIdx == NumTypes - 1)
3037 IsMemberSpecialization =
true;
3039 if (ParamIdx < ParamLists.size()) {
3040 if (ParamLists[ParamIdx]->size() > 0) {
3042 if (!SuppressDiagnostic)
3043 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
3044 diag::err_template_param_list_matches_nontemplate)
3046 <<
SourceRange(ParamLists[ParamIdx]->getLAngleLoc(),
3047 ParamLists[ParamIdx]->getRAngleLoc())
3059 if (DiagnoseMissingExplicitSpecialization(
3066 if (NeedNonemptyTemplateHeader) {
3072 if (ParamIdx < ParamLists.size() &&
3074 ExpectedTemplateParams =
nullptr;
3079 if (ParamIdx < ParamLists.size()) {
3081 if (ExpectedTemplateParams &&
3082 !TemplateParameterListsAreEqual(ParamLists[ParamIdx],
3083 ExpectedTemplateParams,
3084 !SuppressDiagnostic, TPL_TemplateMatch))
3088 CheckTemplateParameterList(ParamLists[ParamIdx],
nullptr,
3089 TPC_ClassTemplateMember))
3096 if (!SuppressDiagnostic)
3097 Diag(DeclLoc, diag::err_template_spec_needs_template_parameters)
3108 if (ParamIdx >= ParamLists.size()) {
3109 if (TemplateId && !IsFriend) {
3125 if (ParamIdx < ParamLists.size() - 1) {
3126 bool HasAnyExplicitSpecHeader =
false;
3127 bool AllExplicitSpecHeaders =
true;
3128 for (
unsigned I = ParamIdx, E = ParamLists.size() - 1; I != E; ++I) {
3129 if (ParamLists[I]->size() == 0)
3130 HasAnyExplicitSpecHeader =
true;
3132 AllExplicitSpecHeaders =
false;
3135 if (!SuppressDiagnostic)
3136 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
3137 AllExplicitSpecHeaders ? diag::warn_template_spec_extra_headers
3138 : diag::err_template_spec_extra_headers)
3139 <<
SourceRange(ParamLists[ParamIdx]->getTemplateLoc(),
3140 ParamLists[ParamLists.size() - 2]->getRAngleLoc());
3145 if (ExplicitSpecLoc.isValid() && HasAnyExplicitSpecHeader &&
3146 !SuppressDiagnostic)
3147 Diag(ExplicitSpecLoc,
3148 diag::note_explicit_template_spec_does_not_need_header)
3149 << NestedTypes.back();
3154 if (!AllExplicitSpecHeaders)
3165 if (ParamLists.back()->size() == 0 &&
3166 CheckExplicitSpecialization(ParamLists[ParamIdx]->
getSourceRange(),
3172 return ParamLists.back();
3177 Diag(Template->getLocation(), diag::note_template_declared_here)
3178 << (isa<FunctionTemplateDecl>(Template)
3180 : isa<ClassTemplateDecl>(Template)
3182 : isa<VarTemplateDecl>(Template)
3184 : isa<TypeAliasTemplateDecl>(Template) ? 3 : 4)
3185 << Template->getDeclName();
3193 Diag((*I)->getLocation(), diag::note_template_declared_here)
3194 << 0 << (*I)->getDeclName();
3213 if (!Converted[1].getAsType()->isIntegralType(Context)) {
3214 SemaRef.
Diag(TemplateArgs[1].getLocation(),
3215 diag::err_integer_sequence_integral_element_type);
3224 SemaRef.
Diag(TemplateArgs[2].getLocation(),
3225 diag::err_integer_sequence_negative_length);
3233 SyntheticTemplateArgs.
addArgument(TemplateArgs[1]);
3235 for (
llvm::APSInt I(NumArgs.getBitWidth(), NumArgs.isUnsigned());
3239 TA, ArgTy, TemplateArgs[2].getLocation()));
3244 TemplateLoc, SyntheticTemplateArgs);
3251 assert(Converted.size() == 2 &&
3252 "__type_pack_element should be given an index and a parameter pack");
3257 assert(Index >= 0 &&
"the index used with __type_pack_element should be of " 3258 "type std::size_t, and hence be non-negative");
3259 if (Index >= Ts.pack_size()) {
3260 SemaRef.
Diag(TemplateArgs[0].getLocation(),
3261 diag::err_type_pack_element_out_of_bounds);
3266 auto Nth = std::next(Ts.pack_begin(), Index.getExtValue());
3267 return Nth->getAsType();
3269 llvm_unreachable(
"unexpected BuiltinTemplateDecl!");
3274 return AliasTemplate->
getName().equals(
"enable_if_t");
3286 if (BinOp->getOpcode() == BO_LAnd) {
3294 Terms.push_back(Clause);
3303 if (!BinOp)
return Cond;
3305 if (BinOp->getOpcode() != BO_LOr)
return Cond;
3308 Expr *LHS = BinOp->getLHS();
3310 if (!InnerBinOp)
return Cond;
3312 if (InnerBinOp->getOpcode() != BO_EQ ||
3313 !isa<IntegerLiteral>(InnerBinOp->getRHS()))
3323 if (MacroName ==
"CONCEPT_REQUIRES" || MacroName ==
"CONCEPT_REQUIRES_")
3324 return BinOp->getRHS();
3334 class FailedBooleanConditionPrinterHelper :
public PrinterHelper {
3339 bool handledStmt(
Stmt *E, raw_ostream &OS)
override {
3341 if (DR && DR->getQualifier()) {
3348 if (
const auto *IV = dyn_cast<VarTemplateSpecializationDecl>(VD)) {
3363 std::pair<Expr *, std::string>
3372 Expr *FailedCond =
nullptr;
3373 for (
Expr *Term : Terms) {
3377 if (isa<CXXBoolLiteralExpr>(TermAsWritten) ||
3378 isa<IntegerLiteral>(TermAsWritten))
3387 if (Term->EvaluateAsBooleanCondition(Succeeded, Context) &&
3389 FailedCond = TermAsWritten;
3396 std::string Description;
3398 llvm::raw_string_ostream Out(Description);
3401 FailedBooleanConditionPrinterHelper Helper(Policy);
3402 FailedCond->
printPretty(Out, &Helper, Policy, 0,
"\n",
nullptr);
3404 return { FailedCond, Description };
3423 if (!Template || isa<FunctionTemplateDecl>(Template) ||
3424 isa<VarTemplateDecl>(Template) || isa<ConceptDecl>(Template)) {
3430 Diag(TemplateLoc, diag::err_template_id_not_a_type)
3432 NoteAllFoundTemplates(Name);
3439 if (CheckTemplateArgumentList(Template, TemplateLoc, TemplateArgs,
3446 bool InstantiationDependent =
false;
3448 dyn_cast<TypeAliasTemplateDecl>(Template)) {
3461 unsigned Depth = AliasTemplate->getTemplateParameters()->getDepth();
3462 for (
unsigned I = 0; I <
Depth; ++I)
3471 TemplateArgLists, AliasTemplate->getLocation(),
3472 AliasTemplate->getDeclName());
3473 if (CanonType.
isNull()) {
3478 if (
auto DeductionInfo = isSFINAEContext()) {
3479 if (*DeductionInfo &&
3480 (*DeductionInfo)->hasSFINAEDiagnostic() &&
3481 (*DeductionInfo)->peekSFINAEDiagnostic().second.getDiagID() ==
3482 diag::err_typename_nested_not_found_enable_if &&
3483 TemplateArgs[0].getArgument().getKind()
3486 std::string FailedDescription;
3487 std::tie(FailedCond, FailedDescription) =
3488 findFailedBooleanCondition(TemplateArgs[0].getSourceExpression());
3493 (*DeductionInfo)->takeSFINAEDiagnostic(OldDiag);
3497 (*DeductionInfo)->addSFINAEDiagnostic(
3499 PDiag(diag::err_typename_nested_not_found_requirement)
3500 << FailedDescription
3510 TemplateArgs, InstantiationDependent)) {
3526 if (isa<ClassTemplateDecl>(Template)) {
3529 if (Ctx->isFileContext())
break;
3533 if (!Record)
continue;
3537 if (!isa<ClassTemplatePartialSpecializationDecl>(Record) &&
3544 QualType Injected = cast<InjectedClassNameType>(ICNT)
3545 ->getInjectedSpecializationType();
3558 = dyn_cast<ClassTemplateDecl>(Template)) {
3561 void *InsertPos =
nullptr;
3563 = ClassTemplate->findSpecialization(Converted, InsertPos);
3569 Context, ClassTemplate->getTemplatedDecl()->getTagKind(),
3570 ClassTemplate->getDeclContext(),
3571 ClassTemplate->getTemplatedDecl()->getBeginLoc(),
3572 ClassTemplate->getLocation(), ClassTemplate, Converted,
nullptr);
3573 ClassTemplate->AddSpecialization(Decl, InsertPos);
3574 if (ClassTemplate->isOutOfLine())
3581 InstantiateAttrsForDecl(TemplateArgLists, ClassTemplate->getTemplatedDecl(),
3586 (void)DiagnoseUseOfDecl(Decl, TemplateLoc);
3589 assert(isa<RecordType>(CanonType) &&
3590 "type of non-dependent specialization is not a RecordType");
3591 }
else if (
auto *BTD = dyn_cast<BuiltinTemplateDecl>(Template)) {
3610 assert(ATN &&
"not an assumed template name");
3611 II = ATN->getDeclName().getAsIdentifierInfo();
3613 if (!resolveAssumedTemplateNameAsType(S, Name, NameLoc,
false)) {
3615 ParsedName = TemplateTy::make(Name);
3627 assert(ATN &&
"not an assumed template name");
3635 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
3636 return std::make_unique<CandidateCallback>(*this);
3641 CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), S,
nullptr,
3642 FilterCCC, CTK_ErrorRecovery);
3644 diagnoseTypo(Corrected, PDiag(diag::err_no_template_suggest)
3651 Diag(R.getNameLoc(), diag::err_no_template) << R.getLookupName();
3660 bool IsCtorOrDtorName,
bool IsClassName) {
3664 if (!IsCtorOrDtorName && !IsClassName && SS.
isSet()) {
3665 DeclContext *LookupCtx = computeDeclContext(SS,
false);
3673 if (!LookupCtx && isDependentScopeSpecifier(SS)) {
3680 return ActOnTypenameType(
nullptr,
SourceLocation(), SS, TemplateKWLoc,
3681 TemplateD, TemplateII, TemplateIILoc, LAngleLoc,
3682 TemplateArgsIn, RAngleLoc);
3689 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
3690 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
3693 ? diag::err_out_of_line_qualified_id_type_names_constructor
3694 : diag::ext_out_of_line_qualified_id_type_names_constructor)
3701 if (Template.getAsAssumedTemplateName() &&
3702 resolveAssumedTemplateNameAsType(S, Template, TemplateIILoc))
3707 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
3712 DTN->getQualifier(),
3713 DTN->getIdentifier(),
3725 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
3730 QualType Result = CheckTemplateIdType(Template, TemplateIILoc, TemplateArgs);
3731 if (Result.isNull())
3742 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
3773 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
3782 DTN->getQualifier(),
3783 DTN->getIdentifier(),
3796 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
3807 Diag(TemplateLoc, diag::err_tag_reference_non_tag)
3808 << TAT << NTK_TypeAliasTemplate << TagKind;
3809 Diag(TAT->getLocation(), diag::note_declared_at);
3812 QualType Result = CheckTemplateIdType(Template, TemplateLoc, TemplateArgs);
3813 if (Result.isNull())
3821 assert(Id &&
"templated class must have an identifier");
3823 if (!isAcceptableTagRedeclaration(D, TagKind, TUK == TUK_Definition,
3825 Diag(TagLoc, diag::err_use_with_wrong_tag)
3840 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
3849 return CreateParsedType(Result, TLB.getTypeSourceInfo(Context, Result));
3889 dyn_cast_or_null<TemplateTemplateParmDecl>(
3893 llvm_unreachable(
"unexpected kind of template argument");
3898 if (Params->
size() != Args.size())
3903 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
3922 template<
typename PartialSpecDecl>
3924 if (Partial->getDeclContext()->isDependentContext())
3933 auto *Template = Partial->getSpecializedTemplate();
3934 S.
Diag(Partial->getLocation(),
3935 diag::ext_partial_spec_not_more_specialized_than_primary)
3936 << isa<VarTemplateDecl>(Template);
3938 if (Info.hasSFINAEDiagnostic()) {
3941 Info.takeSFINAEDiagnostic(Diag);
3945 diag::note_partial_spec_not_more_specialized_than_primary)
3949 S.
Diag(Template->getLocation(), diag::note_template_decl_here);
3951 Template->getAssociatedConstraints(TemplateAC);
3952 Partial->getAssociatedConstraints(PartialAC);
3959 const llvm::SmallBitVector &DeducibleParams) {
3960 for (
unsigned I = 0, N = DeducibleParams.size(); I != N; ++I) {
3961 if (!DeducibleParams[I]) {
3974 template<
typename PartialSpecDecl>
3976 PartialSpecDecl *Partial) {
3989 auto *TemplateParams = Partial->getTemplateParameters();
3990 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
3992 TemplateParams->getDepth(), DeducibleParams);
3994 if (!DeducibleParams.all()) {
3995 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
3996 S.
Diag(Partial->getLocation(), diag::ext_partial_specs_not_deducible)
3997 << isa<VarTemplatePartialSpecializationDecl>(Partial)
3998 << (NumNonDeducible > 1)
4000 Partial->getTemplateArgsAsWritten()->RAngleLoc);
4021 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
4022 MarkDeducedTemplateParameters(TD, DeducibleParams);
4023 for (
unsigned I = 0; I != TemplateParams->size(); ++I) {
4025 auto *Param = TemplateParams->getParam(I);
4027 DeducibleParams[I] =
true;
4030 if (!DeducibleParams.all()) {
4031 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
4032 Diag(TD->
getLocation(), diag::err_deduction_guide_template_not_deducible)
4033 << (NumNonDeducible > 1);
4044 "Variable template specialization is declared with a template it.");
4061 FnTemplate = *OTS->begin();
4068 << IsPartialSpecialization;
4072 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
4073 if (DiagnoseUnexpandedParameterPack(TemplateArgs[I],
4074 UPPC_PartialSpecialization))
4080 if (CheckTemplateArgumentList(VarTemplate, TemplateNameLoc, TemplateArgs,
4087 if (IsPartialSpecialization) {
4088 if (CheckTemplatePartialSpecializationArgs(TemplateNameLoc, VarTemplate,
4089 TemplateArgs.
size(), Converted))
4094 bool InstantiationDependent;
4098 InstantiationDependent)) {
4099 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
4101 IsPartialSpecialization =
false;
4112 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
4114 << (SC !=
SC_Extern && !CurContext->isRecord())
4122 void *InsertPos =
nullptr;
4125 if (IsPartialSpecialization)
4137 IsPartialSpecialization))
4145 Specialization = PrevDecl;
4148 }
else if (IsPartialSpecialization) {
4151 cast_or_null<VarTemplatePartialSpecializationDecl>(PrevDecl);
4155 TemplateNameLoc, TemplateParams, VarTemplate, DI->
getType(), DI, SC,
4156 Converted, TemplateArgs);
4159 VarTemplate->AddPartialSpecialization(Partial, InsertPos);
4160 Specialization = Partial;
4167 CheckTemplatePartialSpecialization(Partial);
4172 Context, VarTemplate->
getDeclContext(), TemplateKWLoc, TemplateNameLoc,
4173 VarTemplate, DI->
getType(), DI, SC, Converted);
4177 VarTemplate->AddSpecialization(Specialization, InsertPos);
4198 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
4202 diag::note_instantiation_required_here)
4215 CurContext->addDecl(Specialization);
4223 LookupResult PrevSpec(*
this, GetNameForDeclarator(D), LookupOrdinaryName,
4224 forRedeclarationInCurContext());
4232 return Specialization;
4238 struct PartialSpecMatchResult {
4248 assert(Template &&
"A variable template id without template?");
4252 if (CheckTemplateArgumentList(
4253 Template, TemplateNameLoc,
4254 const_cast<TemplateArgumentListInfo &>(TemplateArgs),
false,
4260 void *InsertPos =
nullptr;
4262 Converted, InsertPos)) {
4263 checkSpecializationVisibility(TemplateNameLoc, Spec);
4276 bool AmbiguousPartialSpec =
false;
4292 bool InstantiationDependent =
false;
4294 TemplateArgs, InstantiationDependent)) {
4299 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
4312 Matched.push_back(PartialSpecMatchResult());
4313 Matched.back().Partial = Partial;
4314 Matched.back().Args = Info.take();
4318 if (Matched.size() >= 1) {
4320 if (Matched.size() == 1) {
4333 PEnd = Matched.end();
4335 if (getMoreSpecializedPartialSpecialization(
P->Partial, Best->Partial,
4336 PointOfInstantiation) ==
4344 PEnd = Matched.end();
4346 if (
P != Best && getMoreSpecializedPartialSpecialization(
4347 P->Partial, Best->Partial,
4348 PointOfInstantiation) != Best->Partial) {
4349 AmbiguousPartialSpec =
true;
4356 InstantiationPattern = Best->Partial;
4357 InstantiationArgs = Best->Args;
4370 Template, InstantiationPattern, *InstantiationArgs, TemplateArgs,
4371 Converted, TemplateNameLoc, InsertPos );
4375 if (AmbiguousPartialSpec) {
4378 Diag(PointOfInstantiation, diag::err_partial_spec_ordering_ambiguous)
4382 for (MatchResult
P : Matched)
4383 Diag(
P.Partial->getLocation(), diag::note_partial_spec_match)
4384 << getTemplateArgumentBindingsText(
P.Partial->getTemplateParameters(),
4390 dyn_cast<VarTemplatePartialSpecializationDecl>(InstantiationPattern))
4393 checkSpecializationVisibility(TemplateNameLoc, Decl);
4395 assert(Decl &&
"No variable template specialization?");
4416 return BuildDeclarationNameExpr(SS, NameInfo, Var,
4417 nullptr, TemplateArgs);
4422 Diag(Loc, diag::err_template_missing_args)
4423 << (int)getTemplateNameKindForDiagnostics(Name) << Name;
4425 Diag(TD->getLocation(), diag::note_template_decl_here)
4426 << TD->getTemplateParameters()->getSourceRange();
4437 assert(NamedConcept &&
"A concept template id without a template?");
4440 if (CheckTemplateArgumentList(NamedConcept, ConceptNameInfo.
getLoc(),
4447 bool AreArgsDependent =
false;
4449 if (Arg.isDependent()) {
4450 AreArgsDependent =
true;
4454 if (!AreArgsDependent &&
4459 ConceptNameInfo.
getLoc(),
4466 TemplateKWLoc, ConceptNameInfo, FoundDecl, NamedConcept,
4468 AreArgsDependent ? nullptr : &Satisfaction);
4487 assert(!R.
isAmbiguous() &&
"ambiguous lookup when building templateid");
4491 if (!TemplateArgs && !isa<FunctionTemplateDecl>(TD)) {
4497 auto AnyDependentArguments = [&]() ->
bool {
4498 bool InstantiationDependent;
4499 return TemplateArgs &&
4501 *TemplateArgs, InstantiationDependent);
4508 TemplateKWLoc, TemplateArgs);
4525 RequiresADL, TemplateArgs,
4538 assert(TemplateArgs || TemplateKWLoc.
isValid());
4540 if (!(DC = computeDeclContext(SS,
false)) ||
4541 DC->isDependentContext() ||
4542 RequireCompleteDeclContext(SS, DC))
4543 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
4545 bool MemberOfUnknownSpecialization;
4548 false, MemberOfUnknownSpecialization,
4562 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_class_template)
4565 Diag(Temp->getLocation(), diag::note_referenced_class_template);
4569 return BuildTemplateIdExpr(SS, TemplateKWLoc, R,
false, TemplateArgs);
4584 bool EnteringContext,
4586 bool AllowInjectedClassName) {
4589 getLangOpts().CPlusPlus11 ?
4590 diag::warn_cxx98_compat_template_outside_of_template :
4591 diag::ext_template_outside_of_template)
4596 LookupCtx = computeDeclContext(SS, EnteringContext);
4597 if (!LookupCtx && ObjectType)
4598 LookupCtx = computeDeclContext(ObjectType.
get());
4616 bool MemberOfUnknownSpecialization;
4618 ObjectType, EnteringContext, Result,
4619 MemberOfUnknownSpecialization);
4628 LookupOrdinaryName);
4630 if (!LookupTemplateName(R, S, SS, ObjectType.get(), EnteringContext,
4631 MOUS, TemplateKWLoc) && !R.isAmbiguous())
4638 if (!AllowInjectedClassName && SS.
isSet() && LookupRD &&
4651 diag::ext_out_of_line_qualified_id_type_names_constructor)
4674 llvm_unreachable(
"literal operator id cannot have a dependent scope");
4680 Diag(Name.
getBeginLoc(), diag::err_template_kw_refers_to_non_template)
4681 << GetNameFromUnqualifiedId(Name).getName() << Name.
getSourceRange()
4708 diagnoseMissingTemplateArguments(Name, SR.
getEnd());
4718 SS.
Adopt(ArgExpr->getQualifierLoc());
4719 NameInfo = ArgExpr->getNameInfo();
4721 dyn_cast<DependentScopeDeclRefExpr>(Arg.
getAsExpr())) {
4722 SS.
Adopt(ArgExpr->getQualifierLoc());
4723 NameInfo = ArgExpr->getNameInfo();
4725 dyn_cast<CXXDependentScopeMemberExpr>(Arg.
getAsExpr())) {
4726 if (ArgExpr->isImplicitAccess()) {
4727 SS.
Adopt(ArgExpr->getQualifierLoc());
4728 NameInfo = ArgExpr->getMemberNameInfo();
4733 LookupResult Result(*
this, NameInfo, LookupOrdinaryName);
4734 LookupParsedName(Result, CurScope, &SS);
4741 Diag(Loc, getLangOpts().MSVCCompat
4742 ? diag::ext_ms_template_type_arg_missing_typename
4743 : diag::err_template_arg_must_be_type_suggest)
4773 Diag(SR.
getBegin(), diag::err_template_arg_must_be_type) << SR;
4780 if (CheckTemplateArgument(Param, TSI))
4789 if (getLangOpts().ObjCAutoRefCount &&
4835 Param, Template, Converted,
4845 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4850 SemaRef.
SubstType(ArgType, TemplateArgLists,
4887 Param, Template, Converted,
4897 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4950 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4980 bool &HasDefaultArg) {
4981 HasDefaultArg =
false;
4987 HasDefaultArg =
true;
5000 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
5004 HasDefaultArg =
true;
5018 = cast<TemplateTemplateParmDecl>(Param);
5022 HasDefaultArg =
true;
5045 if (ETLoc.getTypePtr()->getKeyword() !=
ETK_None)
5048 QualLoc = ETLoc.getQualifierLoc();
5049 TLoc = ETLoc.getNamedTypeLoc();
5056 QualLoc, InjLoc.getNameLoc());
5064 dyn_cast<ClassTemplateSpecializationDecl>(RecLoc.getDecl()))
5066 QualLoc, RecLoc.getNameLoc());
5102 unsigned ArgumentPackIndex,
5107 return CheckTemplateTypeArgument(TTP, Arg, Converted);
5114 QualType NTTPType = NTTP->getType();
5115 if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack())
5116 NTTPType = NTTP->getExpansionType(ArgumentPackIndex);
5119 !isa<TemplateTemplateParmDecl>(Template) &&
5135 NTTPType = SubstType(PET->getPattern(),
5137 NTTP->getLocation(),
5138 NTTP->getDeclName());
5140 NTTPType = SubstType(NTTPType,
5142 NTTP->getLocation(),
5143 NTTP->getDeclName());
5149 NTTPType = CheckNonTypeTemplateParameterType(NTTPType,
5150 NTTP->getLocation());
5157 llvm_unreachable(
"Should never see a NULL template argument here");
5161 unsigned CurSFINAEErrors = NumSFINAEErrors;
5168 if (CurSFINAEErrors < NumSFINAEErrors)
5178 Converted.push_back(Result);
5212 Context, SS.getWithLocInContext(Context), TemplateKWLoc, NameInfo,
5224 E = CheckTemplateArgument(NTTP, NTTPType, E.
get(), Result);
5228 Converted.push_back(Result);
5255 Diag(SR.
getBegin(), diag::err_template_arg_nontype_ambig) << SR << T;
5257 Diag(SR.
getBegin(), diag::err_template_arg_must_be_expr) << SR;
5263 llvm_unreachable(
"Caller must expand template argument packs");
5286 TempParm, Converted,
5292 Params = SubstTemplateParams(Params, CurContext,
5311 llvm_unreachable(
"Should never see a NULL template argument here");
5315 if (CheckTemplateTemplateArgument(TempParm, Params, Arg))
5326 << getLangOpts().CPlusPlus11;
5330 llvm_unreachable(
"Declaration argument with template template parameter");
5332 llvm_unreachable(
"Integral argument with template template parameter");
5334 llvm_unreachable(
"Null pointer argument with template template parameter");
5337 llvm_unreachable(
"Caller must expand template argument packs");
5356 = dyn_cast<TemplateTypeParmDecl>(Param)) {
5357 if (TTP->isExpandedParameterPack())
5358 return TTP->getNumExpansionParameters();
5362 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
5363 if (NTTP->isExpandedParameterPack())
5364 return NTTP->getNumExpansionTypes();
5368 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
5369 if (TTP->isExpandedParameterPack())
5370 return TTP->getNumExpansionTemplateParameters();
5377 template<
typename TemplateParmDecl>
5380 const TemplateParmDecl *D,
5385 ->getTemplateParameters()
5386 ->getParam(D->getIndex()));
5393 D->getDefaultArgumentLoc(), Modules,
5404 S.
Diag(Loc, diag::err_template_arg_list_different_arity)
5419 bool UpdateArgsWithConversions,
bool *ConstraintsNotSatisfied) {
5421 if (ConstraintsNotSatisfied)
5422 *ConstraintsNotSatisfied =
false;
5434 ->getTemplateParameters();
5443 bool isTemplateTemplateParameter = isa<TemplateTemplateParmDecl>(Template);
5445 unsigned ArgIdx = 0, NumArgs = NewArgs.
size();
5448 ParamEnd = Params->
end();
5449 Param != ParamEnd; ) {
5453 if (*Expansions == ArgumentPack.size()) {
5456 Converted.push_back(
5458 ArgumentPack.clear();
5463 }
else if (ArgIdx == NumArgs && !PartialTemplateArgs) {
5465 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
5467 << (int)getTemplateNameKindForDiagnostics(
TemplateName(Template))
5475 if (ArgIdx < NumArgs) {
5477 if (CheckTemplateArgument(*Param, NewArgs[ArgIdx], Template,
5478 TemplateLoc, RAngleLoc,
5479 ArgumentPack.size(), Converted))
5482 bool PackExpansionIntoNonPack =
5483 NewArgs[ArgIdx].getArgument().isPackExpansion() &&
5485 if (PackExpansionIntoNonPack && (isa<TypeAliasTemplateDecl>(Template) ||
5486 isa<ConceptDecl>(Template))) {
5492 Diag(NewArgs[ArgIdx].getLocation(),
5493 diag::err_template_expansion_into_fixed_list)
5494 << (isa<ConceptDecl>(Template) ? 1 : 0)
5495 << NewArgs[ArgIdx].getSourceRange();
5496 Diag((*Param)->getLocation(), diag::note_template_param_here);
5503 if ((*Param)->isTemplateParameterPack()) {
5508 ArgumentPack.push_back(Converted.pop_back_val());
5517 if (PackExpansionIntoNonPack) {
5518 if (!ArgumentPack.empty()) {
5521 Converted.insert(Converted.end(),
5522 ArgumentPack.begin(), ArgumentPack.end());
5523 ArgumentPack.clear();
5526 while (ArgIdx < NumArgs) {
5527 Converted.push_back(NewArgs[ArgIdx].
getArgument());
5538 if (PartialTemplateArgs) {
5539 if ((*Param)->isTemplateParameterPack() && !ArgumentPack.empty())
5540 Converted.push_back(
5547 if ((*Param)->isTemplateParameterPack()) {
5549 "Should have dealt with this already");
5554 if (Param + 1 != ParamEnd)
5557 Converted.push_back(
5559 ArgumentPack.clear();
5590 = dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
5607 = cast<TemplateTemplateParmDecl>(*Param);
5633 if (Inst.isInvalid())
5637 if (CheckTemplateArgument(*Param, Arg, Template, TemplateLoc,
5638 RAngleLoc, 0, Converted))
5644 if (isTemplateTemplateParameter)
5656 if (ArgIdx < NumArgs && CurrentInstantiationScope &&
5657 CurrentInstantiationScope->getPartiallySubstitutedPack()) {
5659 Converted.push_back(NewArgs[ArgIdx++].getArgument());
5664 if (ArgIdx < NumArgs) {
5665 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
5667 << (int)getTemplateNameKindForDiagnostics(
TemplateName(Template))
5677 if (UpdateArgsWithConversions)
5678 TemplateArgs = std::move(NewArgs);
5680 if (!PartialTemplateArgs &&
5681 EnsureTemplateArgumentListConstraints(
5684 if (ConstraintsNotSatisfied)
5685 *ConstraintsNotSatisfied =
true;
5693 class UnnamedLocalNoLinkageFinder
5694 :
public TypeVisitor<UnnamedLocalNoLinkageFinder, bool>
5702 UnnamedLocalNoLinkageFinder(
Sema &S,
SourceRange SR) : S(S), SR(SR) { }
5708 #define TYPE(Class, Parent) \ 5709 bool Visit##Class##Type(const Class##Type *); 5710 #define ABSTRACT_TYPE(Class, Parent) \ 5711 bool Visit##Class##Type(const Class##Type *) { return false; } 5712 #define NON_CANONICAL_TYPE(Class, Parent) \ 5713 bool Visit##Class##Type(const Class##Type *) { return false; } 5714 #include "clang/AST/TypeNodes.inc" 5716 bool VisitTagDecl(
const TagDecl *Tag);
5721 bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(
const BuiltinType*) {
5725 bool UnnamedLocalNoLinkageFinder::VisitComplexType(
const ComplexType* T) {
5729 bool UnnamedLocalNoLinkageFinder::VisitPointerType(
const PointerType* T) {
5733 bool UnnamedLocalNoLinkageFinder::VisitBlockPointerType(
5738 bool UnnamedLocalNoLinkageFinder::VisitLValueReferenceType(
5743 bool UnnamedLocalNoLinkageFinder::VisitRValueReferenceType(
5748 bool UnnamedLocalNoLinkageFinder::VisitMemberPointerType(
5753 bool UnnamedLocalNoLinkageFinder::VisitConstantArrayType(
5758 bool UnnamedLocalNoLinkageFinder::VisitIncompleteArrayType(
5763 bool UnnamedLocalNoLinkageFinder::VisitVariableArrayType(
5768 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedArrayType(
5773 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedExtVectorType(
5778 bool UnnamedLocalNoLinkageFinder::VisitDependentAddressSpaceType(
5783 bool UnnamedLocalNoLinkageFinder::VisitVectorType(
const VectorType* T) {
5787 bool UnnamedLocalNoLinkageFinder::VisitDependentVectorType(
5792 bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(
const ExtVectorType* T) {
5796 bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
5806 bool UnnamedLocalNoLinkageFinder::VisitFunctionNoProtoType(
5811 bool UnnamedLocalNoLinkageFinder::VisitUnresolvedUsingType(
5816 bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(
const TypeOfExprType*) {
5820 bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(
const TypeOfType* T) {
5824 bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(
const DecltypeType*) {
5828 bool UnnamedLocalNoLinkageFinder::VisitUnaryTransformType(
5833 bool UnnamedLocalNoLinkageFinder::VisitAutoType(
const AutoType *T) {
5837 bool UnnamedLocalNoLinkageFinder::VisitDeducedTemplateSpecializationType(
5842 bool UnnamedLocalNoLinkageFinder::VisitRecordType(
const RecordType* T) {
5843 return VisitTagDecl(T->
getDecl());
5846 bool UnnamedLocalNoLinkageFinder::VisitEnumType(
const EnumType* T) {
5847 return VisitTagDecl(T->
getDecl());
5850 bool UnnamedLocalNoLinkageFinder::VisitTemplateTypeParmType(
5855 bool UnnamedLocalNoLinkageFinder::VisitSubstTemplateTypeParmPackType(
5860 bool UnnamedLocalNoLinkageFinder::VisitTemplateSpecializationType(
5865 bool UnnamedLocalNoLinkageFinder::VisitInjectedClassNameType(
5867 return VisitTagDecl(T->
getDecl());
5870 bool UnnamedLocalNoLinkageFinder::VisitDependentNameType(
5875 bool UnnamedLocalNoLinkageFinder::VisitDependentTemplateSpecializationType(
5880 bool UnnamedLocalNoLinkageFinder::VisitPackExpansionType(
5885 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectType(
const ObjCObjectType *) {
5889 bool UnnamedLocalNoLinkageFinder::VisitObjCInterfaceType(
5894 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectPointerType(
5899 bool UnnamedLocalNoLinkageFinder::VisitAtomicType(
const AtomicType* T) {
5903 bool UnnamedLocalNoLinkageFinder::VisitPipeType(
const PipeType* T) {
5907 bool UnnamedLocalNoLinkageFinder::VisitTagDecl(
const TagDecl *Tag) {
5909 S.
Diag(SR.getBegin(),
5911 diag::warn_cxx98_compat_template_arg_local_type :
5912 diag::ext_template_arg_local_type)
5918 S.
Diag(SR.getBegin(),
5920 diag::warn_cxx98_compat_template_arg_unnamed_type :
5921 diag::ext_template_arg_unnamed_type) << SR;
5929 bool UnnamedLocalNoLinkageFinder::VisitNestedNameSpecifier(
5946 llvm_unreachable(
"Invalid NestedNameSpecifier::Kind!");
5956 assert(ArgInfo &&
"invalid TypeSourceInfo");
5961 return Diag(SR.
getBegin(), diag::err_variably_modified_template_arg) << Arg;
5963 return Diag(SR.
getBegin(), diag::err_template_arg_overload_type) << SR;
5974 UnnamedLocalNoLinkageFinder Finder(*
this, SR);
5992 Decl *Entity =
nullptr) {
5998 if (Entity && Entity->hasAttr<DLLImportAttr>())
6003 "Incomplete parameter type in isNullPointerValueTemplateArgument!");
6016 EvalResult.
Diag = &Notes;
6024 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
6025 diag::note_invalid_subexpr_in_const_expr) {
6026 DiagLoc = Notes[0].first;
6030 S.
Diag(DiagLoc, diag::err_template_arg_not_address_constant)
6032 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
6033 S.
Diag(Notes[I].first, Notes[I].second);
6051 bool ObjCLifetimeConversion;
6054 ObjCLifetimeConversion))
6059 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
6068 std::string Code =
"static_cast<" + ParamType.
getAsString() +
">(";
6069 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_untyped_null_constant)
6088 bool ObjCLifetimeConversion;
6092 ObjCLifetimeConversion)) {
6097 if (!ParamRef->getPointeeType()->isFunctionType()) {
6107 unsigned ParamQuals = ParamRef->getPointeeType().getCVRQualifiers();
6110 if ((ParamQuals | ArgQuals) != ParamQuals) {
6112 diag::err_template_arg_ref_bind_ignores_quals)
6148 bool Invalid =
false;
6152 bool AddressTaken =
false;
6159 bool ExtWarnMSTemplateArg =
false;
6162 while (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(Arg)) {
6164 if (UnOpKind == UO_Deref)
6165 ExtWarnMSTemplateArg =
true;
6166 if (UnOpKind == UO_AddrOf || UnOpKind == UO_Deref) {
6169 FirstOpKind = UnOpKind;
6170 FirstOpLoc = UnOp->getOperatorLoc();
6176 if (ExtWarnMSTemplateArg)
6180 if (FirstOpKind == UO_AddrOf)
6181 AddressTaken =
true;
6185 assert(FirstOpKind == UO_Deref);
6208 bool ExtraParens =
false;
6209 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
6210 if (!Invalid && !ExtraParens) {
6213 ? diag::warn_cxx98_compat_template_arg_extra_parens
6214 : diag::ext_template_arg_extra_parens)
6219 Arg = Parens->getSubExpr();
6223 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6227 if (UnOp->getOpcode() == UO_AddrOf) {
6228 Arg = UnOp->getSubExpr();
6229 AddressTaken =
true;
6230 AddrOpLoc = UnOp->getOperatorLoc();
6235 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6247 S.
Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
6267 if (isa<CXXUuidofExpr>(Arg)) {
6269 ArgIn, Arg, ArgType))
6284 if (isa<FieldDecl>(Entity) || isa<IndirectFieldDecl>(Entity)) {
6292 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Entity)) {
6293 if (!Method->isStatic()) {
6305 if (!Func && !Var) {
6317 ? diag::warn_cxx98_compat_template_arg_object_internal
6318 : diag::ext_template_arg_object_internal)
6320 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
6322 }
else if (!Entity->hasLinkage()) {
6325 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
6340 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
6346 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
6355 if (Var->getType()->isReferenceType()) {
6363 if (Var->getTLSKind()) {
6366 S.
Diag(Var->getLocation(), diag::note_template_arg_refers_here);
6379 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
6385 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
6390 ArgType = Var->getType();
6393 if (Var->getType()->isArrayType()) {
6434 bool Invalid =
false;
6436 Expr *Arg = ResultArg;
6437 bool ObjCLifetimeConversion;
6449 bool ExtraParens =
false;
6450 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
6451 if (!Invalid && !ExtraParens) {
6454 ? diag::warn_cxx98_compat_template_arg_extra_parens
6455 : diag::ext_template_arg_extra_parens)
6460 Arg = Parens->getSubExpr();
6464 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6469 if (UnOp->getOpcode() == UO_AddrOf) {
6476 else if ((DRE = dyn_cast<DeclRefExpr>(Arg))) {
6479 if (isa<NonTypeTemplateParmDecl>(VD)) {
6501 S.
Diag(ResultArg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
6511 ObjCLifetimeConversion)) {
6518 S.
Diag(ResultArg->
getBeginLoc(), diag::err_template_arg_not_convertible)
6526 diag::err_template_arg_not_pointer_to_member_form)
6529 if (isa<FieldDecl>(DRE->
getDecl()) ||
6530 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
6531 isa<CXXMethodDecl>(DRE->
getDecl())) {
6532 assert((isa<FieldDecl>(DRE->
getDecl()) ||
6533 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
6534 !cast<CXXMethodDecl>(DRE->
getDecl())->isStatic()) &&
6535 "Only non-static member pointers can make it here");
6549 S.
Diag(Arg->
getBeginLoc(), diag::err_template_arg_not_pointer_to_member_form)
6576 auto *AT = dyn_cast<
AutoType>(ParamType);
6577 if (AT && AT->isDecltypeAuto()) {
6587 Expr *DeductionArg = Arg;
6588 if (
auto *PE = dyn_cast<PackExpansionExpr>(DeductionArg))
6589 DeductionArg = PE->getPattern();
6592 DeductionArg, ParamType, Depth,
6597 true) == DAR_Failed) {
6599 diag::err_non_type_template_parm_type_deduction_failure)
6609 ParamType = CheckNonTypeTemplateParameterType(ParamType, Arg->
getExprLoc());
6610 if (ParamType.
isNull()) {
6618 "non-type template parameter type cannot be qualified");
6620 if (CTAK == CTAK_Deduced &&
6639 Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
6655 Arg = PE->getPattern();
6666 PE->getNumExpansions());
6683 Arg, ParamType, Value, CCEK_TemplateArg);
6689 if (ArgResult.
get()->isValueDependent()) {
6703 llvm_unreachable(
"result of constant evaluation should be initialized");
6715 diag::err_template_arg_member_ptr_base_derived_not_supported)
6723 : TemplateArgument(CanonParamType,
true);
6738 auto *E = Base.dyn_cast<
const Expr *>();
6739 if (E && isa<CXXUuidofExpr>(E)) {
6749 VD && VD->getType()->isArrayType() &&
6757 Diag(StartLoc, diag::err_non_type_template_arg_subobject)
6762 "null reference should not be a constant expression");
6764 "non-null value of type nullptr_t?");
6766 : TemplateArgument(CanonParamType,
true);
6770 return Diag(StartLoc, diag::err_non_type_template_arg_addr_label_diff);
6779 llvm_unreachable(
"invalid kind for template argument");
6782 return ArgResult.
get();
6802 if (getLangOpts().CPlusPlus11) {
6818 if (ArgResult.
get()->isValueDependent()) {
6828 IntegerType = Enum->getDecl()->getIntegerType();
6829 Value = Value.extOrTrunc(Context.
getTypeSize(IntegerType));
6836 ExprResult ArgResult = DefaultLvalueConversion(Arg);
6839 Arg = ArgResult.
get();
6852 Diag(Arg->
getBeginLoc(), diag::err_template_arg_not_integral_or_enumeral)
6861 TmplArgICEDiagnoser(
QualType T) : T(T) { }
6865 S.
Diag(Loc, diag::err_template_arg_not_ice) << T << SR;
6867 } Diagnoser(ArgType);
6869 Arg = VerifyIntegerConstantExpression(Arg, &Value, Diagnoser,
6884 Arg = ImpCastExprToType(Arg, ParamType, CK_IntegralToBoolean).get();
6885 }
else if (IsIntegralPromotion(Arg, ArgType, ParamType) ||
6888 Arg = ImpCastExprToType(Arg, ParamType, CK_IntegralCast).get();
6914 unsigned AllowedBits = Context.
getTypeSize(IntegerType);
6915 if (Value.getBitWidth() != AllowedBits)
6916 Value = Value.extOrTrunc(AllowedBits);
6923 unsigned AllowedBits = Context.
getTypeSize(IntegerType);
6924 if (Value.getBitWidth() != AllowedBits)
6925 Value = Value.extOrTrunc(AllowedBits);
6930 && (OldValue.isSigned() && OldValue.isNegative())) {
6932 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
6938 unsigned RequiredBits;
6940 RequiredBits = OldValue.getActiveBits();
6941 else if (OldValue.isUnsigned())
6942 RequiredBits = OldValue.getActiveBits() + 1;
6944 RequiredBits = OldValue.getMinSignedBits();
6945 if (RequiredBits > AllowedBits) {
6947 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
6988 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg, ParamType,
6994 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
7020 "Only object pointers allowed here");
7036 assert(ParamRefType->getPointeeType()->isIncompleteOrObjectType() &&
7037 "Only object references allowed here");
7040 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg,
7041 ParamRefType->getPointeeType(),
7047 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
7070 << Arg->
getType() << ParamType;
7078 Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
7111 assert(Name.
isDependent() &&
"Non-dependent template isn't a declaration?");
7130 if (!isa<ClassTemplateDecl>(Template) &&
7131 !isa<TemplateTemplateParmDecl>(Template) &&
7132 !isa<TypeAliasTemplateDecl>(Template) &&
7133 !isa<BuiltinTemplateDecl>(Template)) {
7134 assert(isa<FunctionTemplateDecl>(Template) &&
7135 "Only function templates are possible here");
7137 Diag(Template->
getLocation(), diag::note_template_arg_refers_here_func)
7147 if (getLangOpts().RelaxedTemplateTemplateArgs) {
7152 if (TemplateParameterListsAreEqual(
7154 TPL_TemplateTemplateArgumentMatch, Arg.
getLocation()) &&
7161 if (isTemplateTemplateParameterAtLeastAsSpecializedAs(Params, Template,
7172 if (ParamsAC.empty())
7175 bool IsParamAtLeastAsConstrained;
7176 if (IsAtLeastAsConstrained(Param, ParamsAC, Template, TemplateAC,
7177 IsParamAtLeastAsConstrained))
7179 if (!IsParamAtLeastAsConstrained) {
7181 diag::err_template_template_parameter_not_at_least_as_constrained)
7186 MaybeEmitAmbiguousAtomicConstraintsDiagnostic(Param, ParamsAC, Template,
7198 TPL_TemplateTemplateArgumentMatch,
7223 return ImpCastExprToType(
7227 ? CK_NullToMemberPointer
7228 : CK_NullToPointer);
7231 "Only declaration template arguments permitted here");
7239 assert(VD->getDeclContext()->isRecord() &&
7240 (isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD) ||
7241 isa<IndirectFieldDecl>(VD)));
7246 ClassType.getTypePtr());
7250 ExprResult RefExpr = BuildDeclarationNameExpr(
7256 QualType ElemT(RefExpr.
get()->getType()->getArrayElementTypeNoTypeQual(), 0);
7260 RefExpr = DefaultFunctionArrayConversion(RefExpr.
get());
7265 RefExpr = CreateBuiltinUnaryOp(Loc, UO_AddrOf, RefExpr.
get());
7270 "unexpected type for decl template argument");
7275 "value kind mismatch for non-type template argument");
7280 if (!Context.
hasSameType(RefExpr.
get()->getType(), DestExprType)) {
7284 IsFunctionConversion(RefExpr.
get()->getType(), DestExprType, Ignored)) {
7287 RefExpr.
get()->getType()->isPointerType()) {
7295 "unexpected conversion required for non-type template argument");
7297 RefExpr = ImpCastExprToType(RefExpr.
get(), DestExprType, CK,
7298 RefExpr.
get()->getValueKind());
7315 "Operation is only valid for integral template arguments");
7325 T = ET->getDecl()->getIntegerType();
7352 if (OrigT->isEnumeralType()) {
7372 unsigned NextDiag = diag::err_template_param_different_kind;
7373 if (TemplateArgLoc.
isValid()) {
7374 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
7375 NextDiag = diag::note_template_param_different_kind;
7394 unsigned NextDiag = diag::err_template_parameter_pack_non_pack;
7395 if (TemplateArgLoc.
isValid()) {
7396 S.
Diag(TemplateArgLoc,
7397 diag::err_template_arg_template_params_mismatch);
7398 NextDiag = diag::note_template_parameter_pack_non_pack;
7401 unsigned ParamKind = isa<TemplateTypeParmDecl>(New)? 0
7402 : isa<NonTypeTemplateParmDecl>(New)? 1
7415 = dyn_cast<NonTypeTemplateParmDecl>(Old)) {
7423 (!OldNTTP->getType()->isDependentType() &&
7427 unsigned NextDiag = diag::err_template_nontype_parm_different_type;
7428 if (TemplateArgLoc.
isValid()) {
7429 S.
Diag(TemplateArgLoc,
7430 diag::err_template_arg_template_params_mismatch);
7431 NextDiag = diag::note_template_nontype_parm_different_type;
7436 S.
Diag(OldNTTP->getLocation(),
7437 diag::note_template_nontype_parm_prev_declaration)
7438 << OldNTTP->getType();
7448 = dyn_cast<TemplateTemplateParmDecl>(Old)) {
7451 OldTTP->getTemplateParameters(),
7459 const Expr *NewC =
nullptr, *OldC =
nullptr;
7460 if (
const auto *TC = cast<TemplateTypeParmDecl>(New)->getTypeConstraint())
7461 NewC = TC->getImmediatelyDeclaredConstraint();
7462 if (
const auto *TC = cast<TemplateTypeParmDecl>(Old)->getTypeConstraint())
7463 OldC = TC->getImmediatelyDeclaredConstraint();
7465 auto Diagnose = [&] {
7467 diag::err_template_different_type_constraint);
7469 diag::note_template_prev_declaration) << 0;
7472 if (!NewC != !OldC) {
7479 llvm::FoldingSetNodeID OldCID, NewCID;
7480 OldC->Profile(OldCID, S.
Context,
true);
7482 if (OldCID != NewCID) {
7501 unsigned NextDiag = diag::err_template_param_list_different_arity;
7502 if (TemplateArgLoc.
isValid()) {
7503 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
7504 NextDiag = diag::note_template_param_list_different_arity;
7544 if (Old->
size() != New->
size() && Kind != TPL_TemplateTemplateArgumentMatch) {
7561 OldParmEnd = Old->
end();
7562 OldParm != OldParmEnd; ++OldParm) {
7563 if (Kind != TPL_TemplateTemplateArgumentMatch ||
7564 !(*OldParm)->isTemplateParameterPack()) {
7565 if (NewParm == NewParmEnd) {
7574 Kind, TemplateArgLoc))
7588 for (; NewParm != NewParmEnd; ++NewParm) {
7590 Kind, TemplateArgLoc))
7596 if (NewParm != NewParmEnd) {
7604 if (Kind != TPL_TemplateTemplateArgumentMatch) {
7608 auto Diagnose = [&] {
7610 diag::err_template_different_requires_clause);
7612 diag::note_template_prev_declaration) << 0;
7615 if (!NewRC != !OldRC) {
7622 llvm::FoldingSetNodeID OldRCID, NewRCID;
7623 OldRC->
Profile(OldRCID, Context,
true);
7624 NewRC->
Profile(NewRCID, Context,
true);
7625 if (OldRCID != NewRCID) {
7653 assert(Ctx &&
"Unknown context");
7658 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
7672 if (RD->isLocalClass())
7674 diag::err_template_inside_local_class)
7682 diag::err_template_outside_namespace_or_class_scope)
7693 return Record->getTemplateSpecializationKind();
7694 if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(D))
7695 return Function->getTemplateSpecializationKind();
7696 if (
VarDecl *Var = dyn_cast<VarDecl>(D))
7697 return Var->getTemplateSpecializationKind();
7734 if (isa<ClassTemplateDecl>(Specialized))
7735 EntityKind = IsPartialSpecialization? 1 : 0;
7736 else if (isa<VarTemplateDecl>(Specialized))
7737 EntityKind = IsPartialSpecialization ? 3 : 2;
7738 else if (isa<FunctionTemplateDecl>(Specialized))
7740 else if (isa<CXXMethodDecl>(Specialized))
7742 else if (isa<VarDecl>(Specialized))
7744 else if (isa<RecordDecl>(Specialized))
7746 else if (isa<EnumDecl>(Specialized) && S.
getLangOpts().CPlusPlus11)
7749 S.
Diag(Loc, diag::err_template_spec_unknown_kind)
7759 S.
Diag(Loc, diag::err_template_spec_decl_function_scope)
7774 : DC->
Equals(SpecializedContext))) {
7775 if (isa<TranslationUnitDecl>(SpecializedContext))
7776 S.
Diag(Loc, diag::err_template_spec_redecl_global_scope)
7777 << EntityKind << Specialized;
7779 auto *ND = cast<NamedDecl>(SpecializedContext);
7780 int Diag = diag::err_template_spec_redecl_out_of_scope;
7782 Diag = diag::ext_ms_template_spec_redecl_out_of_scope;
7783 S.
Diag(Loc, Diag) << EntityKind << Specialized
7784 << ND << isa<CXXRecordDecl>(ND);
7787 S.
Diag(Specialized->getLocation(), diag::note_specialized_entity);
7801 DependencyChecker Checker(Depth,
true);
7802 Checker.TraverseStmt(E);
7803 if (Checker.MatchLoc.isInvalid())
7805 return Checker.MatchLoc;
7811 DependencyChecker Checker(Depth,
true);
7812 Checker.TraverseTypeLoc(TL);
7813 if (Checker.MatchLoc.isInvalid())
7815 return Checker.MatchLoc;
7823 for (
unsigned I = 0; I != NumArgs; ++I) {
7826 S, TemplateNameLoc, Param, Args[I].pack_begin(),
7827 Args[I].pack_size(), IsDefaultArgument))
7840 ArgExpr = Expansion->getPattern();
7844 ArgExpr = ICE->getSubExpr();
7854 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ArgExpr))
7855 if (isa<NonTypeTemplateParmDecl>(DRE->getDecl()))
7875 if (ParamUseRange.
isValid()) {
7876 if (IsDefaultArgument) {
7877 S.
Diag(TemplateNameLoc,
7878 diag::err_dependent_non_type_arg_in_partial_spec);
7880 diag::note_dependent_non_type_default_arg_in_partial_spec)
7884 diag::err_dependent_non_type_arg_in_partial_spec)
7892 if (ParamUseRange.
isValid()) {
7894 diag::err_dependent_typed_non_type_arg_in_partial_spec)
7897 << (IsDefaultArgument ? ParamUseRange :
SourceRange())
7927 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
7934 Param, &TemplateArgs[I],
7935 1, I >= NumExplicit))
7947 assert(TUK != TUK_Reference &&
"References are not specializations");
7952 ? TemplateParameterLists[0]->getTemplateLoc() : KWLoc;
7962 if (!ClassTemplate) {
7963 Diag(TemplateNameLoc, diag::err_not_class_template_specialization)
7969 bool isMemberSpecialization =
false;
7970 bool isPartialSpecialization =
false;
7976 bool Invalid =
false;
7978 MatchTemplateParametersToScopeSpecifier(
7979 KWLoc, TemplateNameLoc, SS, &TemplateId,
7980 TemplateParameterLists, TUK == TUK_Friend, isMemberSpecialization,
7985 if (TemplateParams && TemplateParams->
size() > 0) {
7986 isPartialSpecialization =
true;
7988 if (TUK == TUK_Friend) {
7989 Diag(KWLoc, diag::err_partial_specialization_friend)
7997 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
8000 if (TTP->hasDefaultArgument()) {
8001 Diag(TTP->getDefaultArgumentLoc(),
8002 diag::err_default_arg_in_partial_spec);
8003 TTP->removeDefaultArgument();
8006 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
8007 if (
Expr *DefArg = NTTP->getDefaultArgument()) {
8008 Diag(NTTP->getDefaultArgumentLoc(),
8009 diag::err_default_arg_in_partial_spec)
8010 << DefArg->getSourceRange();
8011 NTTP->removeDefaultArgument();
8017 diag::err_default_arg_in_partial_spec)
8023 }
else if (TemplateParams) {
8024 if (TUK == TUK_Friend)
8025 Diag(KWLoc, diag::err_template_spec_friend)
8031 assert(TUK == TUK_Friend &&
"should have a 'template<>' for this decl");
8037 assert(Kind !=
TTK_Enum &&
"Invalid enum tag in class template spec!");
8039 Kind, TUK == TUK_Definition, KWLoc,
8041 Diag(KWLoc, diag::err_use_with_wrong_tag)
8046 diag::note_previous_use);
8055 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
8056 if (DiagnoseUnexpandedParameterPack(TemplateArgs[I],
8057 UPPC_PartialSpecialization))
8063 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
8064 TemplateArgs,
false, Converted,
8070 if (isPartialSpecialization) {
8071 if (CheckTemplatePartialSpecializationArgs(TemplateNameLoc, ClassTemplate,
8072 TemplateArgs.
size(), Converted))
8077 bool InstantiationDependent;
8080 TemplateArgs.
arguments(), InstantiationDependent)) {
8081 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
8083 isPartialSpecialization =
false;
8087 void *InsertPos =
nullptr;
8090 if (isPartialSpecialization)
8101 if (TUK != TUK_Friend &&
8104 isPartialSpecialization))
8109 if (isPartialSpecialization) {
8127 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
8128 << 0 << (TUK == TUK_Definition)
8130 return CheckClassTemplate(S, TagSpec, TUK, KWLoc, SS,
8137 TemplateParameterLists.size() - 1,
8138 TemplateParameterLists.data());
8143 = cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl);
8147 KWLoc, TemplateNameLoc,
8155 if (TemplateParameterLists.size() > 1 && SS.
isSet()) {
8156 Partial->setTemplateParameterListsInfo(
8157 Context, TemplateParameterLists.drop_back(1));
8161 ClassTemplate->AddPartialSpecialization(Partial, InsertPos);
8162 Specialization = Partial;
8166 if (PrevPartial && PrevPartial->getInstantiatedFromMember())
8167 PrevPartial->setMemberSpecialization();
8169 CheckTemplatePartialSpecialization(Partial);
8176 KWLoc, TemplateNameLoc,
8181 if (TemplateParameterLists.size() > 0) {
8183 TemplateParameterLists);
8187 ClassTemplate->AddSpecialization(Specialization, InsertPos);
8189 if (CurContext->isDependentContext()) {
8192 CanonTemplate, Converted);
8216 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
8220 diag::note_instantiation_required_here)
8228 if (TUK != TUK_Friend)
8232 if (TUK == TUK_Definition) {
8235 if (Def && SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
8238 makeMergedDefinitionVisible(Hidden);
8241 Diag(TemplateNameLoc, diag::err_redefinition) << Specialization << Range;
8248 ProcessDeclAttributeList(S, Specialization, Attr);
8252 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip)) {
8253 AddAlignmentAttributesForRecord(Specialization);
8254 AddMsStructLayoutForRecord(Specialization);
8257 if (ModulePrivateLoc.
isValid())
8258 Diag(Specialization->
getLocation(), diag::err_module_private_specialization)
8259 << (isPartialSpecialization? 1 : 0)
8271 TemplateArgs, CanonType);
8272 if (TUK != TUK_Friend) {
8288 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip))
8291 if (TUK == TUK_Friend) {
8297 CurContext->addDecl(Friend);
8302 CurContext->addDecl(Specialization);
8308 return Specialization;
8314 Decl *NewDecl = HandleDeclarator(S, D, TemplateParameterLists);
8315 ActOnDocumentableDecl(NewDecl);
8322 Expr *ConstraintExpr) {
8327 diag::err_concept_decls_may_only_appear_in_global_namespace_scope);
8331 if (TemplateParameterLists.size() > 1) {
8332 Diag(NameLoc, diag::err_concept_extra_headers);
8336 if (TemplateParameterLists.front()->size() == 0) {
8337 Diag(NameLoc, diag::err_concept_no_parameters);
8342 TemplateParameterLists.front(),
8348 Diag(NameLoc, diag::err_concept_no_associated_constraints);
8355 ForVisibleRedeclaration);
8356 LookupName(Previous, S);
8358 FilterLookupForScope(Previous, DC, S,
false,
8360 if (!Previous.empty()) {
8361 auto *Old = Previous.getRepresentativeDecl();
8362 Diag(NameLoc, isa<ConceptDecl>(Old) ? diag::err_redefinition :
8363 diag::err_redefinition_different_kind) << NewDecl->
getDeclName();
8364 Diag(Old->getLocation(), diag::note_previous_definition);
8367 ActOnDocumentableDecl(NewDecl);
8368 PushOnScopeChains(NewDecl, S);
8379 FD->setInlineSpecified(
false);
8390 for (
Decl *Prev = D; Prev && !PrevDiagLoc.
isValid();
8391 Prev = Prev->getPreviousDecl()) {
8392 PrevDiagLoc = Prev->getLocation();
8394 assert(PrevDiagLoc.
isValid() &&
8395 "Explicit instantiation without point of instantiation?");
8427 bool &HasNoEffect) {
8428 HasNoEffect =
false;
8435 "previous declaration must be implicit!");
8448 if (PrevPointOfInstantiation.
isInvalid()) {
8460 PrevPointOfInstantiation.
isValid()) &&
8461 "Explicit instantiation without point of instantiation?");
8475 Diag(NewLoc, diag::err_specialization_after_instantiation)
8477 Diag(PrevPointOfInstantiation, diag::note_instantiation_required_here)
8482 llvm_unreachable(
"The switch over PrevTSK must be exhaustive.");
8512 diag::err_explicit_instantiation_declaration_after_definition);
8518 diag::note_explicit_instantiation_definition_here);
8522 llvm_unreachable(
"Unexpected TemplateSpecializationKind!");
8538 Diag(NewLoc, diag::warn_explicit_instantiation_after_specialization)
8541 diag::note_previous_template_specialization);
8571 Diag(NewLoc, (getLangOpts().MSVCCompat)
8572 ? diag::ext_explicit_instantiation_duplicate
8573 : diag::err_explicit_instantiation_duplicate)
8576 diag::note_previous_explicit_instantiation);
8582 llvm_unreachable(
"Missing specialization/instantiation case?");
8608 enum DiscardReason { NotAFunctionTemplate, NotAMemberOfEnclosing };
8612 if (!isa<FunctionTemplateDecl>(D)) {
8614 DiscardedCandidates.push_back(std::make_pair(NotAFunctionTemplate, D));
8621 DiscardedCandidates.push_back(std::make_pair(NotAMemberOfEnclosing, D));
8627 if (Previous.
empty()) {
8629 diag::err_dependent_function_template_spec_no_match);
8630 for (
auto &
P : DiscardedCandidates)
8631 Diag(
P.second->getLocation(),
8632 diag::note_dependent_function_template_spec_discard_reason)
8638 ExplicitTemplateArgs);
8673 llvm::SmallDenseMap<FunctionDecl *, TemplateArgumentListInfo, 8>
8674 ConvertedTemplateArgs;
8696 if (OldMD && OldMD->
isConst()) {
8706 if (ExplicitTemplateArgs)
8707 Args = *ExplicitTemplateArgs;
8719 cast<FunctionTemplateDecl>(FunTmpl->getFirstDecl()),
8720 ExplicitTemplateArgs ? &Args :
nullptr, FT, Specialization,
8724 FailedCandidates.addCandidate().set(
8725 I.getPair(), FunTmpl->getTemplatedDecl(),
8736 if (LangOpts.CUDA &&
8737 IdentifyCUDATarget(Specialization,
8739 IdentifyCUDATarget(FD,
true)) {
8740 FailedCandidates.addCandidate().set(
8741 I.getPair(), FunTmpl->getTemplatedDecl(),
8747 if (ExplicitTemplateArgs)
8748 ConvertedTemplateArgs[Specialization] = std::move(Args);
8749 Candidates.
addDecl(Specialization, I.getAccess());
8756 if (QualifiedFriend && Candidates.
empty()) {
8761 for (
auto *OldND : Previous) {
8762 if (
auto *OldFD = dyn_cast<FunctionDecl>(OldND->getUnderlyingDecl()))
8765 FailedCandidates.NoteCandidates(*
this, FD->
getLocation());
8772 PDiag(diag::err_function_template_spec_no_match) << FD->
getDeclName(),
8773 PDiag(diag::err_function_template_spec_ambiguous)
8774 << FD->
getDeclName() << (ExplicitTemplateArgs !=
nullptr),
8775 PDiag(diag::note_function_template_spec_matched));
8777 if (Result == Candidates.
end())
8781 FunctionDecl *Specialization = cast<FunctionDecl>(*Result);
8785 assert(SpecInfo &&
"Function template specialization info missing?");
8823 bool HasNoEffect =
false;
8825 CheckSpecializationInstantiationRedecl(FD->
getLocation(),
8845 !Specialization->getCanonicalDecl()->isReferenced()) {
8848 Specialization->getCanonicalDecl() == Specialization &&
8849 "This must be the only existing declaration of this specialization");
8851 Specialization->setDeletedAsWritten(
false);
8855 MarkUnusedFileScopedDecl(Specialization);
8864 FD->setFunctionTemplateSpecialization(
8865 Specialization->getPrimaryTemplate(), TemplArgs,
nullptr,
8867 ExplicitTemplateArgs ? &ConvertedTemplateArgs[Specialization] :
nullptr);
8880 Previous.
addDecl(Specialization);
8900 assert(!isa<TemplateDecl>(Member) &&
"Only for non-template members");
8903 NamedDecl *FoundInstantiation =
nullptr;
8908 if (Previous.
empty()) {
8910 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(Member)) {
8913 NamedDecl *D = (*I)->getUnderlyingDecl();
8915 QualType Adjusted = Function->getType();
8916 if (!hasExplicitCallingConv(Adjusted))
8917 Adjusted = adjustCCAndNoReturn(Adjusted, Method->getType());
8920 if (Context.
hasSameType(Adjusted, Method->getType())) {
8921 FoundInstantiation = *I;
8922 Instantiation = Method;
8923 InstantiatedFrom = Method->getInstantiatedFromMemberFunction();
8924 MSInfo = Method->getMemberSpecializationInfo();
8929 }
else if (isa<VarDecl>(Member)) {
8935 Instantiation = PrevVar;
8939 }
else if (isa<RecordDecl>(Member)) {
8944 Instantiation = PrevRecord;
8948 }
else if (isa<EnumDecl>(Member)) {
8953 Instantiation = PrevEnum;
8959 if (!Instantiation) {
8973 if (InstantiatedFrom && isa<CXXMethodDecl>(Member)) {
8974 cast<CXXMethodDecl>(Member)->setInstantiationOfMemberFunction(
8975 cast<CXXMethodDecl>(InstantiatedFrom),
8977 }
else if (InstantiatedFrom && isa<CXXRecordDecl>(Member)) {
8978 cast<CXXRecordDecl>(Member)->setInstantiationOfMemberClass(
8979 cast<CXXRecordDecl>(InstantiatedFrom),
8984 Previous.
addDecl(FoundInstantiation);
8989 if (!InstantiatedFrom) {
9002 assert(MSInfo &&
"Member specialization info missing?");
9004 bool HasNoEffect =
false;
9005 if (CheckSpecializationInstantiationRedecl(Member->
getLocation(),
9022 if (
auto *MemberFunction = dyn_cast<FunctionDecl>(Member)) {
9023 FunctionDecl *InstantiationFunction = cast<FunctionDecl>(Instantiation);
9028 if (InstantiationFunction->
isDeleted()) {
9031 InstantiationFunction);
9037 MemberFunction->setInstantiationOfMemberFunction(
9039 }
else if (
auto *MemberVar = dyn_cast<VarDecl>(Member)) {
9040 MemberVar->setInstantiationOfStaticDataMember(
9042 }
else if (
auto *MemberClass = dyn_cast<CXXRecordDecl>(Member)) {
9043 MemberClass->setInstantiationOfMemberClass(
9045 }
else if (
auto *MemberEnum = dyn_cast<EnumDecl>(Member)) {
9046 MemberEnum->setInstantiationOfMemberEnum(
9049 llvm_unreachable(
"unknown member specialization kind");
9055 Previous.
addDecl(FoundInstantiation);
9064 template<
typename DeclT>
9075 OrigD->setLocation(Loc);
9081 if (Instantiation == Member)
9084 if (
auto *Function = dyn_cast<CXXMethodDecl>(Instantiation))
9086 else if (
auto *Var = dyn_cast<VarDecl>(Instantiation))
9088 else if (
auto *Record = dyn_cast<CXXRecordDecl>(Instantiation))
9090 else if (
auto *Enum = dyn_cast<EnumDecl>(Instantiation))
9093 llvm_unreachable(
"unknown member specialization kind");
9101 bool WasQualifiedName) {
9106 S.
Diag(InstLoc, diag::err_explicit_instantiation_in_class)
9119 if (WasQualifiedName) {
9120 if (CurContext->
Encloses(OrigContext))
9127 if (
NamespaceDecl *NS = dyn_cast<NamespaceDecl>(OrigContext)) {
9128 if (WasQualifiedName)
9131 diag::err_explicit_instantiation_out_of_scope :
9132 diag::warn_explicit_instantiation_out_of_scope_0x)
9137 diag::err_explicit_instantiation_unqualified_wrong_namespace :
9138 diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x)
9143 diag::err_explicit_instantiation_must_be_global :
9144 diag::warn_explicit_instantiation_must_be_global_0x)
9153 bool WasQualifiedName,
9160 S.
Diag(InstLoc, diag::err_explicit_instantiation_internal_linkage) << D;
9188 if (isa<TemplateSpecializationType>(T))
9198 auto *A = cast_or_null<InheritableAttr>(
getDLLAttr(Def));
9199 assert(A &&
"dllExportImportClassTemplateSpecialization called " 9200 "on Def without dllexport or dllimport");
9205 "delayed exports present at explicit instantiation");
9209 for (
auto &B : Def->
bases()) {
9210 if (
auto *BT = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
9211 B.getType()->getAsCXXRecordDecl()))
9232 "Invalid enum tag in class template explicit instantiation!");
9236 if (!ClassTemplate) {
9237 NonTagKind NTK = getNonTagTypeDeclKind(TD, Kind);
9238 Diag(TemplateNameLoc, diag::err_tag_reference_non_tag) << TD << NTK <<
Kind;
9246 Diag(KWLoc, diag::err_use_with_wrong_tag)
9251 diag::note_previous_use);
9268 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
9270 diag::warn_attribute_dllexport_explicit_instantiation_decl);
9271 Diag(AL.getLoc(), diag::note_attribute);
9278 diag::warn_attribute_dllexport_explicit_instantiation_decl);
9279 Diag(A->getLocation(), diag::note_attribute);
9285 bool DLLImportExplicitInstantiationDef =
false;
9292 if (AL.getKind() == ParsedAttr::AT_DLLImport)
9294 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
9302 DLLImportExplicitInstantiationDef =
true;
9308 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
9313 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
9314 TemplateArgs,
false, Converted,
9320 void *InsertPos =
nullptr;
9332 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
9334 diag::warn_attribute_dllexport_explicit_instantiation_def);
9346 bool HasNoEffect =
false;
9348 if (CheckSpecializationInstantiationRedecl(TemplateNameLoc, TSK,
9349 PrevDecl, PrevDecl_TSK,
9364 Specialization = PrevDecl;
9370 DLLImportExplicitInstantiationDef) {
9372 HasNoEffect =
false;
9376 if (!Specialization) {
9382 KWLoc, TemplateNameLoc,
9388 if (!HasNoEffect && !PrevDecl) {
9390 ClassTemplate->AddSpecialization(Specialization, InsertPos);
9412 bool PreviouslyDLLExported = Specialization->
hasAttr<DLLExportAttr>();
9413 ProcessDeclAttributeList(S, Specialization, Attr);
9419 CurContext->addDecl(Specialization);
9425 return Specialization;
9436 = cast_or_null<ClassTemplateSpecializationDecl>(
9439 InstantiateClassTemplateSpecialization(TemplateNameLoc, Specialization, TSK);
9441 MarkVTableUsed(TemplateNameLoc, Specialization,
true);
9446 Def = cast_or_null<ClassTemplateSpecializationDecl>(
9454 DLLImportExplicitInstantiationDef)) {
9464 auto *A = cast<InheritableAttr>(
9466 A->setInherited(
true);
9474 bool NewlyDLLExported =
9475 !PreviouslyDLLExported && Specialization->
hasAttr<DLLExportAttr>();
9491 assert(Def == Specialization &&
9492 "Def and Specialization should match for implicit instantiation");
9500 PrevDecl->
hasAttr<DLLExportAttr>()) {
9507 InstantiateClassTemplateSpecializationMembers(TemplateNameLoc, Def, TSK);
9514 return Specialization;
9526 bool IsDependent =
false;
9528 KWLoc, SS, Name, NameLoc, Attr,
AS_none,
9534 assert(!IsDependent &&
"explicit instantiation of dependent name not yet handled");
9539 TagDecl *Tag = cast<TagDecl>(TagD);
9540 assert(!Tag->
isEnum() &&
"shouldn't see enumerations here");
9548 Diag(TemplateLoc, diag::err_explicit_instantiation_nontemplate_type)
9561 Diag(TemplateLoc, diag::ext_explicit_instantiation_without_qualified_id)
9581 bool HasNoEffect =
false;
9582 assert(MSInfo &&
"No member specialization information?");
9583 if (CheckSpecializationInstantiationRedecl(TemplateLoc, TSK,
9600 = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
9602 Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member)
9604 Diag(Pattern->getLocation(), diag::note_forward_declaration)
9608 if (InstantiateClass(NameLoc, Record, Def,
9609 getTemplateInstantiationArgs(Record),
9613 RecordDef = cast_or_null<CXXRecordDecl>(Record->
getDefinition());
9620 InstantiateClassMembers(NameLoc, RecordDef,
9621 getTemplateInstantiationArgs(Record), TSK);
9624 MarkVTableUsed(NameLoc, RecordDef,
true);
9644 diag::err_explicit_instantiation_requires_name)
9685 getLangOpts().CPlusPlus11 ?
9686 diag::err_explicit_instantiation_inline :
9687 diag::warn_explicit_instantiation_inline_0x)
9693 diag::err_explicit_instantiation_constexpr);
9728 if (!PrevTemplate) {
9735 Diag((*P)->getLocation(), diag::note_explicit_instantiation_here);
9742 diag::err_explicit_instantiation_data_member_not_instantiated)
9758 diag::err_auto_not_allowed_var_inst);
9767 diag::err_explicit_instantiation_without_template_id)
9769 Diag(PrevTemplate->getLocation(),
9770 diag::note_explicit_instantiation_here);
9778 DeclResult Res = CheckVarTemplateId(PrevTemplate, TemplateLoc,
9780 if (Res.isInvalid())
9785 Prev = cast<VarDecl>(Res.get());
9800 diag::ext_explicit_instantiation_without_qualified_id)
9808 bool HasNoEffect =
false;
9809 if (CheckSpecializationInstantiationRedecl(D.
getIdentifierLoc(), TSK, Prev,
9810 PrevTSK, POI, HasNoEffect))
9823 if (PrevTemplate && Prev && !Context.
hasSameType(Prev->getType(), R)) {
9825 diag::err_invalid_var_template_spec_type)
9826 << 0 << PrevTemplate << R << Prev->getType();
9827 Diag(PrevTemplate->getLocation(), diag::note_template_declared_here)
9828 << 2 << PrevTemplate->getDeclName();
9833 return (
Decl*)
nullptr;
9838 bool HasExplicitTemplateArgs =
false;
9842 HasExplicitTemplateArgs =
true;
9856 if (!HasExplicitTemplateArgs) {
9857 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Prev)) {
9858 QualType Adjusted = adjustCCAndNoReturn(R, Method->getType(),
9861 if (Method->getPrimaryTemplate()) {
9862 TemplateMatches.
addDecl(Method,
P.getAccess());
9865 assert(!NonTemplateMatch &&
"Multiple NonTemplateMatches");
9866 NonTemplateMatch = Method;
9880 (HasExplicitTemplateArgs ? &TemplateArgs
9882 R, Specialization, Info)) {
9884 FailedCandidates.addCandidate()
9896 if (LangOpts.CUDA &&
9897 IdentifyCUDATarget(Specialization,
9900 FailedCandidates.addCandidate().set(
9906 TemplateMatches.
addDecl(Specialization,
P.getAccess());
9910 if (!Specialization) {
9913 TemplateMatches.
begin(), TemplateMatches.
end(), FailedCandidates,
9915 PDiag(diag::err_explicit_instantiation_not_known) << Name,
9916 PDiag(diag::err_explicit_instantiation_ambiguous) << Name,
9917 PDiag(diag::note_explicit_instantiation_candidate));
9919 if (Result == TemplateMatches.
end())
9923 Specialization = cast<FunctionDecl>(*Result);
9933 if (FPT->hasExceptionSpec()) {
9935 diag::err_mismatched_exception_spec_explicit_instantiation;
9936 if (getLangOpts().MicrosoftExt)
9937 DiagID = diag::ext_mismatched_exception_spec_explicit_instantiation;
9938 bool Result = CheckEquivalentExceptionSpec(
9939 PDiag(DiagID) << Specialization->
getType(),
9940 PDiag(diag::note_explicit_instantiation_here),
9945 if (!getLangOpts().MicrosoftExt && Result)
9951 diag::err_explicit_instantiation_member_function_not_instantiated)
9955 Diag(Specialization->
getLocation(), diag::note_explicit_instantiation_here);
9961 PrevDecl = Specialization;
9964 bool HasNoEffect =
false;
9968 PrevDecl->getPointOfInstantiation(),
9975 return (
Decl*)
nullptr;
9984 if (Specialization->
hasAttr<InternalLinkageAttr>() &&
9986 if (
auto *RD = dyn_cast<CXXRecordDecl>(Specialization->
getDeclContext()))
9987 if (RD->getIdentifier() && RD->getIdentifier()->isStr(
"valarray") &&
9988 RD->isInStdNamespace())
9989 return (
Decl*)
nullptr;
9997 Specialization->
hasAttr<DLLImportAttr>() &&
10006 Consumer.HandleTopLevelDecl(
DeclGroupRef(Specialization));
10022 diag::ext_explicit_instantiation_without_qualified_id)
10032 return (
Decl*)
nullptr;
10040 assert(Name &&
"Expected a name in a dependent tag");
10048 if (TUK == TUK_Declaration || TUK == TUK_Definition) {
10049 Diag(NameLoc, diag::err_dependent_tag_decl)
10050 << (TUK == TUK_Definition) << Kind << SS.
getRange();
10076 getLangOpts().CPlusPlus11 ?
10077 diag::warn_cxx98_compat_typename_outside_of_template :
10078 diag::ext_typename_outside_of_template)
10084 TypenameLoc, QualifierLoc, II, IdLoc, &TSI,
10088 return CreateParsedType(T, TSI);
10104 getLangOpts().CPlusPlus11 ?
10105 diag::warn_cxx98_compat_typename_outside_of_template :
10106 diag::ext_typename_outside_of_template)
10113 dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS,
false));
10114 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
10115 Diag(TemplateIILoc,
10116 diag::ext_out_of_line_qualified_id_type_names_constructor)
10118 << (TemplateKWLoc.
isValid() ? 1 : 0 );
10124 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
10129 assert(DTN &&
"dependent template has non-dependent name?");
10132 DTN->getQualifier(),
10133 DTN->getIdentifier(),
10146 for (
unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
10151 QualType T = CheckTemplateIdType(Template, TemplateIILoc, TemplateArgs);
10163 for (
unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
10172 return CreateParsedType(T, TSI);
10181 if (!II.
isStr(
"type"))
10190 if (!EnableIfTSTLoc || EnableIfTSTLoc.
getNumArgs() == 0)
10203 if (!EnableIfII || !EnableIfII->
isStr(
"enable_if"))
10231 bool DeducedTSTContext) {
10232 QualType T = CheckTypenameType(Keyword, KeywordLoc, QualifierLoc, II, IILoc,
10233 DeducedTSTContext);
10238 if (isa<DependentNameType>(T)) {
10262 SS.
Adopt(QualifierLoc);
10265 if (QualifierLoc) {
10266 Ctx = computeDeclContext(SS);
10282 if (RequireCompleteDeclContext(SS, Ctx))
10287 LookupResult Result(*
this, Name, IILoc, LookupOrdinaryName);
10289 LookupQualifiedName(Result, Ctx, SS);
10291 LookupName(Result, CurScope);
10292 unsigned DiagID = 0;
10293 Decl *Referenced =
nullptr;
10299 Expr *Cond =
nullptr;
10300 if (Ctx &&
isEnableIf(QualifierLoc, II, CondRange, Cond)) {
10305 std::string FailedDescription;
10306 std::tie(FailedCond, FailedDescription) =
10307 findFailedBooleanCondition(Cond);
10310 diag::err_typename_nested_not_found_requirement)
10311 << FailedDescription
10317 diag::err_typename_nested_not_found_enable_if)
10318 << Ctx << CondRange;
10322 DiagID = Ctx ? diag::err_typename_nested_not_found
10323 : diag::err_unknown_typename;
10332 Diag(IILoc, diag::err_typename_refers_to_using_value_decl)
10333 << Name << Ctx << FullRange;
10337 Diag(Loc, diag::note_using_value_decl_missing_typename)
10367 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(Ctx);
10370 FoundRD->isInjectedClassName() &&
10372 Diag(IILoc, diag::ext_out_of_line_qualified_id_type_names_constructor)
10377 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
10387 if (getLangOpts().CPlusPlus17) {
10389 if (!DeducedTSTContext) {
10394 Diag(IILoc, diag::err_dependent_deduced_tst)
10395 << (int)getTemplateNameKindForDiagnostics(
TemplateName(TD)) << T;
10397 Diag(IILoc, diag::err_deduced_tst)
10398 << (int)getTemplateNameKindForDiagnostics(
TemplateName(TD));
10399 Diag(TD->getLocation(), diag::note_template_decl_here);
10409 DiagID = Ctx ? diag::err_typename_nested_not_type
10410 : diag::err_typename_not_type;
10415 DiagID = Ctx ? diag::err_typename_nested_not_type
10416 : diag::err_typename_not_type;
10417 Referenced = *Result.
begin();
10429 Diag(IILoc, DiagID) << FullRange << Name << Ctx;
10431 Diag(IILoc, DiagID) << FullRange << Name;
10434 Ctx ? diag::note_typename_member_refers_here
10435 : diag::note_typename_refers_here)
10442 class CurrentInstantiationRebuilder
10450 CurrentInstantiationRebuilder(
Sema &SemaRef,
10454 Loc(Loc), Entity(Entity) { }
10461 bool AlreadyTransformed(
QualType T) {
10476 this->Entity = Entity;
10518 CurrentInstantiationRebuilder Rebuilder(*
this, Loc, Name);
10519 return Rebuilder.TransformType(T);
10523 CurrentInstantiationRebuilder Rebuilder(*
this, E->
getExprLoc(),
10525 return Rebuilder.TransformExpr(E);
10536 = Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
10548 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
10552 if (isa<TemplateTypeParmDecl>(Param))
10557 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
10558 if (RebuildTemplateParamsInCurrentInstantiation(
10559 TTP->getTemplateParameters()))
10574 if (NewTSI->getType()->isUndeducedType()) {
10580 NewTSI = SubstAutoTypeSourceInfo(NewTSI, Context.
DependentTy);
10585 NTTP->
setType(NewTSI->getType());
10597 return getTemplateArgumentBindingsText(Params, Args.
data(), Args.
size());
10603 unsigned NumArgs) {
10605 llvm::raw_svector_ostream Out(Str);
10607 if (!Params || Params->
size() == 0 || NumArgs == 0)
10608 return std::string();
10610 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
10620 Out <<
Id->getName();
10626 Args[I].
print(getPrintingPolicy(), Out);
10638 auto LPT = std::make_unique<LateParsedTemplate>();
10641 LPT->Toks.swap(Toks);
10643 LateParsedTemplateMap.insert(std::make_pair(FD, std::move(LPT)));
10658 if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(CurContext)) {
10687 class ExplicitSpecializationVisibilityChecker {
10694 : S(S), Loc(Loc) {}
10697 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
10698 return checkImpl(FD);
10699 if (
auto *RD = dyn_cast<CXXRecordDecl>(ND))
10700 return checkImpl(RD);
10701 if (
auto *VD = dyn_cast<VarDecl>(ND))
10702 return checkImpl(VD);
10703 if (
auto *ED = dyn_cast<EnumDecl>(ND))
10704 return checkImpl(ED);
10708 void diagnose(
NamedDecl *D,
bool IsPartialSpec) {
10711 const bool Recover =
true;
10716 if (Modules.empty())
10734 template<
typename SpecDecl>
10735 void checkImpl(SpecDecl *Spec) {
10736 bool IsHiddenExplicitSpecialization =
false;
10738 IsHiddenExplicitSpecialization =
10739 Spec->getMemberSpecializationInfo()
10743 checkInstantiated(Spec);
10746 if (IsHiddenExplicitSpecialization)
10747 diagnose(Spec->getMostRecentDecl(),
false);
10763 else if (
auto *TD =
10766 diagnose(TD,
true);
10771 void checkInstantiated(
VarDecl *RD) {
10779 else if (
auto *TD =
10782 diagnose(TD,
true);
10787 void checkInstantiated(
EnumDecl *FD) {}
10789 template<
typename TemplDecl>
10790 void checkTemplate(TemplDecl *TD) {
10791 if (TD->isMemberSpecialization()) {
10793 diagnose(TD->getMostRecentDecl(),
false);
10800 if (!getLangOpts().Modules)
10803 ExplicitSpecializationVisibilityChecker(*
this, Loc).check(Spec);
10811 if (!hasVisibleDeclaration(Spec, &Modules))
10812 diagnoseMissingImport(Loc, Spec, Spec->
getLocation(), Modules,
10813 MissingImportKind::PartialSpecialization,
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
ExprResult BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
Construct a new expression that refers to the given integral template argument with the given source-...
Defines the clang::ASTContext interface.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
void FilterAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true)
The null pointer literal (C++11 [lex.nullptr])
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
static const Decl * getCanonicalDecl(const Decl *D)
void setImplicit(bool I=true)
Represents a function declaration or definition.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
static bool CheckConstraintSatisfaction(Sema &S, const NamedDecl *Template, ArrayRef< const Expr *> ConstraintExprs, ArrayRef< TemplateArgument > TemplateArgs, SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction)
Name lookup found a set of overloaded functions that met the criteria.
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
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.
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.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
const TypeClass * getTypePtr() const
bool TemplateParameterListsAreEqual(TemplateParameterList *New, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
TemplateDeductionResult
Describes the result of template argument deduction.
void InstantiatedLocal(const Decl *D, Decl *Inst)
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that makes a template template argument into a pack expansion...
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
bool isMemberPointerType() const
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
static const TemplateArgument & getArgument(const TemplateArgument &A)
QualType getInjectedSpecializationType() const
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
Candidate is not a rewritten candidate.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
void diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName, SourceLocation Less, SourceLocation Greater)
const TypeClass * getTypePtr() const
unsigned getNumArgs() const
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
NestedNameSpecifierLoc getTemplateQualifierLoc() const
void addOuterTemplateArguments(const TemplateArgumentList *TemplateArgs)
Add a new outermost level to the multi-level template argument list.
void setLookupName(DeclarationName Name)
Sets the name to look up.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
void setRParenLoc(SourceLocation Loc)
Stmt - This represents one statement.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
Filter makeFilter()
Create a filter for this result set.
void setLAngleLoc(SourceLocation Loc)
void setExceptionSpecRange(SourceRange R)
We are matching the template parameter lists of two templates that might be redeclarations.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
Provides information about an attempted template argument deduction, whose success or failure was des...
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
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)
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization)
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
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 ...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
The name refers to a function template or a set of overloaded functions that includes at least one fu...
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...
The name refers to a dependent template name:
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
Represents a qualified type name for which the type name is dependent.
void setObjCLifetime(ObjCLifetime type)
The template argument is an expression, and we've not resolved it to one of the other forms yet...
unsigned size() const
Retrieve the number of template arguments in this template argument list.
bool isEmpty() const
No scope specifier.
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params)
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments...
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
void erase()
Erase the last element returned from this iterator.
static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D)
Determine what kind of template specialization the given declaration is.
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, Optional< unsigned > NumExpanded=None)
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
const Type * getTypeForDecl() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
bool isVariadic() const
Whether this function prototype is variadic.
SourceLocation getBeginLoc() const LLVM_READONLY
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
bool LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType, bool EnteringContext, bool &MemberOfUnknownSpecialization, SourceLocation TemplateKWLoc=SourceLocation(), AssumedTemplateKind *ATK=nullptr)
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Defines the C++ template declaration subclasses.
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
static SourceRange getRangeOfTypeInNestedNameSpecifier(ASTContext &Context, QualType T, const CXXScopeSpec &SS)
Expr * getAsExpr() const
Retrieve the non-type template argument's expression.
ParenExpr - This represents a parethesized expression, e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
The base class of the type hierarchy.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
SourceLocation getBeginLoc() const LLVM_READONLY
void setTemplateKeywordLoc(SourceLocation Loc)
Declaration of a variable template.
TemplateParamListContext
The context in which we are checking a template parameter list.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Represent a C++ namespace.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Wrapper for source info for typedefs.
DeclarationName getDeclName() const
Get the name of the template.
void setSpecializationKind(TemplateSpecializationKind TSK)
NamedDecl * getParam(unsigned Idx)
SourceLocation getEndLoc() const LLVM_READONLY
const TargetInfo & getTargetInfo() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
A container of type source information.
Store information needed for an explicit specifier.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
bool isSuppressingDiagnostics() const
Determines whether this lookup is suppressing diagnostics.
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine whether any declaration of an entity is visible.
bool hasExplicitSpecifier() const
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
An overloaded operator name, e.g., operator+.
bool isDefined(const FunctionDecl *&Definition) const
Returns true if the function has a definition that does not need to be instantiated.
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
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...
TSCS getThreadStorageClassSpec() const
static void StripImplicitInstantiation(NamedDecl *D)
Strips various properties off an implicit instantiation that has just been explicitly specialized...
Abstract base class used for diagnosing integer constant expression violations.
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...
Represents a C++ constructor within a class.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
TemplateName SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs)
QualType getElementType() const
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
An identifier, stored as an IdentifierInfo*.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
void setRAngleLoc(SourceLocation Loc)
unsigned getDepth() const
Get the nesting depth of the template parameter.
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
RAII object that enters a new expression evaluation context.
Represents a variable declaration or definition.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
DeclarationName getLookupName() const
Gets the name to look up.
Information about one declarator, including the parsed type information and the identifier.
MatchFinder::MatchResult MatchResult
bool isEnumeralType() const
static SourceLocation DiagLocForExplicitInstantiation(NamedDecl *D, SourceLocation PointOfInstantiation)
Compute the diagnostic location for an explicit instantiation.
const T * getAs() const
Member-template getAs<specific type>'.
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Represents an empty template argument, e.g., one that has not been deduced.
Extra information about a function prototype.
TypeSpecifierType
Specifies the kind of type.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
Represents a C++17 deduced template specialization type.
Represents a variable template specialization, which refers to a variable template with a given set o...
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
ArrayRef< LValuePathEntry > getLValuePath() const
SourceLocation getLAngleLoc() const
static bool isTemplateArgumentTemplateParameter(const TemplateArgument &Arg, unsigned Depth, unsigned Index)
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
A namespace, stored as a NamespaceDecl*.
DeclClass * getCorrectionDeclAs() const
TypeLoc getNamedTypeLoc() const
bool isInvalidDecl() const
bool isChar32Type() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
TemplateArgumentLoc SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, Decl *Param, SmallVectorImpl< TemplateArgument > &Converted, bool &HasDefaultArg)
If the given template parameter has a default template argument, substitute into that default templat...
Describes how types, statements, expressions, and declarations should be printed. ...
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
bool isParameterPack() const
Whether this declaration is a parameter pack.
static Optional< unsigned > getExpandedPackSize(NamedDecl *Param)
Check whether the template parameter is a pack expansion, and if so, determine the number of paramete...
static const NamedDecl * getDefinition(const Decl *D)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Represents a parameter to a function.
Represents the result of substituting a type for a template type parameter.
Defines the clang::Expr interface and subclasses for C++ expressions.
QualType getIntegralType() const
Retrieve the type of the integral value.
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
ConceptDecl * getNamedConcept() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier...
The collection of all-type qualifiers we support.
bool isLValueOnePastTheEnd() const
Information about a template-id annotation token.
bool isObjCObjectOrInterfaceType() const
const ValueDecl * getMemberPointerDecl() const
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 SourceRange findTemplateParameter(unsigned Depth, TypeLoc TL)
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
Represents a struct/union/class.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
Scope * getTemplateParamParent()
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
static ExprResult formImmediatelyDeclaredConstraint(Sema &S, NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, ConceptDecl *NamedConcept, SourceLocation LAngleLoc, SourceLocation RAngleLoc, QualType ConstrainedType, SourceLocation ParamNameLoc, ArgumentLocAppender Appender, SourceLocation EllipsisLoc)
ExprResult BuildCXXFoldExpr(SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, Optional< unsigned > NumExpansions)
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
bool isWideCharType() const
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
One of these records is kept for each identifier that is lexed.
Represents a class template specialization, which refers to a class template with a given set of temp...
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
TemplateName getUnderlying() const
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
void setLocalRangeEnd(SourceLocation L)
unsigned getDepth() const
Retrieve the depth of the template parameter.
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl)
DiagnoseTemplateParameterShadow - Produce a diagnostic complaining that the template parameter 'PrevD...
static bool isEnableIfAliasTemplate(TypeAliasTemplateDecl *AliasTemplate)
Determine whether this alias template is "enable_if_t".
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
Represents a class type in Objective C.
QualType getPointeeType() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
CXXRecordDecl * getPreviousDecl()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
Lookup for the name failed, but we're assuming it was a template name anyway.
Represents a dependent template name that cannot be resolved prior to template instantiation.
NestedNameSpecifierLoc SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const MultiLevelTemplateArgumentList &TemplateArgs)
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
ArrayRef< QualType > getParamTypes() const
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
TypeSourceInfo * getTypeSourceInfo() const
ConstexprSpecKind getConstexprKind() const
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD, const TemplateArgumentListInfo &ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given dependent function template specialization.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
SourceLocation getBeginLoc() const LLVM_READONLY
NameKind getNameKind() const
Determine what kind of name this is.
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a templated declaration that would trigger an implicit instantiation.
static SourceRange findTemplateParameterInType(unsigned Depth, Expr *E)
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
SourceLocation getLocation() const
Retrieve the location of the template argument.
SourceLocation getLocation() const
OverloadedOperatorKind Operator
The kind of overloaded operator.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
void startDefinition()
Starts the definition of this tag declaration.
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
bool isReferenceType() const
void setElaboratedKeywordLoc(SourceLocation Loc)
The iterator over UnresolvedSets.
Represents the result of substituting a set of types for a template type parameter pack...
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
A non-type template parameter, stored as an expression.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
SourceLocation getRParenLoc() const
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
LookupResultKind getResultKind() const
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
Perform semantic analysis for the given non-template member specialization.
static QualType checkBuiltinTemplateIdType(Sema &SemaRef, BuiltinTemplateDecl *BTD, const SmallVectorImpl< TemplateArgument > &Converted, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
void ClearStorageClassSpecs()
SourceLocation getBeginLoc() const LLVM_READONLY
The type of a non-type template parameter.
ParsedType getAsType() const
Retrieve the template type argument's type.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getTemplateLoc() const
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
A user-defined literal name, e.g., operator "" _i.
void setDefaultArgument(Expr *DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
DeclarationNameInfo getConceptNameInfo() const
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
bool isInvalidType() const
TypeSourceInfo * getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &Args, QualType Canon=QualType()) const
Provides information about a function template specialization, which is a FunctionDecl that has been ...
DeclClass * getAsSingle() const
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
NamedDecl * ActOnTemplateTemplateParameter(Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params, SourceLocation EllipsisLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg)
ActOnTemplateTemplateParameter - Called when a C++ template template parameter (e.g.
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)
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.
static void maybeDiagnoseTemplateParameterShadow(Sema &SemaRef, Scope *S, SourceLocation Loc, IdentifierInfo *Name)
Represents a C++ unqualified-id that has been parsed.
bool isCompleteType(SourceLocation Loc, QualType T)
An rvalue reference type, per C++11 [dcl.ref].
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization. ...
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
void setNameLoc(SourceLocation Loc)
static CXXDeductionGuideDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation)
Represents the results of name lookup.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
void setRAngleLoc(SourceLocation Loc)
Wrapper for source info for injected class names of class templates.
static void dllExportImportClassTemplateSpecialization(Sema &S, ClassTemplateSpecializationDecl *Def)
Make a dllexport or dllimport attr on a class template specialization take effect.
TagKind getTagKind() const
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
APValue Val
Val - This is the value the expression can be folded to.
A convenient class for passing around template argument information.
bool isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl *T, sema::TemplateDeductionInfo &Info)
An x-value expression is a reference to an object with independent storage but which can be "moved"...
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
SourceLocation getBeginLoc() const LLVM_READONLY
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
Represents a typeof (or typeof) expression (a GCC extension).
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
void ActOnUndeclaredTypeTemplateName(Scope *S, TemplateTy &Name, TemplateNameKind &TNK, SourceLocation NameLoc, IdentifierInfo *&II)
Try to resolve an undeclared template name as a type template.
Represents a declaration of a type.
void setRedeclaration(bool Val)
A builtin binary operation expression such as "x + y" or "x <= y".
static void collectConjunctionTerms(Expr *Clause, SmallVectorImpl< Expr *> &Terms)
Collect all of the separable terms in the given condition, which might be a conjunction.
SourceLocation getLParenLoc() const
static bool MatchTemplateParameterKind(Sema &S, NamedDecl *New, NamedDecl *Old, bool Complain, Sema::TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc)
Match two template parameters within template parameter lists.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
const Type * getClass() const
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
bool isRValueReferenceType() const
CXXRecordDecl * getDecl() const
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
ActionResult< ParsedType > TypeResult
SourceLocation getTemplateEllipsisLoc() const
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
void setSpecializationKind(TemplateSpecializationKind TSK)
Scope - A scope is a transient data structure that is used while parsing the program.
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
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...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type...
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNoreturnSpecified() const
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
const LangOptions & getLangOpts() const
TemplateArgumentLoc getArgLoc(unsigned i) const
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Decl * ActOnTemplateDeclarator(Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization, retrieves the function from which it was instantiated.
Represents a C++ member access expression where the actual member referenced could not be resolved be...
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
void setLocalRangeBegin(SourceLocation L)
static bool CheckTemplateArgumentPointerToMember(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *&ResultArg, TemplateArgument &Converted)
Checks whether the given template argument is a pointer to member constant according to C++ [temp...
Represents a linkage specification.
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
NamedDecl *const * iterator
We are matching the template parameter lists of a template template argument against the template par...
static void SetNestedNameSpecifier(Sema &S, TagDecl *T, const CXXScopeSpec &SS)
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
SourceRange getSourceRange() const LLVM_READONLY
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
bool isExplicitSpecialization() const
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
unsigned getNumArgs() const
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
IdentifierInfo * getIdentifier() const
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location...
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
QualType getElementType() const
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point...
RAII object used to change the argument pack substitution index within a Sema object.
unsigned PrintCanonicalTypes
Whether to print types as written or canonically.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
Represents an extended vector type where either the type or size is dependent.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
We are matching the template parameter lists of two template template parameters as part of matching ...
DiagnosticsEngine & getDiagnostics() const
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
unsigned getFlags() const
getFlags - Return the flags for this scope.
void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD)
static Sema::TemplateDeductionResult DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, const TemplateArgument &Param, TemplateArgument Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
void print(const PrintingPolicy &Policy, raw_ostream &Out) const
Print this template argument to the given output stream.
bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg, SmallVectorImpl< TemplateArgument > &Converted)
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
Sema - This implements semantic analysis and AST building for C.
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
Represents the declaration of a typedef-name via a C++11 alias-declaration.
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, SmallVectorImpl< TemplateArgument > &Converted, CheckTemplateArgumentKind CTAK=CTAK_Specified)
Check that the given template argument corresponds to the given template parameter.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
bool hasConstexprSpecifier() const
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
SourceLocation getBeginLoc() const LLVM_READONLY
bool hasLValuePath() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
CastKind
CastKind - The kind of operation required for a conversion.
static TypeSourceInfo * SubstDefaultTemplateArgument(Sema &SemaRef, TemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, TemplateTypeParmDecl *Param, SmallVectorImpl< TemplateArgument > &Converted)
Substitute template arguments into the default template argument for the given template type paramete...
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...
ExplicitSpecifier getExplicitSpecifier()
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...
DeclarationNameTable DeclarationNames
Specifies that the expression should never be value-dependent.
bool CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, TemplateSpecializationKind NewTSK, NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK, SourceLocation PrevPtOfInstantiation, bool &SuppressNew)
Diagnose cases where we have an explicit template specialization before/after an explicit template in...
void addOuterRetainedLevel()
Add an outermost level that we are not substituting.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
SourceRange getRange() const
TemplateParameterListEqualKind
Enumeration describing how template parameter lists are compared for equality.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams)
Check whether a template can be declared within this scope.
TypeSourceInfo * getTypeSourceInfo() const
void setTemplateNameLoc(SourceLocation Loc)
Represents an array type in C++ whose size is a value-dependent expression.
SourceLocation getBeginLoc() const
Get the begin source location.
bool hasAssociatedConstraints() const
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, Optional< unsigned > NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
QualType getElementType() const
unsigned getFunctionScopeDepth() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
Defines the clang::LangOptions interface.
StringRef getKindName() const
DeclResult CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation TemplateNameLoc, const TemplateArgumentListInfo &TemplateArgs)
SourceLocation getLocalRangeEnd() const
LookupNameKind
Describes the kind of name lookup to perform.
QualType getPointeeType() const
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos, QualType CanonInjectedType, ClassTemplatePartialSpecializationDecl *PrevDecl)
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
QualType getCanonicalTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args) const
Declaration of a template type parameter.
unsigned getIndex() const
DeclContext * getEntity() const
SourceLocation getLAngleLoc() const
This file defines the classes used to store parsed information about declaration-specifiers and decla...
const T * castAs() const
Member-template castAs<specific type>.
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
The name refers to a concept.
std::string getAsString() const
Retrieve the human-readable string for this name.
bool isChar16Type() const
SourceLocation getThreadStorageClassSpecLoc() const
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs, SmallVectorImpl< TemplateArgument > &Converted, bool UpdateArgsWithConversions=true, bool *ConstraintsNotSatisfied=nullptr)
Check that the given template arguments can be be provided to the given template, converting the argu...
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...
bool isNullPtrType() const
bool isFileContext() const
SourceLocation getBeginLoc() const
DeclContext * getDeclContext()
CXXRecordDecl * getDefinition() const
ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs)
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)
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
void setMemberSpecialization()
Note that this member template is a specialization.
bool wasNotFoundInCurrentInstantiation() const
Determine whether no result was found because we could not search into dependent base classes of the ...
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
void NoteAllFoundTemplates(TemplateName Name)
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack...
Represents a C++ template name within the type system.
Represents the type decltype(expr) (C++11).
SourceLocation getStorageClassSpecLoc() const
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this...
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
A namespace alias, stored as a NamespaceAliasDecl*.
bool isIdentifier() const
Determine whether this template name refers to an identifier.
void setLateTemplateParsed(bool ILT=true)
State that this templated function will be late parsed.
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
bool isTypeConcept() const
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined...
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...
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
bool isFunctionOrMethod() const
StorageClass
Storage classes.
SourceLocation getLocalRangeBegin() const
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...
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
bool isIdentifier() const
Predicate functions for querying what type of name this is.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
Declaration of an alias template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
void setTypeConstraint(NestedNameSpecifierLoc NNS, DeclarationNameInfo NameInfo, NamedDecl *FoundDecl, ConceptDecl *CD, const ASTTemplateArgumentListInfo *ArgsAsWritten, Expr *ImmediatelyDeclaredConstraint)
Data structure that captures multiple levels of template argument lists for use in template instantia...
void diagnoseMissingImport(SourceLocation Loc, 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...
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
Represents a GCC generic vector type.
void setLocation(SourceLocation L)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization, retrieves the member specialization information.
An lvalue reference type, per C++11 [dcl.ref].
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
BuiltinTemplateKind getBuiltinTemplateKind() const
bool hasAssociatedConstraints() const
void setDescribedClassTemplate(ClassTemplateDecl *Template)
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
This template specialization was implicitly instantiated from a template.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A type, stored as a Type*.
bool resolveAssumedTemplateNameAsType(Scope *S, TemplateName &Name, SourceLocation NameLoc, bool Diagnose=true)
static TemplateArgumentLoc translateTemplateArgument(Sema &SemaRef, const ParsedTemplateArgument &Arg)
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList *> TPLists)
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
SourceLocation getEndLoc() const LLVM_READONLY
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
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...
bool isVoidPointerType() const
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
RecordDecl * getDecl() const
SourceLocation getNoreturnSpecLoc() const
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
const CXXScopeSpec & getScopeSpec() const
Retrieve the nested-name-specifier that precedes the template name in a template template argument...
char * location_data() const
Retrieve the data associated with the source-location information.
static bool DiagnoseUnexpandedParameterPacks(Sema &S, TemplateTemplateParmDecl *TTP)
Check for unexpanded parameter packs within the template parameters of a template template parameter...
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...
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to...
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
This object has an indeterminate value (C++ [basic.indet]).
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template apply...
AutoTypeLoc getContainedAutoTypeLoc() const
Get the typeloc of an AutoType whose type will be deduced for a variable with an initializer of this ...
Assigning into this object requires the old value to be released and the new value to be retained...
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...
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
const LValueBase getLValueBase() const
param_type_range param_types() const
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
void setLAngleLoc(SourceLocation Loc)
Represents the parsed form of a C++ template argument.
A stack object to be created when performing template instantiation.
ExtProtoInfo getExtProtoInfo() const
SCS getStorageClassSpec() const
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
bool Subst(const TemplateArgumentLoc *Args, unsigned NumArgs, TemplateArgumentListInfo &Result, const MultiLevelTemplateArgumentList &TemplateArgs)
ASTContext & getASTContext() const
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList *> FriendTypeTPLists=None)
static bool isSameAsPrimaryTemplate(TemplateParameterList *Params, ArrayRef< TemplateArgument > Args)
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
bool isParameterPack() const
Returns whether this is a parameter pack.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
QualType getReturnType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
void setBraceRange(SourceRange R)
Attr * clone(ASTContext &C) const
static bool CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *ArgIn, TemplateArgument &Converted)
Checks whether the given template argument is the address of an object or function according to C++ [...
This names the __make_integer_seq BuiltinTemplateDecl.
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
DeclarationName getName() const
getName - Returns the embedded declaration name.
Represents the declaration of a struct/union/class/enum.
TemplateArgument getArgumentPack() const
void referenceDLLExportedClassMethods()
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name, SourceLocation NameLoc, ParsedTemplateTy *Template=nullptr)
Determine whether a particular identifier might be the name in a C++1z deduction-guide declaration...
QualType getElementType() const
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
ParsedAttr - Represents a syntactic attribute.
Represents a vector type where either the type or size is dependent.
Represents a dependent using declaration which was not marked with typename.
NamedDecl * ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, unsigned Depth, unsigned Position, SourceLocation EqualLoc, Expr *DefaultArg)
KindType getKind() const
Determine what kind of template argument we have.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
Represents a static or instance method of a struct/union/class.
static bool CheckExplicitInstantiation(Sema &S, NamedDecl *D, SourceLocation InstLoc, bool WasQualifiedName, TemplateSpecializationKind TSK)
Common checks for whether an explicit instantiation of D is valid.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isMemberPointer() const
Name lookup found an unresolvable value declaration and cannot yet complete.
static bool CheckTemplateSpecializationScope(Sema &S, NamedDecl *Specialized, NamedDecl *PrevDecl, SourceLocation Loc, bool IsPartialSpecialization)
Check whether a specialization is well-formed in the current context.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template...
TemplateNameKind ActOnDependentTemplateName(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool AllowInjectedClassName=false)
Form a dependent template name.
static bool hasVisibleDefaultArgument(Sema &S, const ParmDecl *D, llvm::SmallVectorImpl< Module *> *Modules)
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
SourceLocation getRAngleLoc() const
void addDecl(NamedDecl *D)
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
void setPointOfInstantiation(SourceLocation Loc)
A class for iterating through a result set and possibly filtering out results.
ClassTemplateDecl * getMostRecentDecl()
void setElaboratedKeywordLoc(SourceLocation Loc)
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
No entity found met the criteria.
This template specialization was instantiated from a template due to an explicit instantiation defini...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
SourceLocation getRAngleLoc() const
EnumDecl * getDecl() const
A template type parameter, stored as a type.
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, Sema::TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
bool isVectorType() const
SourceLocation getInlineSpecLoc() const
static ConceptSpecializationExpr * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten, ArrayRef< TemplateArgument > ConvertedArgs, const ConstraintSatisfaction *Satisfaction)
ArrayRef< ParmVarDecl * > getParams() const
void checkPartialSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a template specialization that would select a partial specialization.
static TemplateArgumentLoc convertTypeTemplateArgumentToTemplate(TypeLoc TLoc)
Convert a template-argument that we parsed as a type into a template, if possible.
void setTemplateNameLookup(bool TemplateName)
Sets whether this is a template-name lookup.
void setLAngleLoc(SourceLocation Loc)
bool isInvalid() const
An error occurred during parsing of the scope specifier.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void addArgument(const TemplateArgumentLoc &Loc)
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
The injected class name of a C++ class template or class template partial specialization.
TypeResult ActOnTemplateIdType(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, IdentifierInfo *TemplateII, SourceLocation TemplateIILoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false, bool IsClassName=false)
A qualified reference to a name whose declaration cannot yet be resolved.
QualType getPointeeType() const
Represents a pack expansion of types.
SourceLocation getLocation() const
A POD class for pairing a NamedDecl* with an access specifier.
void setLParenLoc(SourceLocation Loc)
void setTemplateKeywordLoc(SourceLocation Loc)
static void checkTemplatePartialSpecialization(Sema &S, PartialSpecDecl *Partial)
StringRef getName() const
Return the actual identifier string.
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<U>...
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template...
Represents a template argument.
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
TagTypeKind
The kind of a tag type.
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...
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
void setPlaceholderTypeConstraint(Expr *E)
The name does not refer to a template.
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
void setMemberSpecialization()
Note that this member template is a specialization.
bool isNull() const
Determine whether this template name is NULL.
bool RebuildTemplateParamsInCurrentInstantiation(TemplateParameterList *Params)
Rebuild the template parameters now that we know we're in a current instantiation.
void removeDefaultArgument()
Removes the default argument of this template parameter.
Dataflow Directional Tag Classes.
bool CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param, TemplateParameterList *Params, TemplateArgumentLoc &Arg)
Check a template argument against its corresponding template template parameter.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
bool isValid() const
Return true if this is a valid SourceLocation object.
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr *> &AC) const
All associated constraints derived from this template parameter list, including the requires clause a...
ParsedTemplateTy getAsTemplate() const
Retrieve the template template argument's template name.
const TemplateArgument & getArgument() const
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization, retrieves the member specialization information.
ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
NestedNameSpecifier * getQualifier() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
EvalResult is a struct with detailed info about an evaluated expression.
The base class of all kinds of template declarations (e.g., class, function, etc.).
bool hasUnnamedOrLocalType() const
Whether this type is or contains a local or unnamed type.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
QualType getType() const
Get the type for which this source info wrapper provides information.
The template argument is a pack expansion of a template name that was provided for a template templat...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a class template node.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
Expr * getSourceExpression() const
QualType getUnderlyingType() const
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
AccessSpecifier getAccess() const
This is a scope that corresponds to the template parameters of a C++ template.
This template specialization was instantiated from a template due to an explicit instantiation declar...
bool isInvalid() const
Determine whether the given template argument is invalid.
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
The name of a declaration.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isBooleanType() const
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo &TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization...
Represents a C++11 pack expansion that produces a sequence of expressions.
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
static Expr * lookThroughRangesV3Condition(Preprocessor &PP, Expr *Cond)
A pointer to member type per C++ 8.3.3 - Pointers to members.
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...
DeclResult ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, CXXScopeSpec &SS, TemplateIdAnnotation &TemplateId, const ParsedAttributesView &Attr, MultiTemplateParamsArg TemplateParameterLists, SkipBodyInfo *SkipBody=nullptr)
This names the __type_pack_element BuiltinTemplateDecl.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set...
TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS, const IdentifierInfo &II, SourceLocation IdLoc)
Called when the parser has parsed a C++ typename specifier, e.g., "typename T::type".
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
A type that was preceded by the 'template' keyword, stored as a Type*.
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
The name refers to a template whose specialization produces a type.
SourceLocation getBeginLoc() const LLVM_READONLY
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
bool isNull() const
Determine whether this template argument has no value.
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration...
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
unsigned getNumParams() const
void setNameLoc(SourceLocation Loc)
Represents a pointer to an Objective C object.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
Name lookup found a single declaration that met the criteria.
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...
const UnresolvedSetImpl & asUnresolvedSet() const
bool HasSideEffects
Whether the evaluated expression has side effects.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, ConceptDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
ParsedTemplateArgument getTemplatePackExpansion(SourceLocation EllipsisLoc) const
Retrieve a pack expansion of the given template template argument.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Determine what kind of template instantiation this function represents.
TemplateName getAssumedTemplateName(DeclarationName Name) const
Retrieve a template name representing an unqualified-id that has been assumed to name a template for ...
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
QualType getCanonicalTypeInternal() const
SourceLocation getVirtualSpecLoc() const
This template specialization was declared or defined by an explicit specialization (C++ [temp...
void setConstexprKind(ConstexprSpecKind CSK)
TypedefNameDecl * getTypedefNameDecl() const
static VarTemplatePartialSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos)
ParsedTemplateArgument ActOnTemplateTypeArgument(TypeResult ParsedType)
Convert a parsed type into a parsed template argument.
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
bool ActOnTypeConstraint(const CXXScopeSpec &SS, TemplateIdAnnotation *TypeConstraint, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
bool isFunctionType() const
bool hasAnyAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true, bool AllowNonTemplateFunctions=false)
void setTypeSourceInfo(TypeSourceInfo *TI)
TypeSourceInfo * getTypeSourceInfo() const
ExtVectorType - Extended vector type.
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
AutoTypeKeyword getAutoKeyword() const
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
Wrapper for source info for record types.
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
SourceRange getTemplateParamsRange(TemplateParameterList const *const *Params, unsigned NumParams)
Retrieves the range of the given template parameter lists.
The template argument is a type.
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
QualType getUnderlyingType() const
AssumedTemplateStorage * getAsAssumedTemplateName() const
Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...
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.
const LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
unsigned getNumArgs() const
void addDecl(Decl *D)
Add the declaration D into this context.
TemplateArgument getInjectedTemplateArg(NamedDecl *ParamDecl)
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
The template argument is actually a parameter pack.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
static bool ScopeSpecifierHasTemplateId(const CXXScopeSpec &SS)
Determine whether the given scope specifier has a template-id in it.
void checkClassLevelDLLAttribute(CXXRecordDecl *Class)
Check class-level dllimport/dllexport attribute.
void setInstantiationOf(VarTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this variable template specialization is actually an instantiation of the given variable te...
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
This is a scope that can contain a declaration.
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 isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
SourceLocation getIdentifierLoc() const
void CheckTemplatePartialSpecialization(ClassTemplatePartialSpecializationDecl *Partial)
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
A template argument list.
bool isSet() const
Deprecated.
bool isLValueReferenceType() const
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
static void checkMoreSpecializedThanPrimary(Sema &S, PartialSpecDecl *Partial)
bool hasSimilarType(QualType T1, QualType T2)
Determine if two types are similar, according to the C++ rules.
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
ArgKind getKind() const
Return the kind of stored template argument.
unsigned getDepth() const
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\, const ASTContext *Context=nullptr) const
ValueKind getKind() const
TranslationUnitDecl * getTranslationUnitDecl() const
QualType CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI, SourceLocation Loc)
Check that the type of a non-type template parameter is well-formed.
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
Captures information about "declaration specifiers".
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
NamedDecl * getAsTemplateNameDecl(NamedDecl *D, bool AllowFunctionTemplates=true, bool AllowDependent=true)
Try to interpret the lookup result D as a template-name.
Represents a C++ struct/union/class.
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization, returns the templated static data member from which it was instantiated.
Represents a template specialization type whose template cannot be resolved, e.g. ...
SourceLocation getEllipsisLoc() const
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr *> &AC) const
Get the total constraint-expression associated with this template, including constraint-expressions d...
The template argument is a template name that was provided for a template template parameter...
Represents a C array with an unspecified size.
TemplateName getCanonicalTemplateName(TemplateName Name) const
Retrieves the "canonical" template name that refers to a given template.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member...
void setParam(unsigned i, ParmVarDecl *VD)
There is no such object (it's outside its lifetime).
Provides information a specialization of a member of a class template, which may be a member function...
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
A structure for storing the information associated with an overloaded template name.
ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
A structure for storing the information associated with a name that has been assumed to be a template...
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
Location information for a TemplateArgument.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
void DeclareImplicitDeductionGuides(TemplateDecl *Template, SourceLocation Loc)
Declare implicit deduction guides for a class template if we've not already done so.
Declaration of a class template.
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool isVirtualSpecified() const
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
This class is used for builtin types like 'int'.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
A template-id, e.g., f<int>.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const
getInjectedClassNameType - Return the unique reference to the injected class name type for the specif...
DeclResult ActOnVarTemplateSpecialization(Scope *S, Declarator &D, TypeSourceInfo *DI, SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, StorageClass SC, bool IsPartialSpecialization)
static TemplateArgumentListInfo makeTemplateArgumentListInfo(Sema &S, TemplateIdAnnotation &TemplateId)
Convert the parser's template argument list representation into our form.
Defines the clang::TargetInfo interface.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
SourceLocation getNameLoc() const
bool isInlineSpecified() const
void setRAngleLoc(SourceLocation Loc)
static bool CheckExplicitInstantiationScope(Sema &S, NamedDecl *D, SourceLocation InstLoc, bool WasQualifiedName)
Check the scope of an explicit instantiation.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Decl * SubstDecl(Decl *D, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs)
SourceLocation getLAngleLoc() const
StringRef getImmediateMacroName(SourceLocation Loc)
Retrieve the name of the immediate macro expansion.
static Decl::Kind getKind(const Decl *D)
std::pair< Expr *, std::string > findFailedBooleanCondition(Expr *Cond)
Find the failed Boolean condition within a given Boolean constant expression, and describe it with a ...
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
SourceLocation getExplicitSpecLoc() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
The name refers to a variable template whose specialization produces a variable.
SourceLocation getConstexprSpecLoc() const
QualType getAsType() const
Retrieve the type for a type template argument.
static ConceptDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, Expr *ConstraintExpr)
A reference to a declared variable, function, enum, etc.
Represents an extended address space qualifier where the input address space value is dependent...
Represents a type template specialization; the template must be a class template, a type alias templa...
Defines utilities for dealing with stack allocation and stack space.
NamedDecl * getMostRecentDecl()
void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
Mark which template parameters are used in a given expression.
bool isDeleted() const
Whether this function has been deleted.
bool isPointerType() const
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
TemplateArgumentLoc getArgLoc(unsigned i) const
SourceLocation getTemplateNameLoc() const
void setInheritedDefaultArgument(const ASTContext &C, TemplateTemplateParmDecl *Prev)
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, const TemplateArgumentListInfo &Args) const
TypeSourceInfo * SubstType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, bool AllowDeducedTST=false)
Perform substitution on the type T with a given set of template arguments.
bool isStaticDataMember() const
Determines whether this is a static data member.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc)
An l-value expression is a reference to an object with independent storage.
bool empty() const
Return true if no decls were found.
static bool DependsOnTemplateParameters(QualType T, TemplateParameterList *Params)
Determines whether a given type depends on the given parameter list.
Wrapper for template type parameters.
A trivial tuple used to represent a source range.
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
void setLexicalDeclContext(DeclContext *DC)
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
This represents a decl that may have a name.
A boolean literal, per ([C++ lex.bool] Boolean literals).
bool isTranslationUnit() const
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
Decl * ActOnConceptDefinition(Scope *S, MultiTemplateParamsArg TemplateParameterLists, IdentifierInfo *Name, SourceLocation NameLoc, Expr *ConstraintExpr)
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
void setAccess(AccessSpecifier AS)
A template template argument, stored as a template name.
Represents a C array with a specified size that is not an integer-constant-expression.
void setTemplateNameLoc(SourceLocation Loc)
No keyword precedes the qualified type name.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
Expr * getConstraintExpr() const
QualType getElementType() const
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
SourceLocation getNameLoc() const
Gets the location of the identifier.
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
SourceLocation getRAngleLoc() const
unsigned NumArgs
NumArgs - The number of template arguments.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
The global specifier '::'. There is no stored value.
static void noteNonDeducibleParameters(Sema &S, TemplateParameterList *TemplateParams, const llvm::SmallBitVector &DeducibleParams)
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
void setType(QualType newType)
SourceLocation getBegin() const
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc, TypeSourceInfo **TSI, bool DeducedTSTContext)
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
const LangOptions & getLangOpts() const
void setDeletedAsWritten(bool D=true)
bool isDependent() const
Determines whether this is a dependent template name.
Represents the canonical version of C arrays with a specified constant size.
Defines enum values for all the target-independent builtin functions.
Declaration of a template function.
bool IsInsideALocalClassWithinATemplateFunction()
void setElaboratedKeywordLoc(SourceLocation Loc)
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
SourceLocation getLocation() const
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type...
static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc, TemplateDecl *TD, const TemplateParmDecl *D, TemplateArgumentListInfo &Args)
Diagnose a missing template argument.
QualType getPointeeType() const
QualType getType() const
Return the type wrapped by this type source info.
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.