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()) {
569 QualType ThisType = cast<CXXMethodDecl>(DC)->getThisType(Context);
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)
800 unsigned Depth,
unsigned Position,
804 "Template type parameter not in template parameter scope!");
810 bool IsParameterPack = EllipsisLoc.
isValid();
813 KeyLoc, Loc,
Depth, Position, ParamName,
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)) {
870 TSI = SubstAutoTypeSourceInfo(TSI, Context.
DependentTy);
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)
933 auto CheckValidDeclSpecifiers = [
this, &D] {
947 Diag(Loc, diag::err_invalid_decl_specifier_in_nontype_parm)
984 CheckValidDeclSpecifiers();
988 diag::warn_cxx14_compat_template_nontype_parm_auto_type)
993 "Non-type template parameter not in template parameter scope!");
994 bool Invalid =
false;
1008 Depth, Position, ParamName,
T,
1009 IsParameterPack, TInfo);
1021 IdResolver.AddDecl(Param);
1027 if (Default && IsParameterPack) {
1028 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1035 if (DiagnoseUnexpandedParameterPack(Default, UPPC_DefaultArgument))
1040 CheckTemplateArgument(Param, Param->
getType(), Default, Converted);
1045 Default = DefaultRes.
get();
1067 "Template template parameter not in template parameter scope!");
1070 bool IsParameterPack = EllipsisLoc.
isValid();
1074 Depth, Position, IsParameterPack,
1084 IdResolver.AddDecl(Param);
1087 if (Params->
size() == 0) {
1096 if (IsParameterPack && !Default.
isInvalid()) {
1097 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1112 Diag(DefaultArg.
getLocation(), diag::err_template_arg_not_valid_template)
1118 if (DiagnoseUnexpandedParameterPack(DefaultArg.
getLocation(),
1120 UPPC_DefaultArgument))
1139 Expr *RequiresClause) {
1141 Diag(ExportLoc, diag::warn_template_export_unsupported);
1144 Context, TemplateLoc, LAngleLoc,
1145 llvm::makeArrayRef(Params.data(), Params.size()),
1146 RAngleLoc, RequiresClause);
1162 unsigned NumOuterTemplateParamLists,
1165 assert(TemplateParams && TemplateParams->
size() > 0 &&
1166 "No template parameters");
1167 assert(TUK != TUK_Reference &&
"Can only declare or define class templates");
1168 bool Invalid =
false;
1171 if (CheckTemplateDeclScope(S, TemplateParams))
1175 assert(Kind !=
TTK_Enum &&
"can't build template of enumerated type");
1179 Diag(KWLoc, diag::err_template_unnamed_class);
1188 (SS.
isEmpty() && TUK == TUK_Friend)
1189 ? LookupTagName : LookupOrdinaryName,
1190 forRedeclarationInCurContext());
1192 SemanticContext = computeDeclContext(SS,
true);
1193 if (!SemanticContext) {
1197 Diag(NameLoc, TUK == TUK_Friend
1198 ? diag::warn_template_qualified_friend_ignored
1199 : diag::err_template_qualified_declarator_no_match)
1201 return TUK != TUK_Friend;
1204 if (RequireCompleteDeclContext(SS, SemanticContext))
1212 if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams))
1214 }
else if (TUK != TUK_Friend && TUK != TUK_Reference)
1215 diagnoseQualifiedDeclaration(SS, SemanticContext, Name, NameLoc);
1217 LookupQualifiedName(
Previous, SemanticContext);
1219 SemanticContext = CurContext;
1225 if (TUK != TUK_Friend &&
1226 DiagnoseClassNameShadow(SemanticContext,
1238 PrevDecl = (*
Previous.begin())->getUnderlyingDecl();
1242 DiagnoseTemplateParameterShadow(NameLoc, PrevDecl);
1250 dyn_cast_or_null<ClassTemplateDecl>(PrevDecl);
1255 if (!PrevClassTemplate && PrevDecl && isa<CXXRecordDecl>(PrevDecl) &&
1256 cast<CXXRecordDecl>(PrevDecl)->isInjectedClassName()) {
1259 = cast<CXXRecordDecl>(PrevDecl)->getDescribedClassTemplate();
1260 if (!PrevClassTemplate && isa<ClassTemplateSpecializationDecl>(PrevDecl)) {
1262 = cast<ClassTemplateSpecializationDecl>(PrevDecl)
1263 ->getSpecializedTemplate();
1267 if (TUK == TUK_Friend) {
1286 PrevDecl = PrevClassTemplate =
nullptr;
1287 SemanticContext = OutermostContext;
1291 Previous.clear(LookupOrdinaryName);
1295 LookupQualifiedName(
Previous, LookupContext);
1301 PrevDecl = (*
Previous.begin())->getUnderlyingDecl();
1304 }
else if (PrevDecl &&
1305 !isDeclInScope(
Previous.getRepresentativeDecl(), SemanticContext,
1307 PrevDecl = PrevClassTemplate =
nullptr;
1309 if (
auto *Shadow = dyn_cast_or_null<UsingShadowDecl>(
1310 PrevDecl ?
Previous.getRepresentativeDecl() :
nullptr)) {
1312 !(PrevClassTemplate &&
1315 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
1316 Diag(Shadow->getTargetDecl()->getLocation(),
1317 diag::note_using_decl_target);
1318 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl) << 0;
1320 PrevDecl = PrevClassTemplate =
nullptr;
1327 if (PrevClassTemplate) {
1331 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
1332 !TemplateParameterListsAreEqual(TemplateParams,
1340 const bool RedeclACMismatch = [&] {
1341 if (!(CurAC || PrevAC))
1343 if (CurAC && PrevAC) {
1344 llvm::FoldingSetNodeID CurACInfo, PrevACInfo;
1345 CurAC->
Profile(CurACInfo, Context,
true);
1346 PrevAC->
Profile(PrevACInfo, Context,
true);
1347 if (CurACInfo == PrevACInfo)
1353 if (RedeclACMismatch) {
1355 diag::err_template_different_associated_constraints);
1357 diag::note_template_prev_declaration) << 0;
1367 if (!isAcceptableTagRedeclaration(PrevRecordDecl, Kind,
1368 TUK == TUK_Definition, KWLoc, Name)) {
1369 Diag(KWLoc, diag::err_use_with_wrong_tag)
1377 if (TUK == TUK_Definition) {
1382 if (SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
1384 auto *Tmpl = cast<CXXRecordDecl>(Hidden)->getDescribedClassTemplate();
1385 assert(Tmpl &&
"original definition of a class template is not a " 1387 makeMergedDefinitionVisible(Hidden);
1388 makeMergedDefinitionVisible(Tmpl);
1392 Diag(NameLoc, diag::err_redefinition) << Name;
1393 Diag(Def->getLocation(), diag::note_previous_definition);
1399 }
else if (PrevDecl) {
1405 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
1414 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
1415 CheckTemplateParameterList(
1419 (SS.
isSet() && SemanticContext && SemanticContext->
isRecord() &&
1421 ? TPC_ClassTemplateMember
1422 : TUK == TUK_Friend ? TPC_FriendClassTemplate
1423 : TPC_ClassTemplate))
1429 if (!SS.
isInvalid() && !Invalid && !PrevClassTemplate) {
1430 Diag(NameLoc, TUK == TUK_Friend ? diag::err_friend_decl_does_not_match
1431 : diag::err_member_decl_does_not_match)
1432 << Name << SemanticContext <<
true << SS.
getRange();
1442 bool ShouldAddRedecl
1443 = !(TUK == TUK_Friend && CurContext->isDependentContext());
1447 PrevClassTemplate && ShouldAddRedecl ?
1451 if (NumOuterTemplateParamLists > 0)
1453 Context, llvm::makeArrayRef(OuterTemplateParamLists,
1454 NumOuterTemplateParamLists));
1458 if (TUK == TUK_Definition) {
1459 AddAlignmentAttributesForRecord(NewClass);
1460 AddMsStructLayoutForRecord(NewClass);
1465 Expr *
const ACtoAttach =
1466 PrevClassTemplate && ShouldAddRedecl ? nullptr : CurAC;
1471 NewClass, ACtoAttach);
1473 if (ShouldAddRedecl)
1478 if (ModulePrivateLoc.
isValid())
1484 assert(T->
isDependentType() &&
"Class template type is not dependent?");
1489 if (PrevClassTemplate &&
1495 SetMemberAccessSpecifier(NewTemplate, PrevClassTemplate, AS);
1501 if (TUK == TUK_Definition)
1505 ProcessDeclAttributeList(S, NewClass, Attr);
1507 if (PrevClassTemplate)
1510 AddPushedVisibilityAttribute(NewClass);
1512 if (TUK != TUK_Friend) {
1517 PushOnScopeChains(NewTemplate, Outer);
1527 if (!CurContext->isDependentContext()) {
1530 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
1531 PushOnScopeChains(NewTemplate, EnclosingScope,
1536 Context, CurContext, NewClass->
getLocation(), NewTemplate, FriendLoc);
1538 CurContext->addDecl(Friend);
1541 if (PrevClassTemplate)
1542 CheckRedeclarationModuleOwnership(NewTemplate, PrevClassTemplate);
1549 ActOnDocumentableDecl(NewTemplate);
1557 struct ConvertConstructorToDeductionGuideTransform {
1558 ConvertConstructorToDeductionGuideTransform(
Sema &S,
1560 : SemaRef(S), Template(Template) {}
1594 AllParams.reserve(TemplateParams->
size() + InnerParams->
size());
1595 AllParams.insert(AllParams.begin(),
1596 TemplateParams->
begin(), TemplateParams->
end());
1597 SubstArgs.reserve(InnerParams->
size());
1605 NamedDecl *NewParam = transformTemplateParameter(Param, Args);
1608 AllParams.push_back(NewParam);
1613 SemaRef.
Context, InnerParams->getTemplateLoc(),
1614 InnerParams->getLAngleLoc(), AllParams, InnerParams->getRAngleLoc(),
1624 Args.addOuterRetainedLevel();
1629 assert(FPTL &&
"no prototype for constructor declaration");
1636 QualType NewType = transformFunctionProtoType(TLB, FPTL, Params, Args);
1641 return buildDeductionGuide(TemplateParams, CD->
isExplicit(), NewTInfo,
1654 DeductionGuideName, EPI);
1662 for (
auto T : ParamTypes) {
1664 SemaRef.
Context, DC, Loc, Loc,
nullptr,
T,
1667 FPTL.
setParam(Params.size(), NewParam);
1668 Params.push_back(NewParam);
1681 if (
auto *TTP = dyn_cast<TemplateTypeParmDecl>(TemplateParam)) {
1685 SemaRef.
Context, DC, TTP->getLocStart(), TTP->getLocation(),
1686 0, Depth1IndexAdjustment + TTP->getIndex(),
1687 TTP->getIdentifier(), TTP->wasDeclaredWithTypename(),
1688 TTP->isParameterPack());
1689 if (TTP->hasDefaultArgument()) {
1691 SemaRef.
SubstType(TTP->getDefaultArgumentInfo(), Args,
1692 TTP->getDefaultArgumentLoc(), TTP->getDeclName());
1693 if (InstantiatedDefaultArg)
1694 NewTTP->setDefaultArgument(InstantiatedDefaultArg);
1701 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(TemplateParam))
1702 return transformTemplateParameterImpl(TTP, Args);
1704 return transformTemplateParameterImpl(
1705 cast<NonTypeTemplateParmDecl>(TemplateParam), Args);
1707 template<
typename TemplateParmDecl>
1709 transformTemplateParameterImpl(TemplateParmDecl *OldParam,
1714 cast_or_null<TemplateParmDecl>(SemaRef.
SubstDecl(OldParam, DC, Args));
1715 assert(NewParam->getDepth() == 0 &&
"unexpected template param depth");
1716 NewParam->setPosition(NewParam->getPosition() + Depth1IndexAdjustment);
1729 ParmVarDecl *NewParam = transformFunctionTypeParam(OldParam, Args);
1732 ParamTypes.push_back(NewParam->
getType());
1733 Params.push_back(NewParam);
1755 ReturnType, ParamTypes, TL.
getLocStart(), DeductionGuideName, EPI);
1765 for (
unsigned I = 0, E = NewTL.
getNumParams(); I != E; ++I)
1782 SemaRef.
SubstType(PackTL.getPatternLoc(), Args,
1784 if (!NewDI)
return nullptr;
1787 PackTL.getTypePtr()->getNumExpansions());
1839 Name, TInfo->
getType(), TInfo, LocEnd);
1841 Guide->setParams(Params);
1843 for (
auto *Param : Params)
1844 Param->setDeclContext(Guide);
1847 SemaRef.
Context, DC, Loc, DeductionGuideName, TemplateParams, Guide);
1848 GuideTemplate->setImplicit();
1849 Guide->setDescribedFunctionTemplate(GuideTemplate);
1851 if (isa<CXXRecordDecl>(DC)) {
1857 return GuideTemplate;
1868 ConvertConstructorToDeductionGuideTransform Transform(
1869 *
this, cast<ClassTemplateDecl>(Template));
1870 if (!isCompleteType(Loc, Transform.DeducedType))
1875 auto Existing = DC->
lookup(Transform.DeductionGuideName);
1876 for (
auto *D : Existing)
1877 if (D->isImplicit())
1893 bool AddedAny =
false;
1894 for (
NamedDecl *D : LookupConstructors(Transform.Primary)) {
1895 D = D->getUnderlyingDecl();
1896 if (D->isInvalidDecl() || D->isImplicit())
1898 D = cast<NamedDecl>(D->getCanonicalDecl());
1902 dyn_cast_or_null<CXXConstructorDecl>(FTD ? FTD->getTemplatedDecl() : D);
1905 if (!CD || (!FTD && CD->isFunctionTemplateSpecialization()))
1908 Transform.transformConstructor(FTD, CD);
1917 Transform.buildSimpleDeductionGuide(None);
1921 cast<CXXDeductionGuideDecl>(
1922 cast<FunctionTemplateDecl>(
1923 Transform.buildSimpleDeductionGuide(Transform.DeducedType))
1924 ->getTemplatedDecl())
1925 ->setIsCopyDeductionCandidate();
1953 diag::warn_cxx98_compat_template_parameter_default_in_function_template
1954 : diag::ext_template_parameter_default_in_function_template)
1963 S.
Diag(ParamLoc, diag::err_template_parameter_default_template_member)
1972 S.
Diag(ParamLoc, diag::err_template_parameter_default_friend_template)
1981 llvm_unreachable(
"Invalid TemplateParamListContext!");
1994 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
1997 if (!NTTP->isParameterPack() &&
1999 NTTP->getTypeSourceInfo(),
2007 = dyn_cast<TemplateTemplateParmDecl>(P))
2040 bool Invalid =
false;
2048 bool SawDefaultArgument =
false;
2054 OldParam = OldParams->
begin();
2056 bool RemoveDefaultArguments =
false;
2058 NewParamEnd = NewParams->
end();
2059 NewParam != NewParamEnd; ++NewParam) {
2061 bool RedundantDefaultArg =
false;
2066 bool MissingDefaultArg =
false;
2069 bool SawParameterPack =
false;
2072 = dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
2074 if (NewTypeParm->hasDefaultArgument() &&
2076 NewTypeParm->getLocation(),
2077 NewTypeParm->getDefaultArgumentInfo()->getTypeLoc()
2079 NewTypeParm->removeDefaultArgument();
2083 = OldParams? cast<TemplateTypeParmDecl>(*OldParam) :
nullptr;
2084 if (NewTypeParm->isParameterPack()) {
2085 assert(!NewTypeParm->hasDefaultArgument() &&
2086 "Parameter packs can't have a default argument!");
2087 SawParameterPack =
true;
2089 NewTypeParm->hasDefaultArgument()) {
2091 NewDefaultLoc = NewTypeParm->getDefaultArgumentLoc();
2092 SawDefaultArgument =
true;
2093 RedundantDefaultArg =
true;
2094 PreviousDefaultArgLoc = NewDefaultLoc;
2098 NewTypeParm->setInheritedDefaultArgument(Context, OldTypeParm);
2100 }
else if (NewTypeParm->hasDefaultArgument()) {
2101 SawDefaultArgument =
true;
2102 PreviousDefaultArgLoc = NewTypeParm->getDefaultArgumentLoc();
2103 }
else if (SawDefaultArgument)
2104 MissingDefaultArg =
true;
2106 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
2108 if (!NewNonTypeParm->isParameterPack() &&
2109 DiagnoseUnexpandedParameterPack(NewNonTypeParm->getLocation(),
2110 NewNonTypeParm->getTypeSourceInfo(),
2111 UPPC_NonTypeTemplateParameterType)) {
2117 if (NewNonTypeParm->hasDefaultArgument() &&
2119 NewNonTypeParm->getLocation(),
2120 NewNonTypeParm->getDefaultArgument()->getSourceRange())) {
2121 NewNonTypeParm->removeDefaultArgument();
2126 = OldParams? cast<NonTypeTemplateParmDecl>(*OldParam) :
nullptr;
2127 if (NewNonTypeParm->isParameterPack()) {
2128 assert(!NewNonTypeParm->hasDefaultArgument() &&
2129 "Parameter packs can't have a default argument!");
2130 if (!NewNonTypeParm->isPackExpansion())
2131 SawParameterPack =
true;
2133 NewNonTypeParm->hasDefaultArgument()) {
2135 NewDefaultLoc = NewNonTypeParm->getDefaultArgumentLoc();
2136 SawDefaultArgument =
true;
2137 RedundantDefaultArg =
true;
2138 PreviousDefaultArgLoc = NewDefaultLoc;
2142 NewNonTypeParm->setInheritedDefaultArgument(Context, OldNonTypeParm);
2144 }
else if (NewNonTypeParm->hasDefaultArgument()) {
2145 SawDefaultArgument =
true;
2146 PreviousDefaultArgLoc = NewNonTypeParm->getDefaultArgumentLoc();
2147 }
else if (SawDefaultArgument)
2148 MissingDefaultArg =
true;
2151 = cast<TemplateTemplateParmDecl>(*NewParam);
2168 = OldParams? cast<TemplateTemplateParmDecl>(*OldParam) :
nullptr;
2171 "Parameter packs can't have a default argument!");
2173 SawParameterPack =
true;
2174 }
else if (OldTemplateParm &&
2179 SawDefaultArgument =
true;
2180 RedundantDefaultArg =
true;
2181 PreviousDefaultArgLoc = NewDefaultLoc;
2186 PreviousDefaultArgLoc
2189 SawDefaultArgument =
true;
2190 PreviousDefaultArgLoc
2192 }
else if (SawDefaultArgument)
2193 MissingDefaultArg =
true;
2199 if (SawParameterPack && (NewParam + 1) != NewParamEnd &&
2200 (TPC == TPC_ClassTemplate || TPC == TPC_VarTemplate ||
2201 TPC == TPC_TypeAliasTemplate)) {
2202 Diag((*NewParam)->getLocation(),
2203 diag::err_template_param_pack_must_be_last_template_parameter);
2207 if (RedundantDefaultArg) {
2211 Diag(NewDefaultLoc, diag::err_template_param_default_arg_redefinition);
2212 Diag(OldDefaultLoc, diag::note_template_param_prev_default_arg);
2214 }
else if (MissingDefaultArg && TPC != TPC_FunctionTemplate) {
2220 Diag((*NewParam)->getLocation(),
2221 diag::err_template_param_default_arg_missing);
2222 Diag(PreviousDefaultArgLoc, diag::note_template_param_prev_default_arg);
2224 RemoveDefaultArguments =
true;
2235 if (RemoveDefaultArguments) {
2237 NewParamEnd = NewParams->
end();
2238 NewParam != NewParamEnd; ++NewParam) {
2240 TTP->removeDefaultArgument();
2242 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
2243 NTTP->removeDefaultArgument();
2245 cast<TemplateTemplateParmDecl>(*NewParam)->removeDefaultArgument();
2265 bool IgnoreNonTypeDependent;
2270 DependencyChecker(
unsigned Depth,
bool IgnoreNonTypeDependent)
2271 :
Depth(Depth), IgnoreNonTypeDependent(IgnoreNonTypeDependent),
2275 : IgnoreNonTypeDependent(IgnoreNonTypeDependent), Match(
false) {
2278 Depth = PD->getDepth();
2280 dyn_cast<NonTypeTemplateParmDecl>(ND)) {
2281 Depth = PD->getDepth();
2283 Depth = cast<TemplateTemplateParmDecl>(ND)->getDepth();
2288 if (ParmDepth >= Depth) {
2296 bool TraverseStmt(
Stmt *S, DataRecursionQueue *Q =
nullptr) {
2301 if (
auto *E = dyn_cast_or_null<Expr>(S))
2302 if (IgnoreNonTypeDependent && !E->isTypeDependent())
2304 return super::TraverseStmt(S, Q);
2307 bool TraverseTypeLoc(
TypeLoc TL) {
2308 if (IgnoreNonTypeDependent && !TL.
isNull() &&
2311 return super::TraverseTypeLoc(TL);
2320 return IgnoreNonTypeDependent || !Matches(T->
getDepth());
2326 if (Matches(PD->getDepth()))
2328 return super::TraverseTemplateName(N);
2333 dyn_cast<NonTypeTemplateParmDecl>(E->
getDecl()))
2334 if (Matches(PD->getDepth(), E->
getExprLoc()))
2336 return super::VisitDeclRefExpr(E);
2358 DependencyChecker Checker(Params,
false);
2359 Checker.TraverseType(T);
2360 return Checker.Match;
2370 if (
const Type *CurType = NNS->getAsType()) {
2376 NNSLoc = NNSLoc.getPrefix();
2419 bool &IsMemberSpecialization,
bool &Invalid) {
2420 IsMemberSpecialization =
false;
2430 = dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS,
true)))
2442 NestedTypes.push_back(T);
2448 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
2449 if (!isa<ClassTemplatePartialSpecializationDecl>(Spec) &&
2451 ExplicitSpecLoc = Spec->getLocation();
2454 }
else if (Record->getTemplateSpecializationKind()
2456 ExplicitSpecLoc = Record->getLocation();
2469 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
2470 if (
TypeDecl *
Parent = dyn_cast<TypeDecl>(Template->getDeclContext()))
2515 std::reverse(NestedTypes.begin(), NestedTypes.end());
2523 bool SawNonEmptyTemplateParameterList =
false;
2525 auto CheckExplicitSpecialization = [&](
SourceRange Range,
bool Recovery) {
2526 if (SawNonEmptyTemplateParameterList) {
2527 Diag(DeclLoc, diag::err_specialize_member_of_template)
2528 << !Recovery << Range;
2530 IsMemberSpecialization =
false;
2537 auto DiagnoseMissingExplicitSpecialization = [&] (
SourceRange Range) {
2539 if (CheckExplicitSpecialization(Range,
true))
2544 if (!ParamLists.empty())
2545 ExpectedTemplateLoc = ParamLists[0]->getTemplateLoc();
2547 ExpectedTemplateLoc = DeclStartLoc;
2549 Diag(DeclLoc, diag::err_template_spec_needs_header)
2555 unsigned ParamIdx = 0;
2556 for (
unsigned TypeIdx = 0, NumTypes = NestedTypes.size(); TypeIdx != NumTypes;
2558 T = NestedTypes[TypeIdx];
2561 bool NeedEmptyTemplateHeader =
false;
2564 bool NeedNonemptyTemplateHeader =
false;
2577 = dyn_cast<ClassTemplatePartialSpecializationDecl>(Record)) {
2578 ExpectedTemplateParams = Partial->getTemplateParameters();
2579 NeedNonemptyTemplateHeader =
true;
2580 }
else if (Record->isDependentType()) {
2581 if (Record->getDescribedClassTemplate()) {
2582 ExpectedTemplateParams = Record->getDescribedClassTemplate()
2583 ->getTemplateParameters();
2584 NeedNonemptyTemplateHeader =
true;
2587 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
2593 NeedEmptyTemplateHeader =
true;
2596 }
else if (Record->getTemplateSpecializationKind()) {
2597 if (Record->getTemplateSpecializationKind()
2599 TypeIdx == NumTypes - 1)
2600 IsMemberSpecialization =
true;
2606 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
2607 ExpectedTemplateParams = Template->getTemplateParameters();
2608 NeedNonemptyTemplateHeader =
true;
2613 NeedNonemptyTemplateHeader =
false;
2623 if (ParamIdx < ParamLists.size()) {
2624 if (ParamLists[ParamIdx]->size() == 0) {
2625 if (CheckExplicitSpecialization(ParamLists[ParamIdx]->
getSourceRange(),
2629 SawNonEmptyTemplateParameterList =
true;
2632 if (NeedEmptyTemplateHeader) {
2635 if (TypeIdx == NumTypes - 1)
2636 IsMemberSpecialization =
true;
2638 if (ParamIdx < ParamLists.size()) {
2639 if (ParamLists[ParamIdx]->size() > 0) {
2641 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
2642 diag::err_template_param_list_matches_nontemplate)
2644 <<
SourceRange(ParamLists[ParamIdx]->getLAngleLoc(),
2645 ParamLists[ParamIdx]->getRAngleLoc())
2657 if (DiagnoseMissingExplicitSpecialization(
2664 if (NeedNonemptyTemplateHeader) {
2670 if (ParamIdx < ParamLists.size() &&
2672 ExpectedTemplateParams =
nullptr;
2677 if (ParamIdx < ParamLists.size()) {
2679 if (ExpectedTemplateParams &&
2680 !TemplateParameterListsAreEqual(ParamLists[ParamIdx],
2681 ExpectedTemplateParams,
2682 true, TPL_TemplateMatch))
2686 CheckTemplateParameterList(ParamLists[ParamIdx],
nullptr,
2687 TPC_ClassTemplateMember))
2694 Diag(DeclLoc, diag::err_template_spec_needs_template_parameters)
2705 if (ParamIdx >= ParamLists.size()) {
2706 if (TemplateId && !IsFriend) {
2722 if (ParamIdx < ParamLists.size() - 1) {
2723 bool HasAnyExplicitSpecHeader =
false;
2724 bool AllExplicitSpecHeaders =
true;
2725 for (
unsigned I = ParamIdx, E = ParamLists.size() - 1; I != E; ++I) {
2726 if (ParamLists[I]->size() == 0)
2727 HasAnyExplicitSpecHeader =
true;
2729 AllExplicitSpecHeaders =
false;
2732 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
2733 AllExplicitSpecHeaders ? diag::warn_template_spec_extra_headers
2734 : diag::err_template_spec_extra_headers)
2735 <<
SourceRange(ParamLists[ParamIdx]->getTemplateLoc(),
2736 ParamLists[ParamLists.size() - 2]->getRAngleLoc());
2741 if (ExplicitSpecLoc.isValid() && HasAnyExplicitSpecHeader)
2742 Diag(ExplicitSpecLoc,
2743 diag::note_explicit_template_spec_does_not_need_header)
2744 << NestedTypes.back();
2749 if (!AllExplicitSpecHeaders)
2760 if (ParamLists.back()->size() == 0 &&
2761 CheckExplicitSpecialization(ParamLists[ParamIdx]->
getSourceRange(),
2767 return ParamLists.back();
2772 Diag(Template->getLocation(), diag::note_template_declared_here)
2773 << (isa<FunctionTemplateDecl>(Template)
2775 : isa<ClassTemplateDecl>(Template)
2777 : isa<VarTemplateDecl>(Template)
2779 : isa<TypeAliasTemplateDecl>(Template) ? 3 : 4)
2780 << Template->getDeclName();
2788 Diag((*I)->getLocation(), diag::note_template_declared_here)
2789 << 0 << (*I)->getDeclName();
2808 if (!Converted[1].getAsType()->isIntegralType(Context)) {
2809 SemaRef.
Diag(TemplateArgs[1].getLocation(),
2810 diag::err_integer_sequence_integral_element_type);
2819 SemaRef.
Diag(TemplateArgs[2].getLocation(),
2820 diag::err_integer_sequence_negative_length);
2828 SyntheticTemplateArgs.
addArgument(TemplateArgs[1]);
2830 for (llvm::APSInt I(NumArgs.getBitWidth(), NumArgs.isUnsigned());
2834 TA, ArgTy, TemplateArgs[2].getLocation()));
2839 TemplateLoc, SyntheticTemplateArgs);
2846 assert(Converted.size() == 2 &&
2847 "__type_pack_element should be given an index and a parameter pack");
2851 llvm::APSInt Index = IndexArg.getAsIntegral();
2852 assert(Index >= 0 &&
"the index used with __type_pack_element should be of " 2853 "type std::size_t, and hence be non-negative");
2854 if (Index >= Ts.pack_size()) {
2855 SemaRef.
Diag(TemplateArgs[0].getLocation(),
2856 diag::err_type_pack_element_out_of_bounds);
2861 auto Nth = std::next(Ts.pack_begin(), Index.getExtValue());
2862 return Nth->getAsType();
2864 llvm_unreachable(
"unexpected BuiltinTemplateDecl!");
2869 return AliasTemplate->
getName().equals(
"enable_if_t");
2881 if (BinOp->getOpcode() == BO_LAnd) {
2889 Terms.push_back(Clause);
2898 if (!BinOp)
return Cond;
2900 if (BinOp->getOpcode() != BO_LOr)
return Cond;
2903 Expr *LHS = BinOp->getLHS();
2905 if (!InnerBinOp)
return Cond;
2907 if (InnerBinOp->getOpcode() != BO_EQ ||
2908 !isa<IntegerLiteral>(InnerBinOp->getRHS()))
2918 if (MacroName ==
"CONCEPT_REQUIRES" || MacroName ==
"CONCEPT_REQUIRES_")
2919 return BinOp->getRHS();
2924 std::pair<Expr *, std::string>
2933 Expr *FailedCond =
nullptr;
2934 for (
Expr *Term : Terms) {
2938 if (isa<CXXBoolLiteralExpr>(TermAsWritten) ||
2939 isa<IntegerLiteral>(TermAsWritten))
2948 if (Term->EvaluateAsBooleanCondition(Succeeded, Context) &&
2950 FailedCond = TermAsWritten;
2956 if (!AllowTopLevelCond)
2957 return {
nullptr,
"" };
2962 std::string Description;
2964 llvm::raw_string_ostream Out(Description);
2965 FailedCond->
printPretty(Out,
nullptr, getPrintingPolicy());
2967 return { FailedCond, Description };
2986 if (!Template || isa<FunctionTemplateDecl>(Template) ||
2987 isa<VarTemplateDecl>(Template)) {
2993 Diag(TemplateLoc, diag::err_template_id_not_a_type)
2995 NoteAllFoundTemplates(Name);
3002 if (CheckTemplateArgumentList(Template, TemplateLoc, TemplateArgs,
3008 bool InstantiationDependent =
false;
3010 dyn_cast<TypeAliasTemplateDecl>(Template)) {
3022 unsigned Depth = AliasTemplate->getTemplateParameters()->getDepth();
3023 for (
unsigned I = 0; I <
Depth; ++I)
3032 TemplateArgLists, AliasTemplate->getLocation(),
3033 AliasTemplate->getDeclName());
3034 if (CanonType.
isNull()) {
3039 if (
auto DeductionInfo = isSFINAEContext()) {
3040 if (*DeductionInfo &&
3041 (*DeductionInfo)->hasSFINAEDiagnostic() &&
3042 (*DeductionInfo)->peekSFINAEDiagnostic().second.getDiagID() ==
3043 diag::err_typename_nested_not_found_enable_if &&
3044 TemplateArgs[0].getArgument().getKind()
3047 std::string FailedDescription;
3048 std::tie(FailedCond, FailedDescription) =
3049 findFailedBooleanCondition(
3050 TemplateArgs[0].getSourceExpression(),
3056 (*DeductionInfo)->takeSFINAEDiagnostic(OldDiag);
3060 (*DeductionInfo)->addSFINAEDiagnostic(
3062 PDiag(diag::err_typename_nested_not_found_requirement)
3063 << FailedDescription
3073 TemplateArgs, InstantiationDependent)) {
3089 if (isa<ClassTemplateDecl>(Template)) {
3092 if (Ctx->isFileContext())
break;
3096 if (!Record)
continue;
3100 if (!isa<ClassTemplatePartialSpecializationDecl>(Record) &&
3107 QualType Injected = cast<InjectedClassNameType>(ICNT)
3108 ->getInjectedSpecializationType();
3121 = dyn_cast<ClassTemplateDecl>(Template)) {
3124 void *InsertPos =
nullptr;
3126 = ClassTemplate->findSpecialization(Converted, InsertPos);
3132 ClassTemplate->getTemplatedDecl()->getTagKind(),
3133 ClassTemplate->getDeclContext(),
3134 ClassTemplate->getTemplatedDecl()->getLocStart(),
3135 ClassTemplate->getLocation(),
3137 Converted,
nullptr);
3138 ClassTemplate->AddSpecialization(Decl, InsertPos);
3139 if (ClassTemplate->isOutOfLine())
3146 InstantiateAttrsForDecl(TemplateArgLists, ClassTemplate->getTemplatedDecl(),
3151 (void)DiagnoseUseOfDecl(Decl, TemplateLoc);
3154 assert(isa<RecordType>(CanonType) &&
3155 "type of non-dependent specialization is not a RecordType");
3156 }
else if (
auto *BTD = dyn_cast<BuiltinTemplateDecl>(Template)) {
3174 bool IsCtorOrDtorName,
bool IsClassName) {
3178 if (!IsCtorOrDtorName && !IsClassName && SS.
isSet()) {
3179 DeclContext *LookupCtx = computeDeclContext(SS,
false);
3187 if (!LookupCtx && isDependentScopeSpecifier(SS)) {
3194 return ActOnTypenameType(
nullptr,
SourceLocation(), SS, TemplateKWLoc,
3195 TemplateD, TemplateII, TemplateIILoc, LAngleLoc,
3196 TemplateArgsIn, RAngleLoc);
3203 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
3204 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
3207 ? diag::err_out_of_line_qualified_id_type_names_constructor
3208 : diag::ext_out_of_line_qualified_id_type_names_constructor)
3218 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
3223 DTN->getQualifier(),
3224 DTN->getIdentifier(),
3236 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
3241 QualType Result = CheckTemplateIdType(Template, TemplateIILoc, TemplateArgs);
3242 if (Result.isNull())
3253 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
3284 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
3293 DTN->getQualifier(),
3294 DTN->getIdentifier(),
3307 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
3318 Diag(TemplateLoc, diag::err_tag_reference_non_tag)
3319 << TAT << NTK_TypeAliasTemplate << TagKind;
3320 Diag(TAT->getLocation(), diag::note_declared_at);
3323 QualType Result = CheckTemplateIdType(Template, TemplateLoc, TemplateArgs);
3324 if (Result.isNull())
3332 assert(Id &&
"templated class must have an identifier");
3334 if (!isAcceptableTagRedeclaration(D, TagKind, TUK == TUK_Definition,
3336 Diag(TagLoc, diag::err_use_with_wrong_tag)
3351 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
3360 return CreateParsedType(Result, TLB.getTypeSourceInfo(Context, Result));
3400 dyn_cast_or_null<TemplateTemplateParmDecl>(
3404 llvm_unreachable(
"unexpected kind of template argument");
3409 if (Params->
size() != Args.size())
3414 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
3441 return TemplateArgs;
3444 template<
typename PartialSpecDecl>
3446 if (Partial->getDeclContext()->isDependentContext())
3455 auto *Template = Partial->getSpecializedTemplate();
3456 S.
Diag(Partial->getLocation(),
3457 diag::ext_partial_spec_not_more_specialized_than_primary)
3458 << isa<VarTemplateDecl>(Template);
3460 if (Info.hasSFINAEDiagnostic()) {
3463 Info.takeSFINAEDiagnostic(Diag);
3467 diag::note_partial_spec_not_more_specialized_than_primary)
3471 S.
Diag(Template->getLocation(), diag::note_template_decl_here);
3476 const llvm::SmallBitVector &DeducibleParams) {
3477 for (
unsigned I = 0, N = DeducibleParams.size(); I != N; ++I) {
3478 if (!DeducibleParams[I]) {
3491 template<
typename PartialSpecDecl>
3493 PartialSpecDecl *Partial) {
3506 auto *TemplateParams = Partial->getTemplateParameters();
3507 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
3509 TemplateParams->getDepth(), DeducibleParams);
3511 if (!DeducibleParams.all()) {
3512 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
3513 S.
Diag(Partial->getLocation(), diag::ext_partial_specs_not_deducible)
3514 << isa<VarTemplatePartialSpecializationDecl>(Partial)
3515 << (NumNonDeducible > 1)
3517 Partial->getTemplateArgsAsWritten()->RAngleLoc);
3538 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
3539 MarkDeducedTemplateParameters(TD, DeducibleParams);
3540 for (
unsigned I = 0; I != TemplateParams->size(); ++I) {
3542 auto *Param = TemplateParams->getParam(I);
3544 DeducibleParams[I] =
true;
3547 if (!DeducibleParams.all()) {
3548 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
3549 Diag(TD->
getLocation(), diag::err_deduction_guide_template_not_deducible)
3550 << (NumNonDeducible > 1);
3561 "Variable template specialization is declared with a template it.");
3578 FnTemplate = *OTS->begin();
3585 << IsPartialSpecialization;
3589 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
3590 if (DiagnoseUnexpandedParameterPack(TemplateArgs[I],
3591 UPPC_PartialSpecialization))
3597 if (CheckTemplateArgumentList(VarTemplate, TemplateNameLoc, TemplateArgs,
3603 if (IsPartialSpecialization) {
3604 if (CheckTemplatePartialSpecializationArgs(TemplateNameLoc, VarTemplate,
3605 TemplateArgs.
size(), Converted))
3610 bool InstantiationDependent;
3614 InstantiationDependent)) {
3615 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
3617 IsPartialSpecialization =
false;
3626 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
3628 << (SC !=
SC_Extern && !CurContext->isRecord())
3636 void *InsertPos =
nullptr;
3639 if (IsPartialSpecialization)
3651 IsPartialSpecialization))
3659 Specialization = PrevDecl;
3662 }
else if (IsPartialSpecialization) {
3665 cast_or_null<VarTemplatePartialSpecializationDecl>(PrevDecl);
3669 TemplateNameLoc, TemplateParams, VarTemplate, DI->
getType(), DI, SC,
3670 Converted, TemplateArgs);
3673 VarTemplate->AddPartialSpecialization(Partial, InsertPos);
3674 Specialization = Partial;
3681 CheckTemplatePartialSpecialization(Partial);
3686 Context, VarTemplate->
getDeclContext(), TemplateKWLoc, TemplateNameLoc,
3687 VarTemplate, DI->
getType(), DI, SC, Converted);
3691 VarTemplate->AddSpecialization(Specialization, InsertPos);
3712 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
3716 diag::note_instantiation_required_here)
3729 CurContext->addDecl(Specialization);
3737 LookupResult PrevSpec(*
this, GetNameForDeclarator(D), LookupOrdinaryName,
3738 forRedeclarationInCurContext());
3753 return Specialization;
3759 struct PartialSpecMatchResult {
3769 assert(Template &&
"A variable template id without template?");
3773 if (CheckTemplateArgumentList(
3774 Template, TemplateNameLoc,
3775 const_cast<TemplateArgumentListInfo &>(TemplateArgs),
false,
3781 void *InsertPos =
nullptr;
3783 Converted, InsertPos)) {
3784 checkSpecializationVisibility(TemplateNameLoc, Spec);
3797 bool AmbiguousPartialSpec =
false;
3798 typedef PartialSpecMatchResult MatchResult;
3813 bool InstantiationDependent =
false;
3815 TemplateArgs, InstantiationDependent)) {
3820 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
3833 Matched.push_back(PartialSpecMatchResult());
3834 Matched.back().Partial = Partial;
3835 Matched.back().Args = Info.take();
3839 if (Matched.size() >= 1) {
3841 if (Matched.size() == 1) {
3854 PEnd = Matched.end();
3856 if (getMoreSpecializedPartialSpecialization(
P->Partial, Best->Partial,
3857 PointOfInstantiation) ==
3865 PEnd = Matched.end();
3867 if (
P != Best && getMoreSpecializedPartialSpecialization(
3868 P->Partial, Best->Partial,
3869 PointOfInstantiation) != Best->Partial) {
3870 AmbiguousPartialSpec =
true;
3877 InstantiationPattern = Best->Partial;
3878 InstantiationArgs = Best->Args;
3891 Template, InstantiationPattern, *InstantiationArgs, TemplateArgs,
3892 Converted, TemplateNameLoc, InsertPos );
3896 if (AmbiguousPartialSpec) {
3899 Diag(PointOfInstantiation, diag::err_partial_spec_ordering_ambiguous)
3903 for (MatchResult
P : Matched)
3904 Diag(
P.Partial->getLocation(), diag::note_partial_spec_match)
3905 << getTemplateArgumentBindingsText(
P.Partial->getTemplateParameters(),
3911 dyn_cast<VarTemplatePartialSpecializationDecl>(InstantiationPattern))
3914 checkSpecializationVisibility(TemplateNameLoc, Decl);
3916 assert(Decl &&
"No variable template specialization?");
3937 return BuildDeclarationNameExpr(SS, NameInfo, Var,
3938 nullptr, TemplateArgs);
3957 assert(!R.
empty() &&
"empty lookup results when building templateid");
3958 assert(!R.
isAmbiguous() &&
"ambiguous lookup when building templateid");
3961 bool InstantiationDependent;
3964 *TemplateArgs, InstantiationDependent)) {
3967 TemplateKWLoc, TemplateArgs);
3978 RequiresADL, TemplateArgs,
3991 assert(TemplateArgs || TemplateKWLoc.
isValid());
3993 if (!(DC = computeDeclContext(SS,
false)) ||
3994 DC->isDependentContext() ||
3995 RequireCompleteDeclContext(SS, DC))
3996 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
3998 bool MemberOfUnknownSpecialization;
4000 LookupTemplateName(R, (
Scope*)
nullptr, SS,
QualType(),
false,
4001 MemberOfUnknownSpecialization);
4007 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_non_template)
4013 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_class_template)
4016 Diag(Temp->getLocation(), diag::note_referenced_class_template);
4020 return BuildTemplateIdExpr(SS, TemplateKWLoc, R,
false, TemplateArgs);
4035 bool EnteringContext,
4037 bool AllowInjectedClassName) {
4040 getLangOpts().CPlusPlus11 ?
4041 diag::warn_cxx98_compat_template_outside_of_template :
4042 diag::ext_template_outside_of_template)
4047 LookupCtx = computeDeclContext(SS, EnteringContext);
4048 if (!LookupCtx && ObjectType)
4049 LookupCtx = computeDeclContext(ObjectType.
get());
4067 bool MemberOfUnknownSpecialization;
4069 ObjectType, EnteringContext, Result,
4070 MemberOfUnknownSpecialization);
4072 isa<CXXRecordDecl>(LookupCtx) &&
4073 (!cast<CXXRecordDecl>(LookupCtx)->hasDefinition() ||
4074 cast<CXXRecordDecl>(LookupCtx)->hasAnyDependentBases())) {
4078 diag::err_template_kw_refers_to_non_template)
4079 << GetNameFromUnqualifiedId(Name).getName()
4086 if (!AllowInjectedClassName && SS.
isSet() && LookupRD &&
4099 diag::ext_out_of_line_qualified_id_type_names_constructor)
4121 llvm_unreachable(
"literal operator id cannot have a dependent scope");
4128 diag::err_template_kw_refers_to_non_template)
4129 << GetNameFromUnqualifiedId(Name).getName()
4157 << (
int)getTemplateNameKindForDiagnostics(Name) << Name << SR;
4170 SS.
Adopt(ArgExpr->getQualifierLoc());
4171 NameInfo = ArgExpr->getNameInfo();
4173 dyn_cast<DependentScopeDeclRefExpr>(Arg.
getAsExpr())) {
4174 SS.
Adopt(ArgExpr->getQualifierLoc());
4175 NameInfo = ArgExpr->getNameInfo();
4177 dyn_cast<CXXDependentScopeMemberExpr>(Arg.
getAsExpr())) {
4178 if (ArgExpr->isImplicitAccess()) {
4179 SS.
Adopt(ArgExpr->getQualifierLoc());
4180 NameInfo = ArgExpr->getMemberNameInfo();
4185 LookupResult Result(*
this, NameInfo, LookupOrdinaryName);
4186 LookupParsedName(Result, CurScope, &SS);
4193 Diag(Loc, getLangOpts().MSVCCompat
4194 ? diag::ext_ms_template_type_arg_missing_typename
4195 : diag::err_template_arg_must_be_type_suggest)
4225 Diag(SR.
getBegin(), diag::err_template_arg_must_be_type) << SR;
4232 if (CheckTemplateArgument(Param, TSI))
4241 if (getLangOpts().ObjCAutoRefCount &&
4287 Param, Template, Converted,
4297 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4302 SemaRef.
SubstType(ArgType, TemplateArgLists,
4339 Param, Template, Converted,
4349 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4401 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4431 bool &HasDefaultArg) {
4432 HasDefaultArg =
false;
4438 HasDefaultArg =
true;
4451 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
4455 HasDefaultArg =
true;
4469 = cast<TemplateTemplateParmDecl>(Param);
4473 HasDefaultArg =
true;
4496 if (ETLoc.getTypePtr()->getKeyword() !=
ETK_None)
4499 QualLoc = ETLoc.getQualifierLoc();
4500 TLoc = ETLoc.getNamedTypeLoc();
4507 QualLoc, InjLoc.getNameLoc());
4515 dyn_cast<ClassTemplateSpecializationDecl>(RecLoc.getDecl()))
4517 QualLoc, RecLoc.getNameLoc());
4553 unsigned ArgumentPackIndex,
4558 return CheckTemplateTypeArgument(TTP, Arg, Converted);
4565 QualType NTTPType = NTTP->getType();
4566 if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack())
4567 NTTPType = NTTP->getExpansionType(ArgumentPackIndex);
4570 !isa<TemplateTemplateParmDecl>(Template) &&
4581 NTTPType = SubstType(NTTPType,
4583 NTTP->getLocation(),
4584 NTTP->getDeclName());
4588 NTTPType = CheckNonTypeTemplateParameterType(NTTPType,
4589 NTTP->getLocation());
4596 llvm_unreachable(
"Should never see a NULL template argument here");
4613 Converted.push_back(Result);
4647 Context, SS.getWithLocInContext(Context), TemplateKWLoc, NameInfo,
4659 E = CheckTemplateArgument(NTTP, NTTPType, E.
get(), Result);
4663 Converted.push_back(Result);
4690 Diag(SR.
getBegin(), diag::err_template_arg_nontype_ambig) << SR << T;
4692 Diag(SR.
getBegin(), diag::err_template_arg_must_be_expr) << SR;
4698 llvm_unreachable(
"Caller must expand template argument packs");
4715 TempParm, Converted,
4721 TempParm = cast_or_null<TemplateTemplateParmDecl>(
4722 SubstDecl(TempParm, CurContext,
4741 llvm_unreachable(
"Should never see a NULL template argument here");
4745 if (CheckTemplateArgument(TempParm, Arg, ArgumentPackIndex))
4756 << getLangOpts().CPlusPlus11;
4760 llvm_unreachable(
"Declaration argument with template template parameter");
4762 llvm_unreachable(
"Integral argument with template template parameter");
4764 llvm_unreachable(
"Null pointer argument with template template parameter");
4767 llvm_unreachable(
"Caller must expand template argument packs");
4778 unsigned NumParams = Params->
size();
4779 unsigned NumArgs = TemplateArgs.
size();
4782 if (NumArgs > NumParams)
4783 Range =
SourceRange(TemplateArgs[NumParams].getLocation(),
4785 S.
Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
4786 << (NumArgs > NumParams)
4788 << Template << Range;
4807 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
4808 if (NTTP->isExpandedParameterPack())
4809 return NTTP->getNumExpansionTypes();
4813 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
4814 if (TTP->isExpandedParameterPack())
4815 return TTP->getNumExpansionTemplateParameters();
4822 template<
typename TemplateParmDecl>
4825 const TemplateParmDecl *D,
4830 ->getTemplateParameters()
4831 ->getParam(D->getIndex()));
4838 D->getDefaultArgumentLoc(), Modules,
4856 bool UpdateArgsWithConversions) {
4867 ->getTemplateParameters();
4876 bool isTemplateTemplateParameter = isa<TemplateTemplateParmDecl>(Template);
4878 unsigned ArgIdx = 0, NumArgs = NewArgs.
size();
4881 ParamEnd = Params->
end();
4882 Param != ParamEnd; ) {
4886 if (*Expansions == ArgumentPack.size()) {
4889 Converted.push_back(
4891 ArgumentPack.clear();
4896 }
else if (ArgIdx == NumArgs && !PartialTemplateArgs) {
4898 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
4900 << (int)getTemplateNameKindForDiagnostics(
TemplateName(Template))
4908 if (ArgIdx < NumArgs) {
4910 if (CheckTemplateArgument(*Param, NewArgs[ArgIdx], Template,
4911 TemplateLoc, RAngleLoc,
4912 ArgumentPack.size(), Converted))
4915 bool PackExpansionIntoNonPack =
4916 NewArgs[ArgIdx].getArgument().isPackExpansion() &&
4918 if (PackExpansionIntoNonPack && isa<TypeAliasTemplateDecl>(Template)) {
4922 Diag(NewArgs[ArgIdx].getLocation(),
4923 diag::err_alias_template_expansion_into_fixed_list)
4924 << NewArgs[ArgIdx].getSourceRange();
4925 Diag((*Param)->getLocation(), diag::note_template_param_here);
4932 if ((*Param)->isTemplateParameterPack()) {
4937 ArgumentPack.push_back(Converted.pop_back_val());
4946 if (PackExpansionIntoNonPack) {
4947 if (!ArgumentPack.empty()) {
4950 Converted.insert(Converted.end(),
4951 ArgumentPack.begin(), ArgumentPack.end());
4952 ArgumentPack.clear();
4955 while (ArgIdx < NumArgs) {
4956 Converted.push_back(NewArgs[ArgIdx].
getArgument());
4967 if (PartialTemplateArgs) {
4968 if ((*Param)->isTemplateParameterPack() && !ArgumentPack.empty())
4969 Converted.push_back(
4977 if ((*Param)->isTemplateParameterPack()) {
4979 "Should have dealt with this already");
4984 if (Param + 1 != ParamEnd)
4987 Converted.push_back(
4989 ArgumentPack.clear();
5020 = dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
5037 = cast<TemplateTemplateParmDecl>(*Param);
5063 if (Inst.isInvalid())
5067 if (CheckTemplateArgument(*Param, Arg, Template, TemplateLoc,
5068 RAngleLoc, 0, Converted))
5074 if (isTemplateTemplateParameter)
5086 if (ArgIdx < NumArgs && CurrentInstantiationScope &&
5087 CurrentInstantiationScope->getPartiallySubstitutedPack()) {
5089 Converted.push_back(NewArgs[ArgIdx++].getArgument());
5094 if (ArgIdx < NumArgs)
5099 if (UpdateArgsWithConversions)
5100 TemplateArgs = std::move(NewArgs);
5106 class UnnamedLocalNoLinkageFinder
5107 :
public TypeVisitor<UnnamedLocalNoLinkageFinder, bool>
5115 UnnamedLocalNoLinkageFinder(
Sema &S,
SourceRange SR) : S(S), SR(SR) { }
5121 #define TYPE(Class, Parent) \ 5122 bool Visit##Class##Type(const Class##Type *); 5123 #define ABSTRACT_TYPE(Class, Parent) \ 5124 bool Visit##Class##Type(const Class##Type *) { return false; } 5125 #define NON_CANONICAL_TYPE(Class, Parent) \ 5126 bool Visit##Class##Type(const Class##Type *) { return false; } 5127 #include "clang/AST/TypeNodes.def" 5129 bool VisitTagDecl(
const TagDecl *Tag);
5134 bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(
const BuiltinType*) {
5138 bool UnnamedLocalNoLinkageFinder::VisitComplexType(
const ComplexType*
T) {
5142 bool UnnamedLocalNoLinkageFinder::VisitPointerType(
const PointerType* T) {
5146 bool UnnamedLocalNoLinkageFinder::VisitBlockPointerType(
5151 bool UnnamedLocalNoLinkageFinder::VisitLValueReferenceType(
5156 bool UnnamedLocalNoLinkageFinder::VisitRValueReferenceType(
5161 bool UnnamedLocalNoLinkageFinder::VisitMemberPointerType(
5166 bool UnnamedLocalNoLinkageFinder::VisitConstantArrayType(
5171 bool UnnamedLocalNoLinkageFinder::VisitIncompleteArrayType(
5176 bool UnnamedLocalNoLinkageFinder::VisitVariableArrayType(
5181 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedArrayType(
5186 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedExtVectorType(
5191 bool UnnamedLocalNoLinkageFinder::VisitDependentAddressSpaceType(
5196 bool UnnamedLocalNoLinkageFinder::VisitVectorType(
const VectorType* T) {
5200 bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(
const ExtVectorType* T) {
5204 bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
5214 bool UnnamedLocalNoLinkageFinder::VisitFunctionNoProtoType(
5219 bool UnnamedLocalNoLinkageFinder::VisitUnresolvedUsingType(
5224 bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(
const TypeOfExprType*) {
5228 bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(
const TypeOfType* T) {
5232 bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(
const DecltypeType*) {
5236 bool UnnamedLocalNoLinkageFinder::VisitUnaryTransformType(
5241 bool UnnamedLocalNoLinkageFinder::VisitAutoType(
const AutoType *T) {
5245 bool UnnamedLocalNoLinkageFinder::VisitDeducedTemplateSpecializationType(
5250 bool UnnamedLocalNoLinkageFinder::VisitRecordType(
const RecordType* T) {
5251 return VisitTagDecl(T->
getDecl());
5254 bool UnnamedLocalNoLinkageFinder::VisitEnumType(
const EnumType* T) {
5255 return VisitTagDecl(T->
getDecl());
5258 bool UnnamedLocalNoLinkageFinder::VisitTemplateTypeParmType(
5263 bool UnnamedLocalNoLinkageFinder::VisitSubstTemplateTypeParmPackType(
5268 bool UnnamedLocalNoLinkageFinder::VisitTemplateSpecializationType(
5273 bool UnnamedLocalNoLinkageFinder::VisitInjectedClassNameType(
5275 return VisitTagDecl(T->
getDecl());
5278 bool UnnamedLocalNoLinkageFinder::VisitDependentNameType(
5283 bool UnnamedLocalNoLinkageFinder::VisitDependentTemplateSpecializationType(
5288 bool UnnamedLocalNoLinkageFinder::VisitPackExpansionType(
5293 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectType(
const ObjCObjectType *) {
5297 bool UnnamedLocalNoLinkageFinder::VisitObjCInterfaceType(
5302 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectPointerType(
5307 bool UnnamedLocalNoLinkageFinder::VisitAtomicType(
const AtomicType* T) {
5311 bool UnnamedLocalNoLinkageFinder::VisitPipeType(
const PipeType* T) {
5315 bool UnnamedLocalNoLinkageFinder::VisitTagDecl(
const TagDecl *Tag) {
5317 S.
Diag(SR.getBegin(),
5319 diag::warn_cxx98_compat_template_arg_local_type :
5320 diag::ext_template_arg_local_type)
5326 S.
Diag(SR.getBegin(),
5328 diag::warn_cxx98_compat_template_arg_unnamed_type :
5329 diag::ext_template_arg_unnamed_type) << SR;
5337 bool UnnamedLocalNoLinkageFinder::VisitNestedNameSpecifier(
5354 llvm_unreachable(
"Invalid NestedNameSpecifier::Kind!");
5364 assert(ArgInfo &&
"invalid TypeSourceInfo");
5369 return Diag(SR.
getBegin(), diag::err_variably_modified_template_arg) << Arg;
5371 return Diag(SR.
getBegin(), diag::err_template_arg_overload_type) << SR;
5382 UnnamedLocalNoLinkageFinder Finder(*
this, SR);
5400 Decl *Entity =
nullptr) {
5406 if (Entity && Entity->hasAttr<DLLImportAttr>())
5411 "Incomplete parameter type in isNullPointerValueTemplateArgument!");
5424 EvalResult.
Diag = &Notes;
5432 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
5433 diag::note_invalid_subexpr_in_const_expr) {
5434 DiagLoc = Notes[0].first;
5438 S.
Diag(DiagLoc, diag::err_template_arg_not_address_constant)
5440 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
5441 S.
Diag(Notes[I].first, Notes[I].second);
5459 bool ObjCLifetimeConversion;
5462 ObjCLifetimeConversion))
5467 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
5476 std::string Code =
"static_cast<" + ParamType.
getAsString() +
">(";
5477 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_untyped_null_constant)
5496 bool ObjCLifetimeConversion;
5500 ObjCLifetimeConversion)) {
5505 if (!ParamRef->getPointeeType()->isFunctionType()) {
5515 unsigned ParamQuals = ParamRef->getPointeeType().getCVRQualifiers();
5518 if ((ParamQuals | ArgQuals) != ParamQuals) {
5520 diag::err_template_arg_ref_bind_ignores_quals)
5556 bool Invalid =
false;
5560 bool AddressTaken =
false;
5567 bool ExtWarnMSTemplateArg =
false;
5570 while (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(Arg)) {
5572 if (UnOpKind == UO_Deref)
5573 ExtWarnMSTemplateArg =
true;
5574 if (UnOpKind == UO_AddrOf || UnOpKind == UO_Deref) {
5577 FirstOpKind = UnOpKind;
5578 FirstOpLoc = UnOp->getOperatorLoc();
5584 if (ExtWarnMSTemplateArg)
5588 if (FirstOpKind == UO_AddrOf)
5589 AddressTaken =
true;
5593 assert(FirstOpKind == UO_Deref);
5616 bool ExtraParens =
false;
5617 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
5618 if (!Invalid && !ExtraParens) {
5621 ? diag::warn_cxx98_compat_template_arg_extra_parens
5622 : diag::ext_template_arg_extra_parens)
5627 Arg = Parens->getSubExpr();
5631 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
5635 if (UnOp->getOpcode() == UO_AddrOf) {
5636 Arg = UnOp->getSubExpr();
5637 AddressTaken =
true;
5638 AddrOpLoc = UnOp->getOperatorLoc();
5643 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
5655 S.
Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
5675 if (isa<CXXUuidofExpr>(Arg)) {
5677 ArgIn, Arg, ArgType))
5692 if (isa<FieldDecl>(Entity) || isa<IndirectFieldDecl>(Entity)) {
5700 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Entity)) {
5701 if (!Method->isStatic()) {
5713 if (!Func && !Var) {
5724 diag::warn_cxx98_compat_template_arg_object_internal :
5725 diag::ext_template_arg_object_internal)
5727 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
5729 }
else if (!Entity->hasLinkage()) {
5732 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
5747 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
5753 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
5762 if (Var->getType()->isReferenceType()) {
5764 diag::err_template_arg_reference_var)
5771 if (Var->getTLSKind()) {
5774 S.
Diag(Var->getLocation(), diag::note_template_arg_refers_here);
5787 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
5793 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
5798 ArgType = Var->getType();
5801 if (Var->getType()->isArrayType()) {
5843 bool Invalid =
false;
5845 Expr *Arg = ResultArg;
5846 bool ObjCLifetimeConversion;
5858 bool ExtraParens =
false;
5859 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
5860 if (!Invalid && !ExtraParens) {
5863 diag::warn_cxx98_compat_template_arg_extra_parens :
5864 diag::ext_template_arg_extra_parens)
5869 Arg = Parens->getSubExpr();
5873 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
5878 if (UnOp->getOpcode() == UO_AddrOf) {
5885 else if ((DRE = dyn_cast<DeclRefExpr>(Arg))) {
5887 if (VD->getType()->isMemberPointerType()) {
5888 if (isa<NonTypeTemplateParmDecl>(VD)) {
5892 VD = cast<ValueDecl>(VD->getCanonicalDecl());
5911 S.
Diag(ResultArg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
5921 ObjCLifetimeConversion)) {
5928 S.
Diag(ResultArg->
getLocStart(), diag::err_template_arg_not_convertible)
5936 diag::err_template_arg_not_pointer_to_member_form)
5939 if (isa<FieldDecl>(DRE->
getDecl()) ||
5940 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
5941 isa<CXXMethodDecl>(DRE->
getDecl())) {
5942 assert((isa<FieldDecl>(DRE->
getDecl()) ||
5943 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
5944 !cast<CXXMethodDecl>(DRE->
getDecl())->isStatic()) &&
5945 "Only non-static member pointers can make it here");
5960 diag::err_template_arg_not_pointer_to_member_form)
5987 auto *AT = dyn_cast<
AutoType>(ParamType);
5988 if (AT && AT->isDecltypeAuto()) {
5998 if (CTAK != CTAK_Specified)
6002 Arg, ParamType, Depth) == DAR_Failed) {
6004 diag::err_non_type_template_parm_type_deduction_failure)
6014 ParamType = CheckNonTypeTemplateParameterType(ParamType, Arg->
getExprLoc());
6015 if (ParamType.
isNull()) {
6023 "non-type template parameter type cannot be qualified");
6025 if (CTAK == CTAK_Deduced &&
6044 Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
6070 Arg, ParamType, Value, CCEK_TemplateArg);
6076 if (ArgResult.
get()->isValueDependent()) {
6099 diag::err_template_arg_member_ptr_base_derived_not_supported)
6107 : TemplateArgument(CanonParamType,
true);
6120 if (isa<CXXUuidofExpr>(E)) {
6132 VD && VD->getType()->isArrayType() &&
6140 Diag(StartLoc, diag::err_non_type_template_arg_subobject)
6145 "null reference should not be a constant expression");
6147 "non-null value of type nullptr_t?");
6149 : TemplateArgument(CanonParamType,
true);
6153 return Diag(StartLoc, diag::err_non_type_template_arg_addr_label_diff);
6161 llvm_unreachable(
"invalid kind for template argument");
6164 return ArgResult.
get();
6184 if (getLangOpts().CPlusPlus11) {
6200 if (ArgResult.
get()->isValueDependent()) {
6210 IntegerType = Enum->getDecl()->getIntegerType();
6211 Value = Value.extOrTrunc(Context.
getTypeSize(IntegerType));
6218 ExprResult ArgResult = DefaultLvalueConversion(Arg);
6221 Arg = ArgResult.
get();
6235 diag::err_template_arg_not_integral_or_enumeral)
6244 TmplArgICEDiagnoser(
QualType T) :
T(T) { }
6248 S.
Diag(Loc, diag::err_template_arg_not_ice) << T << SR;
6250 } Diagnoser(ArgType);
6252 Arg = VerifyIntegerConstantExpression(Arg, &Value, Diagnoser,
6267 Arg = ImpCastExprToType(Arg, ParamType, CK_IntegralToBoolean).get();
6268 }
else if (IsIntegralPromotion(Arg, ArgType, ParamType) ||
6271 Arg = ImpCastExprToType(Arg, ParamType, CK_IntegralCast).get();
6275 diag::err_template_arg_not_convertible)
6298 unsigned AllowedBits = Context.
getTypeSize(IntegerType);
6299 if (Value.getBitWidth() != AllowedBits)
6300 Value = Value.extOrTrunc(AllowedBits);
6303 llvm::APSInt OldValue =
Value;
6307 unsigned AllowedBits = Context.
getTypeSize(IntegerType);
6308 if (Value.getBitWidth() != AllowedBits)
6309 Value = Value.extOrTrunc(AllowedBits);
6314 && (OldValue.isSigned() && OldValue.isNegative())) {
6316 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
6322 unsigned RequiredBits;
6324 RequiredBits = OldValue.getActiveBits();
6325 else if (OldValue.isUnsigned())
6326 RequiredBits = OldValue.getActiveBits() + 1;
6328 RequiredBits = OldValue.getMinSignedBits();
6329 if (RequiredBits > AllowedBits) {
6331 diag::warn_template_arg_too_large)
6332 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
6373 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg, ParamType,
6379 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
6405 "Only object pointers allowed here");
6421 assert(ParamRefType->getPointeeType()->isIncompleteOrObjectType() &&
6422 "Only object references allowed here");
6425 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg,
6426 ParamRefType->getPointeeType(),
6432 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
6455 << Arg->
getType() << ParamType;
6463 Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
6491 unsigned ArgumentPackIndex) {
6496 assert(Name.
isDependent() &&
"Non-dependent template isn't a declaration?");
6515 if (!isa<ClassTemplateDecl>(Template) &&
6516 !isa<TemplateTemplateParmDecl>(Template) &&
6517 !isa<TypeAliasTemplateDecl>(Template) &&
6518 !isa<BuiltinTemplateDecl>(Template)) {
6519 assert(isa<FunctionTemplateDecl>(Template) &&
6520 "Only function templates are possible here");
6522 Diag(Template->
getLocation(), diag::note_template_arg_refers_here_func)
6533 if (getLangOpts().RelaxedTemplateTemplateArgs) {
6538 if (TemplateParameterListsAreEqual(
6540 TPL_TemplateTemplateArgumentMatch, Arg.
getLocation()))
6543 if (isTemplateTemplateParameterAtLeastAsSpecializedAs(Params, Template,
6552 TPL_TemplateTemplateArgumentMatch,
6577 return ImpCastExprToType(
6581 ? CK_NullToMemberPointer
6582 : CK_NullToPointer);
6585 "Only declaration template arguments permitted here");
6589 if (VD->getDeclContext()->isRecord() &&
6590 (isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD) ||
6591 isa<IndirectFieldDecl>(VD))) {
6610 if (isa<CXXMethodDecl>(VD) && cast<CXXMethodDecl>(VD)->isInstance())
6614 VD->getType().getNonReferenceType(),
6621 RefExpr = CreateBuiltinUnaryOp(Loc, UO_AddrOf, RefExpr.
get());
6626 bool ObjCLifetimeConversion;
6627 if (IsQualificationConversion(((
Expr*) RefExpr.
get())->getType(),
6629 ObjCLifetimeConversion))
6639 QualType T = VD->getType().getNonReferenceType();
6651 RefExpr = DefaultFunctionArrayConversion(RefExpr.
get());
6659 return CreateBuiltinUnaryOp(Loc, UO_AddrOf, RefExpr.
get());
6671 }
else if (isa<FunctionDecl>(VD)) {
6676 return BuildDeclRefExpr(VD, T, VK, Loc);
6690 "Operation is only valid for integral template arguments");
6700 T = ET->getDecl()->getIntegerType();
6727 if (OrigT->isEnumeralType()) {
6747 unsigned NextDiag = diag::err_template_param_different_kind;
6748 if (TemplateArgLoc.
isValid()) {
6749 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
6750 NextDiag = diag::note_template_param_different_kind;
6769 unsigned NextDiag = diag::err_template_parameter_pack_non_pack;
6770 if (TemplateArgLoc.
isValid()) {
6771 S.
Diag(TemplateArgLoc,
6772 diag::err_template_arg_template_params_mismatch);
6773 NextDiag = diag::note_template_parameter_pack_non_pack;
6776 unsigned ParamKind = isa<TemplateTypeParmDecl>(New)? 0
6777 : isa<NonTypeTemplateParmDecl>(New)? 1
6790 = dyn_cast<NonTypeTemplateParmDecl>(Old)) {
6798 (OldNTTP->getType()->isDependentType() ||
6804 unsigned NextDiag = diag::err_template_nontype_parm_different_type;
6805 if (TemplateArgLoc.
isValid()) {
6806 S.
Diag(TemplateArgLoc,
6807 diag::err_template_arg_template_params_mismatch);
6808 NextDiag = diag::note_template_nontype_parm_different_type;
6813 S.
Diag(OldNTTP->getLocation(),
6814 diag::note_template_nontype_parm_prev_declaration)
6815 << OldNTTP->getType();
6828 = dyn_cast<TemplateTemplateParmDecl>(Old)) {
6831 OldTTP->getTemplateParameters(),
6850 unsigned NextDiag = diag::err_template_param_list_different_arity;
6851 if (TemplateArgLoc.
isValid()) {
6852 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
6853 NextDiag = diag::note_template_param_list_different_arity;
6893 if (Old->
size() != New->
size() && Kind != TPL_TemplateTemplateArgumentMatch) {
6910 OldParmEnd = Old->
end();
6911 OldParm != OldParmEnd; ++OldParm) {
6912 if (Kind != TPL_TemplateTemplateArgumentMatch ||
6913 !(*OldParm)->isTemplateParameterPack()) {
6914 if (NewParm == NewParmEnd) {
6923 Kind, TemplateArgLoc))
6937 for (; NewParm != NewParmEnd; ++NewParm) {
6939 Kind, TemplateArgLoc))
6945 if (NewParm != NewParmEnd) {
6977 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
6991 if (RD->isLocalClass())
6993 diag::err_template_inside_local_class)
7001 diag::err_template_outside_namespace_or_class_scope)
7012 return Record->getTemplateSpecializationKind();
7013 if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(D))
7014 return Function->getTemplateSpecializationKind();
7015 if (
VarDecl *Var = dyn_cast<VarDecl>(D))
7016 return Var->getTemplateSpecializationKind();
7053 if (isa<ClassTemplateDecl>(Specialized))
7054 EntityKind = IsPartialSpecialization? 1 : 0;
7055 else if (isa<VarTemplateDecl>(Specialized))
7056 EntityKind = IsPartialSpecialization ? 3 : 2;
7057 else if (isa<FunctionTemplateDecl>(Specialized))
7059 else if (isa<CXXMethodDecl>(Specialized))
7061 else if (isa<VarDecl>(Specialized))
7063 else if (isa<RecordDecl>(Specialized))
7065 else if (isa<EnumDecl>(Specialized) && S.
getLangOpts().CPlusPlus11)
7068 S.
Diag(Loc, diag::err_template_spec_unknown_kind)
7088 S.
Diag(Loc, diag::err_template_spec_decl_function_scope)
7099 S.
Diag(Loc, diag::ext_function_specialization_in_class)
7102 S.
Diag(Loc, diag::err_template_spec_decl_class_scope)
7112 S.
Diag(Loc, diag::err_template_spec_decl_class_scope)
7132 if (!DC->
Encloses(SpecializedContext) &&
7133 !(isa<FunctionTemplateDecl>(Specialized) ||
7134 isa<FunctionDecl>(Specialized) ||
7135 isa<VarTemplateDecl>(Specialized) ||
7136 isa<VarDecl>(Specialized))) {
7137 if (isa<TranslationUnitDecl>(SpecializedContext))
7138 S.
Diag(Loc, diag::err_template_spec_redecl_global_scope)
7139 << EntityKind << Specialized;
7140 else if (isa<NamespaceDecl>(SpecializedContext)) {
7141 int Diag = diag::err_template_spec_redecl_out_of_scope;
7143 Diag = diag::ext_ms_template_spec_redecl_out_of_scope;
7144 S.
Diag(Loc, Diag) << EntityKind << Specialized
7145 << cast<NamedDecl>(SpecializedContext);
7147 llvm_unreachable(
"unexpected namespace context for specialization");
7149 S.
Diag(Specialized->getLocation(), diag::note_specialized_entity);
7150 }
else if ((!PrevDecl ||
7169 bool IsCPlusPlus11Extension = DC->
Encloses(SpecializedContext);
7170 if (isa<TranslationUnitDecl>(SpecializedContext)) {
7171 assert(!IsCPlusPlus11Extension &&
7172 "DC encloses TU but isn't in enclosing namespace set");
7173 S.
Diag(Loc, diag::err_template_spec_decl_out_of_scope_global)
7174 << EntityKind << Specialized;
7175 }
else if (isa<NamespaceDecl>(SpecializedContext)) {
7177 if (!IsCPlusPlus11Extension)
7178 Diag = diag::err_template_spec_decl_out_of_scope;
7180 Diag = diag::ext_template_spec_decl_out_of_scope;
7182 Diag = diag::warn_cxx98_compat_template_spec_decl_out_of_scope;
7184 << EntityKind << Specialized << cast<NamedDecl>(SpecializedContext);
7197 DependencyChecker Checker(Depth,
true);
7198 Checker.TraverseStmt(E);
7199 if (Checker.MatchLoc.isInvalid())
7201 return Checker.MatchLoc;
7207 DependencyChecker Checker(Depth,
true);
7208 Checker.TraverseTypeLoc(TL);
7209 if (Checker.MatchLoc.isInvalid())
7211 return Checker.MatchLoc;
7219 for (
unsigned I = 0; I != NumArgs; ++I) {
7222 S, TemplateNameLoc, Param, Args[I].pack_begin(),
7223 Args[I].pack_size(), IsDefaultArgument))
7236 ArgExpr = Expansion->getPattern();
7240 ArgExpr = ICE->getSubExpr();
7250 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ArgExpr))
7251 if (isa<NonTypeTemplateParmDecl>(DRE->getDecl()))
7271 if (ParamUseRange.
isValid()) {
7272 if (IsDefaultArgument) {
7273 S.
Diag(TemplateNameLoc,
7274 diag::err_dependent_non_type_arg_in_partial_spec);
7276 diag::note_dependent_non_type_default_arg_in_partial_spec)
7280 diag::err_dependent_non_type_arg_in_partial_spec)
7288 if (ParamUseRange.
isValid()) {
7290 diag::err_dependent_typed_non_type_arg_in_partial_spec)
7293 << (IsDefaultArgument ? ParamUseRange :
SourceRange())
7323 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
7330 Param, &TemplateArgs[I],
7331 1, I >= NumExplicit))
7346 TemplateParameterLists,
7348 assert(TUK != TUK_Reference &&
"References are not specializations");
7355 ? TemplateParameterLists[0]->getTemplateLoc() : KWLoc;
7365 if (!ClassTemplate) {
7366 Diag(TemplateNameLoc, diag::err_not_class_template_specialization)
7372 bool isMemberSpecialization =
false;
7373 bool isPartialSpecialization =
false;
7379 bool Invalid =
false;
7381 MatchTemplateParametersToScopeSpecifier(
7382 KWLoc, TemplateNameLoc, SS, &TemplateId,
7383 TemplateParameterLists, TUK == TUK_Friend, isMemberSpecialization,
7388 if (TemplateParams && TemplateParams->
size() > 0) {
7389 isPartialSpecialization =
true;
7391 if (TUK == TUK_Friend) {
7392 Diag(KWLoc, diag::err_partial_specialization_friend)
7400 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
7403 if (TTP->hasDefaultArgument()) {
7404 Diag(TTP->getDefaultArgumentLoc(),
7405 diag::err_default_arg_in_partial_spec);
7406 TTP->removeDefaultArgument();
7409 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
7410 if (
Expr *DefArg = NTTP->getDefaultArgument()) {
7411 Diag(NTTP->getDefaultArgumentLoc(),
7412 diag::err_default_arg_in_partial_spec)
7413 << DefArg->getSourceRange();
7414 NTTP->removeDefaultArgument();
7420 diag::err_default_arg_in_partial_spec)
7426 }
else if (TemplateParams) {
7427 if (TUK == TUK_Friend)
7428 Diag(KWLoc, diag::err_template_spec_friend)
7434 assert(TUK == TUK_Friend &&
"should have a 'template<>' for this decl");
7440 assert(Kind !=
TTK_Enum &&
"Invalid enum tag in class template spec!");
7442 Kind, TUK == TUK_Definition, KWLoc,
7444 Diag(KWLoc, diag::err_use_with_wrong_tag)
7449 diag::note_previous_use);
7458 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
7459 if (DiagnoseUnexpandedParameterPack(TemplateArgs[I],
7460 UPPC_PartialSpecialization))
7466 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
7467 TemplateArgs,
false, Converted))
7472 if (isPartialSpecialization) {
7473 if (CheckTemplatePartialSpecializationArgs(TemplateNameLoc, ClassTemplate,
7474 TemplateArgs.
size(), Converted))
7479 bool InstantiationDependent;
7482 TemplateArgs.
arguments(), InstantiationDependent)) {
7483 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
7485 isPartialSpecialization =
false;
7489 void *InsertPos =
nullptr;
7492 if (isPartialSpecialization)
7502 if (TUK != TUK_Friend &&
7505 isPartialSpecialization))
7510 if (isPartialSpecialization) {
7526 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
7527 << 0 << (TUK == TUK_Definition)
7529 return CheckClassTemplate(S, TagSpec, TUK, KWLoc, SS,
7536 TemplateParameterLists.size() - 1,
7537 TemplateParameterLists.data());
7542 = cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl);
7546 KWLoc, TemplateNameLoc,
7554 if (TemplateParameterLists.size() > 1 && SS.
isSet()) {
7555 Partial->setTemplateParameterListsInfo(
7556 Context, TemplateParameterLists.drop_back(1));
7560 ClassTemplate->AddPartialSpecialization(Partial, InsertPos);
7561 Specialization = Partial;
7565 if (PrevPartial && PrevPartial->getInstantiatedFromMember())
7566 PrevPartial->setMemberSpecialization();
7568 CheckTemplatePartialSpecialization(Partial);
7575 KWLoc, TemplateNameLoc,
7580 if (TemplateParameterLists.size() > 0) {
7582 TemplateParameterLists);
7586 ClassTemplate->AddSpecialization(Specialization, InsertPos);
7588 if (CurContext->isDependentContext()) {
7591 assert(getLangOpts().MicrosoftExt &&
7592 "Only possible with -fms-extensions!");
7595 CanonTemplate, Converted);
7619 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
7623 diag::note_instantiation_required_here)
7631 if (TUK != TUK_Friend)
7635 if (TUK == TUK_Definition) {
7638 if (Def && SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
7640 makeMergedDefinitionVisible(Hidden);
7642 TUK = TUK_Declaration;
7645 Diag(TemplateNameLoc, diag::err_redefinition) << Specialization << Range;
7653 ProcessDeclAttributeList(S, Specialization, Attr);
7657 if (TUK == TUK_Definition) {
7658 AddAlignmentAttributesForRecord(Specialization);
7659 AddMsStructLayoutForRecord(Specialization);
7662 if (ModulePrivateLoc.
isValid())
7663 Diag(Specialization->
getLocation(), diag::err_module_private_specialization)
7664 << (isPartialSpecialization? 1 : 0)
7676 TemplateArgs, CanonType);
7677 if (TUK != TUK_Friend) {
7693 if (TUK == TUK_Definition)
7696 if (TUK == TUK_Friend) {
7702 CurContext->addDecl(Friend);
7707 CurContext->addDecl(Specialization);
7709 return Specialization;
7715 Decl *NewDecl = HandleDeclarator(S, D, TemplateParameterLists);
7716 ActOnDocumentableDecl(NewDecl);
7727 FD->setInlineSpecified(
false);
7738 for (
Decl *Prev = D; Prev && !PrevDiagLoc.
isValid();
7739 Prev = Prev->getPreviousDecl()) {
7740 PrevDiagLoc = Prev->getLocation();
7742 assert(PrevDiagLoc.
isValid() &&
7743 "Explicit instantiation without point of instantiation?");
7775 bool &HasNoEffect) {
7776 HasNoEffect =
false;
7783 "previous declaration must be implicit!");
7796 if (PrevPointOfInstantiation.
isInvalid()) {
7808 PrevPointOfInstantiation.
isValid()) &&
7809 "Explicit instantiation without point of instantiation?");
7823 Diag(NewLoc, diag::err_specialization_after_instantiation)
7825 Diag(PrevPointOfInstantiation, diag::note_instantiation_required_here)
7830 llvm_unreachable(
"The switch over PrevTSK must be exhaustive.");
7860 diag::err_explicit_instantiation_declaration_after_definition);
7866 diag::note_explicit_instantiation_definition_here);
7885 Diag(NewLoc, diag::warn_explicit_instantiation_after_specialization)
7888 diag::note_previous_template_specialization);
7918 Diag(NewLoc, (getLangOpts().MSVCCompat)
7919 ? diag::ext_explicit_instantiation_duplicate
7920 : diag::err_explicit_instantiation_duplicate)
7923 diag::note_previous_explicit_instantiation);
7929 llvm_unreachable(
"Missing specialization/instantiation case?");
7957 if (!isa<FunctionTemplateDecl>(D) ||
7965 if (Previous.
empty())
return true;
7968 ExplicitTemplateArgs);
7999 llvm::SmallDenseMap<FunctionDecl *, TemplateArgumentListInfo, 8>
8000 ConvertedTemplateArgs;
8022 if (OldMD && OldMD->
isConst()) {
8032 if (ExplicitTemplateArgs)
8033 Args = *ExplicitTemplateArgs;
8045 cast<FunctionTemplateDecl>(FunTmpl->getFirstDecl()),
8046 ExplicitTemplateArgs ? &Args :
nullptr, FT, Specialization,
8050 FailedCandidates.addCandidate().set(
8051 I.getPair(), FunTmpl->getTemplatedDecl(),
8062 if (LangOpts.CUDA &&
8063 IdentifyCUDATarget(Specialization,
8065 IdentifyCUDATarget(FD,
true)) {
8066 FailedCandidates.addCandidate().set(
8067 I.getPair(), FunTmpl->getTemplatedDecl(),
8073 if (ExplicitTemplateArgs)
8074 ConvertedTemplateArgs[Specialization] = std::move(Args);
8075 Candidates.
addDecl(Specialization, I.getAccess());
8081 Candidates.
begin(), Candidates.
end(), FailedCandidates,
8083 PDiag(diag::err_function_template_spec_no_match) << FD->
getDeclName(),
8084 PDiag(diag::err_function_template_spec_ambiguous)
8085 << FD->
getDeclName() << (ExplicitTemplateArgs !=
nullptr),
8086 PDiag(diag::note_function_template_spec_matched));
8088 if (Result == Candidates.
end())
8092 FunctionDecl *Specialization = cast<FunctionDecl>(*Result);
8096 assert(SpecInfo &&
"Function template specialization info missing?");
8134 bool HasNoEffect =
false;
8136 CheckSpecializationInstantiationRedecl(FD->
getLocation(),
8156 !Specialization->getCanonicalDecl()->isReferenced()) {
8159 Specialization->getCanonicalDecl() == Specialization &&
8160 "This must be the only existing declaration of this specialization");
8162 Specialization->setDeletedAsWritten(
false);
8166 MarkUnusedFileScopedDecl(Specialization);
8175 FD->setFunctionTemplateSpecialization(
8176 Specialization->getPrimaryTemplate(), TemplArgs,
nullptr,
8178 ExplicitTemplateArgs ? &ConvertedTemplateArgs[Specialization] :
nullptr);
8191 Previous.
addDecl(Specialization);
8211 assert(!isa<TemplateDecl>(Member) &&
"Only for non-template members");
8214 NamedDecl *FoundInstantiation =
nullptr;
8219 if (Previous.
empty()) {
8221 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(Member)) {
8224 NamedDecl *D = (*I)->getUnderlyingDecl();
8226 QualType Adjusted = Function->getType();
8227 if (!hasExplicitCallingConv(Adjusted))
8228 Adjusted = adjustCCAndNoReturn(Adjusted, Method->getType());
8229 if (Context.
hasSameType(Adjusted, Method->getType())) {
8230 FoundInstantiation = *I;
8231 Instantiation = Method;
8232 InstantiatedFrom = Method->getInstantiatedFromMemberFunction();
8233 MSInfo = Method->getMemberSpecializationInfo();
8238 }
else if (isa<VarDecl>(Member)) {
8244 Instantiation = PrevVar;
8248 }
else if (isa<RecordDecl>(Member)) {
8253 Instantiation = PrevRecord;
8257 }
else if (isa<EnumDecl>(Member)) {
8262 Instantiation = PrevEnum;
8268 if (!Instantiation) {
8282 if (InstantiatedFrom && isa<CXXMethodDecl>(Member)) {
8283 cast<CXXMethodDecl>(Member)->setInstantiationOfMemberFunction(
8284 cast<CXXMethodDecl>(InstantiatedFrom),
8286 }
else if (InstantiatedFrom && isa<CXXRecordDecl>(Member)) {
8287 cast<CXXRecordDecl>(Member)->setInstantiationOfMemberClass(
8288 cast<CXXRecordDecl>(InstantiatedFrom),
8293 Previous.
addDecl(FoundInstantiation);
8298 if (!InstantiatedFrom) {
8311 assert(MSInfo &&
"Member specialization info missing?");
8313 bool HasNoEffect =
false;
8314 if (CheckSpecializationInstantiationRedecl(Member->
getLocation(),
8331 if (
auto *MemberFunction = dyn_cast<FunctionDecl>(Member)) {
8332 FunctionDecl *InstantiationFunction = cast<FunctionDecl>(Instantiation);
8337 if (InstantiationFunction->
isDeleted()) {
8340 InstantiationFunction);
8346 MemberFunction->setInstantiationOfMemberFunction(
8348 }
else if (
auto *MemberVar = dyn_cast<VarDecl>(Member)) {
8349 MemberVar->setInstantiationOfStaticDataMember(
8351 }
else if (
auto *MemberClass = dyn_cast<CXXRecordDecl>(Member)) {
8352 MemberClass->setInstantiationOfMemberClass(
8354 }
else if (
auto *MemberEnum = dyn_cast<EnumDecl>(Member)) {
8355 MemberEnum->setInstantiationOfMemberEnum(
8358 llvm_unreachable(
"unknown member specialization kind");
8364 Previous.
addDecl(FoundInstantiation);
8373 template<
typename DeclT>
8384 OrigD->setLocation(Loc);
8390 if (Instantiation == Member)
8393 if (
auto *Function = dyn_cast<CXXMethodDecl>(Instantiation))
8395 else if (
auto *Var = dyn_cast<VarDecl>(Instantiation))
8397 else if (
auto *Record = dyn_cast<CXXRecordDecl>(Instantiation))
8399 else if (
auto *Enum = dyn_cast<EnumDecl>(Instantiation))
8402 llvm_unreachable(
"unknown member specialization kind");
8410 bool WasQualifiedName) {
8415 S.
Diag(InstLoc, diag::err_explicit_instantiation_in_class)
8428 if (WasQualifiedName) {
8429 if (CurContext->
Encloses(OrigContext))
8436 if (
NamespaceDecl *NS = dyn_cast<NamespaceDecl>(OrigContext)) {
8437 if (WasQualifiedName)
8440 diag::err_explicit_instantiation_out_of_scope :
8441 diag::warn_explicit_instantiation_out_of_scope_0x)
8446 diag::err_explicit_instantiation_unqualified_wrong_namespace :
8447 diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x)
8452 diag::err_explicit_instantiation_must_be_global :
8453 diag::warn_explicit_instantiation_must_be_global_0x)
8474 if (isa<TemplateSpecializationType>(T))
8484 auto *A = cast_or_null<InheritableAttr>(
getDLLAttr(Def));
8485 assert(A &&
"dllExportImportClassTemplateSpecialization called " 8486 "on Def without dllexport or dllimport");
8491 "delayed exports present at explicit instantiation");
8495 for (
auto &B : Def->
bases()) {
8496 if (
auto *BT = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
8497 B.getType()->getAsCXXRecordDecl()))
8525 "Invalid enum tag in class template explicit instantiation!");
8529 if (!ClassTemplate) {
8530 NonTagKind NTK = getNonTagTypeDeclKind(TD, Kind);
8531 Diag(TemplateNameLoc, diag::err_tag_reference_non_tag) << TD << NTK <<
Kind;
8539 Diag(KWLoc, diag::err_use_with_wrong_tag)
8544 diag::note_previous_use);
8559 if (A->getKind() == AttributeList::AT_DLLExport) {
8561 diag::warn_attribute_dllexport_explicit_instantiation_decl);
8562 Diag(A->getLoc(), diag::note_attribute);
8569 diag::warn_attribute_dllexport_explicit_instantiation_decl);
8570 Diag(A->getLocation(), diag::note_attribute);
8576 bool DLLImportExplicitInstantiationDef =
false;
8583 if (A->getKind() == AttributeList::AT_DLLImport)
8585 if (A->getKind() == AttributeList::AT_DLLExport) {
8593 DLLImportExplicitInstantiationDef =
true;
8599 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
8604 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
8605 TemplateArgs,
false, Converted))
8610 void *InsertPos =
nullptr;
8628 bool HasNoEffect =
false;
8630 if (CheckSpecializationInstantiationRedecl(TemplateNameLoc, TSK,
8631 PrevDecl, PrevDecl_TSK,
8646 Specialization = PrevDecl;
8652 DLLImportExplicitInstantiationDef) {
8654 HasNoEffect =
false;
8658 if (!Specialization) {
8664 KWLoc, TemplateNameLoc,
8670 if (!HasNoEffect && !PrevDecl) {
8672 ClassTemplate->AddSpecialization(Specialization, InsertPos);
8694 bool PreviouslyDLLExported = Specialization->
hasAttr<DLLExportAttr>();
8696 ProcessDeclAttributeList(S, Specialization, Attr);
8702 CurContext->addDecl(Specialization);
8708 return Specialization;
8719 = cast_or_null<ClassTemplateSpecializationDecl>(
8722 InstantiateClassTemplateSpecialization(TemplateNameLoc, Specialization, TSK);
8724 MarkVTableUsed(TemplateNameLoc, Specialization,
true);
8729 Def = cast_or_null<ClassTemplateSpecializationDecl>(
8737 DLLImportExplicitInstantiationDef)) {
8747 auto *A = cast<InheritableAttr>(
8749 A->setInherited(
true);
8757 bool NewlyDLLExported =
8758 !PreviouslyDLLExported && Specialization->
hasAttr<DLLExportAttr>();
8774 assert(Def == Specialization &&
8775 "Def and Specialization should match for implicit instantiation");
8782 InstantiateClassTemplateSpecializationMembers(TemplateNameLoc, Def, TSK);
8789 return Specialization;
8805 bool IsDependent =
false;
8807 KWLoc, SS, Name, NameLoc, Attr,
AS_none,
8813 assert(!IsDependent &&
"explicit instantiation of dependent name not yet handled");
8818 TagDecl *Tag = cast<TagDecl>(TagD);
8819 assert(!Tag->
isEnum() &&
"shouldn't see enumerations here");
8827 Diag(TemplateLoc, diag::err_explicit_instantiation_nontemplate_type)
8840 Diag(TemplateLoc, diag::ext_explicit_instantiation_without_qualified_id)
8865 bool HasNoEffect =
false;
8866 assert(MSInfo &&
"No member specialization information?");
8867 if (CheckSpecializationInstantiationRedecl(TemplateLoc, TSK,
8884 = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
8886 Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member)
8888 Diag(Pattern->getLocation(), diag::note_forward_declaration)
8892 if (InstantiateClass(NameLoc, Record, Def,
8893 getTemplateInstantiationArgs(Record),
8897 RecordDef = cast_or_null<CXXRecordDecl>(Record->
getDefinition());
8904 InstantiateClassMembers(NameLoc, RecordDef,
8905 getTemplateInstantiationArgs(Record), TSK);
8908 MarkVTableUsed(NameLoc, RecordDef,
true);
8928 diag::err_explicit_instantiation_requires_name)
8970 getLangOpts().CPlusPlus11 ?
8971 diag::err_explicit_instantiation_inline :
8972 diag::warn_explicit_instantiation_inline_0x)
8978 diag::err_explicit_instantiation_constexpr);
9013 if (!PrevTemplate) {
9020 Diag((*P)->getLocation(), diag::note_explicit_instantiation_here);
9027 diag::err_explicit_instantiation_data_member_not_instantiated)
9043 diag::err_auto_not_allowed_var_inst);
9052 diag::err_explicit_instantiation_without_template_id)
9054 Diag(PrevTemplate->getLocation(),
9055 diag::note_explicit_instantiation_here);
9063 DeclResult Res = CheckVarTemplateId(PrevTemplate, TemplateLoc,
9065 if (Res.isInvalid())
9070 Prev = cast<VarDecl>(Res.get());
9085 diag::ext_explicit_instantiation_without_qualified_id)
9094 bool HasNoEffect =
false;
9095 if (CheckSpecializationInstantiationRedecl(D.
getIdentifierLoc(), TSK, Prev,
9096 PrevTSK, POI, HasNoEffect))
9105 ProcessDeclAttributeList(S, Prev,
Attr);
9112 if (PrevTemplate && Prev && !Context.
hasSameType(Prev->getType(), R)) {
9114 diag::err_invalid_var_template_spec_type)
9115 << 0 << PrevTemplate << R << Prev->getType();
9116 Diag(PrevTemplate->getLocation(), diag::note_template_declared_here)
9117 << 2 << PrevTemplate->getDeclName();
9122 return (
Decl*)
nullptr;
9127 bool HasExplicitTemplateArgs =
false;
9131 HasExplicitTemplateArgs =
true;
9146 if (!HasExplicitTemplateArgs) {
9147 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Prev)) {
9148 QualType Adjusted = adjustCCAndNoReturn(R, Method->getType(),
9151 if (Method->getPrimaryTemplate()) {
9152 TemplateMatches.
addDecl(Method,
P.getAccess());
9155 assert(!NonTemplateMatch &&
"Multiple NonTemplateMatches");
9156 NonTemplateMatch = Method;
9170 (HasExplicitTemplateArgs ? &TemplateArgs
9172 R, Specialization, Info)) {
9174 FailedCandidates.addCandidate()
9186 if (LangOpts.CUDA &&
9187 IdentifyCUDATarget(Specialization,
9189 IdentifyCUDATarget(Attr)) {
9190 FailedCandidates.addCandidate().set(
9196 TemplateMatches.
addDecl(Specialization,
P.getAccess());
9200 if (!Specialization) {
9203 TemplateMatches.
begin(), TemplateMatches.
end(), FailedCandidates,
9205 PDiag(diag::err_explicit_instantiation_not_known) << Name,
9206 PDiag(diag::err_explicit_instantiation_ambiguous) << Name,
9207 PDiag(diag::note_explicit_instantiation_candidate));
9209 if (Result == TemplateMatches.
end())
9213 Specialization = cast<FunctionDecl>(*Result);
9223 if (FPT->hasExceptionSpec()) {
9225 diag::err_mismatched_exception_spec_explicit_instantiation;
9226 if (getLangOpts().MicrosoftExt)
9227 DiagID = diag::ext_mismatched_exception_spec_explicit_instantiation;
9228 bool Result = CheckEquivalentExceptionSpec(
9229 PDiag(DiagID) << Specialization->
getType(),
9230 PDiag(diag::note_explicit_instantiation_here),
9235 if (!getLangOpts().MicrosoftExt && Result)
9241 diag::err_explicit_instantiation_member_function_not_instantiated)
9245 Diag(Specialization->
getLocation(), diag::note_explicit_instantiation_here);
9251 PrevDecl = Specialization;
9254 bool HasNoEffect =
false;
9258 PrevDecl->getPointOfInstantiation(),
9265 return (
Decl*)
nullptr;
9269 ProcessDeclAttributeList(S, Specialization, Attr);
9274 Specialization->
hasAttr<DLLImportAttr>() &&
9283 Consumer.HandleTopLevelDecl(
DeclGroupRef(Specialization));
9299 diag::ext_explicit_instantiation_without_qualified_id)
9309 return (
Decl*)
nullptr;
9317 assert(Name &&
"Expected a name in a dependent tag");
9325 if (TUK == TUK_Declaration || TUK == TUK_Definition) {
9326 Diag(NameLoc, diag::err_dependent_tag_decl)
9327 << (TUK == TUK_Definition) << Kind << SS.
getRange();
9353 getLangOpts().CPlusPlus11 ?
9354 diag::warn_cxx98_compat_typename_outside_of_template :
9355 diag::ext_typename_outside_of_template)
9360 TypenameLoc, QualifierLoc, II, IdLoc);
9365 if (isa<DependentNameType>(T)) {
9377 return CreateParsedType(T, TSI);
9393 getLangOpts().CPlusPlus11 ?
9394 diag::warn_cxx98_compat_typename_outside_of_template :
9395 diag::ext_typename_outside_of_template)
9402 dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS,
false));
9403 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
9405 diag::ext_out_of_line_qualified_id_type_names_constructor)
9407 << (TemplateKWLoc.
isValid() ? 1 : 0 );
9413 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
9418 assert(DTN &&
"dependent template has non-dependent name?");
9421 DTN->getQualifier(),
9422 DTN->getIdentifier(),
9435 for (
unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
9440 QualType T = CheckTemplateIdType(Template, TemplateIILoc, TemplateArgs);
9452 for (
unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
9461 return CreateParsedType(T, TSI);
9470 if (!II.
isStr(
"type"))
9479 if (!EnableIfTSTLoc || EnableIfTSTLoc.
getNumArgs() == 0)
9482 cast<TemplateSpecializationType>(EnableIfTSTLoc.
getTypePtr());
9492 EnableIfDecl->getDeclName().getAsIdentifierInfo();
9493 if (!EnableIfII || !EnableIfII->
isStr(
"enable_if"))
9523 SS.
Adopt(QualifierLoc);
9541 if (RequireCompleteDeclContext(SS, Ctx))
9545 LookupResult Result(*
this, Name, IILoc, LookupOrdinaryName);
9546 LookupQualifiedName(Result, Ctx, SS);
9547 unsigned DiagID = 0;
9548 Decl *Referenced =
nullptr;
9554 Expr *Cond =
nullptr;
9555 if (
isEnableIf(QualifierLoc, II, CondRange, Cond)) {
9560 std::string FailedDescription;
9561 std::tie(FailedCond, FailedDescription) =
9562 findFailedBooleanCondition(Cond,
true);
9565 diag::err_typename_nested_not_found_requirement)
9566 << FailedDescription
9571 Diag(CondRange.
getBegin(), diag::err_typename_nested_not_found_enable_if)
9572 << Ctx << CondRange;
9576 DiagID = diag::err_typename_nested_not_found;
9585 Diag(IILoc, diag::err_typename_refers_to_using_value_decl)
9586 << Name << Ctx << FullRange;
9590 Diag(Loc, diag::note_using_value_decl_missing_typename)
9620 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(Ctx);
9623 FoundRD->isInjectedClassName() &&
9625 Diag(IILoc, diag::ext_out_of_line_qualified_id_type_names_constructor)
9630 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
9640 if (getLangOpts().CPlusPlus17) {
9649 DiagID = diag::err_typename_nested_not_type;
9654 DiagID = diag::err_typename_nested_not_type;
9655 Referenced = *Result.
begin();
9666 Diag(IILoc, DiagID) << FullRange << Name << Ctx;
9675 class CurrentInstantiationRebuilder
9683 CurrentInstantiationRebuilder(
Sema &SemaRef,
9687 Loc(Loc), Entity(Entity) { }
9694 bool AlreadyTransformed(
QualType T) {
9709 this->Entity = Entity;
9751 CurrentInstantiationRebuilder Rebuilder(*
this, Loc, Name);
9752 return Rebuilder.TransformType(T);
9756 CurrentInstantiationRebuilder Rebuilder(*
this, E->
getExprLoc(),
9758 return Rebuilder.TransformExpr(E);
9769 = Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
9781 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
9785 if (isa<TemplateTypeParmDecl>(Param))
9790 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
9791 if (RebuildTemplateParamsInCurrentInstantiation(
9792 TTP->getTemplateParameters()))
9809 NTTP->
setType(NewTSI->getType());
9821 return getTemplateArgumentBindingsText(Params, Args.
data(), Args.
size());
9829 llvm::raw_svector_ostream Out(Str);
9831 if (!Params || Params->
size() == 0 || NumArgs == 0)
9832 return std::string();
9834 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
9844 Out <<
Id->getName();
9850 Args[I].
print(getPrintingPolicy(), Out);
9862 auto LPT = llvm::make_unique<LateParsedTemplate>();
9865 LPT->Toks.swap(Toks);
9867 LateParsedTemplateMap.insert(std::make_pair(FD, std::move(LPT)));
9882 if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(CurContext)) {
9911 class ExplicitSpecializationVisibilityChecker {
9921 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
9922 return checkImpl(FD);
9923 if (
auto *RD = dyn_cast<CXXRecordDecl>(ND))
9924 return checkImpl(RD);
9925 if (
auto *VD = dyn_cast<VarDecl>(ND))
9926 return checkImpl(VD);
9927 if (
auto *ED = dyn_cast<EnumDecl>(ND))
9928 return checkImpl(ED);
9932 void diagnose(
NamedDecl *D,
bool IsPartialSpec) {
9935 const bool Recover =
true;
9940 if (Modules.empty())
9958 template<
typename SpecDecl>
9959 void checkImpl(SpecDecl *Spec) {
9960 bool IsHiddenExplicitSpecialization =
false;
9962 IsHiddenExplicitSpecialization =
9963 Spec->getMemberSpecializationInfo()
9967 checkInstantiated(Spec);
9970 if (IsHiddenExplicitSpecialization)
9971 diagnose(Spec->getMostRecentDecl(),
false);
9995 void checkInstantiated(
VarDecl *RD) {
10003 else if (
auto *TD =
10006 diagnose(TD,
true);
10011 void checkInstantiated(
EnumDecl *FD) {}
10013 template<
typename TemplDecl>
10014 void checkTemplate(TemplDecl *TD) {
10015 if (TD->isMemberSpecialization()) {
10017 diagnose(TD->getMostRecentDecl(),
false);
10024 if (!getLangOpts().Modules)
10027 ExplicitSpecializationVisibilityChecker(*
this, Loc).check(Spec);
10035 if (!hasVisibleDeclaration(Spec, &Modules))
10036 diagnoseMissingImport(Loc, Spec, Spec->
getLocation(), Modules,
10037 MissingImportKind::PartialSpecialization,
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
ExprResult BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
Construct a new expression that refers to the given integral template argument with the given source-...
Defines the clang::ASTContext interface.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
The null pointer literal (C++11 [lex.nullptr])
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
void setImplicit(bool I=true)
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)
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)
static bool CheckTemplateArgumentIsCompatibleWithParameter(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *ArgIn, Expr *Arg, QualType ArgType)
Checks whether the given template argument is compatible with its template parameter.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
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...
const TypeClass * getTypePtr() const
bool TemplateParameterListsAreEqual(TemplateParameterList *New, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
TemplateDeductionResult
Describes the result of template argument deduction.
void InstantiatedLocal(const Decl *D, Decl *Inst)
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that makes a template template argument into a pack expansion...
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
bool isMemberPointerType() const
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
static const TemplateArgument & getArgument(const TemplateArgument &A)
QualType getInjectedSpecializationType() const
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
AttributeList * getNext() const
llvm::PointerUnion3< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
void diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName, SourceLocation Less, SourceLocation Greater)
const TypeClass * getTypePtr() const
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...
NestedNameSpecifierLoc getTemplateQualifierLoc() const
void addOuterTemplateArguments(const TemplateArgumentList *TemplateArgs)
Add a new outermost level to the multi-level template argument list.
void setLookupName(DeclarationName Name)
Sets the name to look up.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
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)
Stmt - This represents one statement.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
Filter makeFilter()
Create a filter for this result set.
void setLAngleLoc(SourceLocation Loc)
void setExceptionSpecRange(SourceRange R)
We are matching the template parameter lists of two templates that might be redeclarations.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
Provides information about an attempted template argument deduction, whose success or failure was des...
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
static bool DiagnoseDefaultTemplateArgument(Sema &S, Sema::TemplateParamListContext TPC, SourceLocation ParamLoc, SourceRange DefArgRange)
Diagnose the presence of a default template argument on a template parameter, which is ill-formed in ...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
The name refers to a function template or a set of overloaded functions that includes at least one fu...
bool CheckTemplatePartialSpecializationArgs(SourceLocation Loc, TemplateDecl *PrimaryTemplate, unsigned NumExplicitArgs, ArrayRef< TemplateArgument > Args)
Check the non-type template arguments of a class template partial specialization according to C++ [te...
The name refers to a dependent template name:
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
Represents a qualified type name for which the type name is dependent.
void setObjCLifetime(ObjCLifetime type)
The template argument is an expression, and we've not resolved it to one of the other forms yet...
unsigned size() const
Retrieve the number of template arguments in this template argument list.
bool isEmpty() const
No scope specifier.
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params)
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments...
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
void erase()
Erase the last element returned from this iterator.
static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D)
Determine what kind of template specialization the given declaration is.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Defines the C++ template declaration subclasses.
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
Represents a C++11 auto or C++14 decltype(auto) type.
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
static SourceRange getRangeOfTypeInNestedNameSpecifier(ASTContext &Context, QualType T, const CXXScopeSpec &SS)
Expr * getAsExpr() const
Retrieve the non-type template argument's expression.
ParenExpr - This represents a parethesized expression, e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
TemplateParameterList * MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, ArrayRef< TemplateParameterList *> ParamLists, bool IsFriend, bool &IsMemberSpecialization, bool &Invalid)
Match the given template parameter lists to the given scope specifier, returning the template paramet...
The base class of the type hierarchy.
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.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
void setSpecializationKind(TemplateSpecializationKind TSK)
NamedDecl * getParam(unsigned Idx)
const TargetInfo & getTargetInfo() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
A container of type source information.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
bool isSuppressingDiagnostics() const
Determines whether this lookup is suppressing diagnostics.
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine whether any declaration of an entity is visible.
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
An overloaded operator name, e.g., operator+.
bool isDefined(const FunctionDecl *&Definition) const
Returns true if the function is defined at all, including a deleted definition.
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation, NamedDecl *Instantiation, bool InstantiatedFromMember, const NamedDecl *Pattern, const NamedDecl *PatternDef, TemplateSpecializationKind TSK, bool Complain=true)
Determine whether we would be unable to instantiate this template (because it either has no definitio...
TSCS getThreadStorageClassSpec() const
SourceLocation getLocEnd() const LLVM_READONLY
static void StripImplicitInstantiation(NamedDecl *D)
Strips various properties off an implicit instantiation that has just been explicitly specialized...
Abstract base class used for diagnosing integer constant expression violations.
static NullPointerValueKind isNullPointerValueTemplateArgument(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *Arg, Decl *Entity=nullptr)
Determine whether the given template argument is a null pointer value of the appropriate type...
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs, SmallVectorImpl< TemplateArgument > &Converted, bool UpdateArgsWithConversions=true)
Check that the given template arguments can be be provided to the given template, converting the argu...
Represents a C++ constructor within a class.
TemplateName SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs)
QualType getElementType() const
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
An identifier, stored as an IdentifierInfo*.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
unsigned getDepth() const
Get the nesting depth of the template parameter.
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
RAII object that enters a new expression evaluation context.
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.
DeclarationName getLookupName() const
Gets the name to look up.
Information about one declarator, including the parsed type information and the identifier.
bool isEnumeralType() const
static SourceLocation DiagLocForExplicitInstantiation(NamedDecl *D, SourceLocation PointOfInstantiation)
Compute the diagnostic location for an explicit instantiation.
const T * getAs() const
Member-template getAs<specific type>'.
bool hasDefaultArg() const
hasDefaultArg - Determines whether this parameter has a default argument, either parsed or not...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Represents an empty template argument, e.g., one that has not been deduced.
Extra information about a function prototype.
TypeSpecifierType
Specifies the kind of type.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
Represents a C++17 deduced template specialization type.
Represents a variable template specialization, which refers to a variable template with a given set o...
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
ArrayRef< LValuePathEntry > getLValuePath() const
SourceLocation getLAngleLoc() const
static bool isTemplateArgumentTemplateParameter(const TemplateArgument &Arg, unsigned Depth, unsigned Index)
A namespace, stored as a NamespaceDecl*.
TypeLoc getNamedTypeLoc() const
bool isInvalidDecl() const
bool isChar32Type() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
TemplateArgumentLoc SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, Decl *Param, SmallVectorImpl< TemplateArgument > &Converted, bool &HasDefaultArg)
If the given template parameter has a default template argument, substitute into that default templat...
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
bool isParameterPack() const
Whether this declaration is a parameter pack.
static Optional< unsigned > getExpandedPackSize(NamedDecl *Param)
Check whether the template parameter is a pack expansion, and if so, determine the number of paramete...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
ParmVarDecl - Represents a parameter to a function.
Represents the result of substituting a type for a template type parameter.
Defines the clang::Expr interface and subclasses for C++ expressions.
QualType getIntegralType() const
Retrieve the type of the integral value.
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
AttributeList * getList() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier...
The collection of all-type qualifiers we support.
bool isLValueOnePastTheEnd() const
Information about a template-id annotation token.
bool isObjCObjectOrInterfaceType() const
const ValueDecl * getMemberPointerDecl() const
static void DiagnoseTemplateParameterListArityMismatch(Sema &S, TemplateParameterList *New, TemplateParameterList *Old, Sema::TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc)
Diagnose a known arity mismatch when comparing template argument lists.
static SourceRange findTemplateParameter(unsigned Depth, TypeLoc TL)
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
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.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
Scope * getTemplateParamParent()
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
bool isWideCharType() const
One of these records is kept for each identifier that is lexed.
Represents a class template specialization, which refers to a class template with a given set of temp...
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
TemplateName getUnderlying() const
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
void setLocalRangeEnd(SourceLocation L)
unsigned getDepth() const
Retrieve the depth of the template parameter.
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl)
DiagnoseTemplateParameterShadow - Produce a diagnostic complaining that the template parameter 'PrevD...
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".
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
Represents a class type in Objective C.
QualType getPointeeType() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
CXXRecordDecl * getPreviousDecl()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
Represents a dependent template name that cannot be resolved prior to template instantiation.
NestedNameSpecifierLoc SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const MultiLevelTemplateArgumentList &TemplateArgs)
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
ArrayRef< QualType > getParamTypes() const
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 isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
TypeSourceInfo * getTypeSourceInfo() const
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD, const TemplateArgumentListInfo &ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given dependent function template specialization.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
RecordDecl * getDefinition() const
getDefinition - Returns the RecordDecl that actually defines this struct/union/class.
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a templated declaration that would trigger an implicit instantiation.
static SourceRange findTemplateParameterInType(unsigned Depth, Expr *E)
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
SourceLocation getLocation() const
Retrieve the location of the template argument.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType) const
SourceLocation getLocation() const
Fetches the primary location of the argument.
OverloadedOperatorKind Operator
The kind of overloaded operator.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
void startDefinition()
Starts the definition of this tag declaration.
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
bool isReferenceType() const
void setElaboratedKeywordLoc(SourceLocation Loc)
The iterator over UnresolvedSets.
Represents the result of substituting a set of types for a template type parameter pack...
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
A non-type template parameter, stored as an expression.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
SourceLocation getRParenLoc() const
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)
LookupResultKind getResultKind() const
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
Perform semantic analysis for the given non-template member specialization.
static QualType checkBuiltinTemplateIdType(Sema &SemaRef, BuiltinTemplateDecl *BTD, const SmallVectorImpl< TemplateArgument > &Converted, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
void ClearStorageClassSpecs()
The type of a non-type template parameter.
ParsedType getAsType() const
Retrieve the template type argument's type.
SourceRange getSourceRange() const LLVM_READONLY
Fetches the full source range of the argument.
SourceLocation getTemplateLoc() const
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
A user-defined literal name, e.g., operator "" _i.
void setDefaultArgument(Expr *DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
bool isInvalidType() const
TypeSourceInfo * getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &Args, QualType Canon=QualType()) const
Provides information about a function template specialization, which is a FunctionDecl that has been ...
DeclClass * getAsSingle() const
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
NamedDecl * ActOnTemplateTemplateParameter(Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params, SourceLocation EllipsisLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg)
ActOnTemplateTemplateParameter - Called when a C++ template template parameter (e.g.
ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, bool isAddressOfOperand, const TemplateArgumentListInfo *TemplateArgs)
ActOnDependentIdExpression - Handle a dependent id-expression that was just parsed.
static void maybeDiagnoseTemplateParameterShadow(Sema &SemaRef, Scope *S, SourceLocation Loc, IdentifierInfo *Name)
Represents a C++ unqualified-id that has been parsed.
bool isCompleteType(SourceLocation Loc, QualType T)
An rvalue reference type, per C++11 [dcl.ref].
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
void setNameLoc(SourceLocation Loc)
Represents the results of name lookup.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
void setRAngleLoc(SourceLocation Loc)
Wrapper for source info for injected class names of class templates.
static void dllExportImportClassTemplateSpecialization(Sema &S, ClassTemplateSpecializationDecl *Def)
Make a dllexport or dllimport attr on a class template specialization take effect.
TagKind getTagKind() const
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
APValue Val
Val - This is the value the expression can be folded to.
A convenient class for passing around template argument information.
void FilterAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true)
bool isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl *T, sema::TemplateDeductionInfo &Info)
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
Represents a typeof (or typeof) expression (a GCC extension).
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
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.
std::string getAsString(ASTContext &Ctx, QualType Ty) const
void setRedeclaration(bool Val)
A builtin binary operation expression such as "x + y" or "x <= y".
static void collectConjunctionTerms(Expr *Clause, SmallVectorImpl< Expr *> &Terms)
Collect all of the separable terms in the given condition, which might be a conjunction.
SourceLocation getLParenLoc() const
static bool MatchTemplateParameterKind(Sema &S, NamedDecl *New, NamedDecl *Old, bool Complain, Sema::TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc)
Match two template parameters within template parameter lists.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
const Type * getClass() const
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
CXXRecordDecl * getDecl() const
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
SourceLocation getTemplateEllipsisLoc() const
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
void setSpecializationKind(TemplateSpecializationKind TSK)
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, const ASTContext *Context=nullptr) const
Scope - A scope is a transient data structure that is used while parsing the program.
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type...
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNoreturnSpecified() const
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
const LangOptions & getLangOpts() const
TemplateArgumentLoc getArgLoc(unsigned i) const
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Decl * ActOnTemplateDeclarator(Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization, retrieves the function from which it was instantiated.
Represents a C++ member access expression where the actual member referenced could not be resolved be...
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
void setLocalRangeBegin(SourceLocation L)
static bool CheckTemplateArgumentPointerToMember(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *&ResultArg, TemplateArgument &Converted)
Checks whether the given template argument is a pointer to member constant according to C++ [temp...
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.
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.
NamedDecl *const * iterator
We are matching the template parameter lists of a template template argument against the template par...
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
SourceRange getSourceRange() const LLVM_READONLY
bool isExplicitSpecialization() const
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
unsigned getNumArgs() const
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
IdentifierInfo * getIdentifier() const
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location...
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
QualType getElementType() const
RAII object used to change the argument pack substitution index within a Sema object.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
Represents an extended vector type where either the type or size is dependent.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
We are matching the template parameter lists of two template template parameters as part of matching ...
DiagnosticsEngine & getDiagnostics() const
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
unsigned getFlags() const
getFlags - Return the flags for this scope.
void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD)
static Sema::TemplateDeductionResult DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, const TemplateArgument &Param, TemplateArgument Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
void print(const PrintingPolicy &Policy, raw_ostream &Out) const
Print this template argument to the given output stream.
bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg, SmallVectorImpl< TemplateArgument > &Converted)
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
Sema - This implements semantic analysis and AST building for C.
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, SmallVectorImpl< TemplateArgument > &Converted, CheckTemplateArgumentKind CTAK=CTAK_Specified)
Check that the given template argument corresponds to the given template parameter.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
SourceLocation getLocStart() const LLVM_READONLY
bool hasLValuePath() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
static TypeSourceInfo * SubstDefaultTemplateArgument(Sema &SemaRef, TemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, TemplateTypeParmDecl *Param, SmallVectorImpl< TemplateArgument > &Converted)
Substitute template arguments into the default template argument for the given template type paramete...
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
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.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
SourceRange getRange() const
TemplateParameterListEqualKind
Enumeration describing how template parameter lists are compared for equality.
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams)
Check whether a template can be declared within this scope.
void setTemplateNameLoc(SourceLocation Loc)
Represents an array type in C++ whose size is a value-dependent expression.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, Optional< unsigned > NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
QualType getElementType() const
unsigned getFunctionScopeDepth() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
Defines the clang::LangOptions interface.
StringRef getKindName() const
DeclResult CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation TemplateNameLoc, const TemplateArgumentListInfo &TemplateArgs)
SourceLocation getLocalRangeEnd() const
LookupNameKind
Describes the kind of name lookup to perform.
QualType getPointeeType() const
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.
bool isExplicitSpecified() const
Expr * getAssociatedConstraints() const
const FunctionProtoType * T
QualType getCanonicalTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args) const
Declaration of a template type parameter.
unsigned getIndex() const
DeclContext * getEntity() const
This file defines the classes used to store parsed information about declaration-specifiers and decla...
const T * castAs() const
Member-template castAs<specific type>.
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
bool isChar16Type() const
SourceLocation getThreadStorageClassSpecLoc() const
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
bool isNullPtrType() const
bool isFileContext() const
SourceLocation getBeginLoc() const
DeclContext * getDeclContext()
CXXRecordDecl * getDefinition() const
bool isConstexprSpecified() const
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
void setMemberSpecialization()
Note that this member template is a specialization.
void NoteAllFoundTemplates(TemplateName Name)
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack...
Represents a C++ template name within the type system.
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.
SourceLocation getStorageClassSpecLoc() const
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this...
A namespace alias, stored as a NamespaceAliasDecl*.
bool isIdentifier() const
Determine whether this template name refers to an identifier.
void setLateTemplateParsed(bool ILT=true)
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined...
void propagateDLLAttrToBaseClassTemplate(CXXRecordDecl *Class, Attr *ClassAttr, ClassTemplateSpecializationDecl *BaseTemplateSpec, SourceLocation BaseLoc)
Perform propagation of DLL attributes from a derived class to a templated base class for MS compatibi...
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
bool isFunctionOrMethod() const
StorageClass
Storage classes.
SourceLocation getLocalRangeBegin() const
static bool isEnableIf(NestedNameSpecifierLoc NNS, const IdentifierInfo &II, SourceRange &CondRange, Expr *&Cond)
Determine whether this failed name lookup should be treated as being disabled by a usage of std::enab...
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
Declaration of an alias template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Data structure that captures multiple levels of template argument lists for use in template instantia...
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.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
Represents a GCC generic vector type.
void setLocation(SourceLocation L)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization, retrieves the member specialization information.
An lvalue reference type, per C++11 [dcl.ref].
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization)
BuiltinTemplateKind getBuiltinTemplateKind() const
void setDescribedClassTemplate(ClassTemplateDecl *Template)
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
This template specialization was implicitly instantiated from a template.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A type, stored as a Type*.
static TemplateArgumentLoc translateTemplateArgument(Sema &SemaRef, const ParsedTemplateArgument &Arg)
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList *> TPLists)
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLock is not of the desire...
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
bool hasVisibleMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine if there is a visible declaration of D that is a member specialization declaration (as oppo...
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
RecordDecl * getDecl() const
SourceLocation getNoreturnSpecLoc() const
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
std::pair< Expr *, std::string > findFailedBooleanCondition(Expr *Cond, bool AllowTopLevelCond)
Find the failed Boolean condition within a given Boolean constant expression, and describe it with a ...
const CXXScopeSpec & getScopeSpec() const
Retrieve the nested-name-specifier that precedes the template name in a template template argument...
char * location_data() const
Retrieve the data associated with the source-location information.
static bool DiagnoseUnexpandedParameterPacks(Sema &S, TemplateTemplateParmDecl *TTP)
Check for unexpanded parameter packs within the template parameters of a template template parameter...
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template apply...
Assigning into this object requires the old value to be released and the new value to be retained...
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
const LValueBase getLValueBase() const
param_type_range param_types() const
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
void setLAngleLoc(SourceLocation Loc)
Represents the parsed form of a C++ template argument.
A stack object to be created when performing template instantiation.
ExtProtoInfo getExtProtoInfo() const
SCS getStorageClassSpec() const
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
ASTContext & getASTContext() const
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList *> FriendTypeTPLists=None)
static bool isSameAsPrimaryTemplate(TemplateParameterList *Params, ArrayRef< TemplateArgument > Args)
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
QualType getReturnType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
void setBraceRange(SourceRange R)
Attr * clone(ASTContext &C) const
static bool CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *ArgIn, TemplateArgument &Converted)
Checks whether the given template argument is the address of an object or function according to C++ [...
This names the __make_integer_seq BuiltinTemplateDecl.
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
static void SetNestedNameSpecifier(TagDecl *T, const CXXScopeSpec &SS)
DeclarationName getName() const
getName - Returns the embedded declaration name.
TagDecl - Represents the declaration of a struct/union/class/enum.
TemplateArgument getArgumentPack() const
void referenceDLLExportedClassMethods()
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc)
Build the type that describes a C++ typename specifier, e.g., "typename T::type". ...
bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name, SourceLocation NameLoc, ParsedTemplateTy *Template=nullptr)
Determine whether a particular identifier might be the name in a C++1z deduction-guide declaration...
ASTContext & getASTContext() const LLVM_READONLY
QualType getElementType() const
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
Represents a dependent using declaration which was not marked with typename.
NamedDecl * ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, unsigned Depth, unsigned Position, SourceLocation EqualLoc, Expr *DefaultArg)
KindType getKind() const
Determine what kind of template argument we have.
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
Represents a static or instance method of a struct/union/class.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isMemberPointer() const
Name lookup found an unresolvable value declaration and cannot yet complete.
static bool CheckTemplateSpecializationScope(Sema &S, NamedDecl *Specialized, NamedDecl *PrevDecl, SourceLocation Loc, bool IsPartialSpecialization)
Check whether a specialization is well-formed in the current context.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template...
static bool hasVisibleDefaultArgument(Sema &S, const ParmDecl *D, llvm::SmallVectorImpl< Module *> *Modules)
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
void addDecl(NamedDecl *D)
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
void setPointOfInstantiation(SourceLocation Loc)
A class for iterating through a result set and possibly filtering out results.
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. ...
No entity found met the criteria.
This template specialization was instantiated from a template due to an explicit instantiation defini...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
SourceLocation getRAngleLoc() const
EnumDecl * getDecl() const
A template type parameter, stored as a type.
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, Sema::TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
SourceLocation getInlineSpecLoc() const
ArrayRef< ParmVarDecl * > getParams() const
void checkPartialSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a template specialization that would select a partial specialization.
static TemplateArgumentLoc convertTypeTemplateArgumentToTemplate(TypeLoc TLoc)
Convert a template-argument that we parsed as a type into a template, if possible.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void addArgument(const TemplateArgumentLoc &Loc)
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl, Expr *AssociatedConstraints=nullptr)
Create a class template node.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
The injected class name of a C++ class template or class template partial specialization.
A qualified reference to a name whose declaration cannot yet be resolved.
QualType getPointeeType() const
Represents a pack expansion of types.
SourceLocation getLocation() const
A POD class for pairing a NamedDecl* with an access specifier.
void setLParenLoc(SourceLocation Loc)
void setTemplateKeywordLoc(SourceLocation Loc)
static void checkTemplatePartialSpecialization(Sema &S, PartialSpecDecl *Partial)
StringRef getName() const
Return the actual identifier string.
TypeResult ActOnTagTemplateIdType(TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc)
Parsed an elaborated-type-specifier that refers to a template-id, such as class T::template apply<U>...
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template...
Represents a template argument.
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
TagTypeKind
The kind of a tag type.
bool hasVisibleExplicitSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine if there is a visible declaration of D that is an explicit specialization declaration for a...
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
The name does not refer to a template.
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
void setMemberSpecialization()
Note that this member template is a specialization.
bool isNull() const
Determine whether this template name is NULL.
bool RebuildTemplateParamsInCurrentInstantiation(TemplateParameterList *Params)
Rebuild the template parameters now that we know we're in a current instantiation.
void removeDefaultArgument()
Removes the default argument of this template parameter.
Dataflow Directional Tag Classes.
bool isExplicit() const
Whether this function is explicit.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
bool isValid() const
Return true if this is a valid SourceLocation object.
ParsedTemplateTy getAsTemplate() const
Retrieve the template template argument's template name.
const TemplateArgument & getArgument() const
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization, retrieves the member specialization information.
ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
NestedNameSpecifier * getQualifier() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
EvalResult is a struct with detailed info about an evaluated expression.
The base class of all kinds of template declarations (e.g., class, function, etc.).
bool hasUnnamedOrLocalType() const
Whether this type is or contains a local or unnamed type.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
QualType getType() const
Get the type for which this source info wrapper provides information.
SourceLocation getLocStart() const LLVM_READONLY
The template argument is a pack expansion of a template name that was provided for a template templat...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
CXXScopeSpec SS
The nested-name-specifier that precedes the template name.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
Expr * getSourceExpression() const
QualType getUnderlyingType() const
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
AccessSpecifier getAccess() const
This is a scope that corresponds to the template parameters of a C++ template.
This template specialization was instantiated from a template due to an explicit instantiation declar...
bool isInvalid() const
Determine whether the given template argument is invalid.
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
DeclarationName - The name of a declaration.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isBooleanType() const
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo &TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization...
Represents a C++11 pack expansion that produces a sequence of expressions.
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
SourceLocation getLocStart() const LLVM_READONLY
static Expr * lookThroughRangesV3Condition(Preprocessor &PP, Expr *Cond)
EnumDecl - Represents an enum.
A pointer to member type per C++ 8.3.3 - Pointers to members.
This names the __type_pack_element BuiltinTemplateDecl.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set...
TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS, const IdentifierInfo &II, SourceLocation IdLoc)
Called when the parser has parsed a C++ typename specifier, e.g., "typename T::type".
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
A type that was preceded by the 'template' keyword, stored as a Type*.
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
The name refers to a template whose specialization produces a type.
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
bool isNull() const
Determine whether this template argument has no value.
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration...
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
unsigned getNumParams() const
void setNameLoc(SourceLocation Loc)
Represents a pointer to an Objective C object.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
Name lookup found a single declaration that met the criteria.
static void completeMemberSpecializationImpl(Sema &S, DeclT *OrigD, SourceLocation Loc)
Complete the explicit specialization of a member of a class template by updating the instantiated mem...
NamedDecl * ActOnTypeParameter(Scope *S, bool Typename, SourceLocation EllipsisLoc, SourceLocation KeyLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedType DefaultArg)
ActOnTypeParameter - Called when a C++ template type parameter (e.g., "typename T") has been parsed...
const UnresolvedSetImpl & asUnresolvedSet() const
bool HasSideEffects
Whether the evaluated expression has side effects.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
ParsedTemplateArgument getTemplatePackExpansion(SourceLocation EllipsisLoc) const
Retrieve a pack expansion of the given template template argument.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Determine what kind of template instantiation this function represents.
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
QualType getCanonicalTypeInternal() const
SourceLocation getVirtualSpecLoc() const
This template specialization was declared or defined by an explicit specialization (C++ [temp...
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)
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
bool isFunctionType() const
void setTypeSourceInfo(TypeSourceInfo *TI)
void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK)
Specify that this variable is an instantiation of the static data member VD.
TypeSourceInfo * getTypeSourceInfo() const
unsigned getNumLevels() const
Determine the number of levels in this template argument list.
ExtVectorType - Extended vector type.
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Wrapper for source info for record types.
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
SourceRange getTemplateParamsRange(TemplateParameterList const *const *Params, unsigned NumParams)
Retrieves the range of the given template parameter lists.
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...
QualType getUnderlyingType() const
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 LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
unsigned getNumArgs() const
void addDecl(Decl *D)
Add the declaration D into this context.
TemplateArgument getInjectedTemplateArg(NamedDecl *ParamDecl)
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
The template argument is actually a parameter pack.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
static bool ScopeSpecifierHasTemplateId(const CXXScopeSpec &SS)
Determine whether the given scope specifier has a template-id in it.
void checkClassLevelDLLAttribute(CXXRecordDecl *Class)
Check class-level dllimport/dllexport attribute.
void setInstantiationOf(VarTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this variable template specialization is actually an instantiation of the given variable te...
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
This is a scope that can contain a declaration.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
SourceLocation getIdentifierLoc() const
void CheckTemplatePartialSpecialization(ClassTemplatePartialSpecializationDecl *Partial)
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
A template argument list.
bool isSet() const
Deprecated.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
static void checkMoreSpecializedThanPrimary(Sema &S, PartialSpecDecl *Partial)
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
ArgKind getKind() const
Return the kind of stored template argument.
unsigned getDepth() const
ValueKind getKind() const
TypeResult ActOnTemplateIdType(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, IdentifierInfo *TemplateII, SourceLocation TemplateIILoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false, bool IsClassName=false)
TranslationUnitDecl * getTranslationUnitDecl() const
QualType CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI, SourceLocation Loc)
Check that the type of a non-type template parameter is well-formed.
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
Captures information about "declaration specifiers".
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Represents a C++ struct/union/class.
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization, returns the templated static data member from which it was instantiated.
Represents a template specialization type whose template cannot be resolved, e.g. ...
The template argument is a template name that was provided for a template template parameter...
Represents a C array with an unspecified size.
TemplateName getCanonicalTemplateName(TemplateName Name) const
Retrieves the "canonical" template name that refers to a given template.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member...
void setConstexpr(bool IC)
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
void setParam(unsigned i, ParmVarDecl *VD)
Provides information a specialization of a member of a class template, which may be a member function...
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
A structure for storing the information associated with an overloaded template name.
ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
Location information for a TemplateArgument.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void DeclareImplicitDeductionGuides(TemplateDecl *Template, SourceLocation Loc)
Declare implicit deduction guides for a class template if we've not already done so.
Declaration of a class template.
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool isVirtualSpecified() const
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
This class is used for builtin types like 'int'.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
A template-id, e.g., f<int>.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const
getInjectedClassNameType - Return the unique reference to the injected class name type for the specif...
DeclResult ActOnVarTemplateSpecialization(Scope *S, Declarator &D, TypeSourceInfo *DI, SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, StorageClass SC, bool IsPartialSpecialization)
static TemplateArgumentListInfo makeTemplateArgumentListInfo(Sema &S, TemplateIdAnnotation &TemplateId)
Convert the parser's template argument list representation into our form.
Defines the clang::TargetInfo interface.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
SourceLocation getNameLoc() const
bool isInlineSpecified() const
void setRAngleLoc(SourceLocation Loc)
static bool CheckExplicitInstantiationScope(Sema &S, NamedDecl *D, SourceLocation InstLoc, bool WasQualifiedName)
Check the scope of an explicit instantiation.
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
Decl * SubstDecl(Decl *D, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs)
StringRef getImmediateMacroName(SourceLocation Loc)
Retrieve the name of the immediate macro expansion.
static Decl::Kind getKind(const Decl *D)
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)
SourceLocation getExplicitSpecLoc() const
static Expr * formAssociatedConstraints(TemplateParameterList *Params, FunctionDecl *FD)
[temp.constr.decl]p2: A template's associated constraints are defined as a single constraint-expressi...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
The name refers to a variable template whose specialization produces a variable.
SourceLocation getConstexprSpecLoc() const
QualType getAsType() const
Retrieve the type for a type template argument.
A reference to a declared variable, function, enum, etc.
Represents an extended address space qualifier where the input address space value is dependent...
Represents a type template specialization; the template must be a class template, a type alias templa...
NamedDecl * getMostRecentDecl()
bool isDeleted() const
Whether this function has been deleted.
bool isPointerType() const
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
SourceLocation getTemplateNameLoc() const
void setInheritedDefaultArgument(const ASTContext &C, TemplateTemplateParmDecl *Prev)
static bool diagnoseArityMismatch(Sema &S, TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
Diagnose an arity mismatch in the.
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, const TemplateArgumentListInfo &Args) const
TypeSourceInfo * SubstType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, bool AllowDeducedTST=false)
Perform substitution on the type T with a given set of template arguments.
bool isStaticDataMember() const
Determines whether this is a static data member.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
An l-value expression is a reference to an object with independent storage.
bool empty() const
Return true if no decls were found.
static bool DependsOnTemplateParameters(QualType T, TemplateParameterList *Params)
Determines whether a given type depends on the given parameter list.
Wrapper for template type parameters.
A trivial tuple used to represent a source range.
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
void setLexicalDeclContext(DeclContext *DC)
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
NamedDecl - This represents a decl with a name.
A boolean literal, per ([C++ lex.bool] Boolean literals).
bool isTranslationUnit() const
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
void setAccess(AccessSpecifier AS)
A template template argument, stored as a template name.
Represents a C array with a specified size that is not an integer-constant-expression.
void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
Mark which template parameters can be deduced from a given template argument list.
void setTemplateNameLoc(SourceLocation Loc)
No keyword precedes the qualified type name.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
SourceLocation getNameLoc() const
Gets the location of the identifier.
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
SourceLocation getRAngleLoc() const
unsigned NumArgs
NumArgs - The number of template arguments.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
The global specifier '::'. There is no stored value.
static void noteNonDeducibleParameters(Sema &S, TemplateParameterList *TemplateParams, const llvm::SmallBitVector &DeducibleParams)
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
SourceLocation getLocStart() const LLVM_READONLY
void setType(QualType newType)
SourceLocation getBegin() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getInnerLocStart() const
getInnerLocStart - Return SourceLocation representing start of source range ignoring outer template d...
void setDeletedAsWritten(bool D=true)
bool isDependent() const
Determines whether this is a dependent template name.
Represents the canonical version of C arrays with a specified constant size.
Defines enum values for all the target-independent builtin functions.
Declaration of a template function.
void clear()
Clears out any current state.
bool IsInsideALocalClassWithinATemplateFunction()
void setElaboratedKeywordLoc(SourceLocation Loc)
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
SourceLocation getLocation() const
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type...
static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc, TemplateDecl *TD, const TemplateParmDecl *D, TemplateArgumentListInfo &Args)
Diagnose a missing template argument.
QualType getPointeeType() const
QualType getType() const
Return the type wrapped by this type source info.
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
AttributeList - Represents a syntactic attribute.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.