31 #include "llvm/ADT/SmallBitVector.h" 32 #include "llvm/ADT/SmallString.h" 33 #include "llvm/ADT/StringExtras.h" 36 using namespace clang;
44 return SourceRange(Ps[0]->getTemplateLoc(), Ps[N-1]->getRAngleLoc());
63 assert(!FD &&
"Cannot collect constraints from function declaration yet.");
74 bool AllowFunctionTemplates,
75 bool AllowDependent) {
78 if (isa<TemplateDecl>(D)) {
79 if (!AllowFunctionTemplates && isa<FunctionTemplateDecl>(D))
97 if (Record->isInjectedClassName()) {
98 Record = cast<CXXRecordDecl>(Record->getDeclContext());
99 if (Record->getDescribedClassTemplate())
100 return Record->getDescribedClassTemplate();
103 = dyn_cast<ClassTemplateSpecializationDecl>(Record))
104 return Spec->getSpecializedTemplate();
113 if (AllowDependent && isa<UnresolvedUsingValueDecl>(D))
120 bool AllowFunctionTemplates,
121 bool AllowDependent) {
125 if (!getAsTemplateNameDecl(Orig, AllowFunctionTemplates, AllowDependent))
132 bool AllowFunctionTemplates,
134 bool AllowNonTemplateFunctions) {
136 if (getAsTemplateNameDecl(*I, AllowFunctionTemplates, AllowDependent))
138 if (AllowNonTemplateFunctions &&
139 isa<FunctionDecl>((*I)->getUnderlyingDecl()))
148 bool hasTemplateKeyword,
151 bool EnteringContext,
153 bool &MemberOfUnknownSpecialization) {
154 assert(getLangOpts().
CPlusPlus &&
"No template names in C!");
157 MemberOfUnknownSpecialization =
false;
181 if (LookupTemplateName(R, S, SS, ObjectType, EnteringContext,
191 return AssumedTemplate == AssumedTemplateKind::FoundNothing
200 if (R.isAmbiguous()) {
203 bool AnyFunctionTemplates =
false;
205 if (
NamedDecl *FoundTemplate = getAsTemplateNameDecl(FoundD)) {
206 if (isa<FunctionTemplateDecl>(FoundTemplate))
207 AnyFunctionTemplates =
true;
217 if (!D && !AnyFunctionTemplates) {
218 R.suppressDiagnostics();
225 FilterAcceptableTemplateNames(R);
235 unsigned ResultCount = R.end() - R.begin();
236 if (!D && ResultCount > 1) {
243 R.suppressDiagnostics();
246 D = getAsTemplateNameDecl(*R.begin());
247 assert(D &&
"unambiguous result is not a template name");
250 if (isa<UnresolvedUsingValueDecl>(D)) {
252 MemberOfUnknownSpecialization =
true;
261 hasTemplateKeyword, TD);
266 if (isa<FunctionTemplateDecl>(TD)) {
270 R.suppressDiagnostics();
272 assert(isa<ClassTemplateDecl>(TD) || isa<TemplateTemplateParmDecl>(TD) ||
273 isa<TypeAliasTemplateDecl>(TD) || isa<VarTemplateDecl>(TD) ||
274 isa<BuiltinTemplateDecl>(TD) || isa<ConceptDecl>(TD));
282 TemplateResult = TemplateTy::make(Template);
290 bool MemberOfUnknownSpecialization =
false;
296 if (LookupTemplateName(R, S, SS,
QualType(),
298 MemberOfUnknownSpecialization))
301 if (R.
empty())
return false;
328 if (!SS || !SS->
isSet() || !isDependentScopeSpecifier(*SS) ||
329 computeDeclContext(*SS))
335 Diag(IILoc, diag::err_template_kw_missing)
347 bool EnteringContext,
348 bool &MemberOfUnknownSpecialization,
357 MemberOfUnknownSpecialization =
false;
359 bool IsDependent =
false;
360 if (!ObjectType.
isNull()) {
363 assert(!SS.
isSet() &&
"ObjectType and scope specifier cannot coexist");
364 LookupCtx = computeDeclContext(ObjectType);
368 "Caller should have completed object type");
389 }
else if (SS.
isSet()) {
392 LookupCtx = computeDeclContext(SS, EnteringContext);
393 IsDependent = !LookupCtx;
396 if (LookupCtx && RequireCompleteDeclContext(SS, LookupCtx))
400 bool ObjectTypeSearchedInScope =
false;
401 bool AllowFunctionTemplatesInLookup =
true;
407 LookupQualifiedName(Found, LookupCtx);
431 LookupName(Found, S);
433 if (!ObjectType.
isNull()) {
437 AllowFunctionTemplatesInLookup =
false;
438 ObjectTypeSearchedInScope =
true;
457 getLangOpts().CPlusPlus2a &&
459 return isa<FunctionDecl>(ND->getUnderlyingDecl());
461 if (AllFunctions || (Found.
empty() && !IsDependent)) {
466 ? AssumedTemplateKind::FoundNothing
467 : AssumedTemplateKind::FoundFunctions;
473 if (Found.
empty() && !IsDependent) {
480 FilterCCC.WantExpressionKeywords =
false;
481 FilterCCC.WantRemainingKeywords =
false;
482 FilterCCC.WantCXXNamedCasts =
true;
485 &SS, FilterCCC, CTK_ErrorRecovery, LookupCtx)) {
486 if (
auto *ND = Corrected.getFoundDecl())
488 FilterAcceptableTemplateNames(Found);
491 }
else if (!Found.
empty()) {
494 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
495 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
497 diagnoseTypo(Corrected, PDiag(diag::err_no_member_template_suggest)
498 << Name << LookupCtx << DroppedSpecifier
501 diagnoseTypo(Corrected, PDiag(diag::err_no_template_suggest) << Name);
509 FilterAcceptableTemplateNames(Found, AllowFunctionTemplatesInLookup);
512 MemberOfUnknownSpecialization =
true;
518 if (ExampleLookupResult && TemplateKWLoc.
isValid()) {
519 Diag(Found.
getNameLoc(), diag::err_template_kw_refers_to_non_template)
522 diag::note_template_kw_refers_to_non_template)
530 if (S && !ObjectType.
isNull() && !ObjectTypeSearchedInScope &&
531 !getLangOpts().CPlusPlus11) {
541 LookupName(FoundOuter, S);
544 FilterAcceptableTemplateNames(FoundOuter,
false);
547 if (FoundOuter.empty()) {
550 }
else if (FoundOuter.isAmbiguous() || !FoundOuter.isSingleResult() ||
552 getAsTemplateNameDecl(FoundOuter.getFoundDecl()))) {
565 diag::ext_nested_name_member_ref_lookup_ambiguous)
569 diag::note_ambig_member_ref_object_type)
571 Diag(FoundOuter.getFoundDecl()->getLocation(),
572 diag::note_ambig_member_ref_scope);
595 bool MissingTemplateKeyword =
false;
598 if (
auto *DRE = dyn_cast<DeclRefExpr>(TemplateName.
get())) {
599 NameInfo = DRE->getNameInfo();
600 SS.
Adopt(DRE->getQualifierLoc());
601 LookupKind = LookupOrdinaryName;
602 Found = DRE->getFoundDecl();
603 }
else if (
auto *ME = dyn_cast<MemberExpr>(TemplateName.
get())) {
604 NameInfo = ME->getMemberNameInfo();
605 SS.
Adopt(ME->getQualifierLoc());
606 LookupKind = LookupMemberName;
607 LookupCtx = ME->getBase()->getType()->getAsCXXRecordDecl();
608 Found = ME->getMemberDecl();
609 }
else if (
auto *DSDRE =
610 dyn_cast<DependentScopeDeclRefExpr>(TemplateName.
get())) {
611 NameInfo = DSDRE->getNameInfo();
612 SS.
Adopt(DSDRE->getQualifierLoc());
613 MissingTemplateKeyword =
true;
614 }
else if (
auto *DSME =
615 dyn_cast<CXXDependentScopeMemberExpr>(TemplateName.
get())) {
616 NameInfo = DSME->getMemberNameInfo();
617 SS.
Adopt(DSME->getQualifierLoc());
618 MissingTemplateKeyword =
true;
620 llvm_unreachable(
"unexpected kind of potential template name");
625 if (MissingTemplateKeyword) {
634 TemplateCandidateFilter(
Sema &S) : S(S) {
635 WantTypeSpecifiers =
false;
636 WantExpressionKeywords =
false;
637 WantRemainingKeywords =
false;
638 WantCXXNamedCasts =
true;
640 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
646 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
647 return llvm::make_unique<TemplateCandidateFilter>(*this);
652 TemplateCandidateFilter CCC(*
this);
653 if (
TypoCorrection Corrected = CorrectTypo(NameInfo, LookupKind, S, &SS, CCC,
654 CTK_ErrorRecovery, LookupCtx)) {
655 auto *ND = Corrected.getFoundDecl();
657 ND = getAsTemplateNameDecl(ND);
658 if (ND || Corrected.isKeyword()) {
660 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
661 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
663 diagnoseTypo(Corrected,
664 PDiag(diag::err_non_template_in_member_template_id_suggest)
665 << Name << LookupCtx << DroppedSpecifier
668 diagnoseTypo(Corrected,
669 PDiag(diag::err_non_template_in_template_id_suggest)
674 diag::note_non_template_in_template_id_found);
679 Diag(NameInfo.
getLoc(), diag::err_non_template_in_template_id)
682 Diag(Found->
getLocation(), diag::note_non_template_in_template_id_found);
692 bool isAddressOfOperand,
707 bool MightBeCxx11UnevalField =
708 getLangOpts().CPlusPlus11 && isUnevaluatedContext();
713 IsEnum = dyn_cast_or_null<EnumType>(NNS->getAsType());
715 if (!MightBeCxx11UnevalField && !isAddressOfOperand && !IsEnum &&
716 isa<CXXMethodDecl>(DC) && cast<CXXMethodDecl>(DC)->isInstance()) {
717 QualType ThisType = cast<CXXMethodDecl>(DC)->getThisType();
721 NamedDecl *FirstQualifierInScope =
nullptr;
724 Context,
nullptr, ThisType,
true,
726 FirstQualifierInScope, NameInfo, TemplateArgs);
729 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
747 bool InstantiatedFromMember,
752 assert(isa<TagDecl>(Instantiation) || isa<FunctionDecl>(Instantiation) ||
753 isa<VarDecl>(Instantiation));
755 bool IsEntityBeingDefined =
false;
756 if (
const TagDecl *TD = dyn_cast_or_null<TagDecl>(PatternDef))
757 IsEntityBeingDefined = TD->isBeingDefined();
759 if (PatternDef && !IsEntityBeingDefined) {
761 if (!hasVisibleDefinition(const_cast<NamedDecl*>(PatternDef), &SuggestedDef,
764 bool Recover = Complain && !isSFINAEContext();
766 diagnoseMissingImport(PointOfInstantiation, SuggestedDef,
773 if (!Complain || (PatternDef && PatternDef->
isInvalidDecl()))
778 if (
TagDecl *TD = dyn_cast<TagDecl>(Instantiation))
781 Diag(PointOfInstantiation,
782 diag::err_template_instantiate_within_definition)
788 }
else if (InstantiatedFromMember) {
789 if (isa<FunctionDecl>(Instantiation)) {
790 Diag(PointOfInstantiation,
791 diag::err_explicit_instantiation_undefined_member)
794 Note = diag::note_explicit_instantiation_here;
796 assert(isa<TagDecl>(Instantiation) &&
"Must be a TagDecl!");
797 Diag(PointOfInstantiation,
798 diag::err_implicit_instantiate_member_undefined)
800 Note = diag::note_member_declared_at;
803 if (isa<FunctionDecl>(Instantiation)) {
804 Diag(PointOfInstantiation,
805 diag::err_explicit_instantiation_undefined_func_template)
807 Note = diag::note_explicit_instantiation_here;
808 }
else if (isa<TagDecl>(Instantiation)) {
809 Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
812 Note = diag::note_template_decl_here;
814 assert(isa<VarDecl>(Instantiation) &&
"Must be a VarDecl!");
815 if (isa<VarTemplateSpecializationDecl>(Instantiation)) {
816 Diag(PointOfInstantiation,
817 diag::err_explicit_instantiation_undefined_var_template)
821 Diag(PointOfInstantiation,
822 diag::err_explicit_instantiation_undefined_member)
825 Note = diag::note_explicit_instantiation_here;
848 if (getLangOpts().MicrosoftExt)
854 Diag(Loc, diag::err_template_param_shadow)
855 << cast<NamedDecl>(PrevDecl)->getDeclName();
863 if (
TemplateDecl *Temp = dyn_cast_or_null<TemplateDecl>(D)) {
864 D = Temp->getTemplatedDecl();
872 assert(
Kind == Template &&
873 "Only template template arguments can be pack expansions here");
874 assert(getAsTemplate().
get().containsUnexpandedParameterPack() &&
875 "Template template argument pack expansion without packs");
877 Result.EllipsisLoc = EllipsisLoc;
913 llvm_unreachable(
"Unhandled parsed template argument");
920 for (
unsigned I = 0,
Last = TemplateArgsIn.size(); I !=
Last; ++I)
940 QualType T = GetTypeFromParser(ParsedType.
get(), &TInfo);
943 assert(TInfo &&
"template argument with no location");
951 EllipsisLoc = PET.getEllipsisLoc();
952 TL = PET.getPatternLoc();
957 SS.
Adopt(ET.getQualifierLoc());
958 TL = ET.getNamedTypeLoc();
962 TemplateName Name = DTST.getTypePtr()->getTemplateName();
968 DTST.getTemplateNameLoc());
970 Result = Result.getTemplatePackExpansion(EllipsisLoc);
980 ParsedType.
get().getAsOpaquePtr(),
998 unsigned Depth,
unsigned Position,
1002 "Template type parameter not in template parameter scope!");
1008 bool IsParameterPack = EllipsisLoc.
isValid();
1011 KeyLoc, Loc,
Depth, Position, ParamName,
1012 Typename, IsParameterPack);
1020 IdResolver.AddDecl(Param);
1026 if (DefaultArg && IsParameterPack) {
1027 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1028 DefaultArg =
nullptr;
1034 GetTypeFromParser(DefaultArg, &DefaultTInfo);
1036 assert(DefaultTInfo &&
"expected source information for type");
1039 if (DiagnoseUnexpandedParameterPack(Loc, DefaultTInfo,
1040 UPPC_DefaultArgument))
1044 if (CheckTemplateArgument(Param, DefaultTInfo)) {
1068 TSI = SubstAutoTypeSourceInfo(TSI, Context.
DependentTy);
1071 return CheckNonTypeTemplateParameterType(TSI->
getType(), Loc);
1079 Diag(Loc, diag::err_variably_modified_nontype_template_param)
1117 Diag(Loc, diag::err_template_nontype_parm_bad_type)
1131 auto CheckValidDeclSpecifiers = [
this, &D] {
1145 Diag(Loc, diag::err_invalid_decl_specifier_in_nontype_parm)
1182 CheckValidDeclSpecifiers();
1186 diag::warn_cxx14_compat_template_nontype_parm_auto_type)
1191 "Non-type template parameter not in template parameter scope!");
1192 bool Invalid =
false;
1200 CheckFunctionOrTemplateParamDeclarator(S, D);
1219 IdResolver.AddDecl(Param);
1225 if (Default && IsParameterPack) {
1226 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1233 if (DiagnoseUnexpandedParameterPack(Default, UPPC_DefaultArgument))
1238 CheckTemplateArgument(Param, Param->
getType(), Default, Converted);
1243 Default = DefaultRes.
get();
1265 "Template template parameter not in template parameter scope!");
1268 bool IsParameterPack = EllipsisLoc.
isValid();
1272 Depth, Position, IsParameterPack,
1282 IdResolver.AddDecl(Param);
1285 if (Params->
size() == 0) {
1294 if (IsParameterPack && !Default.
isInvalid()) {
1295 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1310 Diag(DefaultArg.
getLocation(), diag::err_template_arg_not_valid_template)
1316 if (DiagnoseUnexpandedParameterPack(DefaultArg.
getLocation(),
1318 UPPC_DefaultArgument))
1337 Expr *RequiresClause) {
1339 Diag(ExportLoc, diag::warn_template_export_unsupported);
1342 Context, TemplateLoc, LAngleLoc,
1343 llvm::makeArrayRef(Params.data(), Params.size()),
1344 RAngleLoc, RequiresClause);
1360 assert(TemplateParams && TemplateParams->
size() > 0 &&
1361 "No template parameters");
1362 assert(TUK != TUK_Reference &&
"Can only declare or define class templates");
1363 bool Invalid =
false;
1366 if (CheckTemplateDeclScope(S, TemplateParams))
1370 assert(Kind !=
TTK_Enum &&
"can't build template of enumerated type");
1374 Diag(KWLoc, diag::err_template_unnamed_class);
1383 (SS.
isEmpty() && TUK == TUK_Friend)
1384 ? LookupTagName : LookupOrdinaryName,
1385 forRedeclarationInCurContext());
1387 SemanticContext = computeDeclContext(SS,
true);
1388 if (!SemanticContext) {
1392 Diag(NameLoc, TUK == TUK_Friend
1393 ? diag::warn_template_qualified_friend_ignored
1394 : diag::err_template_qualified_declarator_no_match)
1396 return TUK != TUK_Friend;
1399 if (RequireCompleteDeclContext(SS, SemanticContext))
1407 if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams))
1409 }
else if (TUK != TUK_Friend && TUK != TUK_Reference)
1410 diagnoseQualifiedDeclaration(SS, SemanticContext, Name, NameLoc,
false);
1412 LookupQualifiedName(
Previous, SemanticContext);
1414 SemanticContext = CurContext;
1420 if (TUK != TUK_Friend &&
1421 DiagnoseClassNameShadow(SemanticContext,
1433 PrevDecl = (*
Previous.begin())->getUnderlyingDecl();
1437 DiagnoseTemplateParameterShadow(NameLoc, PrevDecl);
1445 dyn_cast_or_null<ClassTemplateDecl>(PrevDecl);
1450 if (!PrevClassTemplate && PrevDecl && isa<CXXRecordDecl>(PrevDecl) &&
1451 cast<CXXRecordDecl>(PrevDecl)->isInjectedClassName()) {
1454 = cast<CXXRecordDecl>(PrevDecl)->getDescribedClassTemplate();
1455 if (!PrevClassTemplate && isa<ClassTemplateSpecializationDecl>(PrevDecl)) {
1457 = cast<ClassTemplateSpecializationDecl>(PrevDecl)
1458 ->getSpecializedTemplate();
1462 if (TUK == TUK_Friend) {
1481 PrevDecl = PrevClassTemplate =
nullptr;
1482 SemanticContext = OutermostContext;
1486 Previous.clear(LookupOrdinaryName);
1490 LookupQualifiedName(
Previous, LookupContext);
1496 PrevDecl = (*
Previous.begin())->getUnderlyingDecl();
1499 }
else if (PrevDecl &&
1500 !isDeclInScope(
Previous.getRepresentativeDecl(), SemanticContext,
1502 PrevDecl = PrevClassTemplate =
nullptr;
1504 if (
auto *Shadow = dyn_cast_or_null<UsingShadowDecl>(
1505 PrevDecl ?
Previous.getRepresentativeDecl() :
nullptr)) {
1507 !(PrevClassTemplate &&
1510 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
1511 Diag(Shadow->getTargetDecl()->getLocation(),
1512 diag::note_using_decl_target);
1513 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl) << 0;
1515 PrevDecl = PrevClassTemplate =
nullptr;
1522 if (PrevClassTemplate) {
1526 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
1527 !TemplateParameterListsAreEqual(TemplateParams,
1535 const bool RedeclACMismatch = [&] {
1536 if (!(CurAC || PrevAC))
1538 if (CurAC && PrevAC) {
1539 llvm::FoldingSetNodeID CurACInfo, PrevACInfo;
1540 CurAC->
Profile(CurACInfo, Context,
true);
1541 PrevAC->
Profile(PrevACInfo, Context,
true);
1542 if (CurACInfo == PrevACInfo)
1548 if (RedeclACMismatch) {
1550 diag::err_template_different_associated_constraints);
1552 diag::note_template_prev_declaration)
1563 if (!isAcceptableTagRedeclaration(PrevRecordDecl, Kind,
1564 TUK == TUK_Definition, KWLoc, Name)) {
1565 Diag(KWLoc, diag::err_use_with_wrong_tag)
1573 if (TUK == TUK_Definition) {
1578 if (SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
1581 auto *Tmpl = cast<CXXRecordDecl>(Hidden)->getDescribedClassTemplate();
1582 assert(Tmpl &&
"original definition of a class template is not a " 1584 makeMergedDefinitionVisible(Hidden);
1585 makeMergedDefinitionVisible(Tmpl);
1587 Diag(NameLoc, diag::err_redefinition) << Name;
1588 Diag(Def->getLocation(), diag::note_previous_definition);
1595 }
else if (PrevDecl) {
1601 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
1610 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
1611 CheckTemplateParameterList(
1616 (SS.
isSet() && SemanticContext && SemanticContext->
isRecord() &&
1618 ? TPC_ClassTemplateMember
1619 : TUK == TUK_Friend ? TPC_FriendClassTemplate : TPC_ClassTemplate,
1626 if (!SS.
isInvalid() && !Invalid && !PrevClassTemplate) {
1627 Diag(NameLoc, TUK == TUK_Friend ? diag::err_friend_decl_does_not_match
1628 : diag::err_member_decl_does_not_match)
1629 << Name << SemanticContext <<
true << SS.
getRange();
1639 bool ShouldAddRedecl
1640 = !(TUK == TUK_Friend && CurContext->isDependentContext());
1644 PrevClassTemplate && ShouldAddRedecl ?
1648 if (NumOuterTemplateParamLists > 0)
1650 Context, llvm::makeArrayRef(OuterTemplateParamLists,
1651 NumOuterTemplateParamLists));
1655 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip)) {
1656 AddAlignmentAttributesForRecord(NewClass);
1657 AddMsStructLayoutForRecord(NewClass);
1662 Expr *
const ACtoAttach =
1663 PrevClassTemplate && ShouldAddRedecl ? nullptr : CurAC;
1668 NewClass, ACtoAttach);
1670 if (ShouldAddRedecl)
1675 if (ModulePrivateLoc.
isValid())
1681 assert(T->
isDependentType() &&
"Class template type is not dependent?");
1686 if (PrevClassTemplate &&
1692 SetMemberAccessSpecifier(NewTemplate, PrevClassTemplate, AS);
1698 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip))
1701 ProcessDeclAttributeList(S, NewClass, Attr);
1703 if (PrevClassTemplate)
1706 AddPushedVisibilityAttribute(NewClass);
1708 if (TUK != TUK_Friend) {
1713 PushOnScopeChains(NewTemplate, Outer);
1723 if (!CurContext->isDependentContext()) {
1726 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
1727 PushOnScopeChains(NewTemplate, EnclosingScope,
1732 Context, CurContext, NewClass->
getLocation(), NewTemplate, FriendLoc);
1734 CurContext->addDecl(Friend);
1737 if (PrevClassTemplate)
1738 CheckRedeclarationModuleOwnership(NewTemplate, PrevClassTemplate);
1745 ActOnDocumentableDecl(NewTemplate);
1756 class ExtractTypeForDeductionGuide
1760 ExtractTypeForDeductionGuide(
Sema &SemaRef) : Base(SemaRef) {}
1765 return TransformType(
1773 struct ConvertConstructorToDeductionGuideTransform {
1774 ConvertConstructorToDeductionGuideTransform(
Sema &S,
1776 : SemaRef(S), Template(Template) {}
1810 AllParams.reserve(TemplateParams->
size() + InnerParams->
size());
1811 AllParams.insert(AllParams.begin(),
1812 TemplateParams->
begin(), TemplateParams->
end());
1813 SubstArgs.reserve(InnerParams->
size());
1821 NamedDecl *NewParam = transformTemplateParameter(Param, Args);
1824 AllParams.push_back(NewParam);
1829 SemaRef.
Context, InnerParams->getTemplateLoc(),
1830 InnerParams->getLAngleLoc(), AllParams, InnerParams->getRAngleLoc(),
1840 Args.addOuterRetainedLevel();
1845 assert(FPTL &&
"no prototype for constructor declaration");
1852 QualType NewType = transformFunctionProtoType(TLB, FPTL, Params, Args);
1870 DeductionGuideName, EPI);
1878 for (
auto T : ParamTypes) {
1880 SemaRef.
Context, DC, Loc, Loc,
nullptr, T,
1883 FPTL.
setParam(Params.size(), NewParam);
1884 Params.push_back(NewParam);
1897 if (
auto *TTP = dyn_cast<TemplateTypeParmDecl>(TemplateParam)) {
1901 SemaRef.
Context, DC, TTP->getBeginLoc(), TTP->getLocation(),
1902 0, Depth1IndexAdjustment + TTP->getIndex(),
1903 TTP->getIdentifier(), TTP->wasDeclaredWithTypename(),
1904 TTP->isParameterPack());
1905 if (TTP->hasDefaultArgument()) {
1907 SemaRef.
SubstType(TTP->getDefaultArgumentInfo(), Args,
1908 TTP->getDefaultArgumentLoc(), TTP->getDeclName());
1909 if (InstantiatedDefaultArg)
1910 NewTTP->setDefaultArgument(InstantiatedDefaultArg);
1917 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(TemplateParam))
1918 return transformTemplateParameterImpl(TTP, Args);
1920 return transformTemplateParameterImpl(
1921 cast<NonTypeTemplateParmDecl>(TemplateParam), Args);
1923 template<
typename TemplateParmDecl>
1925 transformTemplateParameterImpl(TemplateParmDecl *OldParam,
1930 cast_or_null<TemplateParmDecl>(SemaRef.
SubstDecl(OldParam, DC, Args));
1931 assert(NewParam->getDepth() == 0 &&
"unexpected template param depth");
1932 NewParam->setPosition(NewParam->getPosition() + Depth1IndexAdjustment);
1945 ParmVarDecl *NewParam = transformFunctionTypeParam(OldParam, Args);
1948 ParamTypes.push_back(NewParam->
getType());
1949 Params.push_back(NewParam);
1971 ReturnType, ParamTypes, TL.
getBeginLoc(), DeductionGuideName, EPI);
1981 for (
unsigned I = 0, E = NewTL.
getNumParams(); I != E; ++I)
1996 SemaRef.
SubstType(PackTL.getPatternLoc(), Args,
1998 if (!NewDI)
return nullptr;
2001 PackTL.getTypePtr()->getNumExpansions());
2012 NewDI = ExtractTypeForDeductionGuide(SemaRef).transform(NewDI);
2048 TInfo->
getType(), TInfo, LocEnd);
2050 Guide->setParams(Params);
2052 for (
auto *Param : Params)
2053 Param->setDeclContext(Guide);
2056 SemaRef.
Context, DC, Loc, DeductionGuideName, TemplateParams, Guide);
2057 GuideTemplate->setImplicit();
2058 Guide->setDescribedFunctionTemplate(GuideTemplate);
2060 if (isa<CXXRecordDecl>(DC)) {
2066 return GuideTemplate;
2075 TemplateDecl *DescribedTemplate = DefRecord->getDescribedClassTemplate();
2076 Template = DescribedTemplate ? DescribedTemplate : Template;
2083 ConvertConstructorToDeductionGuideTransform Transform(
2084 *
this, cast<ClassTemplateDecl>(Template));
2085 if (!isCompleteType(Loc, Transform.DeducedType))
2090 auto Existing = DC->
lookup(Transform.DeductionGuideName);
2091 for (
auto *D : Existing)
2092 if (D->isImplicit())
2103 if (BuildingDeductionGuides.
isInvalid())
2110 bool AddedAny =
false;
2111 for (
NamedDecl *D : LookupConstructors(Transform.Primary)) {
2112 D = D->getUnderlyingDecl();
2113 if (D->isInvalidDecl() || D->isImplicit())
2115 D = cast<NamedDecl>(D->getCanonicalDecl());
2119 dyn_cast_or_null<CXXConstructorDecl>(FTD ? FTD->getTemplatedDecl() : D);
2122 if (!CD || (!FTD && CD->isFunctionTemplateSpecialization()))
2125 Transform.transformConstructor(FTD, CD);
2134 Transform.buildSimpleDeductionGuide(None);
2138 cast<CXXDeductionGuideDecl>(
2139 cast<FunctionTemplateDecl>(
2140 Transform.buildSimpleDeductionGuide(Transform.DeducedType))
2141 ->getTemplatedDecl())
2142 ->setIsCopyDeductionCandidate();
2170 diag::warn_cxx98_compat_template_parameter_default_in_function_template
2171 : diag::ext_template_parameter_default_in_function_template)
2180 S.
Diag(ParamLoc, diag::err_template_parameter_default_template_member)
2189 S.
Diag(ParamLoc, diag::err_template_parameter_default_friend_template)
2198 llvm_unreachable(
"Invalid TemplateParamListContext!");
2211 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
2214 if (!NTTP->isParameterPack() &&
2216 NTTP->getTypeSourceInfo(),
2224 = dyn_cast<TemplateTemplateParmDecl>(P))
2264 bool Invalid =
false;
2272 bool SawDefaultArgument =
false;
2278 OldParam = OldParams->
begin();
2280 bool RemoveDefaultArguments =
false;
2282 NewParamEnd = NewParams->
end();
2283 NewParam != NewParamEnd; ++NewParam) {
2285 bool RedundantDefaultArg =
false;
2290 bool MissingDefaultArg =
false;
2293 bool SawParameterPack =
false;
2296 = dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
2298 if (NewTypeParm->hasDefaultArgument() &&
2300 NewTypeParm->getLocation(),
2301 NewTypeParm->getDefaultArgumentInfo()->getTypeLoc()
2303 NewTypeParm->removeDefaultArgument();
2307 = OldParams? cast<TemplateTypeParmDecl>(*OldParam) :
nullptr;
2308 if (NewTypeParm->isParameterPack()) {
2309 assert(!NewTypeParm->hasDefaultArgument() &&
2310 "Parameter packs can't have a default argument!");
2311 SawParameterPack =
true;
2313 NewTypeParm->hasDefaultArgument() &&
2316 NewDefaultLoc = NewTypeParm->getDefaultArgumentLoc();
2317 SawDefaultArgument =
true;
2318 RedundantDefaultArg =
true;
2319 PreviousDefaultArgLoc = NewDefaultLoc;
2323 NewTypeParm->setInheritedDefaultArgument(Context, OldTypeParm);
2325 }
else if (NewTypeParm->hasDefaultArgument()) {
2326 SawDefaultArgument =
true;
2327 PreviousDefaultArgLoc = NewTypeParm->getDefaultArgumentLoc();
2328 }
else if (SawDefaultArgument)
2329 MissingDefaultArg =
true;
2331 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
2333 if (!NewNonTypeParm->isParameterPack() &&
2334 DiagnoseUnexpandedParameterPack(NewNonTypeParm->getLocation(),
2335 NewNonTypeParm->getTypeSourceInfo(),
2336 UPPC_NonTypeTemplateParameterType)) {
2342 if (NewNonTypeParm->hasDefaultArgument() &&
2344 NewNonTypeParm->getLocation(),
2345 NewNonTypeParm->getDefaultArgument()->getSourceRange())) {
2346 NewNonTypeParm->removeDefaultArgument();
2351 = OldParams? cast<NonTypeTemplateParmDecl>(*OldParam) :
nullptr;
2352 if (NewNonTypeParm->isParameterPack()) {
2353 assert(!NewNonTypeParm->hasDefaultArgument() &&
2354 "Parameter packs can't have a default argument!");
2355 if (!NewNonTypeParm->isPackExpansion())
2356 SawParameterPack =
true;
2358 NewNonTypeParm->hasDefaultArgument() &&
2361 NewDefaultLoc = NewNonTypeParm->getDefaultArgumentLoc();
2362 SawDefaultArgument =
true;
2363 RedundantDefaultArg =
true;
2364 PreviousDefaultArgLoc = NewDefaultLoc;
2368 NewNonTypeParm->setInheritedDefaultArgument(Context, OldNonTypeParm);
2370 }
else if (NewNonTypeParm->hasDefaultArgument()) {
2371 SawDefaultArgument =
true;
2372 PreviousDefaultArgLoc = NewNonTypeParm->getDefaultArgumentLoc();
2373 }
else if (SawDefaultArgument)
2374 MissingDefaultArg =
true;
2377 = cast<TemplateTemplateParmDecl>(*NewParam);
2394 = OldParams? cast<TemplateTemplateParmDecl>(*OldParam) :
nullptr;
2397 "Parameter packs can't have a default argument!");
2399 SawParameterPack =
true;
2400 }
else if (OldTemplateParm &&
2406 SawDefaultArgument =
true;
2407 RedundantDefaultArg =
true;
2408 PreviousDefaultArgLoc = NewDefaultLoc;
2413 PreviousDefaultArgLoc
2416 SawDefaultArgument =
true;
2417 PreviousDefaultArgLoc
2419 }
else if (SawDefaultArgument)
2420 MissingDefaultArg =
true;
2426 if (SawParameterPack && (NewParam + 1) != NewParamEnd &&
2427 (TPC == TPC_ClassTemplate || TPC == TPC_VarTemplate ||
2428 TPC == TPC_TypeAliasTemplate)) {
2429 Diag((*NewParam)->getLocation(),
2430 diag::err_template_param_pack_must_be_last_template_parameter);
2434 if (RedundantDefaultArg) {
2438 Diag(NewDefaultLoc, diag::err_template_param_default_arg_redefinition);
2439 Diag(OldDefaultLoc, diag::note_template_param_prev_default_arg);
2441 }
else if (MissingDefaultArg && TPC != TPC_FunctionTemplate) {
2447 Diag((*NewParam)->getLocation(),
2448 diag::err_template_param_default_arg_missing);
2449 Diag(PreviousDefaultArgLoc, diag::note_template_param_prev_default_arg);
2451 RemoveDefaultArguments =
true;
2462 if (RemoveDefaultArguments) {
2464 NewParamEnd = NewParams->
end();
2465 NewParam != NewParamEnd; ++NewParam) {
2467 TTP->removeDefaultArgument();
2469 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
2470 NTTP->removeDefaultArgument();
2472 cast<TemplateTemplateParmDecl>(*NewParam)->removeDefaultArgument();
2492 bool IgnoreNonTypeDependent;
2497 DependencyChecker(
unsigned Depth,
bool IgnoreNonTypeDependent)
2498 :
Depth(Depth), IgnoreNonTypeDependent(IgnoreNonTypeDependent),
2502 : IgnoreNonTypeDependent(IgnoreNonTypeDependent), Match(
false) {
2505 Depth = PD->getDepth();
2507 dyn_cast<NonTypeTemplateParmDecl>(ND)) {
2508 Depth = PD->getDepth();
2510 Depth = cast<TemplateTemplateParmDecl>(ND)->getDepth();
2515 if (ParmDepth >= Depth) {
2523 bool TraverseStmt(
Stmt *S, DataRecursionQueue *Q =
nullptr) {
2528 if (
auto *E = dyn_cast_or_null<Expr>(S))
2529 if (IgnoreNonTypeDependent && !E->isTypeDependent())
2531 return super::TraverseStmt(S, Q);
2534 bool TraverseTypeLoc(
TypeLoc TL) {
2535 if (IgnoreNonTypeDependent && !TL.
isNull() &&
2538 return super::TraverseTypeLoc(TL);
2547 return IgnoreNonTypeDependent || !Matches(T->
getDepth());
2553 if (Matches(PD->getDepth()))
2555 return super::TraverseTemplateName(N);
2560 dyn_cast<NonTypeTemplateParmDecl>(E->
getDecl()))
2561 if (Matches(PD->getDepth(), E->
getExprLoc()))
2563 return super::VisitDeclRefExpr(E);
2585 DependencyChecker Checker(Params,
false);
2586 Checker.TraverseType(T);
2587 return Checker.Match;
2597 if (
const Type *CurType = NNS->getAsType()) {
2603 NNSLoc = NNSLoc.getPrefix();
2646 bool &IsMemberSpecialization,
bool &Invalid) {
2647 IsMemberSpecialization =
false;
2657 = dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS,
true)))
2669 NestedTypes.push_back(T);
2675 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
2676 if (!isa<ClassTemplatePartialSpecializationDecl>(Spec) &&
2678 ExplicitSpecLoc = Spec->getLocation();
2681 }
else if (Record->getTemplateSpecializationKind()
2683 ExplicitSpecLoc = Record->getLocation();
2696 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
2697 if (
TypeDecl *
Parent = dyn_cast<TypeDecl>(Template->getDeclContext()))
2742 std::reverse(NestedTypes.begin(), NestedTypes.end());
2750 bool SawNonEmptyTemplateParameterList =
false;
2752 auto CheckExplicitSpecialization = [&](
SourceRange Range,
bool Recovery) {
2753 if (SawNonEmptyTemplateParameterList) {
2754 Diag(DeclLoc, diag::err_specialize_member_of_template)
2755 << !Recovery << Range;
2757 IsMemberSpecialization =
false;
2764 auto DiagnoseMissingExplicitSpecialization = [&] (
SourceRange Range) {
2766 if (CheckExplicitSpecialization(Range,
true))
2771 if (!ParamLists.empty())
2772 ExpectedTemplateLoc = ParamLists[0]->getTemplateLoc();
2774 ExpectedTemplateLoc = DeclStartLoc;
2776 Diag(DeclLoc, diag::err_template_spec_needs_header)
2783 for (
unsigned TypeIdx = 0, NumTypes = NestedTypes.size(); TypeIdx != NumTypes;
2785 T = NestedTypes[TypeIdx];
2788 bool NeedEmptyTemplateHeader =
false;
2791 bool NeedNonemptyTemplateHeader =
false;
2804 = dyn_cast<ClassTemplatePartialSpecializationDecl>(Record)) {
2805 ExpectedTemplateParams = Partial->getTemplateParameters();
2806 NeedNonemptyTemplateHeader =
true;
2807 }
else if (Record->isDependentType()) {
2808 if (Record->getDescribedClassTemplate()) {
2809 ExpectedTemplateParams = Record->getDescribedClassTemplate()
2810 ->getTemplateParameters();
2811 NeedNonemptyTemplateHeader =
true;
2814 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
2820 NeedEmptyTemplateHeader =
true;
2823 }
else if (Record->getTemplateSpecializationKind()) {
2824 if (Record->getTemplateSpecializationKind()
2826 TypeIdx == NumTypes - 1)
2827 IsMemberSpecialization =
true;
2833 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
2834 ExpectedTemplateParams = Template->getTemplateParameters();
2835 NeedNonemptyTemplateHeader =
true;
2840 NeedNonemptyTemplateHeader =
false;
2850 if (ParamIdx < ParamLists.size()) {
2851 if (ParamLists[ParamIdx]->size() == 0) {
2852 if (CheckExplicitSpecialization(ParamLists[ParamIdx]->
getSourceRange(),
2856 SawNonEmptyTemplateParameterList =
true;
2859 if (NeedEmptyTemplateHeader) {
2862 if (TypeIdx == NumTypes - 1)
2863 IsMemberSpecialization =
true;
2865 if (ParamIdx < ParamLists.size()) {
2866 if (ParamLists[ParamIdx]->size() > 0) {
2868 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
2869 diag::err_template_param_list_matches_nontemplate)
2871 <<
SourceRange(ParamLists[ParamIdx]->getLAngleLoc(),
2872 ParamLists[ParamIdx]->getRAngleLoc())
2884 if (DiagnoseMissingExplicitSpecialization(
2891 if (NeedNonemptyTemplateHeader) {
2897 if (ParamIdx < ParamLists.size() &&
2899 ExpectedTemplateParams =
nullptr;
2904 if (ParamIdx < ParamLists.size()) {
2906 if (ExpectedTemplateParams &&
2907 !TemplateParameterListsAreEqual(ParamLists[ParamIdx],
2908 ExpectedTemplateParams,
2909 true, TPL_TemplateMatch))
2913 CheckTemplateParameterList(ParamLists[ParamIdx],
nullptr,
2914 TPC_ClassTemplateMember))
2921 Diag(DeclLoc, diag::err_template_spec_needs_template_parameters)
2932 if (ParamIdx >= ParamLists.size()) {
2933 if (TemplateId && !IsFriend) {
2949 if (ParamIdx < ParamLists.size() - 1) {
2950 bool HasAnyExplicitSpecHeader =
false;
2951 bool AllExplicitSpecHeaders =
true;
2952 for (
unsigned I = ParamIdx, E = ParamLists.size() - 1; I != E; ++I) {
2953 if (ParamLists[I]->size() == 0)
2954 HasAnyExplicitSpecHeader =
true;
2956 AllExplicitSpecHeaders =
false;
2959 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
2960 AllExplicitSpecHeaders ? diag::warn_template_spec_extra_headers
2961 : diag::err_template_spec_extra_headers)
2962 <<
SourceRange(ParamLists[ParamIdx]->getTemplateLoc(),
2963 ParamLists[ParamLists.size() - 2]->getRAngleLoc());
2968 if (ExplicitSpecLoc.isValid() && HasAnyExplicitSpecHeader)
2969 Diag(ExplicitSpecLoc,
2970 diag::note_explicit_template_spec_does_not_need_header)
2971 << NestedTypes.back();
2976 if (!AllExplicitSpecHeaders)
2987 if (ParamLists.back()->size() == 0 &&
2988 CheckExplicitSpecialization(ParamLists[ParamIdx]->
getSourceRange(),
2994 return ParamLists.back();
2999 Diag(Template->getLocation(), diag::note_template_declared_here)
3000 << (isa<FunctionTemplateDecl>(Template)
3002 : isa<ClassTemplateDecl>(Template)
3004 : isa<VarTemplateDecl>(Template)
3006 : isa<TypeAliasTemplateDecl>(Template) ? 3 : 4)
3007 << Template->getDeclName();
3015 Diag((*I)->getLocation(), diag::note_template_declared_here)
3016 << 0 << (*I)->getDeclName();
3035 if (!Converted[1].getAsType()->isIntegralType(Context)) {
3036 SemaRef.
Diag(TemplateArgs[1].getLocation(),
3037 diag::err_integer_sequence_integral_element_type);
3046 SemaRef.
Diag(TemplateArgs[2].getLocation(),
3047 diag::err_integer_sequence_negative_length);
3055 SyntheticTemplateArgs.
addArgument(TemplateArgs[1]);
3057 for (llvm::APSInt I(NumArgs.getBitWidth(), NumArgs.isUnsigned());
3061 TA, ArgTy, TemplateArgs[2].getLocation()));
3066 TemplateLoc, SyntheticTemplateArgs);
3073 assert(Converted.size() == 2 &&
3074 "__type_pack_element should be given an index and a parameter pack");
3078 llvm::APSInt Index = IndexArg.getAsIntegral();
3079 assert(Index >= 0 &&
"the index used with __type_pack_element should be of " 3080 "type std::size_t, and hence be non-negative");
3081 if (Index >= Ts.pack_size()) {
3082 SemaRef.
Diag(TemplateArgs[0].getLocation(),
3083 diag::err_type_pack_element_out_of_bounds);
3088 auto Nth = std::next(Ts.pack_begin(), Index.getExtValue());
3089 return Nth->getAsType();
3091 llvm_unreachable(
"unexpected BuiltinTemplateDecl!");
3096 return AliasTemplate->
getName().equals(
"enable_if_t");
3108 if (BinOp->getOpcode() == BO_LAnd) {
3116 Terms.push_back(Clause);
3125 if (!BinOp)
return Cond;
3127 if (BinOp->getOpcode() != BO_LOr)
return Cond;
3130 Expr *LHS = BinOp->getLHS();
3132 if (!InnerBinOp)
return Cond;
3134 if (InnerBinOp->getOpcode() != BO_EQ ||
3135 !isa<IntegerLiteral>(InnerBinOp->getRHS()))
3145 if (MacroName ==
"CONCEPT_REQUIRES" || MacroName ==
"CONCEPT_REQUIRES_")
3146 return BinOp->getRHS();
3156 class FailedBooleanConditionPrinterHelper :
public PrinterHelper {
3161 bool handledStmt(
Stmt *E, raw_ostream &OS)
override {
3163 if (DR && DR->getQualifier()) {
3170 if (
const auto *IV = dyn_cast<VarTemplateSpecializationDecl>(VD)) {
3185 std::pair<Expr *, std::string>
3194 Expr *FailedCond =
nullptr;
3195 for (
Expr *Term : Terms) {
3199 if (isa<CXXBoolLiteralExpr>(TermAsWritten) ||
3200 isa<IntegerLiteral>(TermAsWritten))
3209 if (Term->EvaluateAsBooleanCondition(Succeeded, Context) &&
3211 FailedCond = TermAsWritten;
3218 std::string Description;
3220 llvm::raw_string_ostream Out(Description);
3223 FailedBooleanConditionPrinterHelper Helper(Policy);
3224 FailedCond->
printPretty(Out, &Helper, Policy, 0,
"\n",
nullptr);
3226 return { FailedCond, Description };
3245 if (!Template || isa<FunctionTemplateDecl>(Template) ||
3246 isa<VarTemplateDecl>(Template) ||
3247 isa<ConceptDecl>(Template)) {
3253 Diag(TemplateLoc, diag::err_template_id_not_a_type)
3255 NoteAllFoundTemplates(Name);
3262 if (CheckTemplateArgumentList(Template, TemplateLoc, TemplateArgs,
3268 bool InstantiationDependent =
false;
3270 dyn_cast<TypeAliasTemplateDecl>(Template)) {
3282 unsigned Depth = AliasTemplate->getTemplateParameters()->getDepth();
3283 for (
unsigned I = 0; I <
Depth; ++I)
3292 TemplateArgLists, AliasTemplate->getLocation(),
3293 AliasTemplate->getDeclName());
3294 if (CanonType.
isNull()) {
3299 if (
auto DeductionInfo = isSFINAEContext()) {
3300 if (*DeductionInfo &&
3301 (*DeductionInfo)->hasSFINAEDiagnostic() &&
3302 (*DeductionInfo)->peekSFINAEDiagnostic().second.getDiagID() ==
3303 diag::err_typename_nested_not_found_enable_if &&
3304 TemplateArgs[0].getArgument().getKind()
3307 std::string FailedDescription;
3308 std::tie(FailedCond, FailedDescription) =
3309 findFailedBooleanCondition(TemplateArgs[0].getSourceExpression());
3314 (*DeductionInfo)->takeSFINAEDiagnostic(OldDiag);
3318 (*DeductionInfo)->addSFINAEDiagnostic(
3320 PDiag(diag::err_typename_nested_not_found_requirement)
3321 << FailedDescription
3331 TemplateArgs, InstantiationDependent)) {
3347 if (isa<ClassTemplateDecl>(Template)) {
3350 if (Ctx->isFileContext())
break;
3354 if (!Record)
continue;
3358 if (!isa<ClassTemplatePartialSpecializationDecl>(Record) &&
3365 QualType Injected = cast<InjectedClassNameType>(ICNT)
3366 ->getInjectedSpecializationType();
3379 = dyn_cast<ClassTemplateDecl>(Template)) {
3382 void *InsertPos =
nullptr;
3384 = ClassTemplate->findSpecialization(Converted, InsertPos);
3390 Context, ClassTemplate->getTemplatedDecl()->getTagKind(),
3391 ClassTemplate->getDeclContext(),
3392 ClassTemplate->getTemplatedDecl()->getBeginLoc(),
3393 ClassTemplate->getLocation(), ClassTemplate, Converted,
nullptr);
3394 ClassTemplate->AddSpecialization(Decl, InsertPos);
3395 if (ClassTemplate->isOutOfLine())
3402 InstantiateAttrsForDecl(TemplateArgLists, ClassTemplate->getTemplatedDecl(),
3407 (void)DiagnoseUseOfDecl(Decl, TemplateLoc);
3410 assert(isa<RecordType>(CanonType) &&
3411 "type of non-dependent specialization is not a RecordType");
3412 }
else if (
auto *BTD = dyn_cast<BuiltinTemplateDecl>(Template)) {
3431 assert(ATN &&
"not an assumed template name");
3432 II = ATN->getDeclName().getAsIdentifierInfo();
3434 if (!resolveAssumedTemplateNameAsType(S, Name, NameLoc,
false)) {
3436 ParsedName = TemplateTy::make(Name);
3448 assert(ATN &&
"not an assumed template name");
3456 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
3457 return llvm::make_unique<CandidateCallback>(*this);
3462 CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), S,
nullptr,
3463 FilterCCC, CTK_ErrorRecovery);
3465 diagnoseTypo(Corrected, PDiag(diag::err_no_template_suggest)
3472 Diag(R.getNameLoc(), diag::err_no_template) << R.getLookupName();
3481 bool IsCtorOrDtorName,
bool IsClassName) {
3485 if (!IsCtorOrDtorName && !IsClassName && SS.
isSet()) {
3486 DeclContext *LookupCtx = computeDeclContext(SS,
false);
3494 if (!LookupCtx && isDependentScopeSpecifier(SS)) {
3501 return ActOnTypenameType(
nullptr,
SourceLocation(), SS, TemplateKWLoc,
3502 TemplateD, TemplateII, TemplateIILoc, LAngleLoc,
3503 TemplateArgsIn, RAngleLoc);
3510 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
3511 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
3514 ? diag::err_out_of_line_qualified_id_type_names_constructor
3515 : diag::ext_out_of_line_qualified_id_type_names_constructor)
3522 if (Template.getAsAssumedTemplateName() &&
3523 resolveAssumedTemplateNameAsType(S, Template, TemplateIILoc))
3528 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
3533 DTN->getQualifier(),
3534 DTN->getIdentifier(),
3546 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
3551 QualType Result = CheckTemplateIdType(Template, TemplateIILoc, TemplateArgs);
3552 if (Result.isNull())
3594 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
3603 DTN->getQualifier(),
3604 DTN->getIdentifier(),
3617 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
3628 Diag(TemplateLoc, diag::err_tag_reference_non_tag)
3629 << TAT << NTK_TypeAliasTemplate << TagKind;
3630 Diag(TAT->getLocation(), diag::note_declared_at);
3633 QualType Result = CheckTemplateIdType(Template, TemplateLoc, TemplateArgs);
3634 if (Result.isNull())
3642 assert(Id &&
"templated class must have an identifier");
3644 if (!isAcceptableTagRedeclaration(D, TagKind, TUK == TUK_Definition,
3646 Diag(TagLoc, diag::err_use_with_wrong_tag)
3670 return CreateParsedType(Result, TLB.getTypeSourceInfo(Context, Result));
3710 dyn_cast_or_null<TemplateTemplateParmDecl>(
3714 llvm_unreachable(
"unexpected kind of template argument");
3719 if (Params->
size() != Args.size())
3724 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
3751 return TemplateArgs;
3754 template<
typename PartialSpecDecl>
3756 if (Partial->getDeclContext()->isDependentContext())
3765 auto *Template = Partial->getSpecializedTemplate();
3766 S.
Diag(Partial->getLocation(),
3767 diag::ext_partial_spec_not_more_specialized_than_primary)
3768 << isa<VarTemplateDecl>(Template);
3770 if (Info.hasSFINAEDiagnostic()) {
3773 Info.takeSFINAEDiagnostic(Diag);
3777 diag::note_partial_spec_not_more_specialized_than_primary)
3781 S.
Diag(Template->getLocation(), diag::note_template_decl_here);
3786 const llvm::SmallBitVector &DeducibleParams) {
3787 for (
unsigned I = 0, N = DeducibleParams.size(); I != N; ++I) {
3788 if (!DeducibleParams[I]) {
3801 template<
typename PartialSpecDecl>
3803 PartialSpecDecl *Partial) {
3816 auto *TemplateParams = Partial->getTemplateParameters();
3817 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
3819 TemplateParams->getDepth(), DeducibleParams);
3821 if (!DeducibleParams.all()) {
3822 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
3823 S.
Diag(Partial->getLocation(), diag::ext_partial_specs_not_deducible)
3824 << isa<VarTemplatePartialSpecializationDecl>(Partial)
3825 << (NumNonDeducible > 1)
3827 Partial->getTemplateArgsAsWritten()->RAngleLoc);
3848 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
3849 MarkDeducedTemplateParameters(TD, DeducibleParams);
3850 for (
unsigned I = 0; I != TemplateParams->size(); ++I) {
3852 auto *Param = TemplateParams->getParam(I);
3854 DeducibleParams[I] =
true;
3857 if (!DeducibleParams.all()) {
3858 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
3859 Diag(TD->
getLocation(), diag::err_deduction_guide_template_not_deducible)
3860 << (NumNonDeducible > 1);
3871 "Variable template specialization is declared with a template it.");
3888 FnTemplate = *OTS->begin();
3895 << IsPartialSpecialization;
3899 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
3900 if (DiagnoseUnexpandedParameterPack(TemplateArgs[I],
3901 UPPC_PartialSpecialization))
3907 if (CheckTemplateArgumentList(VarTemplate, TemplateNameLoc, TemplateArgs,
3913 if (IsPartialSpecialization) {
3914 if (CheckTemplatePartialSpecializationArgs(TemplateNameLoc, VarTemplate,
3915 TemplateArgs.
size(), Converted))
3920 bool InstantiationDependent;
3924 InstantiationDependent)) {
3925 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
3927 IsPartialSpecialization =
false;
3936 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
3938 << (SC !=
SC_Extern && !CurContext->isRecord())
3946 void *InsertPos =
nullptr;
3949 if (IsPartialSpecialization)
3961 IsPartialSpecialization))
3969 Specialization = PrevDecl;
3972 }
else if (IsPartialSpecialization) {
3975 cast_or_null<VarTemplatePartialSpecializationDecl>(PrevDecl);
3979 TemplateNameLoc, TemplateParams, VarTemplate, DI->
getType(), DI, SC,
3980 Converted, TemplateArgs);
3983 VarTemplate->AddPartialSpecialization(Partial, InsertPos);
3984 Specialization = Partial;
3991 CheckTemplatePartialSpecialization(Partial);
3996 Context, VarTemplate->
getDeclContext(), TemplateKWLoc, TemplateNameLoc,
3997 VarTemplate, DI->
getType(), DI, SC, Converted);
4001 VarTemplate->AddSpecialization(Specialization, InsertPos);
4022 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
4026 diag::note_instantiation_required_here)
4039 CurContext->addDecl(Specialization);
4047 LookupResult PrevSpec(*
this, GetNameForDeclarator(D), LookupOrdinaryName,
4048 forRedeclarationInCurContext());
4056 return Specialization;
4062 struct PartialSpecMatchResult {
4072 assert(Template &&
"A variable template id without template?");
4076 if (CheckTemplateArgumentList(
4077 Template, TemplateNameLoc,
4078 const_cast<TemplateArgumentListInfo &>(TemplateArgs),
false,
4084 void *InsertPos =
nullptr;
4086 Converted, InsertPos)) {
4087 checkSpecializationVisibility(TemplateNameLoc, Spec);
4100 bool AmbiguousPartialSpec =
false;
4116 bool InstantiationDependent =
false;
4118 TemplateArgs, InstantiationDependent)) {
4123 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
4136 Matched.push_back(PartialSpecMatchResult());
4137 Matched.back().Partial = Partial;
4138 Matched.back().Args = Info.take();
4142 if (Matched.size() >= 1) {
4144 if (Matched.size() == 1) {
4157 PEnd = Matched.end();
4159 if (getMoreSpecializedPartialSpecialization(
P->Partial, Best->Partial,
4160 PointOfInstantiation) ==
4168 PEnd = Matched.end();
4170 if (
P != Best && getMoreSpecializedPartialSpecialization(
4171 P->Partial, Best->Partial,
4172 PointOfInstantiation) != Best->Partial) {
4173 AmbiguousPartialSpec =
true;
4180 InstantiationPattern = Best->Partial;
4181 InstantiationArgs = Best->Args;
4194 Template, InstantiationPattern, *InstantiationArgs, TemplateArgs,
4195 Converted, TemplateNameLoc, InsertPos );
4199 if (AmbiguousPartialSpec) {
4202 Diag(PointOfInstantiation, diag::err_partial_spec_ordering_ambiguous)
4206 for (MatchResult
P : Matched)
4207 Diag(
P.Partial->getLocation(), diag::note_partial_spec_match)
4208 << getTemplateArgumentBindingsText(
P.Partial->getTemplateParameters(),
4214 dyn_cast<VarTemplatePartialSpecializationDecl>(InstantiationPattern))
4217 checkSpecializationVisibility(TemplateNameLoc, Decl);
4219 assert(Decl &&
"No variable template specialization?");
4240 return BuildDeclarationNameExpr(SS, NameInfo, Var,
4241 nullptr, TemplateArgs);
4246 Diag(Loc, diag::err_template_missing_args)
4247 << (int)getTemplateNameKindForDiagnostics(Name) << Name;
4249 Diag(TD->getLocation(), diag::note_template_decl_here)
4250 << TD->getTemplateParameters()->getSourceRange();
4262 "concept specialization";
4282 assert(!R.
isAmbiguous() &&
"ambiguous lookup when building templateid");
4286 if (!TemplateArgs && !isa<FunctionTemplateDecl>(TD)) {
4292 auto AnyDependentArguments = [&]() ->
bool {
4293 bool InstantiationDependent;
4294 return TemplateArgs &&
4296 *TemplateArgs, InstantiationDependent);
4303 TemplateKWLoc, TemplateArgs);
4309 TemplateKWLoc, TemplateArgs);
4320 RequiresADL, TemplateArgs,
4333 assert(TemplateArgs || TemplateKWLoc.
isValid());
4335 if (!(DC = computeDeclContext(SS,
false)) ||
4336 DC->isDependentContext() ||
4337 RequireCompleteDeclContext(SS, DC))
4338 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
4340 bool MemberOfUnknownSpecialization;
4343 false, MemberOfUnknownSpecialization,
4357 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_class_template)
4360 Diag(Temp->getLocation(), diag::note_referenced_class_template);
4364 return BuildTemplateIdExpr(SS, TemplateKWLoc, R,
false, TemplateArgs);
4379 bool EnteringContext,
4381 bool AllowInjectedClassName) {
4384 getLangOpts().CPlusPlus11 ?
4385 diag::warn_cxx98_compat_template_outside_of_template :
4386 diag::ext_template_outside_of_template)
4391 LookupCtx = computeDeclContext(SS, EnteringContext);
4392 if (!LookupCtx && ObjectType)
4393 LookupCtx = computeDeclContext(ObjectType.
get());
4411 bool MemberOfUnknownSpecialization;
4413 ObjectType, EnteringContext, Result,
4414 MemberOfUnknownSpecialization);
4423 LookupOrdinaryName);
4425 if (!LookupTemplateName(R, S, SS, ObjectType.get(), EnteringContext,
4426 MOUS, TemplateKWLoc) && !R.isAmbiguous())
4433 if (!AllowInjectedClassName && SS.
isSet() && LookupRD &&
4446 diag::ext_out_of_line_qualified_id_type_names_constructor)
4469 llvm_unreachable(
"literal operator id cannot have a dependent scope");
4475 Diag(Name.
getBeginLoc(), diag::err_template_kw_refers_to_non_template)
4476 << GetNameFromUnqualifiedId(Name).getName() << Name.
getSourceRange()
4503 diagnoseMissingTemplateArguments(Name, SR.
getEnd());
4513 SS.
Adopt(ArgExpr->getQualifierLoc());
4514 NameInfo = ArgExpr->getNameInfo();
4516 dyn_cast<DependentScopeDeclRefExpr>(Arg.
getAsExpr())) {
4517 SS.
Adopt(ArgExpr->getQualifierLoc());
4518 NameInfo = ArgExpr->getNameInfo();
4520 dyn_cast<CXXDependentScopeMemberExpr>(Arg.
getAsExpr())) {
4521 if (ArgExpr->isImplicitAccess()) {
4522 SS.
Adopt(ArgExpr->getQualifierLoc());
4523 NameInfo = ArgExpr->getMemberNameInfo();
4528 LookupResult Result(*
this, NameInfo, LookupOrdinaryName);
4529 LookupParsedName(Result, CurScope, &SS);
4536 Diag(Loc, getLangOpts().MSVCCompat
4537 ? diag::ext_ms_template_type_arg_missing_typename
4538 : diag::err_template_arg_must_be_type_suggest)
4568 Diag(SR.
getBegin(), diag::err_template_arg_must_be_type) << SR;
4575 if (CheckTemplateArgument(Param, TSI))
4584 if (getLangOpts().ObjCAutoRefCount &&
4630 Param, Template, Converted,
4640 for (
unsigned i = 0, e = Param->
getDepth();
i != e; ++
i)
4645 SemaRef.
SubstType(ArgType, TemplateArgLists,
4682 Param, Template, Converted,
4692 for (
unsigned i = 0, e = Param->
getDepth();
i != e; ++
i)
4745 for (
unsigned i = 0, e = Param->
getDepth();
i != e; ++
i)
4775 bool &HasDefaultArg) {
4776 HasDefaultArg =
false;
4782 HasDefaultArg =
true;
4795 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
4799 HasDefaultArg =
true;
4813 = cast<TemplateTemplateParmDecl>(Param);
4817 HasDefaultArg =
true;
4840 if (ETLoc.getTypePtr()->getKeyword() !=
ETK_None)
4843 QualLoc = ETLoc.getQualifierLoc();
4844 TLoc = ETLoc.getNamedTypeLoc();
4851 QualLoc, InjLoc.getNameLoc());
4859 dyn_cast<ClassTemplateSpecializationDecl>(RecLoc.getDecl()))
4861 QualLoc, RecLoc.getNameLoc());
4897 unsigned ArgumentPackIndex,
4902 return CheckTemplateTypeArgument(TTP, Arg, Converted);
4909 QualType NTTPType = NTTP->getType();
4910 if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack())
4911 NTTPType = NTTP->getExpansionType(ArgumentPackIndex);
4916 !isa<TemplateTemplateParmDecl>(Template) &&
4932 NTTPType = SubstType(PET->getPattern(),
4934 NTTP->getLocation(),
4935 NTTP->getDeclName());
4937 NTTPType = SubstType(NTTPType,
4939 NTTP->getLocation(),
4940 NTTP->getDeclName());
4946 NTTPType = CheckNonTypeTemplateParameterType(NTTPType,
4947 NTTP->getLocation());
4954 llvm_unreachable(
"Should never see a NULL template argument here");
4958 unsigned CurSFINAEErrors = NumSFINAEErrors;
4965 if (CurSFINAEErrors < NumSFINAEErrors)
4975 Converted.push_back(Result);
5009 Context, SS.getWithLocInContext(Context), TemplateKWLoc, NameInfo,
5021 E = CheckTemplateArgument(NTTP, NTTPType, E.
get(), Result);
5025 Converted.push_back(Result);
5052 Diag(SR.
getBegin(), diag::err_template_arg_nontype_ambig) << SR << T;
5054 Diag(SR.
getBegin(), diag::err_template_arg_must_be_expr) << SR;
5060 llvm_unreachable(
"Caller must expand template argument packs");
5083 TempParm, Converted,
5089 Params = SubstTemplateParams(Params, CurContext,
5108 llvm_unreachable(
"Should never see a NULL template argument here");
5112 if (CheckTemplateTemplateArgument(Params, Arg))
5123 << getLangOpts().CPlusPlus11;
5127 llvm_unreachable(
"Declaration argument with template template parameter");
5129 llvm_unreachable(
"Integral argument with template template parameter");
5131 llvm_unreachable(
"Null pointer argument with template template parameter");
5134 llvm_unreachable(
"Caller must expand template argument packs");
5153 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
5154 if (NTTP->isExpandedParameterPack())
5155 return NTTP->getNumExpansionTypes();
5159 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
5160 if (TTP->isExpandedParameterPack())
5161 return TTP->getNumExpansionTemplateParameters();
5168 template<
typename TemplateParmDecl>
5171 const TemplateParmDecl *D,
5176 ->getTemplateParameters()
5177 ->getParam(D->getIndex()));
5184 D->getDefaultArgumentLoc(), Modules,
5195 S.
Diag(Loc, diag::err_template_arg_list_different_arity)
5210 bool UpdateArgsWithConversions) {
5221 ->getTemplateParameters();
5230 bool isTemplateTemplateParameter = isa<TemplateTemplateParmDecl>(Template);
5232 unsigned ArgIdx = 0, NumArgs = NewArgs.
size();
5235 ParamEnd = Params->
end();
5236 Param != ParamEnd; ) {
5240 if (*Expansions == ArgumentPack.size()) {
5243 Converted.push_back(
5245 ArgumentPack.clear();
5250 }
else if (ArgIdx == NumArgs && !PartialTemplateArgs) {
5252 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
5254 << (int)getTemplateNameKindForDiagnostics(
TemplateName(Template))
5262 if (ArgIdx < NumArgs) {
5264 if (CheckTemplateArgument(*Param, NewArgs[ArgIdx], Template,
5265 TemplateLoc, RAngleLoc,
5266 ArgumentPack.size(), Converted))
5269 bool PackExpansionIntoNonPack =
5270 NewArgs[ArgIdx].getArgument().isPackExpansion() &&
5272 if (PackExpansionIntoNonPack && isa<TypeAliasTemplateDecl>(Template)) {
5276 Diag(NewArgs[ArgIdx].getLocation(),
5277 diag::err_alias_template_expansion_into_fixed_list)
5278 << NewArgs[ArgIdx].getSourceRange();
5279 Diag((*Param)->getLocation(), diag::note_template_param_here);
5286 if ((*Param)->isTemplateParameterPack()) {
5291 ArgumentPack.push_back(Converted.pop_back_val());
5300 if (PackExpansionIntoNonPack) {
5301 if (!ArgumentPack.empty()) {
5304 Converted.insert(Converted.end(),
5305 ArgumentPack.begin(), ArgumentPack.end());
5306 ArgumentPack.clear();
5309 while (ArgIdx < NumArgs) {
5310 Converted.push_back(NewArgs[ArgIdx].
getArgument());
5321 if (PartialTemplateArgs) {
5322 if ((*Param)->isTemplateParameterPack() && !ArgumentPack.empty())
5323 Converted.push_back(
5331 if ((*Param)->isTemplateParameterPack()) {
5333 "Should have dealt with this already");
5338 if (Param + 1 != ParamEnd)
5341 Converted.push_back(
5343 ArgumentPack.clear();
5374 = dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
5391 = cast<TemplateTemplateParmDecl>(*Param);
5417 if (Inst.isInvalid())
5421 if (CheckTemplateArgument(*Param, Arg, Template, TemplateLoc,
5422 RAngleLoc, 0, Converted))
5428 if (isTemplateTemplateParameter)
5440 if (ArgIdx < NumArgs && CurrentInstantiationScope &&
5441 CurrentInstantiationScope->getPartiallySubstitutedPack()) {
5443 Converted.push_back(NewArgs[ArgIdx++].getArgument());
5448 if (ArgIdx < NumArgs) {
5449 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
5451 << (int)getTemplateNameKindForDiagnostics(
TemplateName(Template))
5461 if (UpdateArgsWithConversions)
5462 TemplateArgs = std::move(NewArgs);
5468 class UnnamedLocalNoLinkageFinder
5469 :
public TypeVisitor<UnnamedLocalNoLinkageFinder, bool>
5477 UnnamedLocalNoLinkageFinder(
Sema &S,
SourceRange SR) : S(S), SR(SR) { }
5483 #define TYPE(Class, Parent) \ 5484 bool Visit##Class##Type(const Class##Type *); 5485 #define ABSTRACT_TYPE(Class, Parent) \ 5486 bool Visit##Class##Type(const Class##Type *) { return false; } 5487 #define NON_CANONICAL_TYPE(Class, Parent) \ 5488 bool Visit##Class##Type(const Class##Type *) { return false; } 5489 #include "clang/AST/TypeNodes.def" 5491 bool VisitTagDecl(
const TagDecl *Tag);
5496 bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(
const BuiltinType*) {
5500 bool UnnamedLocalNoLinkageFinder::VisitComplexType(
const ComplexType* T) {
5504 bool UnnamedLocalNoLinkageFinder::VisitPointerType(
const PointerType* T) {
5508 bool UnnamedLocalNoLinkageFinder::VisitBlockPointerType(
5513 bool UnnamedLocalNoLinkageFinder::VisitLValueReferenceType(
5518 bool UnnamedLocalNoLinkageFinder::VisitRValueReferenceType(
5523 bool UnnamedLocalNoLinkageFinder::VisitMemberPointerType(
5528 bool UnnamedLocalNoLinkageFinder::VisitConstantArrayType(
5533 bool UnnamedLocalNoLinkageFinder::VisitIncompleteArrayType(
5538 bool UnnamedLocalNoLinkageFinder::VisitVariableArrayType(
5543 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedArrayType(
5548 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedExtVectorType(
5553 bool UnnamedLocalNoLinkageFinder::VisitDependentAddressSpaceType(
5558 bool UnnamedLocalNoLinkageFinder::VisitVectorType(
const VectorType* T) {
5562 bool UnnamedLocalNoLinkageFinder::VisitDependentVectorType(
5567 bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(
const ExtVectorType* T) {
5571 bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
5581 bool UnnamedLocalNoLinkageFinder::VisitFunctionNoProtoType(
5586 bool UnnamedLocalNoLinkageFinder::VisitUnresolvedUsingType(
5591 bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(
const TypeOfExprType*) {
5595 bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(
const TypeOfType* T) {
5599 bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(
const DecltypeType*) {
5603 bool UnnamedLocalNoLinkageFinder::VisitUnaryTransformType(
5608 bool UnnamedLocalNoLinkageFinder::VisitAutoType(
const AutoType *T) {
5612 bool UnnamedLocalNoLinkageFinder::VisitDeducedTemplateSpecializationType(
5617 bool UnnamedLocalNoLinkageFinder::VisitRecordType(
const RecordType* T) {
5618 return VisitTagDecl(T->
getDecl());
5621 bool UnnamedLocalNoLinkageFinder::VisitEnumType(
const EnumType* T) {
5622 return VisitTagDecl(T->
getDecl());
5625 bool UnnamedLocalNoLinkageFinder::VisitTemplateTypeParmType(
5630 bool UnnamedLocalNoLinkageFinder::VisitSubstTemplateTypeParmPackType(
5635 bool UnnamedLocalNoLinkageFinder::VisitTemplateSpecializationType(
5640 bool UnnamedLocalNoLinkageFinder::VisitInjectedClassNameType(
5642 return VisitTagDecl(T->
getDecl());
5645 bool UnnamedLocalNoLinkageFinder::VisitDependentNameType(
5650 bool UnnamedLocalNoLinkageFinder::VisitDependentTemplateSpecializationType(
5655 bool UnnamedLocalNoLinkageFinder::VisitPackExpansionType(
5660 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectType(
const ObjCObjectType *) {
5664 bool UnnamedLocalNoLinkageFinder::VisitObjCInterfaceType(
5669 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectPointerType(
5674 bool UnnamedLocalNoLinkageFinder::VisitAtomicType(
const AtomicType* T) {
5678 bool UnnamedLocalNoLinkageFinder::VisitPipeType(
const PipeType* T) {
5682 bool UnnamedLocalNoLinkageFinder::VisitTagDecl(
const TagDecl *Tag) {
5684 S.
Diag(SR.getBegin(),
5686 diag::warn_cxx98_compat_template_arg_local_type :
5687 diag::ext_template_arg_local_type)
5693 S.
Diag(SR.getBegin(),
5695 diag::warn_cxx98_compat_template_arg_unnamed_type :
5696 diag::ext_template_arg_unnamed_type) << SR;
5704 bool UnnamedLocalNoLinkageFinder::VisitNestedNameSpecifier(
5721 llvm_unreachable(
"Invalid NestedNameSpecifier::Kind!");
5731 assert(ArgInfo &&
"invalid TypeSourceInfo");
5736 return Diag(SR.
getBegin(), diag::err_variably_modified_template_arg) << Arg;
5738 return Diag(SR.
getBegin(), diag::err_template_arg_overload_type) << SR;
5749 UnnamedLocalNoLinkageFinder Finder(*
this, SR);
5767 Decl *Entity =
nullptr) {
5773 if (Entity && Entity->hasAttr<DLLImportAttr>())
5778 "Incomplete parameter type in isNullPointerValueTemplateArgument!");
5791 EvalResult.
Diag = &Notes;
5799 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
5800 diag::note_invalid_subexpr_in_const_expr) {
5801 DiagLoc = Notes[0].first;
5805 S.
Diag(DiagLoc, diag::err_template_arg_not_address_constant)
5807 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
5808 S.
Diag(Notes[I].first, Notes[I].second);
5826 bool ObjCLifetimeConversion;
5829 ObjCLifetimeConversion))
5834 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
5843 std::string Code =
"static_cast<" + ParamType.
getAsString() +
">(";
5844 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_untyped_null_constant)
5863 bool ObjCLifetimeConversion;
5867 ObjCLifetimeConversion)) {
5872 if (!ParamRef->getPointeeType()->isFunctionType()) {
5882 unsigned ParamQuals = ParamRef->getPointeeType().getCVRQualifiers();
5885 if ((ParamQuals | ArgQuals) != ParamQuals) {
5887 diag::err_template_arg_ref_bind_ignores_quals)
5923 bool Invalid =
false;
5927 bool AddressTaken =
false;
5934 bool ExtWarnMSTemplateArg =
false;
5937 while (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(Arg)) {
5939 if (UnOpKind == UO_Deref)
5940 ExtWarnMSTemplateArg =
true;
5941 if (UnOpKind == UO_AddrOf || UnOpKind == UO_Deref) {
5944 FirstOpKind = UnOpKind;
5945 FirstOpLoc = UnOp->getOperatorLoc();
5951 if (ExtWarnMSTemplateArg)
5955 if (FirstOpKind == UO_AddrOf)
5956 AddressTaken =
true;
5960 assert(FirstOpKind == UO_Deref);
5983 bool ExtraParens =
false;
5984 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
5985 if (!Invalid && !ExtraParens) {
5988 ? diag::warn_cxx98_compat_template_arg_extra_parens
5989 : diag::ext_template_arg_extra_parens)
5994 Arg = Parens->getSubExpr();
5998 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6002 if (UnOp->getOpcode() == UO_AddrOf) {
6003 Arg = UnOp->getSubExpr();
6004 AddressTaken =
true;
6005 AddrOpLoc = UnOp->getOperatorLoc();
6010 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6022 S.
Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
6042 if (isa<CXXUuidofExpr>(Arg)) {
6044 ArgIn, Arg, ArgType))
6059 if (isa<FieldDecl>(Entity) || isa<IndirectFieldDecl>(Entity)) {
6067 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Entity)) {
6068 if (!Method->isStatic()) {
6080 if (!Func && !Var) {
6092 ? diag::warn_cxx98_compat_template_arg_object_internal
6093 : diag::ext_template_arg_object_internal)
6095 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
6097 }
else if (!Entity->hasLinkage()) {
6100 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
6115 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
6121 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
6130 if (Var->getType()->isReferenceType()) {
6138 if (Var->getTLSKind()) {
6141 S.
Diag(Var->getLocation(), diag::note_template_arg_refers_here);
6154 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
6160 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
6165 ArgType = Var->getType();
6168 if (Var->getType()->isArrayType()) {
6209 bool Invalid =
false;
6211 Expr *Arg = ResultArg;
6212 bool ObjCLifetimeConversion;
6224 bool ExtraParens =
false;
6225 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
6226 if (!Invalid && !ExtraParens) {
6229 ? diag::warn_cxx98_compat_template_arg_extra_parens
6230 : diag::ext_template_arg_extra_parens)
6235 Arg = Parens->getSubExpr();
6239 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6244 if (UnOp->getOpcode() == UO_AddrOf) {
6251 else if ((DRE = dyn_cast<DeclRefExpr>(Arg))) {
6254 if (isa<NonTypeTemplateParmDecl>(VD)) {
6276 S.
Diag(ResultArg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
6286 ObjCLifetimeConversion)) {
6293 S.
Diag(ResultArg->
getBeginLoc(), diag::err_template_arg_not_convertible)
6301 diag::err_template_arg_not_pointer_to_member_form)
6304 if (isa<FieldDecl>(DRE->
getDecl()) ||
6305 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
6306 isa<CXXMethodDecl>(DRE->
getDecl())) {
6307 assert((isa<FieldDecl>(DRE->
getDecl()) ||
6308 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
6309 !cast<CXXMethodDecl>(DRE->
getDecl())->isStatic()) &&
6310 "Only non-static member pointers can make it here");
6324 S.
Diag(Arg->
getBeginLoc(), diag::err_template_arg_not_pointer_to_member_form)
6351 auto *AT = dyn_cast<
AutoType>(ParamType);
6352 if (AT && AT->isDecltypeAuto()) {
6362 Expr *DeductionArg = Arg;
6363 if (
auto *PE = dyn_cast<PackExpansionExpr>(DeductionArg))
6364 DeductionArg = PE->getPattern();
6367 DeductionArg, ParamType, Depth) == DAR_Failed) {
6369 diag::err_non_type_template_parm_type_deduction_failure)
6379 ParamType = CheckNonTypeTemplateParameterType(ParamType, Arg->
getExprLoc());
6380 if (ParamType.
isNull()) {
6388 "non-type template parameter type cannot be qualified");
6390 if (CTAK == CTAK_Deduced &&
6409 Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
6422 Arg = PE->getPattern();
6433 PE->getNumExpansions());
6450 Arg, ParamType, Value, CCEK_TemplateArg);
6456 if (ArgResult.
get()->isValueDependent()) {
6470 llvm_unreachable(
"result of constant evaluation should be initialized");
6482 diag::err_template_arg_member_ptr_base_derived_not_supported)
6490 : TemplateArgument(CanonParamType,
true);
6505 auto *E = Base.dyn_cast<
const Expr *>();
6506 if (E && isa<CXXUuidofExpr>(E)) {
6516 VD && VD->getType()->isArrayType() &&
6524 Diag(StartLoc, diag::err_non_type_template_arg_subobject)
6529 "null reference should not be a constant expression");
6531 "non-null value of type nullptr_t?");
6533 : TemplateArgument(CanonParamType,
true);
6537 return Diag(StartLoc, diag::err_non_type_template_arg_addr_label_diff);
6546 llvm_unreachable(
"invalid kind for template argument");
6549 return ArgResult.
get();
6569 if (getLangOpts().CPlusPlus11) {
6585 if (ArgResult.
get()->isValueDependent()) {
6595 IntegerType = Enum->getDecl()->getIntegerType();
6596 Value = Value.extOrTrunc(Context.
getTypeSize(IntegerType));
6603 ExprResult ArgResult = DefaultLvalueConversion(Arg);
6606 Arg = ArgResult.
get();
6619 Diag(Arg->
getBeginLoc(), diag::err_template_arg_not_integral_or_enumeral)
6628 TmplArgICEDiagnoser(
QualType T) : T(T) { }
6632 S.
Diag(Loc, diag::err_template_arg_not_ice) << T << SR;
6634 } Diagnoser(ArgType);
6636 Arg = VerifyIntegerConstantExpression(Arg, &Value, Diagnoser,
6651 Arg = ImpCastExprToType(Arg, ParamType, CK_IntegralToBoolean).get();
6652 }
else if (IsIntegralPromotion(Arg, ArgType, ParamType) ||
6655 Arg = ImpCastExprToType(Arg, ParamType, CK_IntegralCast).get();
6681 unsigned AllowedBits = Context.
getTypeSize(IntegerType);
6682 if (Value.getBitWidth() != AllowedBits)
6683 Value = Value.extOrTrunc(AllowedBits);
6686 llvm::APSInt OldValue =
Value;
6690 unsigned AllowedBits = Context.
getTypeSize(IntegerType);
6691 if (Value.getBitWidth() != AllowedBits)
6692 Value = Value.extOrTrunc(AllowedBits);
6697 && (OldValue.isSigned() && OldValue.isNegative())) {
6699 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
6705 unsigned RequiredBits;
6707 RequiredBits = OldValue.getActiveBits();
6708 else if (OldValue.isUnsigned())
6709 RequiredBits = OldValue.getActiveBits() + 1;
6711 RequiredBits = OldValue.getMinSignedBits();
6712 if (RequiredBits > AllowedBits) {
6714 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
6755 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg, ParamType,
6761 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
6787 "Only object pointers allowed here");
6803 assert(ParamRefType->getPointeeType()->isIncompleteOrObjectType() &&
6804 "Only object references allowed here");
6807 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg,
6808 ParamRefType->getPointeeType(),
6814 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
6837 << Arg->
getType() << ParamType;
6845 Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
6877 assert(Name.
isDependent() &&
"Non-dependent template isn't a declaration?");
6896 if (!isa<ClassTemplateDecl>(Template) &&
6897 !isa<TemplateTemplateParmDecl>(Template) &&
6898 !isa<TypeAliasTemplateDecl>(Template) &&
6899 !isa<BuiltinTemplateDecl>(Template)) {
6900 assert(isa<FunctionTemplateDecl>(Template) &&
6901 "Only function templates are possible here");
6903 Diag(Template->
getLocation(), diag::note_template_arg_refers_here_func)
6910 if (getLangOpts().RelaxedTemplateTemplateArgs) {
6915 if (TemplateParameterListsAreEqual(
6917 TPL_TemplateTemplateArgumentMatch, Arg.
getLocation()))
6920 if (isTemplateTemplateParameterAtLeastAsSpecializedAs(Params, Template,
6929 TPL_TemplateTemplateArgumentMatch,
6954 return ImpCastExprToType(
6958 ? CK_NullToMemberPointer
6959 : CK_NullToPointer);
6962 "Only declaration template arguments permitted here");
6966 if (VD->getDeclContext()->isRecord() &&
6967 (isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD) ||
6968 isa<IndirectFieldDecl>(VD))) {
6987 if (isa<CXXMethodDecl>(VD) && cast<CXXMethodDecl>(VD)->isInstance())
6991 VD->getType().getNonReferenceType(),
6998 RefExpr = CreateBuiltinUnaryOp(Loc, UO_AddrOf, RefExpr.
get());
7003 bool ObjCLifetimeConversion;
7004 if (IsQualificationConversion(((
Expr*) RefExpr.
get())->getType(),
7006 ObjCLifetimeConversion))
7016 QualType T = VD->getType().getNonReferenceType();
7028 RefExpr = DefaultFunctionArrayConversion(RefExpr.
get());
7036 return CreateBuiltinUnaryOp(Loc, UO_AddrOf, RefExpr.
get());
7048 }
else if (isa<FunctionDecl>(VD)) {
7053 return BuildDeclRefExpr(VD, T, VK, Loc);
7067 "Operation is only valid for integral template arguments");
7077 T = ET->getDecl()->getIntegerType();
7104 if (OrigT->isEnumeralType()) {
7124 unsigned NextDiag = diag::err_template_param_different_kind;
7125 if (TemplateArgLoc.
isValid()) {
7126 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
7127 NextDiag = diag::note_template_param_different_kind;
7146 unsigned NextDiag = diag::err_template_parameter_pack_non_pack;
7147 if (TemplateArgLoc.
isValid()) {
7148 S.
Diag(TemplateArgLoc,
7149 diag::err_template_arg_template_params_mismatch);
7150 NextDiag = diag::note_template_parameter_pack_non_pack;
7153 unsigned ParamKind = isa<TemplateTypeParmDecl>(New)? 0
7154 : isa<NonTypeTemplateParmDecl>(New)? 1
7167 = dyn_cast<NonTypeTemplateParmDecl>(Old)) {
7175 (OldNTTP->getType()->isDependentType() ||
7181 unsigned NextDiag = diag::err_template_nontype_parm_different_type;
7182 if (TemplateArgLoc.
isValid()) {
7183 S.
Diag(TemplateArgLoc,
7184 diag::err_template_arg_template_params_mismatch);
7185 NextDiag = diag::note_template_nontype_parm_different_type;
7190 S.
Diag(OldNTTP->getLocation(),
7191 diag::note_template_nontype_parm_prev_declaration)
7192 << OldNTTP->getType();
7205 = dyn_cast<TemplateTemplateParmDecl>(Old)) {
7208 OldTTP->getTemplateParameters(),
7227 unsigned NextDiag = diag::err_template_param_list_different_arity;
7228 if (TemplateArgLoc.
isValid()) {
7229 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
7230 NextDiag = diag::note_template_param_list_different_arity;
7270 if (Old->
size() != New->
size() && Kind != TPL_TemplateTemplateArgumentMatch) {
7287 OldParmEnd = Old->
end();
7288 OldParm != OldParmEnd; ++OldParm) {
7289 if (Kind != TPL_TemplateTemplateArgumentMatch ||
7290 !(*OldParm)->isTemplateParameterPack()) {
7291 if (NewParm == NewParmEnd) {
7300 Kind, TemplateArgLoc))
7314 for (; NewParm != NewParmEnd; ++NewParm) {
7316 Kind, TemplateArgLoc))
7322 if (NewParm != NewParmEnd) {
7354 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
7368 if (RD->isLocalClass())
7370 diag::err_template_inside_local_class)
7378 diag::err_template_outside_namespace_or_class_scope)
7389 return Record->getTemplateSpecializationKind();
7390 if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(D))
7391 return Function->getTemplateSpecializationKind();
7392 if (
VarDecl *Var = dyn_cast<VarDecl>(D))
7393 return Var->getTemplateSpecializationKind();
7430 if (isa<ClassTemplateDecl>(Specialized))
7431 EntityKind = IsPartialSpecialization? 1 : 0;
7432 else if (isa<VarTemplateDecl>(Specialized))
7433 EntityKind = IsPartialSpecialization ? 3 : 2;
7434 else if (isa<FunctionTemplateDecl>(Specialized))
7436 else if (isa<CXXMethodDecl>(Specialized))
7438 else if (isa<VarDecl>(Specialized))
7440 else if (isa<RecordDecl>(Specialized))
7442 else if (isa<EnumDecl>(Specialized) && S.
getLangOpts().CPlusPlus11)
7445 S.
Diag(Loc, diag::err_template_spec_unknown_kind)
7455 S.
Diag(Loc, diag::err_template_spec_decl_function_scope)
7470 : DC->
Equals(SpecializedContext))) {
7471 if (isa<TranslationUnitDecl>(SpecializedContext))
7472 S.
Diag(Loc, diag::err_template_spec_redecl_global_scope)
7473 << EntityKind << Specialized;
7475 auto *ND = cast<NamedDecl>(SpecializedContext);
7476 int Diag = diag::err_template_spec_redecl_out_of_scope;
7478 Diag = diag::ext_ms_template_spec_redecl_out_of_scope;
7479 S.
Diag(Loc, Diag) << EntityKind << Specialized
7480 << ND << isa<CXXRecordDecl>(ND);
7483 S.
Diag(Specialized->getLocation(), diag::note_specialized_entity);
7497 DependencyChecker Checker(Depth,
true);
7498 Checker.TraverseStmt(E);
7499 if (Checker.MatchLoc.isInvalid())
7501 return Checker.MatchLoc;
7507 DependencyChecker Checker(Depth,
true);
7508 Checker.TraverseTypeLoc(TL);
7509 if (Checker.MatchLoc.isInvalid())
7511 return Checker.MatchLoc;
7519 for (
unsigned I = 0; I != NumArgs; ++I) {
7522 S, TemplateNameLoc, Param, Args[I].pack_begin(),
7523 Args[I].pack_size(), IsDefaultArgument))
7536 ArgExpr = Expansion->getPattern();
7540 ArgExpr = ICE->getSubExpr();
7550 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ArgExpr))
7551 if (isa<NonTypeTemplateParmDecl>(DRE->getDecl()))
7571 if (ParamUseRange.
isValid()) {
7572 if (IsDefaultArgument) {
7573 S.
Diag(TemplateNameLoc,
7574 diag::err_dependent_non_type_arg_in_partial_spec);
7576 diag::note_dependent_non_type_default_arg_in_partial_spec)
7580 diag::err_dependent_non_type_arg_in_partial_spec)
7588 if (ParamUseRange.
isValid()) {
7590 diag::err_dependent_typed_non_type_arg_in_partial_spec)
7593 << (IsDefaultArgument ? ParamUseRange :
SourceRange())
7623 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
7630 Param, &TemplateArgs[I],
7631 1, I >= NumExplicit))
7643 assert(TUK != TUK_Reference &&
"References are not specializations");
7650 ? TemplateParameterLists[0]->getTemplateLoc() : KWLoc;
7660 if (!ClassTemplate) {
7661 Diag(TemplateNameLoc, diag::err_not_class_template_specialization)
7667 bool isMemberSpecialization =
false;
7668 bool isPartialSpecialization =
false;
7674 bool Invalid =
false;
7676 MatchTemplateParametersToScopeSpecifier(
7677 KWLoc, TemplateNameLoc, SS, &TemplateId,
7678 TemplateParameterLists, TUK == TUK_Friend, isMemberSpecialization,
7683 if (TemplateParams && TemplateParams->
size() > 0) {
7684 isPartialSpecialization =
true;
7686 if (TUK == TUK_Friend) {
7687 Diag(KWLoc, diag::err_partial_specialization_friend)
7695 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
7698 if (TTP->hasDefaultArgument()) {
7699 Diag(TTP->getDefaultArgumentLoc(),
7700 diag::err_default_arg_in_partial_spec);
7701 TTP->removeDefaultArgument();
7704 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
7705 if (
Expr *DefArg = NTTP->getDefaultArgument()) {
7706 Diag(NTTP->getDefaultArgumentLoc(),
7707 diag::err_default_arg_in_partial_spec)
7708 << DefArg->getSourceRange();
7709 NTTP->removeDefaultArgument();
7715 diag::err_default_arg_in_partial_spec)
7721 }
else if (TemplateParams) {
7722 if (TUK == TUK_Friend)
7723 Diag(KWLoc, diag::err_template_spec_friend)
7729 assert(TUK == TUK_Friend &&
"should have a 'template<>' for this decl");
7735 assert(Kind !=
TTK_Enum &&
"Invalid enum tag in class template spec!");
7737 Kind, TUK == TUK_Definition, KWLoc,
7739 Diag(KWLoc, diag::err_use_with_wrong_tag)
7744 diag::note_previous_use);
7753 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
7754 if (DiagnoseUnexpandedParameterPack(TemplateArgs[I],
7755 UPPC_PartialSpecialization))
7761 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
7762 TemplateArgs,
false, Converted))
7767 if (isPartialSpecialization) {
7768 if (CheckTemplatePartialSpecializationArgs(TemplateNameLoc, ClassTemplate,
7769 TemplateArgs.
size(), Converted))
7774 bool InstantiationDependent;
7777 TemplateArgs.
arguments(), InstantiationDependent)) {
7778 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
7780 isPartialSpecialization =
false;
7784 void *InsertPos =
nullptr;
7787 if (isPartialSpecialization)
7797 if (TUK != TUK_Friend &&
7800 isPartialSpecialization))
7805 if (isPartialSpecialization) {
7821 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
7822 << 0 << (TUK == TUK_Definition)
7824 return CheckClassTemplate(S, TagSpec, TUK, KWLoc, SS,
7831 TemplateParameterLists.size() - 1,
7832 TemplateParameterLists.data());
7837 = cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl);
7841 KWLoc, TemplateNameLoc,
7849 if (TemplateParameterLists.size() > 1 && SS.
isSet()) {
7850 Partial->setTemplateParameterListsInfo(
7851 Context, TemplateParameterLists.drop_back(1));
7855 ClassTemplate->AddPartialSpecialization(Partial, InsertPos);
7856 Specialization = Partial;
7860 if (PrevPartial && PrevPartial->getInstantiatedFromMember())
7861 PrevPartial->setMemberSpecialization();
7863 CheckTemplatePartialSpecialization(Partial);
7870 KWLoc, TemplateNameLoc,
7875 if (TemplateParameterLists.size() > 0) {
7877 TemplateParameterLists);
7881 ClassTemplate->AddSpecialization(Specialization, InsertPos);
7883 if (CurContext->isDependentContext()) {
7886 CanonTemplate, Converted);
7910 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
7914 diag::note_instantiation_required_here)
7922 if (TUK != TUK_Friend)
7926 if (TUK == TUK_Definition) {
7929 if (Def && SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
7932 makeMergedDefinitionVisible(Hidden);
7935 Diag(TemplateNameLoc, diag::err_redefinition) << Specialization << Range;
7942 ProcessDeclAttributeList(S, Specialization, Attr);
7946 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip)) {
7947 AddAlignmentAttributesForRecord(Specialization);
7948 AddMsStructLayoutForRecord(Specialization);
7951 if (ModulePrivateLoc.
isValid())
7952 Diag(Specialization->
getLocation(), diag::err_module_private_specialization)
7953 << (isPartialSpecialization? 1 : 0)
7965 TemplateArgs, CanonType);
7966 if (TUK != TUK_Friend) {
7982 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip))
7985 if (TUK == TUK_Friend) {
7991 CurContext->addDecl(Friend);
7996 CurContext->addDecl(Specialization);
8002 return Specialization;
8008 Decl *NewDecl = HandleDeclarator(S, D, TemplateParameterLists);
8009 ActOnDocumentableDecl(NewDecl);
8016 Expr *ConstraintExpr) {
8021 diag::err_concept_decls_may_only_appear_in_global_namespace_scope);
8025 if (TemplateParameterLists.size() > 1) {
8026 Diag(NameLoc, diag::err_concept_extra_headers);
8030 if (TemplateParameterLists.front()->size() == 0) {
8031 Diag(NameLoc, diag::err_concept_no_parameters);
8036 TemplateParameterLists.front(),
8047 diag::err_concept_initialized_with_non_bool_type)
8056 Diag(NameLoc, diag::err_concept_no_associated_constraints);
8063 ForVisibleRedeclaration);
8064 LookupName(Previous, S);
8066 FilterLookupForScope(Previous, DC, S,
false,
8068 if (!Previous.empty()) {
8069 auto *Old = Previous.getRepresentativeDecl();
8070 Diag(NameLoc, isa<ConceptDecl>(Old) ? diag::err_redefinition :
8071 diag::err_redefinition_different_kind) << NewDecl->
getDeclName();
8072 Diag(Old->getLocation(), diag::note_previous_definition);
8075 ActOnDocumentableDecl(NewDecl);
8076 PushOnScopeChains(NewDecl, S);
8087 FD->setInlineSpecified(
false);
8098 for (
Decl *Prev = D; Prev && !PrevDiagLoc.
isValid();
8099 Prev = Prev->getPreviousDecl()) {
8100 PrevDiagLoc = Prev->getLocation();
8102 assert(PrevDiagLoc.
isValid() &&
8103 "Explicit instantiation without point of instantiation?");
8135 bool &HasNoEffect) {
8136 HasNoEffect =
false;
8143 "previous declaration must be implicit!");
8156 if (PrevPointOfInstantiation.
isInvalid()) {
8168 PrevPointOfInstantiation.
isValid()) &&
8169 "Explicit instantiation without point of instantiation?");
8183 Diag(NewLoc, diag::err_specialization_after_instantiation)
8185 Diag(PrevPointOfInstantiation, diag::note_instantiation_required_here)
8190 llvm_unreachable(
"The switch over PrevTSK must be exhaustive.");
8220 diag::err_explicit_instantiation_declaration_after_definition);
8226 diag::note_explicit_instantiation_definition_here);
8230 llvm_unreachable(
"Unexpected TemplateSpecializationKind!");
8246 Diag(NewLoc, diag::warn_explicit_instantiation_after_specialization)
8249 diag::note_previous_template_specialization);
8279 Diag(NewLoc, (getLangOpts().MSVCCompat)
8280 ? diag::ext_explicit_instantiation_duplicate
8281 : diag::err_explicit_instantiation_duplicate)
8284 diag::note_previous_explicit_instantiation);
8290 llvm_unreachable(
"Missing specialization/instantiation case?");
8316 enum DiscardReason { NotAFunctionTemplate, NotAMemberOfEnclosing };
8320 if (!isa<FunctionTemplateDecl>(D)) {
8322 DiscardedCandidates.push_back(std::make_pair(NotAFunctionTemplate, D));
8329 DiscardedCandidates.push_back(std::make_pair(NotAMemberOfEnclosing, D));
8335 if (Previous.
empty()) {
8337 diag::err_dependent_function_template_spec_no_match);
8338 for (
auto &
P : DiscardedCandidates)
8339 Diag(
P.second->getLocation(),
8340 diag::note_dependent_function_template_spec_discard_reason)
8346 ExplicitTemplateArgs);
8381 llvm::SmallDenseMap<FunctionDecl *, TemplateArgumentListInfo, 8>
8382 ConvertedTemplateArgs;
8404 if (OldMD && OldMD->
isConst()) {
8414 if (ExplicitTemplateArgs)
8415 Args = *ExplicitTemplateArgs;
8427 cast<FunctionTemplateDecl>(FunTmpl->getFirstDecl()),
8428 ExplicitTemplateArgs ? &Args :
nullptr, FT, Specialization,
8432 FailedCandidates.addCandidate().set(
8433 I.getPair(), FunTmpl->getTemplatedDecl(),
8444 if (LangOpts.CUDA &&
8445 IdentifyCUDATarget(Specialization,
8447 IdentifyCUDATarget(FD,
true)) {
8448 FailedCandidates.addCandidate().set(
8449 I.getPair(), FunTmpl->getTemplatedDecl(),
8455 if (ExplicitTemplateArgs)
8456 ConvertedTemplateArgs[Specialization] = std::move(Args);
8457 Candidates.
addDecl(Specialization, I.getAccess());
8464 if (QualifiedFriend && Candidates.
empty()) {
8469 for (
auto *OldND : Previous) {
8470 if (
auto *OldFD = dyn_cast<FunctionDecl>(OldND->getUnderlyingDecl()))
8471 NoteOverloadCandidate(OldND, OldFD, FD->
getType(),
false);
8473 FailedCandidates.NoteCandidates(*
this, FD->
getLocation());
8480 PDiag(diag::err_function_template_spec_no_match) << FD->
getDeclName(),
8481 PDiag(diag::err_function_template_spec_ambiguous)
8482 << FD->
getDeclName() << (ExplicitTemplateArgs !=
nullptr),
8483 PDiag(diag::note_function_template_spec_matched));
8485 if (Result == Candidates.
end())
8489 FunctionDecl *Specialization = cast<FunctionDecl>(*Result);
8493 assert(SpecInfo &&
"Function template specialization info missing?");
8531 bool HasNoEffect =
false;
8533 CheckSpecializationInstantiationRedecl(FD->
getLocation(),
8553 !Specialization->getCanonicalDecl()->isReferenced()) {
8556 Specialization->getCanonicalDecl() == Specialization &&
8557 "This must be the only existing declaration of this specialization");
8559 Specialization->setDeletedAsWritten(
false);
8563 MarkUnusedFileScopedDecl(Specialization);
8572 FD->setFunctionTemplateSpecialization(
8573 Specialization->getPrimaryTemplate(), TemplArgs,
nullptr,
8575 ExplicitTemplateArgs ? &ConvertedTemplateArgs[Specialization] :
nullptr);
8588 Previous.
addDecl(Specialization);
8608 assert(!isa<TemplateDecl>(Member) &&
"Only for non-template members");
8611 NamedDecl *FoundInstantiation =
nullptr;
8616 if (Previous.
empty()) {
8618 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(Member)) {
8621 NamedDecl *D = (*I)->getUnderlyingDecl();
8623 QualType Adjusted = Function->getType();
8624 if (!hasExplicitCallingConv(Adjusted))
8625 Adjusted = adjustCCAndNoReturn(Adjusted, Method->getType());
8628 if (Context.
hasSameType(Adjusted, Method->getType())) {
8629 FoundInstantiation = *I;
8630 Instantiation = Method;
8631 InstantiatedFrom = Method->getInstantiatedFromMemberFunction();
8632 MSInfo = Method->getMemberSpecializationInfo();
8637 }
else if (isa<VarDecl>(Member)) {
8643 Instantiation = PrevVar;
8647 }
else if (isa<RecordDecl>(Member)) {
8652 Instantiation = PrevRecord;
8656 }
else if (isa<EnumDecl>(Member)) {
8661 Instantiation = PrevEnum;
8667 if (!Instantiation) {
8681 if (InstantiatedFrom && isa<CXXMethodDecl>(Member)) {
8682 cast<CXXMethodDecl>(Member)->setInstantiationOfMemberFunction(
8683 cast<CXXMethodDecl>(InstantiatedFrom),
8685 }
else if (InstantiatedFrom && isa<CXXRecordDecl>(Member)) {
8686 cast<CXXRecordDecl>(Member)->setInstantiationOfMemberClass(
8687 cast<CXXRecordDecl>(InstantiatedFrom),
8692 Previous.
addDecl(FoundInstantiation);
8697 if (!InstantiatedFrom) {
8710 assert(MSInfo &&
"Member specialization info missing?");
8712 bool HasNoEffect =
false;
8713 if (CheckSpecializationInstantiationRedecl(Member->
getLocation(),
8730 if (
auto *MemberFunction = dyn_cast<FunctionDecl>(Member)) {
8731 FunctionDecl *InstantiationFunction = cast<FunctionDecl>(Instantiation);
8736 if (InstantiationFunction->
isDeleted()) {
8739 InstantiationFunction);
8745 MemberFunction->setInstantiationOfMemberFunction(
8747 }
else if (
auto *MemberVar = dyn_cast<VarDecl>(Member)) {
8748 MemberVar->setInstantiationOfStaticDataMember(
8750 }
else if (
auto *MemberClass = dyn_cast<CXXRecordDecl>(Member)) {
8751 MemberClass->setInstantiationOfMemberClass(
8753 }
else if (
auto *MemberEnum = dyn_cast<EnumDecl>(Member)) {
8754 MemberEnum->setInstantiationOfMemberEnum(
8757 llvm_unreachable(
"unknown member specialization kind");
8763 Previous.
addDecl(FoundInstantiation);
8772 template<
typename DeclT>
8783 OrigD->setLocation(Loc);
8789 if (Instantiation == Member)
8792 if (
auto *Function = dyn_cast<CXXMethodDecl>(Instantiation))
8794 else if (
auto *Var = dyn_cast<VarDecl>(Instantiation))
8796 else if (
auto *Record = dyn_cast<CXXRecordDecl>(Instantiation))
8798 else if (
auto *Enum = dyn_cast<EnumDecl>(Instantiation))
8801 llvm_unreachable(
"unknown member specialization kind");
8809 bool WasQualifiedName) {
8814 S.
Diag(InstLoc, diag::err_explicit_instantiation_in_class)
8827 if (WasQualifiedName) {
8828 if (CurContext->
Encloses(OrigContext))
8835 if (
NamespaceDecl *NS = dyn_cast<NamespaceDecl>(OrigContext)) {
8836 if (WasQualifiedName)
8839 diag::err_explicit_instantiation_out_of_scope :
8840 diag::warn_explicit_instantiation_out_of_scope_0x)
8845 diag::err_explicit_instantiation_unqualified_wrong_namespace :
8846 diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x)
8851 diag::err_explicit_instantiation_must_be_global :
8852 diag::warn_explicit_instantiation_must_be_global_0x)
8861 bool WasQualifiedName,
8868 S.
Diag(InstLoc, diag::err_explicit_instantiation_internal_linkage) << D;
8896 if (isa<TemplateSpecializationType>(T))
8906 auto *A = cast_or_null<InheritableAttr>(
getDLLAttr(Def));
8907 assert(A &&
"dllExportImportClassTemplateSpecialization called " 8908 "on Def without dllexport or dllimport");
8913 "delayed exports present at explicit instantiation");
8917 for (
auto &B : Def->
bases()) {
8918 if (
auto *BT = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
8919 B.getType()->getAsCXXRecordDecl()))
8940 "Invalid enum tag in class template explicit instantiation!");
8944 if (!ClassTemplate) {
8945 NonTagKind NTK = getNonTagTypeDeclKind(TD, Kind);
8946 Diag(TemplateNameLoc, diag::err_tag_reference_non_tag) << TD << NTK <<
Kind;
8954 Diag(KWLoc, diag::err_use_with_wrong_tag)
8959 diag::note_previous_use);
8976 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
8978 diag::warn_attribute_dllexport_explicit_instantiation_decl);
8979 Diag(AL.getLoc(), diag::note_attribute);
8986 diag::warn_attribute_dllexport_explicit_instantiation_decl);
8987 Diag(A->getLocation(), diag::note_attribute);
8993 bool DLLImportExplicitInstantiationDef =
false;
9000 if (AL.getKind() == ParsedAttr::AT_DLLImport)
9002 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
9010 DLLImportExplicitInstantiationDef =
true;
9016 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
9021 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
9022 TemplateArgs,
false, Converted))
9027 void *InsertPos =
nullptr;
9039 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
9041 diag::warn_attribute_dllexport_explicit_instantiation_def);
9053 bool HasNoEffect =
false;
9055 if (CheckSpecializationInstantiationRedecl(TemplateNameLoc, TSK,
9056 PrevDecl, PrevDecl_TSK,
9071 Specialization = PrevDecl;
9077 DLLImportExplicitInstantiationDef) {
9079 HasNoEffect =
false;
9083 if (!Specialization) {
9089 KWLoc, TemplateNameLoc,
9095 if (!HasNoEffect && !PrevDecl) {
9097 ClassTemplate->AddSpecialization(Specialization, InsertPos);
9119 bool PreviouslyDLLExported = Specialization->
hasAttr<DLLExportAttr>();
9120 ProcessDeclAttributeList(S, Specialization, Attr);
9126 CurContext->addDecl(Specialization);
9132 return Specialization;
9143 = cast_or_null<ClassTemplateSpecializationDecl>(
9146 InstantiateClassTemplateSpecialization(TemplateNameLoc, Specialization, TSK);
9148 MarkVTableUsed(TemplateNameLoc, Specialization,
true);
9153 Def = cast_or_null<ClassTemplateSpecializationDecl>(
9161 DLLImportExplicitInstantiationDef)) {
9171 auto *A = cast<InheritableAttr>(
9173 A->setInherited(
true);
9181 bool NewlyDLLExported =
9182 !PreviouslyDLLExported && Specialization->
hasAttr<DLLExportAttr>();
9198 assert(Def == Specialization &&
9199 "Def and Specialization should match for implicit instantiation");
9207 PrevDecl->
hasAttr<DLLExportAttr>()) {
9214 InstantiateClassTemplateSpecializationMembers(TemplateNameLoc, Def, TSK);
9221 return Specialization;
9233 bool IsDependent =
false;
9235 KWLoc, SS, Name, NameLoc, Attr,
AS_none,
9241 assert(!IsDependent &&
"explicit instantiation of dependent name not yet handled");
9246 TagDecl *Tag = cast<TagDecl>(TagD);
9247 assert(!Tag->
isEnum() &&
"shouldn't see enumerations here");
9255 Diag(TemplateLoc, diag::err_explicit_instantiation_nontemplate_type)
9268 Diag(TemplateLoc, diag::ext_explicit_instantiation_without_qualified_id)
9288 bool HasNoEffect =
false;
9289 assert(MSInfo &&
"No member specialization information?");
9290 if (CheckSpecializationInstantiationRedecl(TemplateLoc, TSK,
9307 = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
9309 Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member)
9311 Diag(Pattern->getLocation(), diag::note_forward_declaration)
9315 if (InstantiateClass(NameLoc, Record, Def,
9316 getTemplateInstantiationArgs(Record),
9320 RecordDef = cast_or_null<CXXRecordDecl>(Record->
getDefinition());
9327 InstantiateClassMembers(NameLoc, RecordDef,
9328 getTemplateInstantiationArgs(Record), TSK);
9331 MarkVTableUsed(NameLoc, RecordDef,
true);
9351 diag::err_explicit_instantiation_requires_name)
9392 getLangOpts().CPlusPlus11 ?
9393 diag::err_explicit_instantiation_inline :
9394 diag::warn_explicit_instantiation_inline_0x)
9400 diag::err_explicit_instantiation_constexpr);
9435 if (!PrevTemplate) {
9442 Diag((*P)->getLocation(), diag::note_explicit_instantiation_here);
9449 diag::err_explicit_instantiation_data_member_not_instantiated)
9465 diag::err_auto_not_allowed_var_inst);
9474 diag::err_explicit_instantiation_without_template_id)
9476 Diag(PrevTemplate->getLocation(),
9477 diag::note_explicit_instantiation_here);
9485 DeclResult Res = CheckVarTemplateId(PrevTemplate, TemplateLoc,
9487 if (Res.isInvalid())
9492 Prev = cast<VarDecl>(Res.get());
9507 diag::ext_explicit_instantiation_without_qualified_id)
9515 bool HasNoEffect =
false;
9516 if (CheckSpecializationInstantiationRedecl(D.
getIdentifierLoc(), TSK, Prev,
9517 PrevTSK, POI, HasNoEffect))
9530 if (PrevTemplate && Prev && !Context.
hasSameType(Prev->getType(), R)) {
9532 diag::err_invalid_var_template_spec_type)
9533 << 0 << PrevTemplate << R << Prev->getType();
9534 Diag(PrevTemplate->getLocation(), diag::note_template_declared_here)
9535 << 2 << PrevTemplate->getDeclName();
9540 return (
Decl*)
nullptr;
9545 bool HasExplicitTemplateArgs =
false;
9549 HasExplicitTemplateArgs =
true;
9563 if (!HasExplicitTemplateArgs) {
9564 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Prev)) {
9565 QualType Adjusted = adjustCCAndNoReturn(R, Method->getType(),
9568 if (Method->getPrimaryTemplate()) {
9569 TemplateMatches.
addDecl(Method,
P.getAccess());
9572 assert(!NonTemplateMatch &&
"Multiple NonTemplateMatches");
9573 NonTemplateMatch = Method;
9587 (HasExplicitTemplateArgs ? &TemplateArgs
9589 R, Specialization, Info)) {
9591 FailedCandidates.addCandidate()
9603 if (LangOpts.CUDA &&
9604 IdentifyCUDATarget(Specialization,
9607 FailedCandidates.addCandidate().set(
9613 TemplateMatches.
addDecl(Specialization,
P.getAccess());
9617 if (!Specialization) {
9620 TemplateMatches.
begin(), TemplateMatches.
end(), FailedCandidates,
9622 PDiag(diag::err_explicit_instantiation_not_known) << Name,
9623 PDiag(diag::err_explicit_instantiation_ambiguous) << Name,
9624 PDiag(diag::note_explicit_instantiation_candidate));
9626 if (Result == TemplateMatches.
end())
9630 Specialization = cast<FunctionDecl>(*Result);
9640 if (FPT->hasExceptionSpec()) {
9642 diag::err_mismatched_exception_spec_explicit_instantiation;
9643 if (getLangOpts().MicrosoftExt)
9644 DiagID = diag::ext_mismatched_exception_spec_explicit_instantiation;
9645 bool Result = CheckEquivalentExceptionSpec(
9646 PDiag(DiagID) << Specialization->
getType(),
9647 PDiag(diag::note_explicit_instantiation_here),
9652 if (!getLangOpts().MicrosoftExt && Result)
9658 diag::err_explicit_instantiation_member_function_not_instantiated)
9662 Diag(Specialization->
getLocation(), diag::note_explicit_instantiation_here);
9668 PrevDecl = Specialization;
9671 bool HasNoEffect =
false;
9675 PrevDecl->getPointOfInstantiation(),
9682 return (
Decl*)
nullptr;
9691 if (Specialization->
hasAttr<InternalLinkageAttr>() &&
9693 if (
auto *RD = dyn_cast<CXXRecordDecl>(Specialization->
getDeclContext()))
9694 if (RD->getIdentifier() && RD->getIdentifier()->isStr(
"valarray") &&
9695 RD->isInStdNamespace())
9696 return (
Decl*)
nullptr;
9704 Specialization->
hasAttr<DLLImportAttr>() &&
9713 Consumer.HandleTopLevelDecl(
DeclGroupRef(Specialization));
9729 diag::ext_explicit_instantiation_without_qualified_id)
9739 return (
Decl*)
nullptr;
9747 assert(Name &&
"Expected a name in a dependent tag");
9755 if (TUK == TUK_Declaration || TUK == TUK_Definition) {
9756 Diag(NameLoc, diag::err_dependent_tag_decl)
9757 << (TUK == TUK_Definition) << Kind << SS.
getRange();
9783 getLangOpts().CPlusPlus11 ?
9784 diag::warn_cxx98_compat_typename_outside_of_template :
9785 diag::ext_typename_outside_of_template)
9790 TypenameLoc, QualifierLoc, II, IdLoc);
9795 if (isa<DependentNameType>(T)) {
9807 return CreateParsedType(T, TSI);
9823 getLangOpts().CPlusPlus11 ?
9824 diag::warn_cxx98_compat_typename_outside_of_template :
9825 diag::ext_typename_outside_of_template)
9832 dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS,
false));
9833 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
9835 diag::ext_out_of_line_qualified_id_type_names_constructor)
9837 << (TemplateKWLoc.
isValid() ? 1 : 0 );
9843 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
9848 assert(DTN &&
"dependent template has non-dependent name?");
9851 DTN->getQualifier(),
9852 DTN->getIdentifier(),
9865 for (
unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
9870 QualType T = CheckTemplateIdType(Template, TemplateIILoc, TemplateArgs);
9882 for (
unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
9891 return CreateParsedType(T, TSI);
9900 if (!II.
isStr(
"type"))
9909 if (!EnableIfTSTLoc || EnableIfTSTLoc.
getNumArgs() == 0)
9922 if (!EnableIfII || !EnableIfII->
isStr(
"enable_if"))
9952 SS.
Adopt(QualifierLoc);
9970 if (RequireCompleteDeclContext(SS, Ctx))
9974 LookupResult Result(*
this, Name, IILoc, LookupOrdinaryName);
9975 LookupQualifiedName(Result, Ctx, SS);
9976 unsigned DiagID = 0;
9977 Decl *Referenced =
nullptr;
9983 Expr *Cond =
nullptr;
9984 if (
isEnableIf(QualifierLoc, II, CondRange, Cond)) {
9989 std::string FailedDescription;
9990 std::tie(FailedCond, FailedDescription) =
9991 findFailedBooleanCondition(Cond);
9994 diag::err_typename_nested_not_found_requirement)
9995 << FailedDescription
10000 Diag(CondRange.
getBegin(), diag::err_typename_nested_not_found_enable_if)
10001 << Ctx << CondRange;
10005 DiagID = diag::err_typename_nested_not_found;
10014 Diag(IILoc, diag::err_typename_refers_to_using_value_decl)
10015 << Name << Ctx << FullRange;
10019 Diag(Loc, diag::note_using_value_decl_missing_typename)
10049 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(Ctx);
10052 FoundRD->isInjectedClassName() &&
10054 Diag(IILoc, diag::ext_out_of_line_qualified_id_type_names_constructor)
10059 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
10069 if (getLangOpts().CPlusPlus17) {
10078 DiagID = diag::err_typename_nested_not_type;
10083 DiagID = diag::err_typename_nested_not_type;
10084 Referenced = *Result.
begin();
10095 Diag(IILoc, DiagID) << FullRange << Name << Ctx;
10104 class CurrentInstantiationRebuilder
10112 CurrentInstantiationRebuilder(
Sema &SemaRef,
10116 Loc(Loc), Entity(Entity) { }
10123 bool AlreadyTransformed(
QualType T) {
10138 this->Entity = Entity;
10180 CurrentInstantiationRebuilder Rebuilder(*
this, Loc, Name);
10181 return Rebuilder.TransformType(T);
10185 CurrentInstantiationRebuilder Rebuilder(*
this, E->
getExprLoc(),
10187 return Rebuilder.TransformExpr(E);
10198 = Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
10210 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
10214 if (isa<TemplateTypeParmDecl>(Param))
10219 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
10220 if (RebuildTemplateParamsInCurrentInstantiation(
10221 TTP->getTemplateParameters()))
10236 if (NewTSI->getType()->isUndeducedType()) {
10242 NewTSI = SubstAutoTypeSourceInfo(NewTSI, Context.
DependentTy);
10247 NTTP->
setType(NewTSI->getType());
10259 return getTemplateArgumentBindingsText(Params, Args.
data(), Args.
size());
10265 unsigned NumArgs) {
10267 llvm::raw_svector_ostream Out(Str);
10269 if (!Params || Params->
size() == 0 || NumArgs == 0)
10270 return std::string();
10272 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
10282 Out <<
Id->getName();
10288 Args[I].
print(getPrintingPolicy(), Out);
10300 auto LPT = llvm::make_unique<LateParsedTemplate>();
10303 LPT->Toks.swap(Toks);
10305 LateParsedTemplateMap.insert(std::make_pair(FD, std::move(LPT)));
10320 if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(CurContext)) {
10349 class ExplicitSpecializationVisibilityChecker {
10356 : S(S), Loc(Loc) {}
10359 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
10360 return checkImpl(FD);
10361 if (
auto *RD = dyn_cast<CXXRecordDecl>(ND))
10362 return checkImpl(RD);
10363 if (
auto *VD = dyn_cast<VarDecl>(ND))
10364 return checkImpl(VD);
10365 if (
auto *ED = dyn_cast<EnumDecl>(ND))
10366 return checkImpl(ED);
10370 void diagnose(
NamedDecl *D,
bool IsPartialSpec) {
10373 const bool Recover =
true;
10378 if (Modules.empty())
10396 template<
typename SpecDecl>
10397 void checkImpl(SpecDecl *Spec) {
10398 bool IsHiddenExplicitSpecialization =
false;
10400 IsHiddenExplicitSpecialization =
10401 Spec->getMemberSpecializationInfo()
10405 checkInstantiated(Spec);
10408 if (IsHiddenExplicitSpecialization)
10409 diagnose(Spec->getMostRecentDecl(),
false);
10425 else if (
auto *TD =
10428 diagnose(TD,
true);
10433 void checkInstantiated(
VarDecl *RD) {
10441 else if (
auto *TD =
10444 diagnose(TD,
true);
10449 void checkInstantiated(
EnumDecl *FD) {}
10451 template<
typename TemplDecl>
10452 void checkTemplate(TemplDecl *TD) {
10453 if (TD->isMemberSpecialization()) {
10455 diagnose(TD->getMostRecentDecl(),
false);
10462 if (!getLangOpts().Modules)
10465 ExplicitSpecializationVisibilityChecker(*
this, Loc).check(Spec);
10473 if (!hasVisibleDeclaration(Spec, &Modules))
10474 diagnoseMissingImport(Loc, Spec, Spec->
getLocation(), Modules,
10475 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.
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 ...
llvm::PointerUnion3< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
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
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
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:
ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, ConceptDecl *Template, SourceLocation TemplateLoc, const TemplateArgumentListInfo *TemplateArgs)
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.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
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.
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.
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...
TemplateParameterList * MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, ArrayRef< TemplateParameterList *> ParamLists, bool IsFriend, bool &IsMemberSpecialization, bool &Invalid)
Match the given template parameter lists to the given scope specifier, returning the template paramet...
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...
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs, SmallVectorImpl< TemplateArgument > &Converted, bool UpdateArgsWithConversions=true)
Check that the given template arguments can be be provided to the given template, converting the argu...
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).
bool CheckTemplateTemplateArgument(TemplateParameterList *Params, TemplateArgumentLoc &Arg)
Check a template argument against its corresponding template template parameter.
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)
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)
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.
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.
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
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...
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...
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.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack)
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.
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...
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 hasQualifiers() const
Determine whether this type has any qualifiers.
SourceRange getRange() const
TemplateParameterListEqualKind
Enumeration describing how template parameter lists are compared for equality.
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.
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)
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Expr * getAssociatedConstraints() const
QualType getCanonicalTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args) const
Declaration of a template type parameter.
unsigned getIndex() const
DeclContext * getEntity() 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 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
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 ...
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...
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.
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.
BuiltinTemplateKind getBuiltinTemplateKind() 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...
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...
DeclResult ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, TemplateIdAnnotation &TemplateId, const ParsedAttributesView &Attr, MultiTemplateParamsArg TemplateParameterLists, SkipBodyInfo *SkipBody=nullptr)
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...
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)
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...
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.
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc)
Build the type that describes a C++ typename specifier, e.g., "typename T::type". ...
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.
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
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.
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)
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl, Expr *AssociatedConstraints=nullptr)
Create a class template node.
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.
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.
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.
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.
CXXScopeSpec SS
The nested-name-specifier that precedes the template name.
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.
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...
NamedDecl * ActOnTypeParameter(Scope *S, bool Typename, SourceLocation EllipsisLoc, SourceLocation KeyLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedType DefaultArg)
ActOnTypeParameter - Called when a C++ template type parameter (e.g., "typename T") has been parsed...
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)
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 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.
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.
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)
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. ...
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...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
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)
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
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.
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)
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
static Expr * formAssociatedConstraints(TemplateParameterList *Params, FunctionDecl *FD)
[temp.constr.decl]p2: A template's associated constraints are defined as a single constraint-expressi...
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...
NamedDecl * getMostRecentDecl()
bool isDeleted() const
Whether this function has been deleted.
bool isPointerType() const
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
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 MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
Mark which template parameters can be deduced from a given template argument list.
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...
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
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
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.