32 #include "llvm/ADT/SmallBitVector.h"
33 #include "llvm/ADT/SmallString.h"
34 #include "llvm/ADT/StringExtras.h"
37 using namespace clang;
45 return SourceRange(Ps[0]->getTemplateLoc(), Ps[N-1]->getRAngleLoc());
64 assert(!FD &&
"Cannot collect constraints from function declaration yet.");
73 bool AllowFunctionTemplates) {
76 if (isa<TemplateDecl>(D)) {
77 if (!AllowFunctionTemplates && isa<FunctionTemplateDecl>(D))
95 if (Record->isInjectedClassName()) {
96 Record = cast<CXXRecordDecl>(Record->getDeclContext());
97 if (Record->getDescribedClassTemplate())
98 return Record->getDescribedClassTemplate();
101 = dyn_cast<ClassTemplateSpecializationDecl>(Record))
102 return Spec->getSpecializedTemplate();
112 bool AllowFunctionTemplates) {
114 llvm::SmallPtrSet<ClassTemplateDecl *, 8> ClassTemplates;
119 AllowFunctionTemplates);
122 else if (Repl != Orig) {
133 if (!ClassTemplates.insert(ClassTmpl).second) {
150 bool AllowFunctionTemplates) {
160 bool hasTemplateKeyword,
163 bool EnteringContext,
165 bool &MemberOfUnknownSpecialization) {
166 assert(getLangOpts().
CPlusPlus &&
"No template names in C!");
169 MemberOfUnknownSpecialization =
false;
192 LookupTemplateName(R, S, SS, ObjectType, EnteringContext,
193 MemberOfUnknownSpecialization);
195 if (R.isAmbiguous()) {
197 R.suppressDiagnostics();
207 unsigned ResultCount = R.end() - R.begin();
208 if (ResultCount > 1) {
215 R.suppressDiagnostics();
217 TemplateDecl *TD = cast<TemplateDecl>((*R.begin())->getUnderlyingDecl());
222 hasTemplateKeyword, TD);
227 if (isa<FunctionTemplateDecl>(TD)) {
231 R.suppressDiagnostics();
233 assert(isa<ClassTemplateDecl>(TD) || isa<TemplateTemplateParmDecl>(TD) ||
234 isa<TypeAliasTemplateDecl>(TD) || isa<VarTemplateDecl>(TD) ||
235 isa<BuiltinTemplateDecl>(TD));
241 TemplateResult = TemplateTy::make(Template);
249 bool MemberOfUnknownSpecialization =
false;
255 LookupTemplateName(R, S, SS,
QualType(),
256 false, MemberOfUnknownSpecialization);
258 if (R.
empty())
return false;
285 if (!SS || !SS->
isSet() || !isDependentScopeSpecifier(*SS) ||
286 computeDeclContext(*SS))
292 Diag(IILoc, diag::err_template_kw_missing)
304 bool EnteringContext,
305 bool &MemberOfUnknownSpecialization) {
307 MemberOfUnknownSpecialization =
false;
309 bool isDependent =
false;
310 if (!ObjectType.
isNull()) {
313 assert(!SS.
isSet() &&
"ObjectType and scope specifier cannot coexist");
314 LookupCtx = computeDeclContext(ObjectType);
318 "Caller should have completed object type");
325 }
else if (SS.
isSet()) {
328 LookupCtx = computeDeclContext(SS, EnteringContext);
329 isDependent = isDependentScopeSpecifier(SS);
332 if (LookupCtx && RequireCompleteDeclContext(SS, LookupCtx))
336 bool ObjectTypeSearchedInScope =
false;
337 bool AllowFunctionTemplatesInLookup =
true;
343 LookupQualifiedName(Found, LookupCtx);
354 if (S) LookupName(Found, S);
355 ObjectTypeSearchedInScope =
true;
356 AllowFunctionTemplatesInLookup =
false;
358 }
else if (isDependent && (!S || ObjectType.
isNull())) {
361 MemberOfUnknownSpecialization =
true;
365 LookupName(Found, S);
368 AllowFunctionTemplatesInLookup =
false;
371 if (Found.
empty() && !isDependent) {
376 auto FilterCCC = llvm::make_unique<CorrectionCandidateCallback>();
377 FilterCCC->WantTypeSpecifiers =
false;
378 FilterCCC->WantExpressionKeywords =
false;
379 FilterCCC->WantRemainingKeywords =
false;
380 FilterCCC->WantCXXNamedCasts =
true;
383 std::move(FilterCCC), CTK_ErrorRecovery, LookupCtx)) {
385 if (
auto *ND = Corrected.getFoundDecl())
387 FilterAcceptableTemplateNames(Found);
388 if (!Found.
empty()) {
390 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
391 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
393 diagnoseTypo(Corrected, PDiag(diag::err_no_member_template_suggest)
394 << Name << LookupCtx << DroppedSpecifier
397 diagnoseTypo(Corrected, PDiag(diag::err_no_template_suggest) << Name);
405 FilterAcceptableTemplateNames(Found, AllowFunctionTemplatesInLookup);
408 MemberOfUnknownSpecialization =
true;
412 if (S && !ObjectType.
isNull() && !ObjectTypeSearchedInScope &&
413 !getLangOpts().CPlusPlus11) {
422 LookupName(FoundOuter, S);
423 FilterAcceptableTemplateNames(FoundOuter,
false);
425 if (FoundOuter.empty()) {
429 FoundOuter.isAmbiguous()) {
442 diag::ext_nested_name_member_ref_lookup_ambiguous)
446 diag::note_ambig_member_ref_object_type)
448 Diag(FoundOuter.getFoundDecl()->getLocation(),
449 diag::note_ambig_member_ref_scope);
472 if (
auto *ME = dyn_cast<MemberExpr>(TemplateName.
get())) {
473 NameInfo = ME->getMemberNameInfo();
474 SS.
Adopt(ME->getQualifierLoc());
475 LookupKind = LookupMemberName;
476 LookupCtx = ME->getBase()->getType()->getAsCXXRecordDecl();
477 Found = ME->getMemberDecl();
479 auto *DRE = cast<DeclRefExpr>(TemplateName.
get());
480 NameInfo = DRE->getNameInfo();
481 SS.
Adopt(DRE->getQualifierLoc());
482 LookupKind = LookupOrdinaryName;
483 Found = DRE->getFoundDecl();
488 TemplateCandidateFilter() {
489 WantTypeSpecifiers =
false;
490 WantExpressionKeywords =
false;
491 WantRemainingKeywords =
false;
492 WantCXXNamedCasts =
true;
494 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
503 CorrectTypo(NameInfo, LookupKind, S, &SS,
504 llvm::make_unique<TemplateCandidateFilter>(),
505 CTK_ErrorRecovery, LookupCtx)) {
506 auto *ND = Corrected.getFoundDecl();
510 if (ND || Corrected.isKeyword()) {
512 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
513 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
515 diagnoseTypo(Corrected,
516 PDiag(diag::err_non_template_in_member_template_id_suggest)
517 << Name << LookupCtx << DroppedSpecifier
520 diagnoseTypo(Corrected,
521 PDiag(diag::err_non_template_in_template_id_suggest)
526 diag::note_non_template_in_template_id_found);
531 Diag(NameInfo.
getLoc(), diag::err_non_template_in_template_id)
534 Diag(Found->
getLocation(), diag::note_non_template_in_template_id_found);
544 bool isAddressOfOperand,
559 bool MightBeCxx11UnevalField =
560 getLangOpts().CPlusPlus11 && isUnevaluatedContext();
565 IsEnum = dyn_cast_or_null<EnumType>(NNS->getAsType());
567 if (!MightBeCxx11UnevalField && !isAddressOfOperand && !IsEnum &&
568 isa<CXXMethodDecl>(DC) && cast<CXXMethodDecl>(DC)->isInstance()) {
573 NamedDecl *FirstQualifierInScope =
nullptr;
576 Context,
nullptr, ThisType,
true,
578 FirstQualifierInScope, NameInfo, TemplateArgs);
581 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
599 bool InstantiatedFromMember,
604 assert(isa<TagDecl>(Instantiation) || isa<FunctionDecl>(Instantiation) ||
605 isa<VarDecl>(Instantiation));
607 bool IsEntityBeingDefined =
false;
608 if (
const TagDecl *TD = dyn_cast_or_null<TagDecl>(PatternDef))
609 IsEntityBeingDefined = TD->isBeingDefined();
611 if (PatternDef && !IsEntityBeingDefined) {
613 if (!hasVisibleDefinition(const_cast<NamedDecl*>(PatternDef), &SuggestedDef,
616 bool Recover = Complain && !isSFINAEContext();
618 diagnoseMissingImport(PointOfInstantiation, SuggestedDef,
625 if (!Complain || (PatternDef && PatternDef->
isInvalidDecl()))
630 if (
TagDecl *TD = dyn_cast<TagDecl>(Instantiation))
633 Diag(PointOfInstantiation,
634 diag::err_template_instantiate_within_definition)
640 }
else if (InstantiatedFromMember) {
641 if (isa<FunctionDecl>(Instantiation)) {
642 Diag(PointOfInstantiation,
643 diag::err_explicit_instantiation_undefined_member)
646 Note = diag::note_explicit_instantiation_here;
648 assert(isa<TagDecl>(Instantiation) &&
"Must be a TagDecl!");
649 Diag(PointOfInstantiation,
650 diag::err_implicit_instantiate_member_undefined)
652 Note = diag::note_member_declared_at;
655 if (isa<FunctionDecl>(Instantiation)) {
656 Diag(PointOfInstantiation,
657 diag::err_explicit_instantiation_undefined_func_template)
659 Note = diag::note_explicit_instantiation_here;
660 }
else if (isa<TagDecl>(Instantiation)) {
661 Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
664 Note = diag::note_template_decl_here;
666 assert(isa<VarDecl>(Instantiation) &&
"Must be a VarDecl!");
667 if (isa<VarTemplateSpecializationDecl>(Instantiation)) {
668 Diag(PointOfInstantiation,
669 diag::err_explicit_instantiation_undefined_var_template)
673 Diag(PointOfInstantiation,
674 diag::err_explicit_instantiation_undefined_member)
677 Note = diag::note_explicit_instantiation_here;
700 if (getLangOpts().MicrosoftExt)
706 Diag(Loc, diag::err_template_param_shadow)
707 << cast<NamedDecl>(PrevDecl)->getDeclName();
715 if (
TemplateDecl *Temp = dyn_cast_or_null<TemplateDecl>(D)) {
716 D = Temp->getTemplatedDecl();
724 assert(
Kind == Template &&
725 "Only template template arguments can be pack expansions here");
726 assert(getAsTemplate().
get().containsUnexpandedParameterPack() &&
727 "Template template argument pack expansion without packs");
729 Result.EllipsisLoc = EllipsisLoc;
765 llvm_unreachable(
"Unhandled parsed template argument");
772 for (
unsigned I = 0, Last = TemplateArgsIn.size();
I != Last; ++
I)
804 "Template type parameter not in template parameter scope!");
810 bool IsParameterPack = EllipsisLoc.
isValid();
814 Typename, IsParameterPack);
822 IdResolver.AddDecl(Param);
828 if (DefaultArg && IsParameterPack) {
829 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
830 DefaultArg =
nullptr;
836 GetTypeFromParser(DefaultArg, &DefaultTInfo);
838 assert(DefaultTInfo &&
"expected source information for type");
841 if (DiagnoseUnexpandedParameterPack(Loc, DefaultTInfo,
842 UPPC_DefaultArgument))
846 if (CheckTemplateArgument(Param, DefaultTInfo)) {
873 return CheckNonTypeTemplateParameterType(TSI->
getType(), Loc);
881 Diag(Loc, diag::err_variably_modified_nontype_template_param)
919 Diag(Loc, diag::err_template_nontype_parm_bad_type)
934 diag::warn_cxx14_compat_template_nontype_parm_auto_type)
939 "Non-type template parameter not in template parameter scope!");
940 bool Invalid =
false;
955 IsParameterPack, TInfo);
967 IdResolver.AddDecl(Param);
973 if (Default && IsParameterPack) {
974 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
981 if (DiagnoseUnexpandedParameterPack(Default, UPPC_DefaultArgument))
986 CheckTemplateArgument(Param, Param->
getType(),
Default, Converted);
991 Default = DefaultRes.
get();
1013 "Template template parameter not in template parameter scope!");
1016 bool IsParameterPack = EllipsisLoc.
isValid();
1030 IdResolver.AddDecl(Param);
1033 if (Params->
size() == 0) {
1042 if (IsParameterPack && !Default.
isInvalid()) {
1043 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1058 Diag(DefaultArg.
getLocation(), diag::err_template_arg_not_valid_template)
1064 if (DiagnoseUnexpandedParameterPack(DefaultArg.
getLocation(),
1066 UPPC_DefaultArgument))
1085 Expr *RequiresClause) {
1087 Diag(ExportLoc, diag::warn_template_export_unsupported);
1090 Context, TemplateLoc, LAngleLoc,
1091 llvm::makeArrayRef((
NamedDecl *
const *)Params.data(), Params.size()),
1092 RAngleLoc, RequiresClause);
1108 unsigned NumOuterTemplateParamLists,
1111 assert(TemplateParams && TemplateParams->
size() > 0 &&
1112 "No template parameters");
1113 assert(TUK != TUK_Reference &&
"Can only declare or define class templates");
1114 bool Invalid =
false;
1117 if (CheckTemplateDeclScope(S, TemplateParams))
1121 assert(Kind !=
TTK_Enum &&
"can't build template of enumerated type");
1125 Diag(KWLoc, diag::err_template_unnamed_class);
1134 (SS.
isEmpty() && TUK == TUK_Friend)
1135 ? LookupTagName : LookupOrdinaryName,
1138 SemanticContext = computeDeclContext(SS,
true);
1139 if (!SemanticContext) {
1143 Diag(NameLoc, TUK == TUK_Friend
1144 ? diag::warn_template_qualified_friend_ignored
1145 : diag::err_template_qualified_declarator_no_match)
1147 return TUK != TUK_Friend;
1150 if (RequireCompleteDeclContext(SS, SemanticContext))
1158 if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams))
1160 }
else if (TUK != TUK_Friend && TUK != TUK_Reference)
1161 diagnoseQualifiedDeclaration(SS, SemanticContext, Name, NameLoc);
1163 LookupQualifiedName(Previous, SemanticContext);
1165 SemanticContext = CurContext;
1171 if (TUK != TUK_Friend &&
1172 DiagnoseClassNameShadow(SemanticContext,
1176 LookupName(Previous, S);
1183 if (Previous.
begin() != Previous.
end())
1184 PrevDecl = (*Previous.
begin())->getUnderlyingDecl();
1188 DiagnoseTemplateParameterShadow(NameLoc, PrevDecl);
1196 = dyn_cast_or_null<ClassTemplateDecl>(PrevDecl);
1201 if (!PrevClassTemplate && PrevDecl && isa<CXXRecordDecl>(PrevDecl) &&
1202 cast<CXXRecordDecl>(PrevDecl)->isInjectedClassName()) {
1205 = cast<CXXRecordDecl>(PrevDecl)->getDescribedClassTemplate();
1206 if (!PrevClassTemplate && isa<ClassTemplateSpecializationDecl>(PrevDecl)) {
1208 = cast<ClassTemplateSpecializationDecl>(PrevDecl)
1209 ->getSpecializedTemplate();
1213 if (TUK == TUK_Friend) {
1232 PrevDecl = PrevClassTemplate =
nullptr;
1233 SemanticContext = OutermostContext;
1237 Previous.
clear(LookupOrdinaryName);
1241 LookupQualifiedName(Previous, LookupContext);
1246 if (Previous.
begin() != Previous.
end())
1247 PrevDecl = (*Previous.
begin())->getUnderlyingDecl();
1250 }
else if (PrevDecl &&
1253 PrevDecl = PrevClassTemplate =
nullptr;
1255 if (
auto *Shadow = dyn_cast_or_null<UsingShadowDecl>(
1258 !(PrevClassTemplate &&
1261 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
1262 Diag(Shadow->getTargetDecl()->getLocation(),
1263 diag::note_using_decl_target);
1264 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl) << 0;
1266 PrevDecl = PrevClassTemplate =
nullptr;
1273 if (PrevClassTemplate) {
1277 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
1278 !TemplateParameterListsAreEqual(TemplateParams,
1286 const bool RedeclACMismatch = [&] {
1287 if (!(CurAC || PrevAC))
1289 if (CurAC && PrevAC) {
1290 llvm::FoldingSetNodeID CurACInfo, PrevACInfo;
1293 if (CurACInfo == PrevACInfo)
1299 if (RedeclACMismatch) {
1301 diag::err_template_different_associated_constraints);
1303 diag::note_template_prev_declaration) << 0;
1313 if (!isAcceptableTagRedeclaration(PrevRecordDecl, Kind,
1314 TUK == TUK_Definition, KWLoc, Name)) {
1315 Diag(KWLoc, diag::err_use_with_wrong_tag)
1323 if (TUK == TUK_Definition) {
1328 if (SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
1330 auto *Tmpl = cast<CXXRecordDecl>(Hidden)->getDescribedClassTemplate();
1331 assert(Tmpl &&
"original definition of a class template is not a "
1333 makeMergedDefinitionVisible(Hidden);
1334 makeMergedDefinitionVisible(Tmpl);
1338 Diag(NameLoc, diag::err_redefinition) <<
Name;
1339 Diag(Def->getLocation(), diag::note_previous_definition);
1345 }
else if (PrevDecl) {
1351 Diag(NameLoc, diag::err_redefinition_different_kind) <<
Name;
1360 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
1361 CheckTemplateParameterList(
1365 (SS.
isSet() && SemanticContext && SemanticContext->
isRecord() &&
1367 ? TPC_ClassTemplateMember
1368 : TUK == TUK_Friend ? TPC_FriendClassTemplate
1369 : TPC_ClassTemplate))
1375 if (!SS.
isInvalid() && !Invalid && !PrevClassTemplate) {
1376 Diag(NameLoc, TUK == TUK_Friend ? diag::err_friend_decl_does_not_match
1377 : diag::err_member_decl_does_not_match)
1378 << Name << SemanticContext <<
true << SS.
getRange();
1388 bool ShouldAddRedecl
1389 = !(TUK == TUK_Friend && CurContext->isDependentContext());
1393 PrevClassTemplate && ShouldAddRedecl ?
1397 if (NumOuterTemplateParamLists > 0)
1399 Context, llvm::makeArrayRef(OuterTemplateParamLists,
1400 NumOuterTemplateParamLists));
1404 if (TUK == TUK_Definition) {
1405 AddAlignmentAttributesForRecord(NewClass);
1406 AddMsStructLayoutForRecord(NewClass);
1411 Expr *
const ACtoAttach =
1412 PrevClassTemplate && ShouldAddRedecl ?
nullptr : CurAC;
1417 NewClass, ACtoAttach);
1419 if (ShouldAddRedecl)
1424 if (ModulePrivateLoc.
isValid())
1430 assert(T->
isDependentType() &&
"Class template type is not dependent?");
1435 if (PrevClassTemplate &&
1441 SetMemberAccessSpecifier(NewTemplate, PrevClassTemplate, AS);
1447 if (TUK == TUK_Definition)
1451 ProcessDeclAttributeList(S, NewClass, Attr);
1453 if (PrevClassTemplate)
1456 AddPushedVisibilityAttribute(NewClass);
1458 if (TUK != TUK_Friend) {
1463 PushOnScopeChains(NewTemplate, Outer);
1473 if (!CurContext->isDependentContext()) {
1476 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
1477 PushOnScopeChains(NewTemplate, EnclosingScope,
1484 CurContext->addDecl(Friend);
1492 ActOnDocumentableDecl(NewTemplate);
1500 struct ConvertConstructorToDeductionGuideTransform {
1501 ConvertConstructorToDeductionGuideTransform(
Sema &
S,
1503 : SemaRef(S), Template(Template) {}
1511 SemaRef.Context.DeclarationNames.getCXXDeductionGuideName(Template);
1517 unsigned Depth1IndexAdjustment = Template->getTemplateParameters()->size();
1537 AllParams.reserve(TemplateParams->
size() + InnerParams->
size());
1538 AllParams.insert(AllParams.begin(),
1539 TemplateParams->
begin(), TemplateParams->
end());
1540 SubstArgs.reserve(InnerParams->
size());
1548 NamedDecl *NewParam = transformTemplateParameter(Param, Args);
1551 AllParams.push_back(NewParam);
1552 SubstArgs.push_back(SemaRef.Context.getCanonicalTemplateArgument(
1553 SemaRef.Context.getInjectedTemplateArg(NewParam)));
1556 SemaRef.Context, InnerParams->getTemplateLoc(),
1557 InnerParams->getLAngleLoc(), AllParams, InnerParams->getRAngleLoc(),
1572 assert(FPTL &&
"no prototype for constructor declaration");
1579 QualType NewType = transformFunctionProtoType(TLB, FPTL, Params, Args);
1584 return buildDeductionGuide(TemplateParams, CD->
isExplicit(), NewTInfo,
1597 DeductionGuideName, EPI);
1598 TypeSourceInfo *TSI = SemaRef.Context.getTrivialTypeSourceInfo(Result, Loc);
1605 for (
auto T : ParamTypes) {
1607 SemaRef.Context, DC, Loc, Loc,
nullptr, T,
1608 SemaRef.Context.getTrivialTypeSourceInfo(T, Loc),
SC_None,
nullptr);
1610 FPTL.
setParam(Params.size(), NewParam);
1611 Params.push_back(NewParam);
1614 return buildDeductionGuide(Template->getTemplateParameters(),
false, TSI,
1624 if (
auto *TTP = dyn_cast<TemplateTypeParmDecl>(TemplateParam)) {
1628 SemaRef.Context, DC, TTP->getLocStart(), TTP->getLocation(),
1629 0, Depth1IndexAdjustment + TTP->getIndex(),
1630 TTP->getIdentifier(), TTP->wasDeclaredWithTypename(),
1631 TTP->isParameterPack());
1632 if (TTP->hasDefaultArgument()) {
1634 SemaRef.SubstType(TTP->getDefaultArgumentInfo(), Args,
1635 TTP->getDefaultArgumentLoc(), TTP->getDeclName());
1636 if (InstantiatedDefaultArg)
1637 NewTTP->setDefaultArgument(InstantiatedDefaultArg);
1639 SemaRef.CurrentInstantiationScope->InstantiatedLocal(TemplateParam,
1644 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(TemplateParam))
1645 return transformTemplateParameterImpl(TTP, Args);
1647 return transformTemplateParameterImpl(
1648 cast<NonTypeTemplateParmDecl>(TemplateParam), Args);
1650 template<
typename TemplateParmDecl>
1652 transformTemplateParameterImpl(TemplateParmDecl *OldParam,
1657 cast_or_null<TemplateParmDecl>(SemaRef.SubstDecl(OldParam, DC, Args));
1658 assert(NewParam->getDepth() == 0 &&
"unexpected template param depth");
1659 NewParam->setPosition(NewParam->getPosition() + Depth1IndexAdjustment);
1672 ParmVarDecl *NewParam = transformFunctionTypeParam(OldParam, Args);
1675 ParamTypes.push_back(NewParam->
getType());
1676 Params.push_back(NewParam);
1697 QualType Result = SemaRef.BuildFunctionType(
1698 ReturnType, ParamTypes, TL.
getLocStart(), DeductionGuideName, EPI);
1725 SemaRef.SubstType(PackTL.getPatternLoc(), Args,
1727 if (!NewDI)
return nullptr;
1729 SemaRef.CheckPackExpansion(NewDI, PackTL.getEllipsisLoc(),
1730 PackTL.getTypePtr()->getNumExpansions());
1732 NewDI = SemaRef.SubstType(OldDI, Args, OldParam->
getLocation(),
1743 NewDI = SemaRef.Context.getTrivialTypeSourceInfo(
1744 SemaRef.Context.getCanonicalType(NewDI->
getType()),
1784 Guide->setParams(Params);
1786 for (
auto *Param : Params)
1787 Param->setDeclContext(Guide);
1790 SemaRef.Context, DC, Loc, DeductionGuideName, TemplateParams, Guide);
1791 GuideTemplate->setImplicit();
1792 Guide->setDescribedFunctionTemplate(GuideTemplate);
1794 if (isa<CXXRecordDecl>(DC)) {
1799 DC->addDecl(GuideTemplate);
1800 return GuideTemplate;
1811 ConvertConstructorToDeductionGuideTransform Transform(
1812 *
this, cast<ClassTemplateDecl>(Template));
1813 if (!isCompleteType(Loc, Transform.DeducedType))
1818 auto Existing = DC->
lookup(Transform.DeductionGuideName);
1819 for (
auto *D : Existing)
1820 if (D->isImplicit())
1836 bool AddedAny =
false;
1837 bool AddedCopyOrMove =
false;
1838 for (
NamedDecl *D : LookupConstructors(Transform.Primary)) {
1839 D = D->getUnderlyingDecl();
1840 if (D->isInvalidDecl() || D->isImplicit())
1842 D = cast<NamedDecl>(D->getCanonicalDecl());
1846 dyn_cast_or_null<CXXConstructorDecl>(FTD ? FTD->getTemplatedDecl() : D);
1849 if (!CD || (!FTD && CD->isFunctionTemplateSpecialization()))
1852 Transform.transformConstructor(FTD, CD);
1855 AddedCopyOrMove |= CD->isCopyOrMoveConstructor();
1861 Transform.buildSimpleDeductionGuide(
None);
1866 if (!AddedCopyOrMove)
1867 Transform.buildSimpleDeductionGuide(Transform.DeducedType);
1895 diag::warn_cxx98_compat_template_parameter_default_in_function_template
1896 : diag::ext_template_parameter_default_in_function_template)
1905 S.
Diag(ParamLoc, diag::err_template_parameter_default_template_member)
1914 S.
Diag(ParamLoc, diag::err_template_parameter_default_friend_template)
1923 llvm_unreachable(
"Invalid TemplateParamListContext!");
1936 for (
unsigned I = 0, N = Params->
size();
I != N; ++
I) {
1939 if (!NTTP->isParameterPack() &&
1941 NTTP->getTypeSourceInfo(),
1949 = dyn_cast<TemplateTemplateParmDecl>(P))
1982 bool Invalid =
false;
1990 bool SawDefaultArgument =
false;
1996 OldParam = OldParams->
begin();
1998 bool RemoveDefaultArguments =
false;
2000 NewParamEnd = NewParams->
end();
2001 NewParam != NewParamEnd; ++NewParam) {
2003 bool RedundantDefaultArg =
false;
2008 bool MissingDefaultArg =
false;
2011 bool SawParameterPack =
false;
2014 = dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
2016 if (NewTypeParm->hasDefaultArgument() &&
2018 NewTypeParm->getLocation(),
2019 NewTypeParm->getDefaultArgumentInfo()->getTypeLoc()
2021 NewTypeParm->removeDefaultArgument();
2025 = OldParams? cast<TemplateTypeParmDecl>(*OldParam) :
nullptr;
2026 if (NewTypeParm->isParameterPack()) {
2027 assert(!NewTypeParm->hasDefaultArgument() &&
2028 "Parameter packs can't have a default argument!");
2029 SawParameterPack =
true;
2031 NewTypeParm->hasDefaultArgument()) {
2033 NewDefaultLoc = NewTypeParm->getDefaultArgumentLoc();
2034 SawDefaultArgument =
true;
2035 RedundantDefaultArg =
true;
2036 PreviousDefaultArgLoc = NewDefaultLoc;
2040 NewTypeParm->setInheritedDefaultArgument(
Context, OldTypeParm);
2042 }
else if (NewTypeParm->hasDefaultArgument()) {
2043 SawDefaultArgument =
true;
2044 PreviousDefaultArgLoc = NewTypeParm->getDefaultArgumentLoc();
2045 }
else if (SawDefaultArgument)
2046 MissingDefaultArg =
true;
2048 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
2050 if (!NewNonTypeParm->isParameterPack() &&
2051 DiagnoseUnexpandedParameterPack(NewNonTypeParm->getLocation(),
2052 NewNonTypeParm->getTypeSourceInfo(),
2053 UPPC_NonTypeTemplateParameterType)) {
2059 if (NewNonTypeParm->hasDefaultArgument() &&
2061 NewNonTypeParm->getLocation(),
2062 NewNonTypeParm->getDefaultArgument()->getSourceRange())) {
2063 NewNonTypeParm->removeDefaultArgument();
2068 = OldParams? cast<NonTypeTemplateParmDecl>(*OldParam) :
nullptr;
2069 if (NewNonTypeParm->isParameterPack()) {
2070 assert(!NewNonTypeParm->hasDefaultArgument() &&
2071 "Parameter packs can't have a default argument!");
2072 if (!NewNonTypeParm->isPackExpansion())
2073 SawParameterPack =
true;
2075 NewNonTypeParm->hasDefaultArgument()) {
2077 NewDefaultLoc = NewNonTypeParm->getDefaultArgumentLoc();
2078 SawDefaultArgument =
true;
2079 RedundantDefaultArg =
true;
2080 PreviousDefaultArgLoc = NewDefaultLoc;
2084 NewNonTypeParm->setInheritedDefaultArgument(
Context, OldNonTypeParm);
2086 }
else if (NewNonTypeParm->hasDefaultArgument()) {
2087 SawDefaultArgument =
true;
2088 PreviousDefaultArgLoc = NewNonTypeParm->getDefaultArgumentLoc();
2089 }
else if (SawDefaultArgument)
2090 MissingDefaultArg =
true;
2093 = cast<TemplateTemplateParmDecl>(*NewParam);
2110 = OldParams? cast<TemplateTemplateParmDecl>(*OldParam) :
nullptr;
2113 "Parameter packs can't have a default argument!");
2115 SawParameterPack =
true;
2116 }
else if (OldTemplateParm &&
2121 SawDefaultArgument =
true;
2122 RedundantDefaultArg =
true;
2123 PreviousDefaultArgLoc = NewDefaultLoc;
2128 PreviousDefaultArgLoc
2131 SawDefaultArgument =
true;
2132 PreviousDefaultArgLoc
2134 }
else if (SawDefaultArgument)
2135 MissingDefaultArg =
true;
2141 if (SawParameterPack && (NewParam + 1) != NewParamEnd &&
2142 (TPC == TPC_ClassTemplate || TPC == TPC_VarTemplate ||
2143 TPC == TPC_TypeAliasTemplate)) {
2144 Diag((*NewParam)->getLocation(),
2145 diag::err_template_param_pack_must_be_last_template_parameter);
2149 if (RedundantDefaultArg) {
2153 Diag(NewDefaultLoc, diag::err_template_param_default_arg_redefinition);
2154 Diag(OldDefaultLoc, diag::note_template_param_prev_default_arg);
2156 }
else if (MissingDefaultArg && TPC != TPC_FunctionTemplate) {
2162 Diag((*NewParam)->getLocation(),
2163 diag::err_template_param_default_arg_missing);
2164 Diag(PreviousDefaultArgLoc, diag::note_template_param_prev_default_arg);
2166 RemoveDefaultArguments =
true;
2177 if (RemoveDefaultArguments) {
2179 NewParamEnd = NewParams->
end();
2180 NewParam != NewParamEnd; ++NewParam) {
2182 TTP->removeDefaultArgument();
2184 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
2185 NTTP->removeDefaultArgument();
2187 cast<TemplateTemplateParmDecl>(*NewParam)->removeDefaultArgument();
2207 bool IgnoreNonTypeDependent;
2212 DependencyChecker(
unsigned Depth,
bool IgnoreNonTypeDependent)
2213 : Depth(Depth), IgnoreNonTypeDependent(IgnoreNonTypeDependent),
2217 : IgnoreNonTypeDependent(IgnoreNonTypeDependent), Match(
false) {
2220 Depth = PD->getDepth();
2222 dyn_cast<NonTypeTemplateParmDecl>(ND)) {
2223 Depth = PD->getDepth();
2225 Depth = cast<TemplateTemplateParmDecl>(ND)->getDepth();
2230 if (ParmDepth >=
Depth) {
2238 bool TraverseStmt(
Stmt *
S, DataRecursionQueue *Q =
nullptr) {
2243 if (
auto *
E = dyn_cast_or_null<Expr>(S))
2244 if (IgnoreNonTypeDependent && !
E->isTypeDependent())
2246 return super::TraverseStmt(S, Q);
2249 bool TraverseTypeLoc(
TypeLoc TL) {
2250 if (IgnoreNonTypeDependent && !TL.
isNull() &&
2253 return super::TraverseTypeLoc(TL);
2270 return super::TraverseTemplateName(N);
2275 dyn_cast<NonTypeTemplateParmDecl>(E->
getDecl()))
2278 return super::VisitDeclRefExpr(E);
2300 DependencyChecker Checker(Params,
false);
2301 Checker.TraverseType(T);
2302 return Checker.Match;
2312 if (
const Type *CurType = NNS->getAsType()) {
2318 NNSLoc = NNSLoc.getPrefix();
2361 bool &IsMemberSpecialization,
bool &Invalid) {
2362 IsMemberSpecialization =
false;
2372 = dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS,
true)))
2384 NestedTypes.push_back(T);
2390 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
2391 if (!isa<ClassTemplatePartialSpecializationDecl>(Spec) &&
2393 ExplicitSpecLoc = Spec->getLocation();
2396 }
else if (Record->getTemplateSpecializationKind()
2398 ExplicitSpecLoc = Record->getLocation();
2402 if (
TypeDecl *Parent = dyn_cast<TypeDecl>(Record->getParent()))
2411 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
2412 if (
TypeDecl *Parent = dyn_cast<TypeDecl>(Template->getDeclContext()))
2457 std::reverse(NestedTypes.begin(), NestedTypes.end());
2465 bool SawNonEmptyTemplateParameterList =
false;
2467 auto CheckExplicitSpecialization = [&](
SourceRange Range,
bool Recovery) {
2468 if (SawNonEmptyTemplateParameterList) {
2469 Diag(DeclLoc, diag::err_specialize_member_of_template)
2470 << !Recovery << Range;
2472 IsMemberSpecialization =
false;
2479 auto DiagnoseMissingExplicitSpecialization = [&] (
SourceRange Range) {
2481 if (CheckExplicitSpecialization(Range,
true))
2486 if (!ParamLists.empty())
2487 ExpectedTemplateLoc = ParamLists[0]->getTemplateLoc();
2489 ExpectedTemplateLoc = DeclStartLoc;
2491 Diag(DeclLoc, diag::err_template_spec_needs_header)
2497 unsigned ParamIdx = 0;
2498 for (
unsigned TypeIdx = 0, NumTypes = NestedTypes.size(); TypeIdx != NumTypes;
2500 T = NestedTypes[TypeIdx];
2503 bool NeedEmptyTemplateHeader =
false;
2506 bool NeedNonemptyTemplateHeader =
false;
2519 = dyn_cast<ClassTemplatePartialSpecializationDecl>(Record)) {
2520 ExpectedTemplateParams = Partial->getTemplateParameters();
2521 NeedNonemptyTemplateHeader =
true;
2522 }
else if (Record->isDependentType()) {
2523 if (Record->getDescribedClassTemplate()) {
2524 ExpectedTemplateParams = Record->getDescribedClassTemplate()
2525 ->getTemplateParameters();
2526 NeedNonemptyTemplateHeader =
true;
2529 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
2535 NeedEmptyTemplateHeader =
true;
2538 }
else if (Record->getTemplateSpecializationKind()) {
2539 if (Record->getTemplateSpecializationKind()
2541 TypeIdx == NumTypes - 1)
2542 IsMemberSpecialization =
true;
2548 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
2549 ExpectedTemplateParams = Template->getTemplateParameters();
2550 NeedNonemptyTemplateHeader =
true;
2555 NeedNonemptyTemplateHeader =
false;
2565 if (ParamIdx < ParamLists.size()) {
2566 if (ParamLists[ParamIdx]->size() == 0) {
2567 if (CheckExplicitSpecialization(ParamLists[ParamIdx]->
getSourceRange(),
2571 SawNonEmptyTemplateParameterList =
true;
2574 if (NeedEmptyTemplateHeader) {
2577 if (TypeIdx == NumTypes - 1)
2578 IsMemberSpecialization =
true;
2580 if (ParamIdx < ParamLists.size()) {
2581 if (ParamLists[ParamIdx]->size() > 0) {
2583 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
2584 diag::err_template_param_list_matches_nontemplate)
2586 <<
SourceRange(ParamLists[ParamIdx]->getLAngleLoc(),
2587 ParamLists[ParamIdx]->getRAngleLoc())
2599 if (DiagnoseMissingExplicitSpecialization(
2606 if (NeedNonemptyTemplateHeader) {
2612 if (ParamIdx < ParamLists.size() &&
2614 ExpectedTemplateParams =
nullptr;
2619 if (ParamIdx < ParamLists.size()) {
2621 if (ExpectedTemplateParams &&
2622 !TemplateParameterListsAreEqual(ParamLists[ParamIdx],
2623 ExpectedTemplateParams,
2624 true, TPL_TemplateMatch))
2628 CheckTemplateParameterList(ParamLists[ParamIdx],
nullptr,
2629 TPC_ClassTemplateMember))
2636 Diag(DeclLoc, diag::err_template_spec_needs_template_parameters)
2647 if (ParamIdx >= ParamLists.size()) {
2648 if (TemplateId && !IsFriend) {
2664 if (ParamIdx < ParamLists.size() - 1) {
2665 bool HasAnyExplicitSpecHeader =
false;
2666 bool AllExplicitSpecHeaders =
true;
2667 for (
unsigned I = ParamIdx, E = ParamLists.size() - 1;
I !=
E; ++
I) {
2668 if (ParamLists[
I]->size() == 0)
2669 HasAnyExplicitSpecHeader =
true;
2671 AllExplicitSpecHeaders =
false;
2674 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
2675 AllExplicitSpecHeaders ? diag::warn_template_spec_extra_headers
2676 : diag::err_template_spec_extra_headers)
2677 <<
SourceRange(ParamLists[ParamIdx]->getTemplateLoc(),
2678 ParamLists[ParamLists.size() - 2]->getRAngleLoc());
2683 if (ExplicitSpecLoc.
isValid() && HasAnyExplicitSpecHeader)
2684 Diag(ExplicitSpecLoc,
2685 diag::note_explicit_template_spec_does_not_need_header)
2686 << NestedTypes.back();
2691 if (!AllExplicitSpecHeaders)
2702 if (ParamLists.back()->size() == 0 &&
2703 CheckExplicitSpecialization(ParamLists[ParamIdx]->
getSourceRange(),
2709 return ParamLists.back();
2714 Diag(Template->getLocation(), diag::note_template_declared_here)
2715 << (isa<FunctionTemplateDecl>(Template)
2717 : isa<ClassTemplateDecl>(Template)
2719 : isa<VarTemplateDecl>(Template)
2721 : isa<TypeAliasTemplateDecl>(Template) ? 3 : 4)
2722 << Template->getDeclName();
2730 Diag((*I)->getLocation(), diag::note_template_declared_here)
2731 << 0 << (*I)->getDeclName();
2750 if (!Converted[1].getAsType()->isIntegralType(Context)) {
2751 SemaRef.
Diag(TemplateArgs[1].getLocation(),
2752 diag::err_integer_sequence_integral_element_type);
2761 SemaRef.
Diag(TemplateArgs[2].getLocation(),
2762 diag::err_integer_sequence_negative_length);
2770 SyntheticTemplateArgs.
addArgument(TemplateArgs[1]);
2772 for (llvm::APSInt
I(NumArgs.getBitWidth(), NumArgs.isUnsigned());
2776 TA, ArgTy, TemplateArgs[2].getLocation()));
2781 TemplateLoc, SyntheticTemplateArgs);
2788 assert(Converted.size() == 2 &&
2789 "__type_pack_element should be given an index and a parameter pack");
2793 llvm::APSInt Index = IndexArg.getAsIntegral();
2794 assert(Index >= 0 &&
"the index used with __type_pack_element should be of "
2795 "type std::size_t, and hence be non-negative");
2796 if (Index >= Ts.pack_size()) {
2797 SemaRef.
Diag(TemplateArgs[0].getLocation(),
2798 diag::err_type_pack_element_out_of_bounds);
2803 auto Nth = std::next(Ts.pack_begin(), Index.getExtValue());
2804 return Nth->getAsType();
2806 llvm_unreachable(
"unexpected BuiltinTemplateDecl!");
2811 return AliasTemplate->
getName().equals(
"enable_if_t");
2823 if (BinOp->getOpcode() == BO_LAnd) {
2831 Terms.push_back(Clause);
2840 if (!BinOp)
return Cond;
2842 if (BinOp->getOpcode() != BO_LOr)
return Cond;
2845 Expr *LHS = BinOp->getLHS();
2847 if (!InnerBinOp)
return Cond;
2849 if (InnerBinOp->getOpcode() != BO_EQ ||
2850 !isa<IntegerLiteral>(InnerBinOp->getRHS()))
2860 if (MacroName ==
"CONCEPT_REQUIRES" || MacroName ==
"CONCEPT_REQUIRES_")
2861 return BinOp->getRHS();
2868 static std::pair<Expr *, std::string>
2877 Expr *FailedCond =
nullptr;
2878 for (
Expr *Term : Terms) {
2885 if (Term->EvaluateAsBooleanCondition(Succeeded, S.
Context) &&
2895 std::string Description;
2897 llvm::raw_string_ostream Out(Description);
2901 return { FailedCond, Description };
2920 if (!Template || isa<FunctionTemplateDecl>(Template) ||
2921 isa<VarTemplateDecl>(Template)) {
2927 Diag(TemplateLoc, diag::err_template_id_not_a_type)
2929 NoteAllFoundTemplates(Name);
2936 if (CheckTemplateArgumentList(Template, TemplateLoc, TemplateArgs,
2942 bool InstantiationDependent =
false;
2944 dyn_cast<TypeAliasTemplateDecl>(Template)) {
2956 unsigned Depth = AliasTemplate->getTemplateParameters()->getDepth();
2957 for (
unsigned I = 0;
I <
Depth; ++
I)
2966 TemplateArgLists, AliasTemplate->getLocation(),
2967 AliasTemplate->getDeclName());
2968 if (CanonType.
isNull()) {
2973 if (
auto DeductionInfo = isSFINAEContext()) {
2974 if (*DeductionInfo &&
2975 (*DeductionInfo)->hasSFINAEDiagnostic() &&
2976 (*DeductionInfo)->peekSFINAEDiagnostic().second.getDiagID() ==
2977 diag::err_typename_nested_not_found_enable_if &&
2978 TemplateArgs[0].getArgument().getKind()
2981 std::string FailedDescription;
2982 std::tie(FailedCond, FailedDescription) =
2984 *
this, TemplateArgs[0].getSourceExpression());
2989 (*DeductionInfo)->takeSFINAEDiagnostic(OldDiag);
2993 (*DeductionInfo)->addSFINAEDiagnostic(
2995 PDiag(diag::err_typename_nested_not_found_requirement)
2996 << FailedDescription
3006 TemplateArgs, InstantiationDependent)) {
3022 if (isa<ClassTemplateDecl>(Template)) {
3025 if (Ctx->isFileContext())
break;
3029 if (!Record)
continue;
3033 if (!isa<ClassTemplatePartialSpecializationDecl>(Record) &&
3040 QualType Injected = cast<InjectedClassNameType>(ICNT)
3041 ->getInjectedSpecializationType();
3054 = dyn_cast<ClassTemplateDecl>(Template)) {
3057 void *InsertPos =
nullptr;
3059 = ClassTemplate->findSpecialization(Converted, InsertPos);
3065 ClassTemplate->getTemplatedDecl()->getTagKind(),
3066 ClassTemplate->getDeclContext(),
3067 ClassTemplate->getTemplatedDecl()->getLocStart(),
3068 ClassTemplate->getLocation(),
3070 Converted,
nullptr);
3071 ClassTemplate->AddSpecialization(Decl, InsertPos);
3072 if (ClassTemplate->isOutOfLine())
3079 InstantiateAttrsForDecl(TemplateArgLists, ClassTemplate->getTemplatedDecl(),
3084 (void)DiagnoseUseOfDecl(Decl, TemplateLoc);
3087 assert(isa<RecordType>(CanonType) &&
3088 "type of non-dependent specialization is not a RecordType");
3089 }
else if (
auto *BTD = dyn_cast<BuiltinTemplateDecl>(Template)) {
3107 bool IsCtorOrDtorName,
bool IsClassName) {
3111 if (!IsCtorOrDtorName && !IsClassName && SS.
isSet()) {
3112 DeclContext *LookupCtx = computeDeclContext(SS,
false);
3120 if (!LookupCtx && isDependentScopeSpecifier(SS)) {
3127 return ActOnTypenameType(
nullptr,
SourceLocation(), SS, TemplateKWLoc,
3128 TemplateD, TemplateII, TemplateIILoc, LAngleLoc,
3129 TemplateArgsIn, RAngleLoc);
3136 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
3137 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
3140 ? diag::err_out_of_line_qualified_id_type_names_constructor
3141 : diag::ext_out_of_line_qualified_id_type_names_constructor)
3151 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
3156 DTN->getQualifier(),
3157 DTN->getIdentifier(),
3174 QualType Result = CheckTemplateIdType(Template, TemplateIILoc, TemplateArgs);
3186 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
3217 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
3226 DTN->getQualifier(),
3227 DTN->getIdentifier(),
3251 Diag(TemplateLoc, diag::err_tag_reference_non_tag)
3252 << TAT << NTK_TypeAliasTemplate << TagKind;
3253 Diag(TAT->getLocation(), diag::note_declared_at);
3256 QualType Result = CheckTemplateIdType(Template, TemplateLoc, TemplateArgs);
3265 assert(Id &&
"templated class must have an identifier");
3267 if (!isAcceptableTagRedeclaration(D, TagKind, TUK == TUK_Definition,
3269 Diag(TagLoc, diag::err_use_with_wrong_tag)
3284 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
3333 dyn_cast_or_null<TemplateTemplateParmDecl>(
3337 llvm_unreachable(
"unexpected kind of template argument");
3342 if (Params->
size() != Args.size())
3347 for (
unsigned I = 0, N = Args.size();
I != N; ++
I) {
3374 return TemplateArgs;
3377 template<
typename PartialSpecDecl>
3379 if (Partial->getDeclContext()->isDependentContext())
3388 auto *Template = Partial->getSpecializedTemplate();
3389 S.
Diag(Partial->getLocation(),
3390 diag::ext_partial_spec_not_more_specialized_than_primary)
3391 << isa<VarTemplateDecl>(Template);
3393 if (Info.hasSFINAEDiagnostic()) {
3396 Info.takeSFINAEDiagnostic(Diag);
3400 diag::note_partial_spec_not_more_specialized_than_primary)
3404 S.
Diag(Template->getLocation(), diag::note_template_decl_here);
3409 const llvm::SmallBitVector &DeducibleParams) {
3410 for (
unsigned I = 0, N = DeducibleParams.size();
I != N; ++
I) {
3411 if (!DeducibleParams[
I]) {
3424 template<
typename PartialSpecDecl>
3426 PartialSpecDecl *Partial) {
3439 auto *TemplateParams = Partial->getTemplateParameters();
3440 llvm::SmallBitVector DeducibleParams(TemplateParams->
size());
3442 TemplateParams->
getDepth(), DeducibleParams);
3444 if (!DeducibleParams.all()) {
3445 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
3446 S.
Diag(Partial->getLocation(), diag::ext_partial_specs_not_deducible)
3447 << isa<VarTemplatePartialSpecializationDecl>(Partial)
3448 << (NumNonDeducible > 1)
3450 Partial->getTemplateArgsAsWritten()->RAngleLoc);
3471 llvm::SmallBitVector DeducibleParams(TemplateParams->
size());
3472 MarkDeducedTemplateParameters(TD, DeducibleParams);
3473 for (
unsigned I = 0;
I != TemplateParams->
size(); ++
I) {
3475 auto *Param = TemplateParams->
getParam(
I);
3477 DeducibleParams[
I] =
true;
3480 if (!DeducibleParams.all()) {
3481 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
3482 Diag(TD->
getLocation(), diag::err_deduction_guide_template_not_deducible)
3483 << (NumNonDeducible > 1);
3494 "Variable template specialization is declared with a template it.");
3511 FnTemplate = *OTS->begin();
3518 << IsPartialSpecialization;
3522 for (
unsigned I = 0, N = TemplateArgs.
size();
I != N; ++
I)
3523 if (DiagnoseUnexpandedParameterPack(TemplateArgs[
I],
3524 UPPC_PartialSpecialization))
3530 if (CheckTemplateArgumentList(VarTemplate, TemplateNameLoc, TemplateArgs,
3536 if (IsPartialSpecialization) {
3537 if (CheckTemplatePartialSpecializationArgs(TemplateNameLoc, VarTemplate,
3538 TemplateArgs.
size(), Converted))
3543 bool InstantiationDependent;
3547 InstantiationDependent)) {
3548 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
3550 IsPartialSpecialization =
false;
3559 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
3561 << (SC !=
SC_Extern && !CurContext->isRecord())
3569 void *InsertPos =
nullptr;
3572 if (IsPartialSpecialization)
3584 IsPartialSpecialization))
3592 Specialization = PrevDecl;
3595 }
else if (IsPartialSpecialization) {
3598 cast_or_null<VarTemplatePartialSpecializationDecl>(PrevDecl);
3602 TemplateNameLoc, TemplateParams, VarTemplate, DI->
getType(), DI, SC,
3603 Converted, TemplateArgs);
3606 VarTemplate->AddPartialSpecialization(Partial, InsertPos);
3607 Specialization = Partial;
3614 CheckTemplatePartialSpecialization(Partial);
3620 VarTemplate, DI->
getType(), DI, SC, Converted);
3624 VarTemplate->AddSpecialization(Specialization, InsertPos);
3645 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
3649 diag::note_instantiation_required_here)
3662 CurContext->addDecl(Specialization);
3670 LookupResult PrevSpec(*
this, GetNameForDeclarator(D), LookupOrdinaryName,
3686 return Specialization;
3692 struct PartialSpecMatchResult {
3702 assert(Template &&
"A variable template id without template?");
3706 if (CheckTemplateArgumentList(
3707 Template, TemplateNameLoc,
3708 const_cast<TemplateArgumentListInfo &>(TemplateArgs),
false,
3714 void *InsertPos =
nullptr;
3716 Converted, InsertPos)) {
3717 checkSpecializationVisibility(TemplateNameLoc, Spec);
3730 bool AmbiguousPartialSpec =
false;
3731 typedef PartialSpecMatchResult MatchResult;
3746 bool InstantiationDependent =
false;
3748 TemplateArgs, InstantiationDependent)) {
3753 for (
unsigned I = 0, N = PartialSpecs.size();
I != N; ++
I) {
3766 Matched.push_back(PartialSpecMatchResult());
3767 Matched.back().Partial = Partial;
3768 Matched.back().Args = Info.take();
3772 if (Matched.size() >= 1) {
3774 if (Matched.size() == 1) {
3787 PEnd = Matched.end();
3789 if (getMoreSpecializedPartialSpecialization(
P->Partial, Best->Partial,
3790 PointOfInstantiation) ==
3798 PEnd = Matched.end();
3800 if (
P != Best && getMoreSpecializedPartialSpecialization(
3801 P->Partial, Best->Partial,
3802 PointOfInstantiation) != Best->Partial) {
3803 AmbiguousPartialSpec =
true;
3810 InstantiationPattern = Best->Partial;
3811 InstantiationArgs = Best->Args;
3824 Template, InstantiationPattern, *InstantiationArgs, TemplateArgs,
3825 Converted, TemplateNameLoc, InsertPos );
3829 if (AmbiguousPartialSpec) {
3832 Diag(PointOfInstantiation, diag::err_partial_spec_ordering_ambiguous)
3836 for (MatchResult
P : Matched)
3837 Diag(
P.Partial->getLocation(), diag::note_partial_spec_match)
3838 << getTemplateArgumentBindingsText(
P.Partial->getTemplateParameters(),
3844 dyn_cast<VarTemplatePartialSpecializationDecl>(InstantiationPattern))
3847 checkSpecializationVisibility(TemplateNameLoc, Decl);
3849 assert(Decl &&
"No variable template specialization?");
3870 return BuildDeclarationNameExpr(SS, NameInfo, Var,
3871 nullptr, TemplateArgs);
3890 assert(!R.
empty() &&
"empty lookup results when building templateid");
3891 assert(!R.
isAmbiguous() &&
"ambiguous lookup when building templateid");
3894 bool InstantiationDependent;
3897 *TemplateArgs, InstantiationDependent)) {
3900 TemplateKWLoc, TemplateArgs);
3911 RequiresADL, TemplateArgs,
3924 assert(TemplateArgs || TemplateKWLoc.
isValid());
3926 if (!(DC = computeDeclContext(SS,
false)) ||
3927 DC->isDependentContext() ||
3928 RequireCompleteDeclContext(SS, DC))
3929 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
3931 bool MemberOfUnknownSpecialization;
3933 LookupTemplateName(R, (
Scope*)
nullptr, SS,
QualType(),
false,
3934 MemberOfUnknownSpecialization);
3940 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_non_template)
3946 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_class_template)
3949 Diag(Temp->getLocation(), diag::note_referenced_class_template);
3953 return BuildTemplateIdExpr(SS, TemplateKWLoc, R,
false, TemplateArgs);
3968 bool EnteringContext,
3970 bool AllowInjectedClassName) {
3973 getLangOpts().CPlusPlus11 ?
3974 diag::warn_cxx98_compat_template_outside_of_template :
3975 diag::ext_template_outside_of_template)
3980 LookupCtx = computeDeclContext(SS, EnteringContext);
3981 if (!LookupCtx && ObjectType)
3982 LookupCtx = computeDeclContext(ObjectType.
get());
4000 bool MemberOfUnknownSpecialization;
4002 ObjectType, EnteringContext, Result,
4003 MemberOfUnknownSpecialization);
4005 isa<CXXRecordDecl>(LookupCtx) &&
4006 (!cast<CXXRecordDecl>(LookupCtx)->hasDefinition() ||
4007 cast<CXXRecordDecl>(LookupCtx)->hasAnyDependentBases())) {
4011 diag::err_template_kw_refers_to_non_template)
4012 << GetNameFromUnqualifiedId(Name).getName()
4019 if (!AllowInjectedClassName && SS.
isSet() && LookupRD &&
4021 LookupRD->getIdentifier() == Name.
Identifier) {
4032 diag::ext_out_of_line_qualified_id_type_names_constructor)
4054 llvm_unreachable(
"literal operator id cannot have a dependent scope");
4061 diag::err_template_kw_refers_to_non_template)
4062 << GetNameFromUnqualifiedId(Name).getName()
4090 << (
int)getTemplateNameKindForDiagnostics(Name) << Name << SR;
4103 SS.
Adopt(ArgExpr->getQualifierLoc());
4104 NameInfo = ArgExpr->getNameInfo();
4106 dyn_cast<DependentScopeDeclRefExpr>(Arg.
getAsExpr())) {
4107 SS.
Adopt(ArgExpr->getQualifierLoc());
4108 NameInfo = ArgExpr->getNameInfo();
4110 dyn_cast<CXXDependentScopeMemberExpr>(Arg.
getAsExpr())) {
4111 if (ArgExpr->isImplicitAccess()) {
4112 SS.
Adopt(ArgExpr->getQualifierLoc());
4113 NameInfo = ArgExpr->getMemberNameInfo();
4118 LookupResult Result(*
this, NameInfo, LookupOrdinaryName);
4119 LookupParsedName(Result, CurScope, &SS);
4126 Diag(Loc, getLangOpts().MSVCCompat
4127 ? diag::ext_ms_template_type_arg_missing_typename
4128 : diag::err_template_arg_must_be_type_suggest)
4158 Diag(SR.
getBegin(), diag::err_template_arg_must_be_type) << SR;
4165 if (CheckTemplateArgument(Param, TSI))
4174 if (getLangOpts().ObjCAutoRefCount &&
4220 Param, Template, Converted,
4230 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4235 SemaRef.
SubstType(ArgType, TemplateArgLists,
4272 Param, Template, Converted,
4282 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4334 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4364 bool &HasDefaultArg) {
4365 HasDefaultArg =
false;
4371 HasDefaultArg =
true;
4384 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
4388 HasDefaultArg =
true;
4402 = cast<TemplateTemplateParmDecl>(Param);
4406 HasDefaultArg =
true;
4429 if (ETLoc.getTypePtr()->getKeyword() !=
ETK_None)
4432 QualLoc = ETLoc.getQualifierLoc();
4433 TLoc = ETLoc.getNamedTypeLoc();
4440 QualLoc, InjLoc.getNameLoc());
4448 dyn_cast<ClassTemplateSpecializationDecl>(RecLoc.getDecl()))
4450 QualLoc, RecLoc.getNameLoc());
4486 unsigned ArgumentPackIndex,
4491 return CheckTemplateTypeArgument(TTP, Arg, Converted);
4498 QualType NTTPType = NTTP->getType();
4499 if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack())
4500 NTTPType = NTTP->getExpansionType(ArgumentPackIndex);
4503 !isa<TemplateTemplateParmDecl>(Template) &&
4514 NTTPType = SubstType(NTTPType,
4516 NTTP->getLocation(),
4517 NTTP->getDeclName());
4521 NTTPType = CheckNonTypeTemplateParameterType(NTTPType,
4522 NTTP->getLocation());
4529 llvm_unreachable(
"Should never see a NULL template argument here");
4546 Converted.push_back(Result);
4580 Context, SS.getWithLocInContext(
Context), TemplateKWLoc, NameInfo,
4592 E = CheckTemplateArgument(NTTP, NTTPType, E.
get(), Result);
4596 Converted.push_back(Result);
4623 Diag(SR.
getBegin(), diag::err_template_arg_nontype_ambig) << SR << T;
4625 Diag(SR.
getBegin(), diag::err_template_arg_must_be_expr) << SR;
4631 llvm_unreachable(
"Caller must expand template argument packs");
4648 TempParm, Converted,
4654 TempParm = cast_or_null<TemplateTemplateParmDecl>(
4655 SubstDecl(TempParm, CurContext,
4674 llvm_unreachable(
"Should never see a NULL template argument here");
4678 if (CheckTemplateArgument(TempParm, Arg, ArgumentPackIndex))
4689 << getLangOpts().CPlusPlus11;
4693 llvm_unreachable(
"Declaration argument with template template parameter");
4695 llvm_unreachable(
"Integral argument with template template parameter");
4697 llvm_unreachable(
"Null pointer argument with template template parameter");
4700 llvm_unreachable(
"Caller must expand template argument packs");
4711 unsigned NumParams = Params->
size();
4712 unsigned NumArgs = TemplateArgs.
size();
4715 if (NumArgs > NumParams)
4716 Range =
SourceRange(TemplateArgs[NumParams].getLocation(),
4718 S.
Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
4719 << (NumArgs > NumParams)
4721 << Template << Range;
4740 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
4741 if (NTTP->isExpandedParameterPack())
4742 return NTTP->getNumExpansionTypes();
4746 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
4747 if (TTP->isExpandedParameterPack())
4748 return TTP->getNumExpansionTemplateParameters();
4755 template<
typename TemplateParmDecl>
4758 const TemplateParmDecl *D,
4763 ->getTemplateParameters()
4764 ->getParam(D->getIndex()));
4771 D->getDefaultArgumentLoc(), Modules,
4789 bool UpdateArgsWithConversions) {
4804 bool isTemplateTemplateParameter = isa<TemplateTemplateParmDecl>(Template);
4806 unsigned ArgIdx = 0, NumArgs = NewArgs.
size();
4809 ParamEnd = Params->
end();
4810 Param != ParamEnd; ) {
4814 if (*Expansions == ArgumentPack.size()) {
4817 Converted.push_back(
4819 ArgumentPack.clear();
4824 }
else if (ArgIdx == NumArgs && !PartialTemplateArgs) {
4826 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
4828 << (int)getTemplateNameKindForDiagnostics(
TemplateName(Template))
4836 if (ArgIdx < NumArgs) {
4838 if (CheckTemplateArgument(*Param, NewArgs[ArgIdx], Template,
4839 TemplateLoc, RAngleLoc,
4840 ArgumentPack.size(), Converted))
4843 bool PackExpansionIntoNonPack =
4844 NewArgs[ArgIdx].getArgument().isPackExpansion() &&
4846 if (PackExpansionIntoNonPack && isa<TypeAliasTemplateDecl>(Template)) {
4850 Diag(NewArgs[ArgIdx].getLocation(),
4851 diag::err_alias_template_expansion_into_fixed_list)
4852 << NewArgs[ArgIdx].getSourceRange();
4853 Diag((*Param)->getLocation(), diag::note_template_param_here);
4860 if ((*Param)->isTemplateParameterPack()) {
4865 ArgumentPack.push_back(Converted.pop_back_val());
4874 if (PackExpansionIntoNonPack) {
4875 if (!ArgumentPack.empty()) {
4878 Converted.insert(Converted.end(),
4879 ArgumentPack.begin(), ArgumentPack.end());
4880 ArgumentPack.clear();
4883 while (ArgIdx < NumArgs) {
4884 Converted.push_back(NewArgs[ArgIdx].getArgument());
4895 if (PartialTemplateArgs) {
4896 if ((*Param)->isTemplateParameterPack() && !ArgumentPack.empty())
4897 Converted.push_back(
4905 if ((*Param)->isTemplateParameterPack()) {
4907 "Should have dealt with this already");
4912 if (Param + 1 != ParamEnd)
4915 Converted.push_back(
4917 ArgumentPack.clear();
4948 = dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
4965 = cast<TemplateTemplateParmDecl>(*Param);
4995 if (CheckTemplateArgument(*Param, Arg, Template, TemplateLoc,
4996 RAngleLoc, 0, Converted))
5002 if (isTemplateTemplateParameter)
5014 if (ArgIdx < NumArgs && CurrentInstantiationScope &&
5015 CurrentInstantiationScope->getPartiallySubstitutedPack()) {
5016 while (ArgIdx < NumArgs && NewArgs[ArgIdx].getArgument().isPackExpansion())
5017 Converted.push_back(NewArgs[ArgIdx++].getArgument());
5022 if (ArgIdx < NumArgs)
5027 if (UpdateArgsWithConversions)
5028 TemplateArgs = std::move(NewArgs);
5034 class UnnamedLocalNoLinkageFinder
5035 :
public TypeVisitor<UnnamedLocalNoLinkageFinder, bool>
5043 UnnamedLocalNoLinkageFinder(
Sema &S,
SourceRange SR) : S(S), SR(SR) { }
5049 #define TYPE(Class, Parent) \
5050 bool Visit##Class##Type(const Class##Type *);
5051 #define ABSTRACT_TYPE(Class, Parent) \
5052 bool Visit##Class##Type(const Class##Type *) { return false; }
5053 #define NON_CANONICAL_TYPE(Class, Parent) \
5054 bool Visit##Class##Type(const Class##Type *) { return false; }
5055 #include "clang/AST/TypeNodes.def"
5057 bool VisitTagDecl(
const TagDecl *Tag);
5062 bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(
const BuiltinType*) {
5066 bool UnnamedLocalNoLinkageFinder::VisitComplexType(
const ComplexType* T) {
5070 bool UnnamedLocalNoLinkageFinder::VisitPointerType(
const PointerType* T) {
5074 bool UnnamedLocalNoLinkageFinder::VisitBlockPointerType(
5079 bool UnnamedLocalNoLinkageFinder::VisitLValueReferenceType(
5084 bool UnnamedLocalNoLinkageFinder::VisitRValueReferenceType(
5089 bool UnnamedLocalNoLinkageFinder::VisitMemberPointerType(
5094 bool UnnamedLocalNoLinkageFinder::VisitConstantArrayType(
5099 bool UnnamedLocalNoLinkageFinder::VisitIncompleteArrayType(
5104 bool UnnamedLocalNoLinkageFinder::VisitVariableArrayType(
5109 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedArrayType(
5114 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedExtVectorType(
5119 bool UnnamedLocalNoLinkageFinder::VisitVectorType(
const VectorType* T) {
5123 bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(
const ExtVectorType* T) {
5127 bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
5137 bool UnnamedLocalNoLinkageFinder::VisitFunctionNoProtoType(
5142 bool UnnamedLocalNoLinkageFinder::VisitUnresolvedUsingType(
5147 bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(
const TypeOfExprType*) {
5151 bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(
const TypeOfType* T) {
5155 bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(
const DecltypeType*) {
5159 bool UnnamedLocalNoLinkageFinder::VisitUnaryTransformType(
5164 bool UnnamedLocalNoLinkageFinder::VisitAutoType(
const AutoType *T) {
5168 bool UnnamedLocalNoLinkageFinder::VisitDeducedTemplateSpecializationType(
5173 bool UnnamedLocalNoLinkageFinder::VisitRecordType(
const RecordType* T) {
5174 return VisitTagDecl(T->
getDecl());
5177 bool UnnamedLocalNoLinkageFinder::VisitEnumType(
const EnumType* T) {
5178 return VisitTagDecl(T->
getDecl());
5181 bool UnnamedLocalNoLinkageFinder::VisitTemplateTypeParmType(
5186 bool UnnamedLocalNoLinkageFinder::VisitSubstTemplateTypeParmPackType(
5191 bool UnnamedLocalNoLinkageFinder::VisitTemplateSpecializationType(
5196 bool UnnamedLocalNoLinkageFinder::VisitInjectedClassNameType(
5198 return VisitTagDecl(T->
getDecl());
5201 bool UnnamedLocalNoLinkageFinder::VisitDependentNameType(
5206 bool UnnamedLocalNoLinkageFinder::VisitDependentTemplateSpecializationType(
5211 bool UnnamedLocalNoLinkageFinder::VisitPackExpansionType(
5216 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectType(
const ObjCObjectType *) {
5220 bool UnnamedLocalNoLinkageFinder::VisitObjCInterfaceType(
5225 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectPointerType(
5230 bool UnnamedLocalNoLinkageFinder::VisitAtomicType(
const AtomicType* T) {
5234 bool UnnamedLocalNoLinkageFinder::VisitPipeType(
const PipeType* T) {
5238 bool UnnamedLocalNoLinkageFinder::VisitTagDecl(
const TagDecl *Tag) {
5240 S.Diag(SR.getBegin(),
5241 S.getLangOpts().CPlusPlus11 ?
5242 diag::warn_cxx98_compat_template_arg_local_type :
5243 diag::ext_template_arg_local_type)
5244 << S.Context.getTypeDeclType(Tag) << SR;
5249 S.Diag(SR.getBegin(),
5250 S.getLangOpts().CPlusPlus11 ?
5251 diag::warn_cxx98_compat_template_arg_unnamed_type :
5252 diag::ext_template_arg_unnamed_type) << SR;
5253 S.Diag(Tag->
getLocation(), diag::note_template_unnamed_type_here);
5260 bool UnnamedLocalNoLinkageFinder::VisitNestedNameSpecifier(
5277 llvm_unreachable(
"Invalid NestedNameSpecifier::Kind!");
5287 assert(ArgInfo &&
"invalid TypeSourceInfo");
5292 return Diag(SR.
getBegin(), diag::err_variably_modified_template_arg) << Arg;
5294 return Diag(SR.
getBegin(), diag::err_template_arg_overload_type) << SR;
5305 UnnamedLocalNoLinkageFinder
Finder(*
this, SR);
5323 Decl *Entity =
nullptr) {
5329 if (Entity && Entity->hasAttr<DLLImportAttr>())
5334 "Incomplete parameter type in isNullPointerValueTemplateArgument!");
5347 EvalResult.
Diag = &Notes;
5355 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
5356 diag::note_invalid_subexpr_in_const_expr) {
5357 DiagLoc = Notes[0].first;
5361 S.
Diag(DiagLoc, diag::err_template_arg_not_address_constant)
5363 for (
unsigned I = 0, N = Notes.size();
I != N; ++
I)
5364 S.
Diag(Notes[
I].first, Notes[I].second);
5382 bool ObjCLifetimeConversion;
5385 ObjCLifetimeConversion))
5390 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
5399 std::string Code =
"static_cast<" + ParamType.
getAsString() +
">(";
5400 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_untyped_null_constant)
5419 bool ObjCLifetimeConversion;
5423 ObjCLifetimeConversion)) {
5428 if (!ParamRef->getPointeeType()->isFunctionType()) {
5438 unsigned ParamQuals = ParamRef->getPointeeType().getCVRQualifiers();
5441 if ((ParamQuals | ArgQuals) != ParamQuals) {
5443 diag::err_template_arg_ref_bind_ignores_quals)
5479 bool Invalid =
false;
5483 bool AddressTaken =
false;
5490 bool ExtWarnMSTemplateArg =
false;
5493 while (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(Arg)) {
5495 if (UnOpKind == UO_Deref)
5496 ExtWarnMSTemplateArg =
true;
5497 if (UnOpKind == UO_AddrOf || UnOpKind == UO_Deref) {
5500 FirstOpKind = UnOpKind;
5501 FirstOpLoc = UnOp->getOperatorLoc();
5507 if (ExtWarnMSTemplateArg)
5511 if (FirstOpKind == UO_AddrOf)
5512 AddressTaken =
true;
5516 assert(FirstOpKind == UO_Deref);
5539 bool ExtraParens =
false;
5540 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
5541 if (!Invalid && !ExtraParens) {
5544 ? diag::warn_cxx98_compat_template_arg_extra_parens
5545 : diag::ext_template_arg_extra_parens)
5550 Arg = Parens->getSubExpr();
5554 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
5558 if (UnOp->getOpcode() == UO_AddrOf) {
5559 Arg = UnOp->getSubExpr();
5560 AddressTaken =
true;
5561 AddrOpLoc = UnOp->getOperatorLoc();
5566 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
5578 S.
Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
5598 if (isa<CXXUuidofExpr>(Arg)) {
5600 ArgIn, Arg, ArgType))
5615 if (isa<FieldDecl>(Entity) || isa<IndirectFieldDecl>(Entity)) {
5623 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Entity)) {
5624 if (!Method->isStatic()) {
5636 if (!Func && !Var) {
5647 diag::warn_cxx98_compat_template_arg_object_internal :
5648 diag::ext_template_arg_object_internal)
5650 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
5652 }
else if (!Entity->hasLinkage()) {
5655 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
5670 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
5676 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
5685 if (Var->getType()->isReferenceType()) {
5687 diag::err_template_arg_reference_var)
5694 if (Var->getTLSKind()) {
5697 S.
Diag(Var->getLocation(), diag::note_template_arg_refers_here);
5710 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
5716 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
5721 ArgType = Var->getType();
5724 if (Var->getType()->isArrayType()) {
5766 bool Invalid =
false;
5768 Expr *Arg = ResultArg;
5769 bool ObjCLifetimeConversion;
5781 bool ExtraParens =
false;
5782 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
5783 if (!Invalid && !ExtraParens) {
5786 diag::warn_cxx98_compat_template_arg_extra_parens :
5787 diag::ext_template_arg_extra_parens)
5792 Arg = Parens->getSubExpr();
5796 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
5801 if (UnOp->getOpcode() == UO_AddrOf) {
5808 else if ((DRE = dyn_cast<DeclRefExpr>(Arg))) {
5810 if (VD->getType()->isMemberPointerType()) {
5811 if (isa<NonTypeTemplateParmDecl>(VD)) {
5815 VD = cast<ValueDecl>(VD->getCanonicalDecl());
5834 S.
Diag(ResultArg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
5844 ObjCLifetimeConversion)) {
5851 S.
Diag(ResultArg->
getLocStart(), diag::err_template_arg_not_convertible)
5859 diag::err_template_arg_not_pointer_to_member_form)
5862 if (isa<FieldDecl>(DRE->
getDecl()) ||
5863 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
5864 isa<CXXMethodDecl>(DRE->
getDecl())) {
5865 assert((isa<FieldDecl>(DRE->
getDecl()) ||
5866 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
5867 !cast<CXXMethodDecl>(DRE->
getDecl())->isStatic()) &&
5868 "Only non-static member pointers can make it here");
5883 diag::err_template_arg_not_pointer_to_member_form)
5910 auto *AT = dyn_cast<
AutoType>(ParamType);
5911 if (AT && AT->isDecltypeAuto()) {
5921 if (CTAK != CTAK_Specified)
5925 Arg, ParamType, Depth) == DAR_Failed) {
5927 diag::err_non_type_template_parm_type_deduction_failure)
5937 ParamType = CheckNonTypeTemplateParameterType(ParamType, Arg->
getExprLoc());
5938 if (ParamType.
isNull()) {
5946 "non-type template parameter type cannot be qualified");
5948 if (CTAK == CTAK_Deduced &&
5967 Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
5993 Arg, ParamType, Value, CCEK_TemplateArg);
6022 diag::err_template_arg_member_ptr_base_derived_not_supported)
6030 : TemplateArgument(CanonParamType,
true);
6043 if (isa<CXXUuidofExpr>(E)) {
6055 VD && VD->getType()->isArrayType() &&
6063 Diag(StartLoc, diag::err_non_type_template_arg_subobject)
6068 "null reference should not be a constant expression");
6070 "non-null value of type nullptr_t?");
6072 : TemplateArgument(CanonParamType,
true);
6076 return Diag(StartLoc, diag::err_non_type_template_arg_addr_label_diff);
6084 llvm_unreachable(
"invalid kind for template argument");
6087 return ArgResult.
get();
6107 if (getLangOpts().CPlusPlus11) {
6133 IntegerType = Enum->getDecl()->getIntegerType();
6141 ExprResult ArgResult = DefaultLvalueConversion(Arg);
6144 Arg = ArgResult.
get();
6159 diag::err_template_arg_not_integral_or_enumeral)
6168 TmplArgICEDiagnoser(
QualType T) : T(T) { }
6172 S.
Diag(Loc, diag::err_template_arg_not_ice) << T << SR;
6174 } Diagnoser(ArgType);
6176 Arg = VerifyIntegerConstantExpression(Arg, &Value, Diagnoser,
6191 Arg = ImpCastExprToType(Arg, ParamType, CK_IntegralToBoolean).get();
6192 }
else if (IsIntegralPromotion(Arg, ArgType, ParamType) ||
6195 Arg = ImpCastExprToType(Arg, ParamType, CK_IntegralCast).get();
6199 diag::err_template_arg_not_convertible)
6223 if (Value.getBitWidth() != AllowedBits)
6224 Value = Value.extOrTrunc(AllowedBits);
6227 llvm::APSInt OldValue =
Value;
6232 if (Value.getBitWidth() != AllowedBits)
6233 Value = Value.extOrTrunc(AllowedBits);
6238 && (OldValue.isSigned() && OldValue.isNegative())) {
6240 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
6246 unsigned RequiredBits;
6248 RequiredBits = OldValue.getActiveBits();
6249 else if (OldValue.isUnsigned())
6250 RequiredBits = OldValue.getActiveBits() + 1;
6252 RequiredBits = OldValue.getMinSignedBits();
6253 if (RequiredBits > AllowedBits) {
6255 diag::warn_template_arg_too_large)
6256 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
6297 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg, ParamType,
6303 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
6329 "Only object pointers allowed here");
6345 assert(ParamRefType->getPointeeType()->isIncompleteOrObjectType() &&
6346 "Only object references allowed here");
6349 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg,
6350 ParamRefType->getPointeeType(),
6356 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
6379 << Arg->
getType() << ParamType;
6387 Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
6415 unsigned ArgumentPackIndex) {
6420 assert(Name.
isDependent() &&
"Non-dependent template isn't a declaration?");
6439 if (!isa<ClassTemplateDecl>(Template) &&
6440 !isa<TemplateTemplateParmDecl>(Template) &&
6441 !isa<TypeAliasTemplateDecl>(Template) &&
6442 !isa<BuiltinTemplateDecl>(Template)) {
6443 assert(isa<FunctionTemplateDecl>(Template) &&
6444 "Only function templates are possible here");
6446 Diag(Template->
getLocation(), diag::note_template_arg_refers_here_func)
6457 if (getLangOpts().RelaxedTemplateTemplateArgs) {
6462 if (TemplateParameterListsAreEqual(
6464 TPL_TemplateTemplateArgumentMatch, Arg.
getLocation()))
6467 if (isTemplateTemplateParameterAtLeastAsSpecializedAs(Params, Template,
6476 TPL_TemplateTemplateArgumentMatch,
6501 return ImpCastExprToType(
6505 ? CK_NullToMemberPointer
6506 : CK_NullToPointer);
6509 "Only declaration template arguments permitted here");
6513 if (VD->getDeclContext()->isRecord() &&
6514 (isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD) ||
6515 isa<IndirectFieldDecl>(VD))) {
6534 if (isa<CXXMethodDecl>(VD) && cast<CXXMethodDecl>(VD)->isInstance())
6538 VD->getType().getNonReferenceType(),
6545 RefExpr = CreateBuiltinUnaryOp(Loc, UO_AddrOf, RefExpr.
get());
6550 bool ObjCLifetimeConversion;
6551 if (IsQualificationConversion(((
Expr*) RefExpr.
get())->getType(),
6553 ObjCLifetimeConversion))
6563 QualType T = VD->getType().getNonReferenceType();
6575 RefExpr = DefaultFunctionArrayConversion(RefExpr.
get());
6583 return CreateBuiltinUnaryOp(Loc, UO_AddrOf, RefExpr.
get());
6595 }
else if (isa<FunctionDecl>(VD)) {
6600 return BuildDeclRefExpr(VD, T, VK, Loc);
6614 "Operation is only valid for integral template arguments");
6624 T = ET->getDecl()->getIntegerType();
6651 if (OrigT->isEnumeralType()) {
6671 unsigned NextDiag = diag::err_template_param_different_kind;
6672 if (TemplateArgLoc.
isValid()) {
6673 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
6674 NextDiag = diag::note_template_param_different_kind;
6693 unsigned NextDiag = diag::err_template_parameter_pack_non_pack;
6694 if (TemplateArgLoc.
isValid()) {
6695 S.
Diag(TemplateArgLoc,
6696 diag::err_template_arg_template_params_mismatch);
6697 NextDiag = diag::note_template_parameter_pack_non_pack;
6700 unsigned ParamKind = isa<TemplateTypeParmDecl>(New)? 0
6701 : isa<NonTypeTemplateParmDecl>(New)? 1
6714 = dyn_cast<NonTypeTemplateParmDecl>(Old)) {
6722 (OldNTTP->getType()->isDependentType() ||
6728 unsigned NextDiag = diag::err_template_nontype_parm_different_type;
6729 if (TemplateArgLoc.
isValid()) {
6730 S.
Diag(TemplateArgLoc,
6731 diag::err_template_arg_template_params_mismatch);
6732 NextDiag = diag::note_template_nontype_parm_different_type;
6737 S.
Diag(OldNTTP->getLocation(),
6738 diag::note_template_nontype_parm_prev_declaration)
6739 << OldNTTP->getType();
6752 = dyn_cast<TemplateTemplateParmDecl>(Old)) {
6755 OldTTP->getTemplateParameters(),
6774 unsigned NextDiag = diag::err_template_param_list_different_arity;
6775 if (TemplateArgLoc.
isValid()) {
6776 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
6777 NextDiag = diag::note_template_param_list_different_arity;
6817 if (Old->
size() != New->
size() && Kind != TPL_TemplateTemplateArgumentMatch) {
6834 OldParmEnd = Old->
end();
6835 OldParm != OldParmEnd; ++OldParm) {
6836 if (Kind != TPL_TemplateTemplateArgumentMatch ||
6837 !(*OldParm)->isTemplateParameterPack()) {
6838 if (NewParm == NewParmEnd) {
6847 Kind, TemplateArgLoc))
6861 for (; NewParm != NewParmEnd; ++NewParm) {
6863 Kind, TemplateArgLoc))
6869 if (NewParm != NewParmEnd) {
6901 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
6915 if (RD->isLocalClass())
6917 diag::err_template_inside_local_class)
6925 diag::err_template_outside_namespace_or_class_scope)
6936 return Record->getTemplateSpecializationKind();
6937 if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(D))
6938 return Function->getTemplateSpecializationKind();
6939 if (
VarDecl *Var = dyn_cast<VarDecl>(D))
6940 return Var->getTemplateSpecializationKind();
6977 if (isa<ClassTemplateDecl>(Specialized))
6978 EntityKind = IsPartialSpecialization? 1 : 0;
6979 else if (isa<VarTemplateDecl>(Specialized))
6980 EntityKind = IsPartialSpecialization ? 3 : 2;
6981 else if (isa<FunctionTemplateDecl>(Specialized))
6983 else if (isa<CXXMethodDecl>(Specialized))
6985 else if (isa<VarDecl>(Specialized))
6987 else if (isa<RecordDecl>(Specialized))
6989 else if (isa<EnumDecl>(Specialized) && S.
getLangOpts().CPlusPlus11)
6992 S.
Diag(Loc, diag::err_template_spec_unknown_kind)
7012 S.
Diag(Loc, diag::err_template_spec_decl_function_scope)
7023 S.
Diag(Loc, diag::ext_function_specialization_in_class)
7026 S.
Diag(Loc, diag::err_template_spec_decl_class_scope)
7036 S.
Diag(Loc, diag::err_template_spec_decl_class_scope)
7056 if (!DC->
Encloses(SpecializedContext) &&
7057 !(isa<FunctionTemplateDecl>(Specialized) ||
7058 isa<FunctionDecl>(Specialized) ||
7059 isa<VarTemplateDecl>(Specialized) ||
7060 isa<VarDecl>(Specialized))) {
7061 if (isa<TranslationUnitDecl>(SpecializedContext))
7062 S.
Diag(Loc, diag::err_template_spec_redecl_global_scope)
7063 << EntityKind << Specialized;
7064 else if (isa<NamespaceDecl>(SpecializedContext)) {
7065 int Diag = diag::err_template_spec_redecl_out_of_scope;
7067 Diag = diag::ext_ms_template_spec_redecl_out_of_scope;
7068 S.
Diag(Loc, Diag) << EntityKind << Specialized
7069 << cast<NamedDecl>(SpecializedContext);
7071 llvm_unreachable(
"unexpected namespace context for specialization");
7073 S.
Diag(Specialized->getLocation(), diag::note_specialized_entity);
7074 }
else if ((!PrevDecl ||
7093 bool IsCPlusPlus11Extension = DC->
Encloses(SpecializedContext);
7094 if (isa<TranslationUnitDecl>(SpecializedContext)) {
7095 assert(!IsCPlusPlus11Extension &&
7096 "DC encloses TU but isn't in enclosing namespace set");
7097 S.
Diag(Loc, diag::err_template_spec_decl_out_of_scope_global)
7098 << EntityKind << Specialized;
7099 }
else if (isa<NamespaceDecl>(SpecializedContext)) {
7101 if (!IsCPlusPlus11Extension)
7102 Diag = diag::err_template_spec_decl_out_of_scope;
7104 Diag = diag::ext_template_spec_decl_out_of_scope;
7106 Diag = diag::warn_cxx98_compat_template_spec_decl_out_of_scope;
7108 << EntityKind << Specialized << cast<NamedDecl>(SpecializedContext);
7121 DependencyChecker Checker(Depth,
true);
7122 Checker.TraverseStmt(E);
7123 if (Checker.MatchLoc.isInvalid())
7125 return Checker.MatchLoc;
7131 DependencyChecker Checker(Depth,
true);
7132 Checker.TraverseTypeLoc(TL);
7133 if (Checker.MatchLoc.isInvalid())
7135 return Checker.MatchLoc;
7143 for (
unsigned I = 0;
I != NumArgs; ++
I) {
7146 S, TemplateNameLoc, Param, Args[
I].pack_begin(),
7147 Args[
I].pack_size(), IsDefaultArgument))
7160 ArgExpr = Expansion->getPattern();
7164 ArgExpr = ICE->getSubExpr();
7174 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ArgExpr))
7175 if (isa<NonTypeTemplateParmDecl>(DRE->getDecl()))
7195 if (ParamUseRange.
isValid()) {
7196 if (IsDefaultArgument) {
7197 S.
Diag(TemplateNameLoc,
7198 diag::err_dependent_non_type_arg_in_partial_spec);
7200 diag::note_dependent_non_type_default_arg_in_partial_spec)
7204 diag::err_dependent_non_type_arg_in_partial_spec)
7212 if (ParamUseRange.
isValid()) {
7214 diag::err_dependent_typed_non_type_arg_in_partial_spec)
7217 << (IsDefaultArgument ? ParamUseRange :
SourceRange())
7247 for (
unsigned I = 0, N = TemplateParams->
size();
I != N; ++
I) {
7254 Param, &TemplateArgs[
I],
7255 1, I >= NumExplicit))
7270 TemplateParameterLists,
7272 assert(TUK != TUK_Reference &&
"References are not specializations");
7279 ? TemplateParameterLists[0]->getTemplateLoc() : KWLoc;
7289 if (!ClassTemplate) {
7290 Diag(TemplateNameLoc, diag::err_not_class_template_specialization)
7296 bool isMemberSpecialization =
false;
7297 bool isPartialSpecialization =
false;
7303 bool Invalid =
false;
7305 MatchTemplateParametersToScopeSpecifier(
7306 KWLoc, TemplateNameLoc, SS, &TemplateId,
7307 TemplateParameterLists, TUK == TUK_Friend, isMemberSpecialization,
7312 if (TemplateParams && TemplateParams->
size() > 0) {
7313 isPartialSpecialization =
true;
7315 if (TUK == TUK_Friend) {
7316 Diag(KWLoc, diag::err_partial_specialization_friend)
7324 for (
unsigned I = 0, N = TemplateParams->
size();
I != N; ++
I) {
7327 if (TTP->hasDefaultArgument()) {
7328 Diag(TTP->getDefaultArgumentLoc(),
7329 diag::err_default_arg_in_partial_spec);
7330 TTP->removeDefaultArgument();
7333 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
7334 if (
Expr *DefArg = NTTP->getDefaultArgument()) {
7335 Diag(NTTP->getDefaultArgumentLoc(),
7336 diag::err_default_arg_in_partial_spec)
7337 << DefArg->getSourceRange();
7338 NTTP->removeDefaultArgument();
7344 diag::err_default_arg_in_partial_spec)
7350 }
else if (TemplateParams) {
7351 if (TUK == TUK_Friend)
7352 Diag(KWLoc, diag::err_template_spec_friend)
7358 assert(TUK == TUK_Friend &&
"should have a 'template<>' for this decl");
7364 assert(Kind !=
TTK_Enum &&
"Invalid enum tag in class template spec!");
7366 Kind, TUK == TUK_Definition, KWLoc,
7368 Diag(KWLoc, diag::err_use_with_wrong_tag)
7373 diag::note_previous_use);
7382 for (
unsigned I = 0, N = TemplateArgs.
size();
I != N; ++
I)
7383 if (DiagnoseUnexpandedParameterPack(TemplateArgs[
I],
7384 UPPC_PartialSpecialization))
7390 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
7391 TemplateArgs,
false, Converted))
7396 if (isPartialSpecialization) {
7397 if (CheckTemplatePartialSpecializationArgs(TemplateNameLoc, ClassTemplate,
7398 TemplateArgs.
size(), Converted))
7403 bool InstantiationDependent;
7406 TemplateArgs.
arguments(), InstantiationDependent)) {
7407 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
7409 isPartialSpecialization =
false;
7413 void *InsertPos =
nullptr;
7416 if (isPartialSpecialization)
7426 if (TUK != TUK_Friend &&
7429 isPartialSpecialization))
7434 if (isPartialSpecialization) {
7450 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
7451 << 0 << (TUK == TUK_Definition)
7453 return CheckClassTemplate(S, TagSpec, TUK, KWLoc, SS,
7460 TemplateParameterLists.size() - 1,
7461 TemplateParameterLists.data());
7466 = cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl);
7470 KWLoc, TemplateNameLoc,
7478 if (TemplateParameterLists.size() > 1 && SS.
isSet()) {
7479 Partial->setTemplateParameterListsInfo(
7480 Context, TemplateParameterLists.drop_back(1));
7484 ClassTemplate->AddPartialSpecialization(Partial, InsertPos);
7485 Specialization = Partial;
7492 CheckTemplatePartialSpecialization(Partial);
7499 KWLoc, TemplateNameLoc,
7504 if (TemplateParameterLists.size() > 0) {
7506 TemplateParameterLists);
7510 ClassTemplate->AddSpecialization(Specialization, InsertPos);
7512 if (CurContext->isDependentContext()) {
7515 assert(getLangOpts().MicrosoftExt &&
7516 "Only possible with -fms-extensions!");
7519 CanonTemplate, Converted);
7543 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
7547 diag::note_instantiation_required_here)
7555 if (TUK != TUK_Friend)
7559 if (TUK == TUK_Definition) {
7562 if (Def && SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
7564 makeMergedDefinitionVisible(Hidden);
7566 TUK = TUK_Declaration;
7569 Diag(TemplateNameLoc, diag::err_redefinition) << Specialization << Range;
7577 ProcessDeclAttributeList(S, Specialization, Attr);
7581 if (TUK == TUK_Definition) {
7582 AddAlignmentAttributesForRecord(Specialization);
7583 AddMsStructLayoutForRecord(Specialization);
7586 if (ModulePrivateLoc.
isValid())
7587 Diag(Specialization->
getLocation(), diag::err_module_private_specialization)
7588 << (isPartialSpecialization? 1 : 0)
7600 TemplateArgs, CanonType);
7601 if (TUK != TUK_Friend) {
7617 if (TUK == TUK_Definition)
7620 if (TUK == TUK_Friend) {
7626 CurContext->addDecl(Friend);
7631 CurContext->addDecl(Specialization);
7633 return Specialization;
7639 Decl *NewDecl = HandleDeclarator(S, D, TemplateParameterLists);
7640 ActOnDocumentableDecl(NewDecl);
7651 FD->setInlineSpecified(
false);
7662 for (
Decl *Prev = D; Prev && !PrevDiagLoc.
isValid();
7663 Prev = Prev->getPreviousDecl()) {
7664 PrevDiagLoc = Prev->getLocation();
7666 assert(PrevDiagLoc.
isValid() &&
7667 "Explicit instantiation without point of instantiation?");
7699 bool &HasNoEffect) {
7700 HasNoEffect =
false;
7707 "previous declaration must be implicit!");
7720 if (PrevPointOfInstantiation.
isInvalid()) {
7732 PrevPointOfInstantiation.
isValid()) &&
7733 "Explicit instantiation without point of instantiation?");
7747 Diag(NewLoc, diag::err_specialization_after_instantiation)
7749 Diag(PrevPointOfInstantiation, diag::note_instantiation_required_here)
7754 llvm_unreachable(
"The switch over PrevTSK must be exhaustive.");
7784 diag::err_explicit_instantiation_declaration_after_definition);
7790 diag::note_explicit_instantiation_definition_here);
7809 Diag(NewLoc, diag::warn_explicit_instantiation_after_specialization)
7812 diag::note_previous_template_specialization);
7842 Diag(NewLoc, (getLangOpts().MSVCCompat)
7843 ? diag::ext_explicit_instantiation_duplicate
7844 : diag::err_explicit_instantiation_duplicate)
7847 diag::note_previous_explicit_instantiation);
7853 llvm_unreachable(
"Missing specialization/instantiation case?");
7881 if (!isa<FunctionTemplateDecl>(D) ||
7889 if (Previous.
empty())
return true;
7892 ExplicitTemplateArgs);
7923 llvm::SmallDenseMap<FunctionDecl *, TemplateArgumentListInfo, 8>
7924 ConvertedTemplateArgs;
7946 if (OldMD && OldMD->
isConst()) {
7956 if (ExplicitTemplateArgs)
7957 Args = *ExplicitTemplateArgs;
7969 cast<FunctionTemplateDecl>(FunTmpl->getFirstDecl()),
7970 ExplicitTemplateArgs ? &Args :
nullptr, FT, Specialization,
7974 FailedCandidates.addCandidate().set(
7975 I.getPair(), FunTmpl->getTemplatedDecl(),
7986 if (LangOpts.CUDA &&
7987 IdentifyCUDATarget(Specialization,
7989 IdentifyCUDATarget(FD,
true)) {
7990 FailedCandidates.addCandidate().set(
7991 I.getPair(), FunTmpl->getTemplatedDecl(),
7997 if (ExplicitTemplateArgs)
7998 ConvertedTemplateArgs[Specialization] = std::move(Args);
7999 Candidates.
addDecl(Specialization,
I.getAccess());
8005 Candidates.
begin(), Candidates.
end(), FailedCandidates,
8007 PDiag(diag::err_function_template_spec_no_match) << FD->
getDeclName(),
8008 PDiag(diag::err_function_template_spec_ambiguous)
8009 << FD->
getDeclName() << (ExplicitTemplateArgs !=
nullptr),
8010 PDiag(diag::note_function_template_spec_matched));
8012 if (Result == Candidates.
end())
8016 FunctionDecl *Specialization = cast<FunctionDecl>(*Result);
8029 assert(SpecInfo &&
"Function template specialization info missing?");
8067 bool HasNoEffect =
false;
8069 CheckSpecializationInstantiationRedecl(FD->
getLocation(),
8089 !Specialization->getCanonicalDecl()->isReferenced()) {
8092 Specialization->getCanonicalDecl() == Specialization &&
8093 "This must be the only existing declaration of this specialization");
8095 Specialization->setDeletedAsWritten(
false);
8099 MarkUnusedFileScopedDecl(Specialization);
8108 FD->setFunctionTemplateSpecialization(
8109 Specialization->getPrimaryTemplate(), TemplArgs,
nullptr,
8111 ExplicitTemplateArgs ? &ConvertedTemplateArgs[Specialization] :
nullptr);
8124 Previous.
addDecl(Specialization);
8144 assert(!isa<TemplateDecl>(Member) &&
"Only for non-template members");
8147 NamedDecl *FoundInstantiation =
nullptr;
8152 if (Previous.
empty()) {
8154 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(Member)) {
8159 QualType Adjusted = Function->getType();
8160 if (!hasExplicitCallingConv(Adjusted))
8161 Adjusted = adjustCCAndNoReturn(Adjusted, Method->getType());
8163 FoundInstantiation = *
I;
8164 Instantiation = Method;
8165 InstantiatedFrom = Method->getInstantiatedFromMemberFunction();
8166 MSInfo = Method->getMemberSpecializationInfo();
8171 }
else if (isa<VarDecl>(Member)) {
8177 Instantiation = PrevVar;
8181 }
else if (isa<RecordDecl>(Member)) {
8186 Instantiation = PrevRecord;
8190 }
else if (isa<EnumDecl>(Member)) {
8195 Instantiation = PrevEnum;
8201 if (!Instantiation) {
8215 if (InstantiatedFrom && isa<CXXMethodDecl>(Member)) {
8216 cast<CXXMethodDecl>(Member)->setInstantiationOfMemberFunction(
8217 cast<CXXMethodDecl>(InstantiatedFrom),
8219 }
else if (InstantiatedFrom && isa<CXXRecordDecl>(Member)) {
8220 cast<CXXRecordDecl>(Member)->setInstantiationOfMemberClass(
8221 cast<CXXRecordDecl>(InstantiatedFrom),
8226 Previous.
addDecl(FoundInstantiation);
8231 if (!InstantiatedFrom) {
8244 assert(MSInfo &&
"Member specialization info missing?");
8246 bool HasNoEffect =
false;
8247 if (CheckSpecializationInstantiationRedecl(Member->
getLocation(),
8264 if (
auto *MemberFunction = dyn_cast<FunctionDecl>(Member)) {
8265 FunctionDecl *InstantiationFunction = cast<FunctionDecl>(Instantiation);
8270 if (InstantiationFunction->
isDeleted()) {
8273 InstantiationFunction);
8279 MemberFunction->setInstantiationOfMemberFunction(
8281 }
else if (
auto *MemberVar = dyn_cast<VarDecl>(Member)) {
8282 MemberVar->setInstantiationOfStaticDataMember(
8284 }
else if (
auto *MemberClass = dyn_cast<CXXRecordDecl>(Member)) {
8285 MemberClass->setInstantiationOfMemberClass(
8287 }
else if (
auto *MemberEnum = dyn_cast<EnumDecl>(Member)) {
8288 MemberEnum->setInstantiationOfMemberEnum(
8291 llvm_unreachable(
"unknown member specialization kind");
8297 Previous.
addDecl(FoundInstantiation);
8306 template<
typename DeclT>
8317 OrigD->setLocation(Loc);
8323 if (Instantiation == Member)
8326 if (
auto *Function = dyn_cast<CXXMethodDecl>(Instantiation))
8328 else if (
auto *Var = dyn_cast<VarDecl>(Instantiation))
8330 else if (
auto *Record = dyn_cast<CXXRecordDecl>(Instantiation))
8332 else if (
auto *Enum = dyn_cast<EnumDecl>(Instantiation))
8335 llvm_unreachable(
"unknown member specialization kind");
8343 bool WasQualifiedName) {
8348 S.
Diag(InstLoc, diag::err_explicit_instantiation_in_class)
8361 if (WasQualifiedName) {
8362 if (CurContext->
Encloses(OrigContext))
8369 if (
NamespaceDecl *NS = dyn_cast<NamespaceDecl>(OrigContext)) {
8370 if (WasQualifiedName)
8373 diag::err_explicit_instantiation_out_of_scope :
8374 diag::warn_explicit_instantiation_out_of_scope_0x)
8379 diag::err_explicit_instantiation_unqualified_wrong_namespace :
8380 diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x)
8385 diag::err_explicit_instantiation_must_be_global :
8386 diag::warn_explicit_instantiation_must_be_global_0x)
8407 if (isa<TemplateSpecializationType>(T))
8417 auto *A = cast_or_null<InheritableAttr>(
getDLLAttr(Def));
8418 assert(A &&
"dllExportImportClassTemplateSpecialization called "
8419 "on Def without dllexport or dllimport");
8424 "delayed exports present at explicit instantiation");
8428 for (
auto &B : Def->
bases()) {
8429 if (
auto *BT = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
8430 B.getType()->getAsCXXRecordDecl()))
8458 "Invalid enum tag in class template explicit instantiation!");
8462 if (!ClassTemplate) {
8463 NonTagKind NTK = getNonTagTypeDeclKind(TD, Kind);
8464 Diag(TemplateNameLoc, diag::err_tag_reference_non_tag) << TD << NTK <<
Kind;
8472 Diag(KWLoc, diag::err_use_with_wrong_tag)
8477 diag::note_previous_use);
8492 if (A->getKind() == AttributeList::AT_DLLExport) {
8494 diag::warn_attribute_dllexport_explicit_instantiation_decl);
8495 Diag(A->getLoc(), diag::note_attribute);
8502 diag::warn_attribute_dllexport_explicit_instantiation_decl);
8503 Diag(A->getLocation(), diag::note_attribute);
8509 bool DLLImportExplicitInstantiationDef =
false;
8516 if (A->getKind() == AttributeList::AT_DLLImport)
8518 if (A->getKind() == AttributeList::AT_DLLExport) {
8526 DLLImportExplicitInstantiationDef =
true;
8532 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
8537 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
8538 TemplateArgs,
false, Converted))
8543 void *InsertPos =
nullptr;
8561 bool HasNoEffect =
false;
8563 if (CheckSpecializationInstantiationRedecl(TemplateNameLoc, TSK,
8564 PrevDecl, PrevDecl_TSK,
8579 Specialization = PrevDecl;
8585 DLLImportExplicitInstantiationDef) {
8587 HasNoEffect =
false;
8591 if (!Specialization) {
8597 KWLoc, TemplateNameLoc,
8603 if (!HasNoEffect && !PrevDecl) {
8605 ClassTemplate->AddSpecialization(Specialization, InsertPos);
8627 bool PreviouslyDLLExported = Specialization->
hasAttr<DLLExportAttr>();
8629 ProcessDeclAttributeList(S, Specialization, Attr);
8635 CurContext->addDecl(Specialization);
8641 return Specialization;
8652 = cast_or_null<ClassTemplateSpecializationDecl>(
8655 InstantiateClassTemplateSpecialization(TemplateNameLoc, Specialization, TSK);
8657 MarkVTableUsed(TemplateNameLoc, Specialization,
true);
8662 Def = cast_or_null<ClassTemplateSpecializationDecl>(
8670 DLLImportExplicitInstantiationDef)) {
8680 auto *A = cast<InheritableAttr>(
8682 A->setInherited(
true);
8690 bool NewlyDLLExported =
8691 !PreviouslyDLLExported && Specialization->
hasAttr<DLLExportAttr>();
8707 assert(Def == Specialization &&
8708 "Def and Specialization should match for implicit instantiation");
8715 InstantiateClassTemplateSpecializationMembers(TemplateNameLoc, Def, TSK);
8722 return Specialization;
8738 bool IsDependent =
false;
8740 KWLoc, SS, Name, NameLoc, Attr,
AS_none,
8746 assert(!IsDependent &&
"explicit instantiation of dependent name not yet handled");
8751 TagDecl *Tag = cast<TagDecl>(TagD);
8752 assert(!Tag->
isEnum() &&
"shouldn't see enumerations here");
8760 Diag(TemplateLoc, diag::err_explicit_instantiation_nontemplate_type)
8773 Diag(TemplateLoc, diag::ext_explicit_instantiation_without_qualified_id)
8798 bool HasNoEffect =
false;
8799 assert(MSInfo &&
"No member specialization information?");
8800 if (CheckSpecializationInstantiationRedecl(TemplateLoc, TSK,
8817 = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
8819 Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member)
8821 Diag(Pattern->getLocation(), diag::note_forward_declaration)
8825 if (InstantiateClass(NameLoc, Record, Def,
8826 getTemplateInstantiationArgs(Record),
8830 RecordDef = cast_or_null<CXXRecordDecl>(Record->
getDefinition());
8837 InstantiateClassMembers(NameLoc, RecordDef,
8838 getTemplateInstantiationArgs(Record), TSK);
8841 MarkVTableUsed(NameLoc, RecordDef,
true);
8861 diag::err_explicit_instantiation_requires_name)
8903 getLangOpts().CPlusPlus11 ?
8904 diag::err_explicit_instantiation_inline :
8905 diag::warn_explicit_instantiation_inline_0x)
8911 diag::err_explicit_instantiation_constexpr);
8918 diag::err_concept_specified_specialization) << 0;
8955 if (!PrevTemplate) {
8962 Diag((*P)->getLocation(), diag::note_explicit_instantiation_here);
8969 diag::err_explicit_instantiation_data_member_not_instantiated)
8985 diag::err_auto_not_allowed_var_inst);
8994 diag::err_explicit_instantiation_without_template_id)
8996 Diag(PrevTemplate->getLocation(),
8997 diag::note_explicit_instantiation_here);
9003 if (PrevTemplate->isConcept()) {
9006 Diag(PrevTemplate->getLocation(), diag::note_previous_declaration);
9014 DeclResult Res = CheckVarTemplateId(PrevTemplate, TemplateLoc,
9016 if (Res.isInvalid())
9021 Prev = cast<VarDecl>(Res.get());
9036 diag::ext_explicit_instantiation_without_qualified_id)
9045 bool HasNoEffect =
false;
9046 if (CheckSpecializationInstantiationRedecl(D.
getIdentifierLoc(), TSK, Prev,
9047 PrevTSK, POI, HasNoEffect))
9057 ProcessDeclAttributeList(S, Prev,
Attr);
9066 diag::err_invalid_var_template_spec_type)
9067 << 0 << PrevTemplate << R << Prev->getType();
9068 Diag(PrevTemplate->getLocation(), diag::note_template_declared_here)
9069 << 2 << PrevTemplate->getDeclName();
9074 return (
Decl*)
nullptr;
9079 bool HasExplicitTemplateArgs =
false;
9083 HasExplicitTemplateArgs =
true;
9098 if (!HasExplicitTemplateArgs) {
9099 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Prev)) {
9100 QualType Adjusted = adjustCCAndNoReturn(R, Method->getType(),
9103 if (Method->getPrimaryTemplate()) {
9104 TemplateMatches.
addDecl(Method,
P.getAccess());
9107 assert(!NonTemplateMatch &&
"Multiple NonTemplateMatches");
9108 NonTemplateMatch = Method;
9122 (HasExplicitTemplateArgs ? &TemplateArgs
9124 R, Specialization, Info)) {
9126 FailedCandidates.addCandidate()
9138 if (LangOpts.CUDA &&
9139 IdentifyCUDATarget(Specialization,
9141 IdentifyCUDATarget(Attr)) {
9142 FailedCandidates.addCandidate().set(
9148 TemplateMatches.
addDecl(Specialization,
P.getAccess());
9152 if (!Specialization) {
9155 TemplateMatches.
begin(), TemplateMatches.
end(), FailedCandidates,
9157 PDiag(diag::err_explicit_instantiation_not_known) <<
Name,
9158 PDiag(diag::err_explicit_instantiation_ambiguous) <<
Name,
9159 PDiag(diag::note_explicit_instantiation_candidate));
9161 if (Result == TemplateMatches.
end())
9165 Specialization = cast<FunctionDecl>(*Result);
9175 if (FPT->hasExceptionSpec()) {
9177 diag::err_mismatched_exception_spec_explicit_instantiation;
9178 if (getLangOpts().MicrosoftExt)
9179 DiagID = diag::ext_mismatched_exception_spec_explicit_instantiation;
9180 bool Result = CheckEquivalentExceptionSpec(
9181 PDiag(DiagID) << Specialization->
getType(),
9182 PDiag(diag::note_explicit_instantiation_here),
9187 if (!getLangOpts().MicrosoftExt && Result)
9193 diag::err_explicit_instantiation_member_function_not_instantiated)
9197 Diag(Specialization->
getLocation(), diag::note_explicit_instantiation_here);
9203 PrevDecl = Specialization;
9206 bool HasNoEffect =
false;
9210 PrevDecl->getPointOfInstantiation(),
9217 return (
Decl*)
nullptr;
9222 ProcessDeclAttributeList(S, Specialization, Attr);
9227 Consumer.HandleTopLevelDecl(
DeclGroupRef(Specialization));
9243 diag::ext_explicit_instantiation_without_qualified_id)
9248 if (FunTmpl && FunTmpl->isConcept() &&
9252 Diag(FunTmpl->getLocation(), diag::note_previous_declaration);
9263 return (
Decl*)
nullptr;
9271 assert(Name &&
"Expected a name in a dependent tag");
9279 if (TUK == TUK_Declaration || TUK == TUK_Definition) {
9280 Diag(NameLoc, diag::err_dependent_tag_decl)
9281 << (TUK == TUK_Definition) << Kind << SS.
getRange();
9307 getLangOpts().CPlusPlus11 ?
9308 diag::warn_cxx98_compat_typename_outside_of_template :
9309 diag::ext_typename_outside_of_template)
9314 TypenameLoc, QualifierLoc, II, IdLoc);
9319 if (isa<DependentNameType>(T)) {
9331 return CreateParsedType(T, TSI);
9347 getLangOpts().CPlusPlus11 ?
9348 diag::warn_cxx98_compat_typename_outside_of_template :
9349 diag::ext_typename_outside_of_template)
9356 dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS,
false));
9357 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
9359 diag::ext_out_of_line_qualified_id_type_names_constructor)
9361 << (TemplateKWLoc.
isValid() ? 1 : 0 );
9367 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
9372 assert(DTN &&
"dependent template has non-dependent name?");
9375 DTN->getQualifier(),
9376 DTN->getIdentifier(),
9389 for (
unsigned I = 0, N = TemplateArgs.
size();
I != N; ++
I)
9394 QualType T = CheckTemplateIdType(Template, TemplateIILoc, TemplateArgs);
9406 for (
unsigned I = 0, N = TemplateArgs.
size();
I != N; ++
I)
9415 return CreateParsedType(T, TSI);
9424 if (!II.
isStr(
"type"))
9433 if (!EnableIfTSTLoc || EnableIfTSTLoc.
getNumArgs() == 0)
9436 cast<TemplateSpecializationType>(EnableIfTSTLoc.
getTypePtr());
9446 EnableIfDecl->getDeclName().getAsIdentifierInfo();
9447 if (!EnableIfII || !EnableIfII->
isStr(
"enable_if"))
9477 SS.
Adopt(QualifierLoc);
9495 if (RequireCompleteDeclContext(SS, Ctx))
9499 LookupResult Result(*
this, Name, IILoc, LookupOrdinaryName);
9500 LookupQualifiedName(Result, Ctx, SS);
9501 unsigned DiagID = 0;
9502 Decl *Referenced =
nullptr;
9508 Expr *Cond =
nullptr;
9509 if (
isEnableIf(QualifierLoc, II, CondRange, Cond)) {
9514 std::string FailedDescription;
9515 std::tie(FailedCond, FailedDescription) =
9519 diag::err_typename_nested_not_found_requirement)
9520 << FailedDescription
9525 Diag(CondRange.
getBegin(), diag::err_typename_nested_not_found_enable_if)
9526 << Ctx << CondRange;
9530 DiagID = diag::err_typename_nested_not_found;
9539 Diag(IILoc, diag::err_typename_refers_to_using_value_decl)
9540 << Name << Ctx << FullRange;
9544 Diag(Loc, diag::note_using_value_decl_missing_typename)
9574 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(Ctx);
9577 FoundRD->isInjectedClassName() &&
9579 Diag(IILoc, diag::ext_out_of_line_qualified_id_type_names_constructor)
9584 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
9594 if (getLangOpts().CPlusPlus1z) {
9603 DiagID = diag::err_typename_nested_not_type;
9608 DiagID = diag::err_typename_nested_not_type;
9609 Referenced = *Result.
begin();
9620 Diag(IILoc, DiagID) << FullRange << Name << Ctx;
9629 class CurrentInstantiationRebuilder
9637 CurrentInstantiationRebuilder(
Sema &SemaRef,
9641 Loc(Loc), Entity(Entity) { }
9648 bool AlreadyTransformed(
QualType T) {
9663 this->Entity = Entity;
9705 CurrentInstantiationRebuilder Rebuilder(*
this, Loc, Name);
9706 return Rebuilder.TransformType(T);
9710 CurrentInstantiationRebuilder Rebuilder(*
this, E->
getExprLoc(),
9712 return Rebuilder.TransformExpr(E);
9723 = Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
9735 for (
unsigned I = 0, N = Params->
size();
I != N; ++
I) {
9739 if (isa<TemplateTypeParmDecl>(Param))
9744 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
9745 if (RebuildTemplateParamsInCurrentInstantiation(
9746 TTP->getTemplateParameters()))
9763 NTTP->
setType(NewTSI->getType());
9775 return getTemplateArgumentBindingsText(Params, Args.
data(), Args.
size());
9783 llvm::raw_svector_ostream Out(Str);
9785 if (!Params || Params->
size() == 0 || NumArgs == 0)
9786 return std::string();
9788 for (
unsigned I = 0, N = Params->
size();
I != N; ++
I) {
9798 Out << Id->getName();
9804 Args[
I].
print(getPrintingPolicy(), Out);
9816 auto LPT = llvm::make_unique<LateParsedTemplate>();
9819 LPT->Toks.swap(Toks);
9821 LateParsedTemplateMap.insert(std::make_pair(FD, std::move(LPT)));
9836 if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(CurContext)) {
9865 class ExplicitSpecializationVisibilityChecker {
9875 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
9876 return checkImpl(FD);
9877 if (
auto *RD = dyn_cast<CXXRecordDecl>(ND))
9878 return checkImpl(RD);
9879 if (
auto *VD = dyn_cast<VarDecl>(ND))
9880 return checkImpl(VD);
9881 if (
auto *ED = dyn_cast<EnumDecl>(ND))
9882 return checkImpl(ED);
9886 void diagnose(
NamedDecl *D,
bool IsPartialSpec) {
9889 const bool Recover =
true;
9894 if (Modules.empty())
9895 S.diagnoseMissingImport(Loc, D,
Kind, Recover);
9897 S.diagnoseMissingImport(Loc, D, D->
getLocation(), Modules,
Kind, Recover);
9912 template<
typename SpecDecl>
9913 void checkImpl(SpecDecl *Spec) {
9914 bool IsHiddenExplicitSpecialization =
false;
9916 IsHiddenExplicitSpecialization =
9917 Spec->getMemberSpecializationInfo()
9918 ? !S.hasVisibleMemberSpecialization(Spec, &Modules)
9919 : !S.hasVisibleExplicitSpecialization(Spec, &Modules);
9921 checkInstantiated(Spec);
9924 if (IsHiddenExplicitSpecialization)
9925 diagnose(Spec->getMostRecentDecl(),
false);
9943 if (!S.hasVisibleDeclaration(TD))
9949 void checkInstantiated(
VarDecl *RD) {
9959 if (!S.hasVisibleDeclaration(TD))
9965 void checkInstantiated(
EnumDecl *FD) {}
9967 template<
typename TemplDecl>
9968 void checkTemplate(TemplDecl *TD) {
9969 if (TD->isMemberSpecialization()) {
9970 if (!S.hasVisibleMemberSpecialization(TD, &Modules))
9971 diagnose(TD->getMostRecentDecl(),
false);
9978 if (!getLangOpts().Modules)
9981 ExplicitSpecializationVisibilityChecker(*
this, Loc).check(Spec);
9989 if (!hasVisibleDeclaration(Spec, &Modules))
9990 diagnoseMissingImport(Loc, Spec, Spec->
getLocation(), Modules,
9991 MissingImportKind::PartialSpecialization,
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
unsigned getFlags() const
getFlags - Return the flags for this scope.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0) const
bool isObjCObjectOrInterfaceType() const
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType) const
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.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
The null pointer literal (C++11 [lex.nullptr])
IdKind getKind() const
Determine what kind of name we have.
void setImplicit(bool I=true)
FunctionDecl - An instance of this class is created to represent 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)
BuiltinTemplateKind getBuiltinTemplateKind() const
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.
DeclResult ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, TemplateIdAnnotation &TemplateId, AttributeList *Attr, MultiTemplateParamsArg TemplateParameterLists, SkipBodyInfo *SkipBody=nullptr)
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.
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
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.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
bool isNullPtrType() const
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
unsigned getDepth() const
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
Expr * getSourceExpression() 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.
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization, retrieves the member specialization information.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
TemplateDeductionResult
Describes the result of template argument deduction.
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
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)
bool isMemberPointerType() const
bool isSuppressingDiagnostics() const
Determines whether this lookup is suppressing diagnostics.
static CXXDependentScopeMemberExpr * Create(const ASTContext &C, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
void addOuterTemplateArguments(const TemplateArgumentList *TemplateArgs)
Add a new outermost level to the multi-level template argument list.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
void setLookupName(DeclarationName Name)
Sets the name to look up.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
ParsedType getAsType() const
Retrieve the template type argument's type.
static UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
void setRParenLoc(SourceLocation Loc)
DeclClass * getAsSingle() const
bool hasDefaultArg() const
hasDefaultArg - Determines whether this parameter has a default argument, either parsed or not...
Stmt - This represents one statement.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
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.
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
void setLAngleLoc(SourceLocation Loc)
void setExceptionSpecRange(SourceRange R)
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
We are matching the template parameter lists of two templates that might be redeclarations.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
TypeLoc getNamedTypeLoc() const
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
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...
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 ...
The name refers to a function template or a set of overloaded functions that includes at least one fu...
const Scope * getParent() const
getParent - Return the scope that this is nested in.
bool CheckTemplatePartialSpecializationArgs(SourceLocation Loc, TemplateDecl *PrimaryTemplate, unsigned NumExplicitArgs, ArrayRef< TemplateArgument > Args)
Check the non-type template arguments of a class template partial specialization according to C++ [te...
The name refers to a dependent template name:
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
Represents a qualified type name for which the type name is dependent.
void setObjCLifetime(ObjCLifetime type)
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
CXXRecordDecl * getDecl() const
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...
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.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
QualType getUnderlyingType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
bool isChar16Type() const
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
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.
Represents a C++11 auto or C++14 decltype(auto) type.
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
bool isEnumeralType() const
static SourceRange getRangeOfTypeInNestedNameSpecifier(ASTContext &Context, QualType T, const CXXScopeSpec &SS)
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.
SCS getStorageClassSpec() const
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
std::string getAsString() const
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
QualType getPointeeType() const
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
bool isMemberPointer() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
SourceLocation getLocalRangeBegin() const
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
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.
NamespaceDecl - Represent a C++ namespace.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
bool hasLValuePath() const
void setSpecializationKind(TemplateSpecializationKind TSK)
NamedDecl * getParam(unsigned Idx)
SourceLocation getInlineSpecLoc() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
bool isBooleanType() const
A container of type source information.
unsigned getIndex() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
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...
SourceLocation getLocEnd() const LLVM_READONLY
static void StripImplicitInstantiation(NamedDecl *D)
Strips various properties off an implicit instantiation that has just been explicitly specialized...
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList * > FriendTypeTPLists=None)
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLock is not of the desire...
Abstract base class used for diagnosing integer constant expression violations.
bool isConceptSpecified() const
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.
TemplateName SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs)
An identifier, stored as an IdentifierInfo*.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
RAII object that enters a new expression evaluation context.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
Information about one declarator, including the parsed type information and the identifier.
static SourceLocation DiagLocForExplicitInstantiation(NamedDecl *D, SourceLocation PointOfInstantiation)
Compute the diagnostic location for an explicit instantiation.
Represents an empty template argument, e.g., one that has not been deduced.
Extra information about a function prototype.
AccessSpecifier getAccess() const
SourceLocation getLocation() const
Retrieve the location of the template argument.
TypeSpecifierType
Specifies the kind of type.
Represents a C++17 deduced template specialization type.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Represents a variable template specialization, which refers to a variable template with a given set o...
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
static bool isTemplateArgumentTemplateParameter(const TemplateArgument &Arg, unsigned Depth, unsigned Index)
A namespace, stored as a NamespaceDecl*.
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
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. ...
static Optional< unsigned > getExpandedPackSize(NamedDecl *Param)
Check whether the template parameter is a pack expansion, and if so, determine the number of paramete...
ParmVarDecl - Represents a parameter to a function.
Represents the result of substituting a type for a template type parameter.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Defines the clang::Expr interface and subclasses for C++ expressions.
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
bool isEmpty() const
No scope specifier.
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.
Information about a template-id annotation token.
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
static void DiagnoseTemplateParameterListArityMismatch(Sema &S, TemplateParameterList *New, TemplateParameterList *Old, Sema::TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc)
Diagnose a known arity mismatch when comparing template argument lists.
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
static SourceRange findTemplateParameter(unsigned Depth, TypeLoc TL)
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
Base wrapper for a particular "section" of type source info.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
RecordDecl - Represents a struct/union/class.
static bool hasVisibleDefaultArgument(Sema &S, const ParmDecl *D, llvm::SmallVectorImpl< Module * > *Modules)
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
Scope * getTemplateParamParent()
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
QualType getElementType() const
DeclarationName getName() const
getName - Returns the embedded declaration name.
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...
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
void setLocalRangeEnd(SourceLocation L)
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template.
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl)
DiagnoseTemplateParameterShadow - Produce a diagnostic complaining that the template parameter 'PrevD...
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
void replace(NamedDecl *D)
Replaces the current entry with the given one, preserving the access bits.
static bool isEnableIfAliasTemplate(TypeAliasTemplateDecl *AliasTemplate)
Determine whether this alias template is "enable_if_t".
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
Represents a class type in Objective C.
AttributeList * getList() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
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.
Represents a dependent template name that cannot be resolved prior to template instantiation.
NestedNameSpecifierLoc SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const MultiLevelTemplateArgumentList &TemplateArgs)
unsigned getNumArgs() const
ArrayRef< QualType > getParamTypes() const
static NamedDecl * isAcceptableTemplateName(ASTContext &Context, NamedDecl *Orig, bool AllowFunctionTemplates)
Determine whether the declaration found is acceptable as the name of a template and, if so, return that template declaration.
bool isIdentifier() const
Determine whether this template name refers to an identifier.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD, const TemplateArgumentListInfo &ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given dependent function template specialization.
Decl * ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, unsigned Depth, unsigned Position, SourceLocation EqualLoc, Expr *DefaultArg)
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...
bool isReferenceType() const
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
SourceLocation getLocalRangeEnd() const
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
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)
SourceLocation getLocation() const
Fetches the primary location of the argument.
OverloadedOperatorKind Operator
The kind of overloaded operator.
QualType getCanonicalTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args) const
void startDefinition()
Starts the definition of this tag declaration.
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
bool isChar32Type() const
CXXRecordDecl * getDefinition() const
bool isTranslationUnit() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
void setElaboratedKeywordLoc(SourceLocation Loc)
TagKind getTagKind() const
The iterator over UnresolvedSets.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Represents the result of substituting a set of types for a template type parameter pack...
A non-type template parameter, stored as an expression.
static CXXDeductionGuideDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, bool IsExplicit, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation)
bool hasAnyAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true)
SourceLocation getLocStart() const LLVM_READONLY
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
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()
The type of a non-type template parameter.
TypeSourceInfo * getTypeSourceInfo() const
bool isExplicitSpecialization() const
SourceRange getSourceRange() const LLVM_READONLY
Fetches the full source range of the argument.
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).
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
SourceLocation getTemplateEllipsisLoc() const
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
QualType getUnderlyingType() const
void setDefaultArgument(Expr *DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
Provides information about a function template specialization, which is a FunctionDecl that has been ...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
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.
TemplateArgument getArgumentPack() const
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 ...
param_type_range param_types() const
SourceLocation getLAngleLoc() const
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)
Represents the results of name lookup.
const TargetInfo & getTargetInfo() const
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
void setRAngleLoc(SourceLocation Loc)
const LangOptions & getLangOpts() const
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.
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.
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
QualType getReturnType() const
void FilterAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true)
const ValueDecl * getMemberPointerDecl() const
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl *T, sema::TemplateDeductionInfo &Info)
ParsedTemplateTy getAsTemplate() const
Retrieve the template template argument's template name.
KindType getKind() const
Determine what kind of template argument we have.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
Represents a typeof (or typeof) expression (a GCC extension).
NestedNameSpecifierLoc getTemplateQualifierLoc() const
char * location_data() const
Retrieve the data associated with the source-location information.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack)
SourceLocation getLocStart() const LLVM_READONLY
TypeDecl - Represents a declaration of a type.
void setRedeclaration(bool Val)
A builtin binary operation expression such as "x + y" or "x <= y".
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
RecordDecl * getDecl() 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.
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
void setSpecializationKind(TemplateSpecializationKind TSK)
Scope - A scope is a transient data structure that is used while parsing the program.
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
bool 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.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
SourceLocation getRAngleLoc() const
Represents a C++ nested-name-specifier or a global scope specifier.
SourceLocation getConceptSpecLoc() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
SourceLocation getTemplateNameLoc() const
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
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)
Represents a C++ member access expression where the actual member referenced could not be resolved be...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
A class that does preordor 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...
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
Represents a linkage specification.
ParsedTemplateArgument getTemplatePackExpansion(SourceLocation EllipsisLoc) const
Retrieve a pack expansion of the given template template argument.
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
SourceLocation getLocStart() const LLVM_READONLY
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
We are matching the template parameter lists of a template template argument against the template par...
SourceRange getSourceRange() const LLVM_READONLY
detail::InMemoryDirectory::const_iterator I
unsigned getNumParams() const
Decl * 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...
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
QualType getCanonicalTypeInternal() const
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const
getInjectedClassNameType - Return the unique reference to the injected class name type for the specif...
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.
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
RAII object used to change the argument pack substitution index within a Sema object.
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
Represents an extended vector type where either the type or size is dependent.
const UnresolvedSetImpl & asUnresolvedSet() const
SourceRange getRange() const
bool isDefined(const FunctionDecl *&Definition) const
isDefined - Returns true if the function is defined at all, including a deleted definition.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
EnumDecl * getDecl() const
We are matching the template parameter lists of two template template parameters as part of matching ...
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
TemplateName getUnderlying() const
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack...
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD)
static Sema::TemplateDeductionResult DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, const TemplateArgument &Param, TemplateArgument Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
QualType getInjectedSpecializationType() const
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
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.
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this...
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< Decl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
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.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
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.
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
SourceLocation getLocStart() const LLVM_READONLY
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
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...
SourceLocation getLocEnd() const LLVM_READONLY
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.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization, retrieves the member specialization information.
TemplateParameterListEqualKind
Enumeration describing how template parameter lists are compared for equality.
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams)
Check whether a template can be declared within this scope.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
void setTemplateNameLoc(SourceLocation Loc)
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, const TemplateArgumentListInfo &Args) const
Represents an array type in C++ whose size is a value-dependent expression.
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool isDeleted() const
Whether this function has been deleted.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
QualType getPointeeType() const
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
Expr - This represents one expression.
Defines the clang::LangOptions interface.
DeclResult CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation TemplateNameLoc, const TemplateArgumentListInfo &TemplateArgs)
DeclarationName getLookupName() const
Gets the name to look up.
LookupNameKind
Describes the kind of name lookup to perform.
StringRef getName() const
Return the actual identifier string.
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.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
Declaration of a template type parameter.
SourceLocation getNameLoc() const
Gets the location of the identifier.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
const LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
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...
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that makes a template template argument into a pack expansion...
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...
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
TranslationUnitDecl * getTranslationUnitDecl() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
SourceLocation getLocation() const
ArgKind getKind() const
Return the kind of stored template argument.
ExtProtoInfo getExtProtoInfo() const
DeclContext * getDeclContext()
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...
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
void setMemberSpecialization()
Note that this member template is a specialization.
void NoteAllFoundTemplates(TemplateName Name)
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
static DependentScopeDeclRefExpr * Create(const ASTContext &C, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Represents the type decltype(expr) (C++11).
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given function template specialization.
TypeSourceInfo * getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &Args, QualType Canon=QualType()) const
A namespace alias, stored as a NamespaceAliasDecl*.
void setLateTemplateParsed(bool ILT=true)
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
bool isConstexprSpecified() const
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined...
void propagateDLLAttrToBaseClassTemplate(CXXRecordDecl *Class, Attr *ClassAttr, ClassTemplateSpecializationDecl *BaseTemplateSpec, SourceLocation BaseLoc)
Perform propagation of DLL attributes from a derived class to a templated base class for MS compatibi...
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
bool isExplicit() const
Whether this function is explicit.
QualType getType() const
Get the type for which this source info wrapper provides information.
StorageClass
Storage classes.
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 isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isFunctionOrMethod() const
Declaration of an alias template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
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.
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
Data structure that captures multiple levels of template argument lists for use in template instantia...
TemplateNameKind ActOnDependentTemplateName(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool AllowInjectedClassName=false)
Form a dependent template name.
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...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Represents a GCC generic vector type.
void setLocation(SourceLocation L)
An lvalue reference type, per C++11 [dcl.ref].
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
DiagnosticsEngine & getDiagnostics() const
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization)
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
void setDescribedClassTemplate(ClassTemplateDecl *Template)
QualType getElementType() const
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.
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type...
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
SourceLocation getStorageClassSpecLoc() const
RecordDecl * getDefinition() const
getDefinition - Returns the RecordDecl that actually defines this struct/union/class.
A type, stored as a Type*.
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
static TemplateArgumentLoc translateTemplateArgument(Sema &SemaRef, const ParsedTemplateArgument &Arg)
TypeSourceInfo * getTypeSourceInfo() const
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
const TypeClass * getTypePtr() const
bool isLValueOnePastTheEnd() const
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
bool hasUnnamedOrLocalType() const
Whether this type is or contains a local or unnamed type.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
static bool DiagnoseUnexpandedParameterPacks(Sema &S, TemplateTemplateParmDecl *TTP)
Check for unexpanded parameter packs within the template parameters of a template template parameter...
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
TemplateArgumentLoc getArgLoc(unsigned i) const
DeclContext * getEntity() const
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
ASTMatchFinder *const Finder
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
Assigning into this object requires the old value to be released and the new value to be retained...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
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.
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
unsigned getNumLevels() const
Determine the number of levels in this template argument list.
static bool isSameAsPrimaryTemplate(TemplateParameterList *Params, ArrayRef< TemplateArgument > Args)
Encodes a location in the source.
Expr * getAsExpr() const
Retrieve the non-type template argument's expression.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
QualType getElementType() 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...
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
void setBraceRange(SourceRange R)
An overloaded operator name, e.g., operator+.
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.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLParenLoc() const
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
static void SetNestedNameSpecifier(TagDecl *T, const CXXScopeSpec &SS)
TagDecl - Represents the declaration of a struct/union/class/enum.
void referenceDLLExportedClassMethods()
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
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". ...
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template apply...
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...
ASTContext & getASTContext() const LLVM_READONLY
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.
ASTContext & getASTContext() const
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
ValueKind getKind() const
Represents a dependent using declaration which was not marked with typename.
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
Represents a static or instance method of a struct/union/class.
unsigned getDepth() const
Retrieve the depth of the template parameter.
void print(const PrintingPolicy &Policy, raw_ostream &Out) const
Print this template argument to the given output stream.
SourceLocation getNameLoc() const
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
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.
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template...
SourceLocation getConstexprSpecLoc() const
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
void addDecl(NamedDecl *D)
void setPointOfInstantiation(SourceLocation Loc)
A class for iterating through a result set and possibly filtering out results.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setElaboratedKeywordLoc(SourceLocation Loc)
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
SourceLocation getBegin() const
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 T * castAs() const
Member-template castAs<specific type>.
SourceLocation getBeginLoc() const
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
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.
bool isFileContext() const
A template type parameter, stored as a type.
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.
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...
Attr * clone(ASTContext &C) 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.
QualType getType() const
Return the type wrapped by this type source info.
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.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
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)
The injected class name of a C++ class template or class template partial specialization.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
QualType getPointeeType() const
A qualified reference to a name whose declaration cannot yet be resolved.
Represents a pack expansion of types.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) 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)
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...
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Decl * 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.
Represents a template argument.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
QualType getAsType() const
Retrieve the type for a type template argument.
TagTypeKind
The kind of a tag type.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
llvm::PointerUnion3< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
The name does not refer to a template.
const CXXScopeSpec & getScopeSpec() const
Retrieve the nested-name-specifier that precedes the template name in a template template argument...
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 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.
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
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.
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
bool isDependent() const
Determines whether this is a dependent template name.
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.
SourceLocation getLocStart() const LLVM_READONLY
The template argument is a pack expansion of a template name that was provided for a template templat...
CXXScopeSpec SS
The nested-name-specifier that precedes the template name.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
TemplateName getCanonicalTemplateName(TemplateName Name) const
Retrieves the "canonical" template name that refers to a given template.
bool isInvalidDecl() const
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
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...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
DeclarationName - The name of a declaration.
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.
std::string getAsString(ASTContext &Ctx, QualType Ty) const
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
SourceLocation getLocStart() const LLVM_READONLY
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
static Expr * lookThroughRangesV3Condition(Preprocessor &PP, Expr *Cond)
bool isNull() const
Determine whether this template argument has no value.
EnumDecl - Represents an enum.
unsigned getFunctionScopeDepth() const
detail::InMemoryDirectory::const_iterator E
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
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...
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set...
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
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".
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*.
The name refers to a template whose specialization produces a type.
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)
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration...
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
bool isWideCharType() const
unsigned getDepth() const
Get the nesting depth of the template parameter.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("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.
bool empty() const
Return true if no decls were found.
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 * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
ArrayRef< LValuePathEntry > getLValuePath() const
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
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.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
Expr * getAssociatedConstraints() const
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
const T * getAs() const
Member-template getAs<specific type>'.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Determine what kind of template instantiation this function represents.
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
This template specialization was declared or defined by an explicit specialization (C++ [temp...
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)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
unsigned getNumArgs() const
QualType getIntegralType() const
Retrieve the type of the integral value.
bool isNull() const
Determine whether this template name is NULL.
void setTypeSourceInfo(TypeSourceInfo *TI)
void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK)
Specify that this variable is an instantiation of the static data member VD.
bool isFunctionType() 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 ...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Wrapper for source info for record types.
bool isInvalid() const
Determine whether the given template argument is invalid.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
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.
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, AttributeList *Attr)
The template argument is a type.
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
ActionResult< ParsedType > TypeResult
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 TypeClass * getTypePtr() const
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
NestedNameSpecifier * getQualifier() const
bool isInlineSpecified() const
The template argument is actually a parameter pack.
A template-id, e.g., f<int>.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
bool isStaticDataMember() const
Determines whether this is a static data member.
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.
bool isConcept() const
Whether this is a (C++ Concepts TS) function or variable concept.
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...
QualType getPointeeType() const
This is a scope that can contain a declaration.
IdentifierInfo * getIdentifier() const
void CheckTemplatePartialSpecialization(ClassTemplatePartialSpecializationDecl *Partial)
A template argument list.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
const Type * getClass() const
static void checkMoreSpecializedThanPrimary(Sema &S, PartialSpecDecl *Partial)
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
TypeResult ActOnTemplateIdType(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, IdentifierInfo *TemplateII, SourceLocation TemplateIILoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false, bool IsClassName=false)
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.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
SourceLocation getIdentifierLoc() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
const LValueBase getLValueBase() const
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
Represents a template specialization type whose template cannot be resolved, e.g. ...
A user-defined literal name, e.g., operator "" _i.
The template argument is a template name that was provided for a template template parameter...
Represents a C array with an unspecified size.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member...
void setConstexpr(bool IC)
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
void setParam(unsigned i, ParmVarDecl *VD)
Provides information a specialization of a member of a class template, which may be a member function...
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
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...
SourceLocation getRParenLoc() const
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.
static void collectConjunctionTerms(Expr *Clause, SmallVectorImpl< Expr * > &Terms)
Collect all of the separable terms in the given condition, which might be a conjunction.
Declaration of a class template.
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
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'.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
LookupResultKind getResultKind() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
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.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
ArrayRef< ParmVarDecl * > getParams() const
void setRAngleLoc(SourceLocation Loc)
static bool CheckExplicitInstantiationScope(Sema &S, NamedDecl *D, SourceLocation InstLoc, bool WasQualifiedName)
Check the scope of an explicit instantiation.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
StringRef getImmediateMacroName(SourceLocation Loc)
Retrieve the name of the immediate macro expansion.
static Decl::Kind getKind(const Decl *D)
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
void LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType, bool EnteringContext, bool &MemberOfUnknownSpecialization)
static Expr * formAssociatedConstraints(TemplateParameterList *Params, FunctionDecl *FD)
[temp.constr.decl]p2: A template's associated constraints are defined as a single constraint-expressi...
The name refers to a variable template whose specialization produces a variable.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
A reference to a declared variable, function, enum, etc.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isSet() const
Deprecated.
Represents a type template specialization; the template must be a class template, a type alias templa...
NamedDecl * getMostRecentDecl()
SourceLocation getRAngleLoc() const
QualType getElementType() const
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
void setMemberSpecialization()
Note that this member template is a specialization.
SourceLocation getInnerLocStart() const
getInnerLocStart - Return SourceLocation representing start of source range ignoring outer template d...
void setInheritedDefaultArgument(const ASTContext &C, TemplateTemplateParmDecl *Prev)
static bool diagnoseArityMismatch(Sema &S, TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
Diagnose an arity mismatch in the.
static std::pair< Expr *, std::string > findFailedEnableIfCondition(Sema &S, Expr *Cond)
Find the failed subexpression within enable_if, and describe it with a string.
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.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
AttributeList * getNext() const
An l-value expression is a reference to an object with independent storage.
static bool DependsOnTemplateParameters(QualType T, TemplateParameterList *Params)
Determines whether a given type depends on the given parameter list.
StringRef getKindName() const
Wrapper for template type parameters.
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
bool isParameterPack() const
Whether this declaration is a parameter pack.
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)
SourceLocation getLocation() const
void setLexicalDeclContext(DeclContext *DC)
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
NamedDecl - This represents a decl with a name.
bool isInvalidType() const
A boolean literal, per ([C++ lex.bool] Boolean literals).
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.
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
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.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
unsigned NumArgs
NumArgs - The number of template arguments.
The global specifier '::'. There is no stored value.
static void noteNonDeducibleParameters(Sema &S, TemplateParameterList *TemplateParams, const llvm::SmallBitVector &DeducibleParams)
SourceLocation getLocStart() const LLVM_READONLY
void setType(QualType newType)
const TemplateArgument & getArgument() const
SourceRange getSourceRange() const LLVM_READONLY
void setDeletedAsWritten(bool D=true)
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.
void clear()
Clears out any current state.
bool IsInsideALocalClassWithinATemplateFunction()
void setElaboratedKeywordLoc(SourceLocation Loc)
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc, TemplateDecl *TD, const TemplateParmDecl *D, TemplateArgumentListInfo &Args)
Diagnose a missing template argument.
std::vector< const ClassTemplatePartialSpecializationDecl * > PartialSpecs
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.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
NamedDecl *const * iterator
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
AttributeList - Represents a syntactic attribute.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isPointerType() const
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++1z deduced class template specialization type.
SourceLocation getTemplateLoc() const
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type...