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();
111 if (isa<UnresolvedUsingValueDecl>(D))
118 bool AllowFunctionTemplates) {
120 llvm::SmallPtrSet<ClassTemplateDecl *, 8> ClassTemplates;
125 AllowFunctionTemplates);
128 else if (Repl != Orig) {
139 if (!ClassTemplates.insert(ClassTmpl).second) {
156 bool AllowFunctionTemplates) {
166 bool hasTemplateKeyword,
169 bool EnteringContext,
171 bool &MemberOfUnknownSpecialization) {
172 assert(getLangOpts().
CPlusPlus &&
"No template names in C!");
175 MemberOfUnknownSpecialization =
false;
198 if (LookupTemplateName(R, S, SS, ObjectType, EnteringContext,
199 MemberOfUnknownSpecialization))
202 if (R.isAmbiguous()) {
204 R.suppressDiagnostics();
214 unsigned ResultCount = R.end() - R.begin();
215 if (ResultCount > 1) {
222 R.suppressDiagnostics();
223 }
else if (isa<UnresolvedUsingValueDecl>((*R.begin())->getUnderlyingDecl())) {
225 MemberOfUnknownSpecialization =
true;
228 TemplateDecl *TD = cast<TemplateDecl>((*R.begin())->getUnderlyingDecl());
233 hasTemplateKeyword, TD);
238 if (isa<FunctionTemplateDecl>(TD)) {
242 R.suppressDiagnostics();
244 assert(isa<ClassTemplateDecl>(TD) || isa<TemplateTemplateParmDecl>(TD) ||
245 isa<TypeAliasTemplateDecl>(TD) || isa<VarTemplateDecl>(TD) ||
246 isa<BuiltinTemplateDecl>(TD));
252 TemplateResult = TemplateTy::make(Template);
260 bool MemberOfUnknownSpecialization =
false;
266 if (LookupTemplateName(R, S, SS,
QualType(),
268 MemberOfUnknownSpecialization))
271 if (R.
empty())
return false;
298 if (!SS || !SS->
isSet() || !isDependentScopeSpecifier(*SS) ||
299 computeDeclContext(*SS))
305 Diag(IILoc, diag::err_template_kw_missing)
317 bool EnteringContext,
318 bool &MemberOfUnknownSpecialization,
321 MemberOfUnknownSpecialization =
false;
323 bool IsDependent =
false;
324 if (!ObjectType.
isNull()) {
327 assert(!SS.
isSet() &&
"ObjectType and scope specifier cannot coexist");
328 LookupCtx = computeDeclContext(ObjectType);
329 IsDependent = !LookupCtx;
332 "Caller should have completed object type");
339 }
else if (SS.
isSet()) {
342 LookupCtx = computeDeclContext(SS, EnteringContext);
343 IsDependent = !LookupCtx;
346 if (LookupCtx && RequireCompleteDeclContext(SS, LookupCtx))
350 bool ObjectTypeSearchedInScope =
false;
351 bool AllowFunctionTemplatesInLookup =
true;
357 LookupQualifiedName(Found, LookupCtx);
381 LookupName(Found, S);
383 if (!ObjectType.
isNull()) {
387 AllowFunctionTemplatesInLookup =
false;
388 ObjectTypeSearchedInScope =
true;
394 if (Found.
empty() && !IsDependent) {
399 auto FilterCCC = llvm::make_unique<CorrectionCandidateCallback>();
400 FilterCCC->WantTypeSpecifiers =
false;
401 FilterCCC->WantExpressionKeywords =
false;
402 FilterCCC->WantRemainingKeywords =
false;
403 FilterCCC->WantCXXNamedCasts =
true;
406 std::move(FilterCCC), CTK_ErrorRecovery, LookupCtx)) {
408 if (
auto *ND = Corrected.getFoundDecl())
410 FilterAcceptableTemplateNames(Found);
411 if (!Found.
empty()) {
413 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
414 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
416 diagnoseTypo(Corrected, PDiag(diag::err_no_member_template_suggest)
417 << Name << LookupCtx << DroppedSpecifier
420 diagnoseTypo(Corrected, PDiag(diag::err_no_template_suggest) << Name);
430 FilterAcceptableTemplateNames(Found, AllowFunctionTemplatesInLookup);
433 MemberOfUnknownSpecialization =
true;
439 if (ExampleLookupResult && TemplateKWLoc.
isValid()) {
440 Diag(Found.
getNameLoc(), diag::err_template_kw_refers_to_non_template)
443 diag::note_template_kw_refers_to_non_template)
451 if (S && !ObjectType.
isNull() && !ObjectTypeSearchedInScope &&
452 !getLangOpts().CPlusPlus11) {
461 LookupName(FoundOuter, S);
462 FilterAcceptableTemplateNames(FoundOuter,
false);
464 if (FoundOuter.empty()) {
468 FoundOuter.isAmbiguous()) {
481 diag::ext_nested_name_member_ref_lookup_ambiguous)
485 diag::note_ambig_member_ref_object_type)
487 Diag(FoundOuter.getFoundDecl()->getLocation(),
488 diag::note_ambig_member_ref_scope);
511 bool MissingTemplateKeyword =
false;
514 if (
auto *DRE = dyn_cast<DeclRefExpr>(TemplateName.
get())) {
515 NameInfo = DRE->getNameInfo();
516 SS.
Adopt(DRE->getQualifierLoc());
517 LookupKind = LookupOrdinaryName;
518 Found = DRE->getFoundDecl();
519 }
else if (
auto *ME = dyn_cast<MemberExpr>(TemplateName.
get())) {
520 NameInfo = ME->getMemberNameInfo();
521 SS.
Adopt(ME->getQualifierLoc());
522 LookupKind = LookupMemberName;
523 LookupCtx = ME->getBase()->getType()->getAsCXXRecordDecl();
524 Found = ME->getMemberDecl();
525 }
else if (
auto *DSDRE =
526 dyn_cast<DependentScopeDeclRefExpr>(TemplateName.
get())) {
527 NameInfo = DSDRE->getNameInfo();
528 SS.
Adopt(DSDRE->getQualifierLoc());
529 MissingTemplateKeyword =
true;
530 }
else if (
auto *DSME =
531 dyn_cast<CXXDependentScopeMemberExpr>(TemplateName.
get())) {
532 NameInfo = DSME->getMemberNameInfo();
533 SS.
Adopt(DSME->getQualifierLoc());
534 MissingTemplateKeyword =
true;
536 llvm_unreachable(
"unexpected kind of potential template name");
541 if (MissingTemplateKeyword) {
549 TemplateCandidateFilter() {
550 WantTypeSpecifiers =
false;
551 WantExpressionKeywords =
false;
552 WantRemainingKeywords =
false;
553 WantCXXNamedCasts =
true;
555 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
564 CorrectTypo(NameInfo, LookupKind, S, &SS,
565 llvm::make_unique<TemplateCandidateFilter>(),
566 CTK_ErrorRecovery, LookupCtx)) {
567 auto *ND = Corrected.getFoundDecl();
571 if (ND || Corrected.isKeyword()) {
573 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
574 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
576 diagnoseTypo(Corrected,
577 PDiag(diag::err_non_template_in_member_template_id_suggest)
578 << Name << LookupCtx << DroppedSpecifier
581 diagnoseTypo(Corrected,
582 PDiag(diag::err_non_template_in_template_id_suggest)
587 diag::note_non_template_in_template_id_found);
592 Diag(NameInfo.
getLoc(), diag::err_non_template_in_template_id)
595 Diag(Found->
getLocation(), diag::note_non_template_in_template_id_found);
605 bool isAddressOfOperand,
620 bool MightBeCxx11UnevalField =
621 getLangOpts().CPlusPlus11 && isUnevaluatedContext();
626 IsEnum = dyn_cast_or_null<EnumType>(NNS->getAsType());
628 if (!MightBeCxx11UnevalField && !isAddressOfOperand && !IsEnum &&
629 isa<CXXMethodDecl>(DC) && cast<CXXMethodDecl>(DC)->isInstance()) {
630 QualType ThisType = cast<CXXMethodDecl>(DC)->getThisType();
634 NamedDecl *FirstQualifierInScope =
nullptr;
637 Context,
nullptr, ThisType,
true,
639 FirstQualifierInScope, NameInfo, TemplateArgs);
642 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
660 bool InstantiatedFromMember,
665 assert(isa<TagDecl>(Instantiation) || isa<FunctionDecl>(Instantiation) ||
666 isa<VarDecl>(Instantiation));
668 bool IsEntityBeingDefined =
false;
669 if (
const TagDecl *TD = dyn_cast_or_null<TagDecl>(PatternDef))
670 IsEntityBeingDefined = TD->isBeingDefined();
672 if (PatternDef && !IsEntityBeingDefined) {
674 if (!hasVisibleDefinition(const_cast<NamedDecl*>(PatternDef), &SuggestedDef,
677 bool Recover = Complain && !isSFINAEContext();
679 diagnoseMissingImport(PointOfInstantiation, SuggestedDef,
686 if (!Complain || (PatternDef && PatternDef->
isInvalidDecl()))
691 if (
TagDecl *TD = dyn_cast<TagDecl>(Instantiation))
694 Diag(PointOfInstantiation,
695 diag::err_template_instantiate_within_definition)
701 }
else if (InstantiatedFromMember) {
702 if (isa<FunctionDecl>(Instantiation)) {
703 Diag(PointOfInstantiation,
704 diag::err_explicit_instantiation_undefined_member)
707 Note = diag::note_explicit_instantiation_here;
709 assert(isa<TagDecl>(Instantiation) &&
"Must be a TagDecl!");
710 Diag(PointOfInstantiation,
711 diag::err_implicit_instantiate_member_undefined)
713 Note = diag::note_member_declared_at;
716 if (isa<FunctionDecl>(Instantiation)) {
717 Diag(PointOfInstantiation,
718 diag::err_explicit_instantiation_undefined_func_template)
720 Note = diag::note_explicit_instantiation_here;
721 }
else if (isa<TagDecl>(Instantiation)) {
722 Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
725 Note = diag::note_template_decl_here;
727 assert(isa<VarDecl>(Instantiation) &&
"Must be a VarDecl!");
728 if (isa<VarTemplateSpecializationDecl>(Instantiation)) {
729 Diag(PointOfInstantiation,
730 diag::err_explicit_instantiation_undefined_var_template)
734 Diag(PointOfInstantiation,
735 diag::err_explicit_instantiation_undefined_member)
738 Note = diag::note_explicit_instantiation_here;
761 if (getLangOpts().MicrosoftExt)
767 Diag(Loc, diag::err_template_param_shadow)
768 << cast<NamedDecl>(PrevDecl)->getDeclName();
776 if (
TemplateDecl *Temp = dyn_cast_or_null<TemplateDecl>(D)) {
777 D = Temp->getTemplatedDecl();
785 assert(
Kind == Template &&
786 "Only template template arguments can be pack expansions here");
787 assert(getAsTemplate().
get().containsUnexpandedParameterPack() &&
788 "Template template argument pack expansion without packs");
790 Result.EllipsisLoc = EllipsisLoc;
826 llvm_unreachable(
"Unhandled parsed template argument");
833 for (
unsigned I = 0,
Last = TemplateArgsIn.size(); I !=
Last; ++I)
853 QualType T = GetTypeFromParser(ParsedType.
get(), &TInfo);
856 assert(TInfo &&
"template argument with no location");
864 EllipsisLoc = PET.getEllipsisLoc();
865 TL = PET.getPatternLoc();
870 SS.
Adopt(ET.getQualifierLoc());
871 TL = ET.getNamedTypeLoc();
875 TemplateName Name = DTST.getTypePtr()->getTemplateName();
881 DTST.getTemplateNameLoc());
883 Result = Result.getTemplatePackExpansion(EllipsisLoc);
893 ParsedType.
get().getAsOpaquePtr(),
911 unsigned Depth,
unsigned Position,
915 "Template type parameter not in template parameter scope!");
921 bool IsParameterPack = EllipsisLoc.
isValid();
924 KeyLoc, Loc,
Depth, Position, ParamName,
925 Typename, IsParameterPack);
933 IdResolver.AddDecl(Param);
939 if (DefaultArg && IsParameterPack) {
940 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
941 DefaultArg =
nullptr;
947 GetTypeFromParser(DefaultArg, &DefaultTInfo);
949 assert(DefaultTInfo &&
"expected source information for type");
952 if (DiagnoseUnexpandedParameterPack(Loc, DefaultTInfo,
953 UPPC_DefaultArgument))
957 if (CheckTemplateArgument(Param, DefaultTInfo)) {
981 TSI = SubstAutoTypeSourceInfo(TSI, Context.
DependentTy);
984 return CheckNonTypeTemplateParameterType(TSI->
getType(), Loc);
992 Diag(Loc, diag::err_variably_modified_nontype_template_param)
1030 Diag(Loc, diag::err_template_nontype_parm_bad_type)
1044 auto CheckValidDeclSpecifiers = [
this, &D] {
1058 Diag(Loc, diag::err_invalid_decl_specifier_in_nontype_parm)
1095 CheckValidDeclSpecifiers();
1099 diag::warn_cxx14_compat_template_nontype_parm_auto_type)
1104 "Non-type template parameter not in template parameter scope!");
1105 bool Invalid =
false;
1130 IdResolver.AddDecl(Param);
1136 if (Default && IsParameterPack) {
1137 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1144 if (DiagnoseUnexpandedParameterPack(Default, UPPC_DefaultArgument))
1149 CheckTemplateArgument(Param, Param->
getType(), Default, Converted);
1154 Default = DefaultRes.
get();
1176 "Template template parameter not in template parameter scope!");
1179 bool IsParameterPack = EllipsisLoc.
isValid();
1183 Depth, Position, IsParameterPack,
1193 IdResolver.AddDecl(Param);
1196 if (Params->
size() == 0) {
1205 if (IsParameterPack && !Default.
isInvalid()) {
1206 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1221 Diag(DefaultArg.
getLocation(), diag::err_template_arg_not_valid_template)
1227 if (DiagnoseUnexpandedParameterPack(DefaultArg.
getLocation(),
1229 UPPC_DefaultArgument))
1248 Expr *RequiresClause) {
1250 Diag(ExportLoc, diag::warn_template_export_unsupported);
1253 Context, TemplateLoc, LAngleLoc,
1254 llvm::makeArrayRef(Params.data(), Params.size()),
1255 RAngleLoc, RequiresClause);
1271 assert(TemplateParams && TemplateParams->
size() > 0 &&
1272 "No template parameters");
1273 assert(TUK != TUK_Reference &&
"Can only declare or define class templates");
1274 bool Invalid =
false;
1277 if (CheckTemplateDeclScope(S, TemplateParams))
1281 assert(Kind !=
TTK_Enum &&
"can't build template of enumerated type");
1285 Diag(KWLoc, diag::err_template_unnamed_class);
1294 (SS.
isEmpty() && TUK == TUK_Friend)
1295 ? LookupTagName : LookupOrdinaryName,
1296 forRedeclarationInCurContext());
1298 SemanticContext = computeDeclContext(SS,
true);
1299 if (!SemanticContext) {
1303 Diag(NameLoc, TUK == TUK_Friend
1304 ? diag::warn_template_qualified_friend_ignored
1305 : diag::err_template_qualified_declarator_no_match)
1307 return TUK != TUK_Friend;
1310 if (RequireCompleteDeclContext(SS, SemanticContext))
1318 if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams))
1320 }
else if (TUK != TUK_Friend && TUK != TUK_Reference)
1321 diagnoseQualifiedDeclaration(SS, SemanticContext, Name, NameLoc,
false);
1323 LookupQualifiedName(
Previous, SemanticContext);
1325 SemanticContext = CurContext;
1331 if (TUK != TUK_Friend &&
1332 DiagnoseClassNameShadow(SemanticContext,
1344 PrevDecl = (*
Previous.begin())->getUnderlyingDecl();
1348 DiagnoseTemplateParameterShadow(NameLoc, PrevDecl);
1356 dyn_cast_or_null<ClassTemplateDecl>(PrevDecl);
1361 if (!PrevClassTemplate && PrevDecl && isa<CXXRecordDecl>(PrevDecl) &&
1362 cast<CXXRecordDecl>(PrevDecl)->isInjectedClassName()) {
1365 = cast<CXXRecordDecl>(PrevDecl)->getDescribedClassTemplate();
1366 if (!PrevClassTemplate && isa<ClassTemplateSpecializationDecl>(PrevDecl)) {
1368 = cast<ClassTemplateSpecializationDecl>(PrevDecl)
1369 ->getSpecializedTemplate();
1373 if (TUK == TUK_Friend) {
1392 PrevDecl = PrevClassTemplate =
nullptr;
1393 SemanticContext = OutermostContext;
1397 Previous.clear(LookupOrdinaryName);
1401 LookupQualifiedName(
Previous, LookupContext);
1407 PrevDecl = (*
Previous.begin())->getUnderlyingDecl();
1410 }
else if (PrevDecl &&
1411 !isDeclInScope(
Previous.getRepresentativeDecl(), SemanticContext,
1413 PrevDecl = PrevClassTemplate =
nullptr;
1415 if (
auto *Shadow = dyn_cast_or_null<UsingShadowDecl>(
1416 PrevDecl ?
Previous.getRepresentativeDecl() :
nullptr)) {
1418 !(PrevClassTemplate &&
1421 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
1422 Diag(Shadow->getTargetDecl()->getLocation(),
1423 diag::note_using_decl_target);
1424 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl) << 0;
1426 PrevDecl = PrevClassTemplate =
nullptr;
1433 if (PrevClassTemplate) {
1437 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
1438 !TemplateParameterListsAreEqual(TemplateParams,
1446 const bool RedeclACMismatch = [&] {
1447 if (!(CurAC || PrevAC))
1449 if (CurAC && PrevAC) {
1450 llvm::FoldingSetNodeID CurACInfo, PrevACInfo;
1451 CurAC->
Profile(CurACInfo, Context,
true);
1452 PrevAC->
Profile(PrevACInfo, Context,
true);
1453 if (CurACInfo == PrevACInfo)
1459 if (RedeclACMismatch) {
1461 diag::err_template_different_associated_constraints);
1463 diag::note_template_prev_declaration)
1474 if (!isAcceptableTagRedeclaration(PrevRecordDecl, Kind,
1475 TUK == TUK_Definition, KWLoc, Name)) {
1476 Diag(KWLoc, diag::err_use_with_wrong_tag)
1484 if (TUK == TUK_Definition) {
1489 if (SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
1492 auto *Tmpl = cast<CXXRecordDecl>(Hidden)->getDescribedClassTemplate();
1493 assert(Tmpl &&
"original definition of a class template is not a " 1495 makeMergedDefinitionVisible(Hidden);
1496 makeMergedDefinitionVisible(Tmpl);
1498 Diag(NameLoc, diag::err_redefinition) << Name;
1499 Diag(Def->getLocation(), diag::note_previous_definition);
1506 }
else if (PrevDecl) {
1512 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
1521 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
1522 CheckTemplateParameterList(
1527 (SS.
isSet() && SemanticContext && SemanticContext->
isRecord() &&
1529 ? TPC_ClassTemplateMember
1530 : TUK == TUK_Friend ? TPC_FriendClassTemplate : TPC_ClassTemplate,
1537 if (!SS.
isInvalid() && !Invalid && !PrevClassTemplate) {
1538 Diag(NameLoc, TUK == TUK_Friend ? diag::err_friend_decl_does_not_match
1539 : diag::err_member_decl_does_not_match)
1540 << Name << SemanticContext <<
true << SS.
getRange();
1550 bool ShouldAddRedecl
1551 = !(TUK == TUK_Friend && CurContext->isDependentContext());
1555 PrevClassTemplate && ShouldAddRedecl ?
1559 if (NumOuterTemplateParamLists > 0)
1561 Context, llvm::makeArrayRef(OuterTemplateParamLists,
1562 NumOuterTemplateParamLists));
1566 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip)) {
1567 AddAlignmentAttributesForRecord(NewClass);
1568 AddMsStructLayoutForRecord(NewClass);
1573 Expr *
const ACtoAttach =
1574 PrevClassTemplate && ShouldAddRedecl ? nullptr : CurAC;
1579 NewClass, ACtoAttach);
1581 if (ShouldAddRedecl)
1586 if (ModulePrivateLoc.
isValid())
1592 assert(T->
isDependentType() &&
"Class template type is not dependent?");
1597 if (PrevClassTemplate &&
1603 SetMemberAccessSpecifier(NewTemplate, PrevClassTemplate, AS);
1609 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip))
1612 ProcessDeclAttributeList(S, NewClass, Attr);
1614 if (PrevClassTemplate)
1617 AddPushedVisibilityAttribute(NewClass);
1619 if (TUK != TUK_Friend) {
1624 PushOnScopeChains(NewTemplate, Outer);
1634 if (!CurContext->isDependentContext()) {
1637 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
1638 PushOnScopeChains(NewTemplate, EnclosingScope,
1643 Context, CurContext, NewClass->
getLocation(), NewTemplate, FriendLoc);
1645 CurContext->addDecl(Friend);
1648 if (PrevClassTemplate)
1649 CheckRedeclarationModuleOwnership(NewTemplate, PrevClassTemplate);
1656 ActOnDocumentableDecl(NewTemplate);
1667 class ExtractTypeForDeductionGuide
1671 ExtractTypeForDeductionGuide(
Sema &SemaRef) : Base(SemaRef) {}
1676 return TransformType(
1684 struct ConvertConstructorToDeductionGuideTransform {
1685 ConvertConstructorToDeductionGuideTransform(
Sema &S,
1687 : SemaRef(S), Template(Template) {}
1721 AllParams.reserve(TemplateParams->
size() + InnerParams->
size());
1722 AllParams.insert(AllParams.begin(),
1723 TemplateParams->
begin(), TemplateParams->
end());
1724 SubstArgs.reserve(InnerParams->
size());
1732 NamedDecl *NewParam = transformTemplateParameter(Param, Args);
1735 AllParams.push_back(NewParam);
1740 SemaRef.
Context, InnerParams->getTemplateLoc(),
1741 InnerParams->getLAngleLoc(), AllParams, InnerParams->getRAngleLoc(),
1751 Args.addOuterRetainedLevel();
1756 assert(FPTL &&
"no prototype for constructor declaration");
1763 QualType NewType = transformFunctionProtoType(TLB, FPTL, Params, Args);
1768 return buildDeductionGuide(TemplateParams, CD->
isExplicit(), NewTInfo,
1781 DeductionGuideName, EPI);
1789 for (
auto T : ParamTypes) {
1791 SemaRef.
Context, DC, Loc, Loc,
nullptr, T,
1794 FPTL.
setParam(Params.size(), NewParam);
1795 Params.push_back(NewParam);
1808 if (
auto *TTP = dyn_cast<TemplateTypeParmDecl>(TemplateParam)) {
1812 SemaRef.
Context, DC, TTP->getBeginLoc(), TTP->getLocation(),
1813 0, Depth1IndexAdjustment + TTP->getIndex(),
1814 TTP->getIdentifier(), TTP->wasDeclaredWithTypename(),
1815 TTP->isParameterPack());
1816 if (TTP->hasDefaultArgument()) {
1818 SemaRef.
SubstType(TTP->getDefaultArgumentInfo(), Args,
1819 TTP->getDefaultArgumentLoc(), TTP->getDeclName());
1820 if (InstantiatedDefaultArg)
1821 NewTTP->setDefaultArgument(InstantiatedDefaultArg);
1828 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(TemplateParam))
1829 return transformTemplateParameterImpl(TTP, Args);
1831 return transformTemplateParameterImpl(
1832 cast<NonTypeTemplateParmDecl>(TemplateParam), Args);
1834 template<
typename TemplateParmDecl>
1836 transformTemplateParameterImpl(TemplateParmDecl *OldParam,
1841 cast_or_null<TemplateParmDecl>(SemaRef.
SubstDecl(OldParam, DC, Args));
1842 assert(NewParam->getDepth() == 0 &&
"unexpected template param depth");
1843 NewParam->setPosition(NewParam->getPosition() + Depth1IndexAdjustment);
1856 ParmVarDecl *NewParam = transformFunctionTypeParam(OldParam, Args);
1859 ParamTypes.push_back(NewParam->
getType());
1860 Params.push_back(NewParam);
1882 ReturnType, ParamTypes, TL.
getBeginLoc(), DeductionGuideName, EPI);
1892 for (
unsigned I = 0, E = NewTL.
getNumParams(); I != E; ++I)
1907 SemaRef.
SubstType(PackTL.getPatternLoc(), Args,
1909 if (!NewDI)
return nullptr;
1912 PackTL.getTypePtr()->getNumExpansions());
1923 NewDI = ExtractTypeForDeductionGuide(SemaRef).transform(NewDI);
1959 Name, TInfo->
getType(), TInfo, LocEnd);
1961 Guide->setParams(Params);
1963 for (
auto *Param : Params)
1964 Param->setDeclContext(Guide);
1967 SemaRef.
Context, DC, Loc, DeductionGuideName, TemplateParams, Guide);
1968 GuideTemplate->setImplicit();
1969 Guide->setDescribedFunctionTemplate(GuideTemplate);
1971 if (isa<CXXRecordDecl>(DC)) {
1977 return GuideTemplate;
1988 ConvertConstructorToDeductionGuideTransform Transform(
1989 *
this, cast<ClassTemplateDecl>(Template));
1990 if (!isCompleteType(Loc, Transform.DeducedType))
1995 auto Existing = DC->
lookup(Transform.DeductionGuideName);
1996 for (
auto *D : Existing)
1997 if (D->isImplicit())
2008 if (BuildingDeductionGuides.
isInvalid())
2015 bool AddedAny =
false;
2016 for (
NamedDecl *D : LookupConstructors(Transform.Primary)) {
2017 D = D->getUnderlyingDecl();
2018 if (D->isInvalidDecl() || D->isImplicit())
2020 D = cast<NamedDecl>(D->getCanonicalDecl());
2024 dyn_cast_or_null<CXXConstructorDecl>(FTD ? FTD->getTemplatedDecl() : D);
2027 if (!CD || (!FTD && CD->isFunctionTemplateSpecialization()))
2030 Transform.transformConstructor(FTD, CD);
2039 Transform.buildSimpleDeductionGuide(None);
2043 cast<CXXDeductionGuideDecl>(
2044 cast<FunctionTemplateDecl>(
2045 Transform.buildSimpleDeductionGuide(Transform.DeducedType))
2046 ->getTemplatedDecl())
2047 ->setIsCopyDeductionCandidate();
2075 diag::warn_cxx98_compat_template_parameter_default_in_function_template
2076 : diag::ext_template_parameter_default_in_function_template)
2085 S.
Diag(ParamLoc, diag::err_template_parameter_default_template_member)
2094 S.
Diag(ParamLoc, diag::err_template_parameter_default_friend_template)
2103 llvm_unreachable(
"Invalid TemplateParamListContext!");
2116 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
2119 if (!NTTP->isParameterPack() &&
2121 NTTP->getTypeSourceInfo(),
2129 = dyn_cast<TemplateTemplateParmDecl>(P))
2169 bool Invalid =
false;
2177 bool SawDefaultArgument =
false;
2183 OldParam = OldParams->
begin();
2185 bool RemoveDefaultArguments =
false;
2187 NewParamEnd = NewParams->
end();
2188 NewParam != NewParamEnd; ++NewParam) {
2190 bool RedundantDefaultArg =
false;
2195 bool MissingDefaultArg =
false;
2198 bool SawParameterPack =
false;
2201 = dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
2203 if (NewTypeParm->hasDefaultArgument() &&
2205 NewTypeParm->getLocation(),
2206 NewTypeParm->getDefaultArgumentInfo()->getTypeLoc()
2208 NewTypeParm->removeDefaultArgument();
2212 = OldParams? cast<TemplateTypeParmDecl>(*OldParam) :
nullptr;
2213 if (NewTypeParm->isParameterPack()) {
2214 assert(!NewTypeParm->hasDefaultArgument() &&
2215 "Parameter packs can't have a default argument!");
2216 SawParameterPack =
true;
2218 NewTypeParm->hasDefaultArgument() &&
2221 NewDefaultLoc = NewTypeParm->getDefaultArgumentLoc();
2222 SawDefaultArgument =
true;
2223 RedundantDefaultArg =
true;
2224 PreviousDefaultArgLoc = NewDefaultLoc;
2228 NewTypeParm->setInheritedDefaultArgument(Context, OldTypeParm);
2230 }
else if (NewTypeParm->hasDefaultArgument()) {
2231 SawDefaultArgument =
true;
2232 PreviousDefaultArgLoc = NewTypeParm->getDefaultArgumentLoc();
2233 }
else if (SawDefaultArgument)
2234 MissingDefaultArg =
true;
2236 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
2238 if (!NewNonTypeParm->isParameterPack() &&
2239 DiagnoseUnexpandedParameterPack(NewNonTypeParm->getLocation(),
2240 NewNonTypeParm->getTypeSourceInfo(),
2241 UPPC_NonTypeTemplateParameterType)) {
2247 if (NewNonTypeParm->hasDefaultArgument() &&
2249 NewNonTypeParm->getLocation(),
2250 NewNonTypeParm->getDefaultArgument()->getSourceRange())) {
2251 NewNonTypeParm->removeDefaultArgument();
2256 = OldParams? cast<NonTypeTemplateParmDecl>(*OldParam) :
nullptr;
2257 if (NewNonTypeParm->isParameterPack()) {
2258 assert(!NewNonTypeParm->hasDefaultArgument() &&
2259 "Parameter packs can't have a default argument!");
2260 if (!NewNonTypeParm->isPackExpansion())
2261 SawParameterPack =
true;
2263 NewNonTypeParm->hasDefaultArgument() &&
2266 NewDefaultLoc = NewNonTypeParm->getDefaultArgumentLoc();
2267 SawDefaultArgument =
true;
2268 RedundantDefaultArg =
true;
2269 PreviousDefaultArgLoc = NewDefaultLoc;
2273 NewNonTypeParm->setInheritedDefaultArgument(Context, OldNonTypeParm);
2275 }
else if (NewNonTypeParm->hasDefaultArgument()) {
2276 SawDefaultArgument =
true;
2277 PreviousDefaultArgLoc = NewNonTypeParm->getDefaultArgumentLoc();
2278 }
else if (SawDefaultArgument)
2279 MissingDefaultArg =
true;
2282 = cast<TemplateTemplateParmDecl>(*NewParam);
2299 = OldParams? cast<TemplateTemplateParmDecl>(*OldParam) :
nullptr;
2302 "Parameter packs can't have a default argument!");
2304 SawParameterPack =
true;
2305 }
else if (OldTemplateParm &&
2311 SawDefaultArgument =
true;
2312 RedundantDefaultArg =
true;
2313 PreviousDefaultArgLoc = NewDefaultLoc;
2318 PreviousDefaultArgLoc
2321 SawDefaultArgument =
true;
2322 PreviousDefaultArgLoc
2324 }
else if (SawDefaultArgument)
2325 MissingDefaultArg =
true;
2331 if (SawParameterPack && (NewParam + 1) != NewParamEnd &&
2332 (TPC == TPC_ClassTemplate || TPC == TPC_VarTemplate ||
2333 TPC == TPC_TypeAliasTemplate)) {
2334 Diag((*NewParam)->getLocation(),
2335 diag::err_template_param_pack_must_be_last_template_parameter);
2339 if (RedundantDefaultArg) {
2343 Diag(NewDefaultLoc, diag::err_template_param_default_arg_redefinition);
2344 Diag(OldDefaultLoc, diag::note_template_param_prev_default_arg);
2346 }
else if (MissingDefaultArg && TPC != TPC_FunctionTemplate) {
2352 Diag((*NewParam)->getLocation(),
2353 diag::err_template_param_default_arg_missing);
2354 Diag(PreviousDefaultArgLoc, diag::note_template_param_prev_default_arg);
2356 RemoveDefaultArguments =
true;
2367 if (RemoveDefaultArguments) {
2369 NewParamEnd = NewParams->
end();
2370 NewParam != NewParamEnd; ++NewParam) {
2372 TTP->removeDefaultArgument();
2374 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
2375 NTTP->removeDefaultArgument();
2377 cast<TemplateTemplateParmDecl>(*NewParam)->removeDefaultArgument();
2397 bool IgnoreNonTypeDependent;
2402 DependencyChecker(
unsigned Depth,
bool IgnoreNonTypeDependent)
2403 :
Depth(Depth), IgnoreNonTypeDependent(IgnoreNonTypeDependent),
2407 : IgnoreNonTypeDependent(IgnoreNonTypeDependent), Match(
false) {
2410 Depth = PD->getDepth();
2412 dyn_cast<NonTypeTemplateParmDecl>(ND)) {
2413 Depth = PD->getDepth();
2415 Depth = cast<TemplateTemplateParmDecl>(ND)->getDepth();
2420 if (ParmDepth >= Depth) {
2428 bool TraverseStmt(
Stmt *S, DataRecursionQueue *Q =
nullptr) {
2433 if (
auto *E = dyn_cast_or_null<Expr>(S))
2434 if (IgnoreNonTypeDependent && !E->isTypeDependent())
2436 return super::TraverseStmt(S, Q);
2439 bool TraverseTypeLoc(
TypeLoc TL) {
2440 if (IgnoreNonTypeDependent && !TL.
isNull() &&
2443 return super::TraverseTypeLoc(TL);
2452 return IgnoreNonTypeDependent || !Matches(T->
getDepth());
2458 if (Matches(PD->getDepth()))
2460 return super::TraverseTemplateName(N);
2465 dyn_cast<NonTypeTemplateParmDecl>(E->
getDecl()))
2466 if (Matches(PD->getDepth(), E->
getExprLoc()))
2468 return super::VisitDeclRefExpr(E);
2490 DependencyChecker Checker(Params,
false);
2491 Checker.TraverseType(T);
2492 return Checker.Match;
2502 if (
const Type *CurType = NNS->getAsType()) {
2508 NNSLoc = NNSLoc.getPrefix();
2551 bool &IsMemberSpecialization,
bool &Invalid) {
2552 IsMemberSpecialization =
false;
2562 = dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS,
true)))
2574 NestedTypes.push_back(T);
2580 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
2581 if (!isa<ClassTemplatePartialSpecializationDecl>(Spec) &&
2583 ExplicitSpecLoc = Spec->getLocation();
2586 }
else if (Record->getTemplateSpecializationKind()
2588 ExplicitSpecLoc = Record->getLocation();
2601 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
2602 if (
TypeDecl *
Parent = dyn_cast<TypeDecl>(Template->getDeclContext()))
2647 std::reverse(NestedTypes.begin(), NestedTypes.end());
2655 bool SawNonEmptyTemplateParameterList =
false;
2657 auto CheckExplicitSpecialization = [&](
SourceRange Range,
bool Recovery) {
2658 if (SawNonEmptyTemplateParameterList) {
2659 Diag(DeclLoc, diag::err_specialize_member_of_template)
2660 << !Recovery << Range;
2662 IsMemberSpecialization =
false;
2669 auto DiagnoseMissingExplicitSpecialization = [&] (
SourceRange Range) {
2671 if (CheckExplicitSpecialization(Range,
true))
2676 if (!ParamLists.empty())
2677 ExpectedTemplateLoc = ParamLists[0]->getTemplateLoc();
2679 ExpectedTemplateLoc = DeclStartLoc;
2681 Diag(DeclLoc, diag::err_template_spec_needs_header)
2688 for (
unsigned TypeIdx = 0, NumTypes = NestedTypes.size(); TypeIdx != NumTypes;
2690 T = NestedTypes[TypeIdx];
2693 bool NeedEmptyTemplateHeader =
false;
2696 bool NeedNonemptyTemplateHeader =
false;
2709 = dyn_cast<ClassTemplatePartialSpecializationDecl>(Record)) {
2710 ExpectedTemplateParams = Partial->getTemplateParameters();
2711 NeedNonemptyTemplateHeader =
true;
2712 }
else if (Record->isDependentType()) {
2713 if (Record->getDescribedClassTemplate()) {
2714 ExpectedTemplateParams = Record->getDescribedClassTemplate()
2715 ->getTemplateParameters();
2716 NeedNonemptyTemplateHeader =
true;
2719 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
2725 NeedEmptyTemplateHeader =
true;
2728 }
else if (Record->getTemplateSpecializationKind()) {
2729 if (Record->getTemplateSpecializationKind()
2731 TypeIdx == NumTypes - 1)
2732 IsMemberSpecialization =
true;
2738 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
2739 ExpectedTemplateParams = Template->getTemplateParameters();
2740 NeedNonemptyTemplateHeader =
true;
2745 NeedNonemptyTemplateHeader =
false;
2755 if (ParamIdx < ParamLists.size()) {
2756 if (ParamLists[ParamIdx]->size() == 0) {
2757 if (CheckExplicitSpecialization(ParamLists[ParamIdx]->
getSourceRange(),
2761 SawNonEmptyTemplateParameterList =
true;
2764 if (NeedEmptyTemplateHeader) {
2767 if (TypeIdx == NumTypes - 1)
2768 IsMemberSpecialization =
true;
2770 if (ParamIdx < ParamLists.size()) {
2771 if (ParamLists[ParamIdx]->size() > 0) {
2773 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
2774 diag::err_template_param_list_matches_nontemplate)
2776 <<
SourceRange(ParamLists[ParamIdx]->getLAngleLoc(),
2777 ParamLists[ParamIdx]->getRAngleLoc())
2789 if (DiagnoseMissingExplicitSpecialization(
2796 if (NeedNonemptyTemplateHeader) {
2802 if (ParamIdx < ParamLists.size() &&
2804 ExpectedTemplateParams =
nullptr;
2809 if (ParamIdx < ParamLists.size()) {
2811 if (ExpectedTemplateParams &&
2812 !TemplateParameterListsAreEqual(ParamLists[ParamIdx],
2813 ExpectedTemplateParams,
2814 true, TPL_TemplateMatch))
2818 CheckTemplateParameterList(ParamLists[ParamIdx],
nullptr,
2819 TPC_ClassTemplateMember))
2826 Diag(DeclLoc, diag::err_template_spec_needs_template_parameters)
2837 if (ParamIdx >= ParamLists.size()) {
2838 if (TemplateId && !IsFriend) {
2854 if (ParamIdx < ParamLists.size() - 1) {
2855 bool HasAnyExplicitSpecHeader =
false;
2856 bool AllExplicitSpecHeaders =
true;
2857 for (
unsigned I = ParamIdx, E = ParamLists.size() - 1; I != E; ++I) {
2858 if (ParamLists[I]->size() == 0)
2859 HasAnyExplicitSpecHeader =
true;
2861 AllExplicitSpecHeaders =
false;
2864 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
2865 AllExplicitSpecHeaders ? diag::warn_template_spec_extra_headers
2866 : diag::err_template_spec_extra_headers)
2867 <<
SourceRange(ParamLists[ParamIdx]->getTemplateLoc(),
2868 ParamLists[ParamLists.size() - 2]->getRAngleLoc());
2873 if (ExplicitSpecLoc.isValid() && HasAnyExplicitSpecHeader)
2874 Diag(ExplicitSpecLoc,
2875 diag::note_explicit_template_spec_does_not_need_header)
2876 << NestedTypes.back();
2881 if (!AllExplicitSpecHeaders)
2892 if (ParamLists.back()->size() == 0 &&
2893 CheckExplicitSpecialization(ParamLists[ParamIdx]->
getSourceRange(),
2899 return ParamLists.back();
2904 Diag(Template->getLocation(), diag::note_template_declared_here)
2905 << (isa<FunctionTemplateDecl>(Template)
2907 : isa<ClassTemplateDecl>(Template)
2909 : isa<VarTemplateDecl>(Template)
2911 : isa<TypeAliasTemplateDecl>(Template) ? 3 : 4)
2912 << Template->getDeclName();
2920 Diag((*I)->getLocation(), diag::note_template_declared_here)
2921 << 0 << (*I)->getDeclName();
2940 if (!Converted[1].getAsType()->isIntegralType(Context)) {
2941 SemaRef.
Diag(TemplateArgs[1].getLocation(),
2942 diag::err_integer_sequence_integral_element_type);
2951 SemaRef.
Diag(TemplateArgs[2].getLocation(),
2952 diag::err_integer_sequence_negative_length);
2960 SyntheticTemplateArgs.
addArgument(TemplateArgs[1]);
2962 for (llvm::APSInt I(NumArgs.getBitWidth(), NumArgs.isUnsigned());
2966 TA, ArgTy, TemplateArgs[2].getLocation()));
2971 TemplateLoc, SyntheticTemplateArgs);
2978 assert(Converted.size() == 2 &&
2979 "__type_pack_element should be given an index and a parameter pack");
2983 llvm::APSInt Index = IndexArg.getAsIntegral();
2984 assert(Index >= 0 &&
"the index used with __type_pack_element should be of " 2985 "type std::size_t, and hence be non-negative");
2986 if (Index >= Ts.pack_size()) {
2987 SemaRef.
Diag(TemplateArgs[0].getLocation(),
2988 diag::err_type_pack_element_out_of_bounds);
2993 auto Nth = std::next(Ts.pack_begin(), Index.getExtValue());
2994 return Nth->getAsType();
2996 llvm_unreachable(
"unexpected BuiltinTemplateDecl!");
3001 return AliasTemplate->
getName().equals(
"enable_if_t");
3013 if (BinOp->getOpcode() == BO_LAnd) {
3021 Terms.push_back(Clause);
3030 if (!BinOp)
return Cond;
3032 if (BinOp->getOpcode() != BO_LOr)
return Cond;
3035 Expr *LHS = BinOp->getLHS();
3037 if (!InnerBinOp)
return Cond;
3039 if (InnerBinOp->getOpcode() != BO_EQ ||
3040 !isa<IntegerLiteral>(InnerBinOp->getRHS()))
3050 if (MacroName ==
"CONCEPT_REQUIRES" || MacroName ==
"CONCEPT_REQUIRES_")
3051 return BinOp->getRHS();
3061 class FailedBooleanConditionPrinterHelper :
public PrinterHelper {
3066 bool handledStmt(
Stmt *E, raw_ostream &OS)
override {
3068 if (DR && DR->getQualifier()) {
3075 if (
const auto *IV = dyn_cast<VarTemplateSpecializationDecl>(VD)) {
3090 std::pair<Expr *, std::string>
3099 Expr *FailedCond =
nullptr;
3100 for (
Expr *Term : Terms) {
3104 if (isa<CXXBoolLiteralExpr>(TermAsWritten) ||
3105 isa<IntegerLiteral>(TermAsWritten))
3114 if (Term->EvaluateAsBooleanCondition(Succeeded, Context) &&
3116 FailedCond = TermAsWritten;
3123 std::string Description;
3125 llvm::raw_string_ostream Out(Description);
3128 FailedBooleanConditionPrinterHelper Helper(Policy);
3129 FailedCond->
printPretty(Out, &Helper, Policy, 0,
"\n",
nullptr);
3131 return { FailedCond, Description };
3150 if (!Template || isa<FunctionTemplateDecl>(Template) ||
3151 isa<VarTemplateDecl>(Template)) {
3157 Diag(TemplateLoc, diag::err_template_id_not_a_type)
3159 NoteAllFoundTemplates(Name);
3166 if (CheckTemplateArgumentList(Template, TemplateLoc, TemplateArgs,
3172 bool InstantiationDependent =
false;
3174 dyn_cast<TypeAliasTemplateDecl>(Template)) {
3186 unsigned Depth = AliasTemplate->getTemplateParameters()->getDepth();
3187 for (
unsigned I = 0; I <
Depth; ++I)
3196 TemplateArgLists, AliasTemplate->getLocation(),
3197 AliasTemplate->getDeclName());
3198 if (CanonType.
isNull()) {
3203 if (
auto DeductionInfo = isSFINAEContext()) {
3204 if (*DeductionInfo &&
3205 (*DeductionInfo)->hasSFINAEDiagnostic() &&
3206 (*DeductionInfo)->peekSFINAEDiagnostic().second.getDiagID() ==
3207 diag::err_typename_nested_not_found_enable_if &&
3208 TemplateArgs[0].getArgument().getKind()
3211 std::string FailedDescription;
3212 std::tie(FailedCond, FailedDescription) =
3213 findFailedBooleanCondition(TemplateArgs[0].getSourceExpression());
3218 (*DeductionInfo)->takeSFINAEDiagnostic(OldDiag);
3222 (*DeductionInfo)->addSFINAEDiagnostic(
3224 PDiag(diag::err_typename_nested_not_found_requirement)
3225 << FailedDescription
3235 TemplateArgs, InstantiationDependent)) {
3251 if (isa<ClassTemplateDecl>(Template)) {
3254 if (Ctx->isFileContext())
break;
3258 if (!Record)
continue;
3262 if (!isa<ClassTemplatePartialSpecializationDecl>(Record) &&
3269 QualType Injected = cast<InjectedClassNameType>(ICNT)
3270 ->getInjectedSpecializationType();
3283 = dyn_cast<ClassTemplateDecl>(Template)) {
3286 void *InsertPos =
nullptr;
3288 = ClassTemplate->findSpecialization(Converted, InsertPos);
3294 Context, ClassTemplate->getTemplatedDecl()->getTagKind(),
3295 ClassTemplate->getDeclContext(),
3296 ClassTemplate->getTemplatedDecl()->getBeginLoc(),
3297 ClassTemplate->getLocation(), ClassTemplate, Converted,
nullptr);
3298 ClassTemplate->AddSpecialization(Decl, InsertPos);
3299 if (ClassTemplate->isOutOfLine())
3306 InstantiateAttrsForDecl(TemplateArgLists, ClassTemplate->getTemplatedDecl(),
3311 (void)DiagnoseUseOfDecl(Decl, TemplateLoc);
3314 assert(isa<RecordType>(CanonType) &&
3315 "type of non-dependent specialization is not a RecordType");
3316 }
else if (
auto *BTD = dyn_cast<BuiltinTemplateDecl>(Template)) {
3334 bool IsCtorOrDtorName,
bool IsClassName) {
3338 if (!IsCtorOrDtorName && !IsClassName && SS.
isSet()) {
3339 DeclContext *LookupCtx = computeDeclContext(SS,
false);
3347 if (!LookupCtx && isDependentScopeSpecifier(SS)) {
3354 return ActOnTypenameType(
nullptr,
SourceLocation(), SS, TemplateKWLoc,
3355 TemplateD, TemplateII, TemplateIILoc, LAngleLoc,
3356 TemplateArgsIn, RAngleLoc);
3363 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
3364 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
3367 ? diag::err_out_of_line_qualified_id_type_names_constructor
3368 : diag::ext_out_of_line_qualified_id_type_names_constructor)
3378 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
3383 DTN->getQualifier(),
3384 DTN->getIdentifier(),
3396 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
3401 QualType Result = CheckTemplateIdType(Template, TemplateIILoc, TemplateArgs);
3402 if (Result.isNull())
3413 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
3444 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
3453 DTN->getQualifier(),
3454 DTN->getIdentifier(),
3467 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
3478 Diag(TemplateLoc, diag::err_tag_reference_non_tag)
3479 << TAT << NTK_TypeAliasTemplate << TagKind;
3480 Diag(TAT->getLocation(), diag::note_declared_at);
3483 QualType Result = CheckTemplateIdType(Template, TemplateLoc, TemplateArgs);
3484 if (Result.isNull())
3492 assert(Id &&
"templated class must have an identifier");
3494 if (!isAcceptableTagRedeclaration(D, TagKind, TUK == TUK_Definition,
3496 Diag(TagLoc, diag::err_use_with_wrong_tag)
3511 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
3520 return CreateParsedType(Result, TLB.getTypeSourceInfo(Context, Result));
3560 dyn_cast_or_null<TemplateTemplateParmDecl>(
3564 llvm_unreachable(
"unexpected kind of template argument");
3569 if (Params->
size() != Args.size())
3574 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
3601 return TemplateArgs;
3604 template<
typename PartialSpecDecl>
3606 if (Partial->getDeclContext()->isDependentContext())
3615 auto *Template = Partial->getSpecializedTemplate();
3616 S.
Diag(Partial->getLocation(),
3617 diag::ext_partial_spec_not_more_specialized_than_primary)
3618 << isa<VarTemplateDecl>(Template);
3620 if (Info.hasSFINAEDiagnostic()) {
3623 Info.takeSFINAEDiagnostic(Diag);
3627 diag::note_partial_spec_not_more_specialized_than_primary)
3631 S.
Diag(Template->getLocation(), diag::note_template_decl_here);
3636 const llvm::SmallBitVector &DeducibleParams) {
3637 for (
unsigned I = 0, N = DeducibleParams.size(); I != N; ++I) {
3638 if (!DeducibleParams[I]) {
3651 template<
typename PartialSpecDecl>
3653 PartialSpecDecl *Partial) {
3666 auto *TemplateParams = Partial->getTemplateParameters();
3667 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
3669 TemplateParams->getDepth(), DeducibleParams);
3671 if (!DeducibleParams.all()) {
3672 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
3673 S.
Diag(Partial->getLocation(), diag::ext_partial_specs_not_deducible)
3674 << isa<VarTemplatePartialSpecializationDecl>(Partial)
3675 << (NumNonDeducible > 1)
3677 Partial->getTemplateArgsAsWritten()->RAngleLoc);
3698 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
3699 MarkDeducedTemplateParameters(TD, DeducibleParams);
3700 for (
unsigned I = 0; I != TemplateParams->size(); ++I) {
3702 auto *Param = TemplateParams->getParam(I);
3704 DeducibleParams[I] =
true;
3707 if (!DeducibleParams.all()) {
3708 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
3709 Diag(TD->
getLocation(), diag::err_deduction_guide_template_not_deducible)
3710 << (NumNonDeducible > 1);
3721 "Variable template specialization is declared with a template it.");
3738 FnTemplate = *OTS->begin();
3745 << IsPartialSpecialization;
3749 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
3750 if (DiagnoseUnexpandedParameterPack(TemplateArgs[I],
3751 UPPC_PartialSpecialization))
3757 if (CheckTemplateArgumentList(VarTemplate, TemplateNameLoc, TemplateArgs,
3763 if (IsPartialSpecialization) {
3764 if (CheckTemplatePartialSpecializationArgs(TemplateNameLoc, VarTemplate,
3765 TemplateArgs.
size(), Converted))
3770 bool InstantiationDependent;
3774 InstantiationDependent)) {
3775 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
3777 IsPartialSpecialization =
false;
3786 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
3788 << (SC !=
SC_Extern && !CurContext->isRecord())
3796 void *InsertPos =
nullptr;
3799 if (IsPartialSpecialization)
3811 IsPartialSpecialization))
3819 Specialization = PrevDecl;
3822 }
else if (IsPartialSpecialization) {
3825 cast_or_null<VarTemplatePartialSpecializationDecl>(PrevDecl);
3829 TemplateNameLoc, TemplateParams, VarTemplate, DI->
getType(), DI, SC,
3830 Converted, TemplateArgs);
3833 VarTemplate->AddPartialSpecialization(Partial, InsertPos);
3834 Specialization = Partial;
3841 CheckTemplatePartialSpecialization(Partial);
3846 Context, VarTemplate->
getDeclContext(), TemplateKWLoc, TemplateNameLoc,
3847 VarTemplate, DI->
getType(), DI, SC, Converted);
3851 VarTemplate->AddSpecialization(Specialization, InsertPos);
3872 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
3876 diag::note_instantiation_required_here)
3889 CurContext->addDecl(Specialization);
3897 LookupResult PrevSpec(*
this, GetNameForDeclarator(D), LookupOrdinaryName,
3898 forRedeclarationInCurContext());
3913 return Specialization;
3919 struct PartialSpecMatchResult {
3929 assert(Template &&
"A variable template id without template?");
3933 if (CheckTemplateArgumentList(
3934 Template, TemplateNameLoc,
3935 const_cast<TemplateArgumentListInfo &>(TemplateArgs),
false,
3941 void *InsertPos =
nullptr;
3943 Converted, InsertPos)) {
3944 checkSpecializationVisibility(TemplateNameLoc, Spec);
3957 bool AmbiguousPartialSpec =
false;
3958 typedef PartialSpecMatchResult MatchResult;
3973 bool InstantiationDependent =
false;
3975 TemplateArgs, InstantiationDependent)) {
3980 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
3993 Matched.push_back(PartialSpecMatchResult());
3994 Matched.back().Partial = Partial;
3995 Matched.back().Args = Info.take();
3999 if (Matched.size() >= 1) {
4001 if (Matched.size() == 1) {
4014 PEnd = Matched.end();
4016 if (getMoreSpecializedPartialSpecialization(
P->Partial, Best->Partial,
4017 PointOfInstantiation) ==
4025 PEnd = Matched.end();
4027 if (
P != Best && getMoreSpecializedPartialSpecialization(
4028 P->Partial, Best->Partial,
4029 PointOfInstantiation) != Best->Partial) {
4030 AmbiguousPartialSpec =
true;
4037 InstantiationPattern = Best->Partial;
4038 InstantiationArgs = Best->Args;
4051 Template, InstantiationPattern, *InstantiationArgs, TemplateArgs,
4052 Converted, TemplateNameLoc, InsertPos );
4056 if (AmbiguousPartialSpec) {
4059 Diag(PointOfInstantiation, diag::err_partial_spec_ordering_ambiguous)
4063 for (MatchResult
P : Matched)
4064 Diag(
P.Partial->getLocation(), diag::note_partial_spec_match)
4065 << getTemplateArgumentBindingsText(
P.Partial->getTemplateParameters(),
4071 dyn_cast<VarTemplatePartialSpecializationDecl>(InstantiationPattern))
4074 checkSpecializationVisibility(TemplateNameLoc, Decl);
4076 assert(Decl &&
"No variable template specialization?");
4097 return BuildDeclarationNameExpr(SS, NameInfo, Var,
4098 nullptr, TemplateArgs);
4103 Diag(Loc, diag::err_template_missing_args)
4104 << (int)getTemplateNameKindForDiagnostics(Name) << Name;
4106 Diag(TD->getLocation(), diag::note_template_decl_here)
4107 << TD->getTemplateParameters()->getSourceRange();
4127 assert(!R.
empty() &&
"empty lookup results when building templateid");
4128 assert(!R.
isAmbiguous() &&
"ambiguous lookup when building templateid");
4132 if (!TemplateArgs && !isa<FunctionTemplateDecl>(TD)) {
4138 auto AnyDependentArguments = [&]() ->
bool {
4139 bool InstantiationDependent;
4140 return TemplateArgs &&
4142 *TemplateArgs, InstantiationDependent);
4149 TemplateKWLoc, TemplateArgs);
4160 RequiresADL, TemplateArgs,
4173 assert(TemplateArgs || TemplateKWLoc.
isValid());
4175 if (!(DC = computeDeclContext(SS,
false)) ||
4176 DC->isDependentContext() ||
4177 RequireCompleteDeclContext(SS, DC))
4178 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
4180 bool MemberOfUnknownSpecialization;
4183 false, MemberOfUnknownSpecialization,
4197 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_class_template)
4200 Diag(Temp->getLocation(), diag::note_referenced_class_template);
4204 return BuildTemplateIdExpr(SS, TemplateKWLoc, R,
false, TemplateArgs);
4219 bool EnteringContext,
4221 bool AllowInjectedClassName) {
4224 getLangOpts().CPlusPlus11 ?
4225 diag::warn_cxx98_compat_template_outside_of_template :
4226 diag::ext_template_outside_of_template)
4231 LookupCtx = computeDeclContext(SS, EnteringContext);
4232 if (!LookupCtx && ObjectType)
4233 LookupCtx = computeDeclContext(ObjectType.
get());
4251 bool MemberOfUnknownSpecialization;
4253 ObjectType, EnteringContext, Result,
4254 MemberOfUnknownSpecialization);
4263 LookupOrdinaryName);
4265 if (!LookupTemplateName(R, S, SS, ObjectType.get(), EnteringContext,
4266 MOUS, TemplateKWLoc))
4273 if (!AllowInjectedClassName && SS.
isSet() && LookupRD &&
4286 diag::ext_out_of_line_qualified_id_type_names_constructor)
4309 llvm_unreachable(
"literal operator id cannot have a dependent scope");
4315 Diag(Name.
getBeginLoc(), diag::err_template_kw_refers_to_non_template)
4316 << GetNameFromUnqualifiedId(Name).getName() << Name.
getSourceRange()
4343 diagnoseMissingTemplateArguments(Name, SR.
getEnd());
4353 SS.
Adopt(ArgExpr->getQualifierLoc());
4354 NameInfo = ArgExpr->getNameInfo();
4356 dyn_cast<DependentScopeDeclRefExpr>(Arg.
getAsExpr())) {
4357 SS.
Adopt(ArgExpr->getQualifierLoc());
4358 NameInfo = ArgExpr->getNameInfo();
4360 dyn_cast<CXXDependentScopeMemberExpr>(Arg.
getAsExpr())) {
4361 if (ArgExpr->isImplicitAccess()) {
4362 SS.
Adopt(ArgExpr->getQualifierLoc());
4363 NameInfo = ArgExpr->getMemberNameInfo();
4368 LookupResult Result(*
this, NameInfo, LookupOrdinaryName);
4369 LookupParsedName(Result, CurScope, &SS);
4376 Diag(Loc, getLangOpts().MSVCCompat
4377 ? diag::ext_ms_template_type_arg_missing_typename
4378 : diag::err_template_arg_must_be_type_suggest)
4408 Diag(SR.
getBegin(), diag::err_template_arg_must_be_type) << SR;
4415 if (CheckTemplateArgument(Param, TSI))
4424 if (getLangOpts().ObjCAutoRefCount &&
4470 Param, Template, Converted,
4480 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4485 SemaRef.
SubstType(ArgType, TemplateArgLists,
4522 Param, Template, Converted,
4532 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4584 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4614 bool &HasDefaultArg) {
4615 HasDefaultArg =
false;
4621 HasDefaultArg =
true;
4634 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
4638 HasDefaultArg =
true;
4652 = cast<TemplateTemplateParmDecl>(Param);
4656 HasDefaultArg =
true;
4679 if (ETLoc.getTypePtr()->getKeyword() !=
ETK_None)
4682 QualLoc = ETLoc.getQualifierLoc();
4683 TLoc = ETLoc.getNamedTypeLoc();
4690 QualLoc, InjLoc.getNameLoc());
4698 dyn_cast<ClassTemplateSpecializationDecl>(RecLoc.getDecl()))
4700 QualLoc, RecLoc.getNameLoc());
4736 unsigned ArgumentPackIndex,
4741 return CheckTemplateTypeArgument(TTP, Arg, Converted);
4748 QualType NTTPType = NTTP->getType();
4749 if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack())
4750 NTTPType = NTTP->getExpansionType(ArgumentPackIndex);
4755 !isa<TemplateTemplateParmDecl>(Template) &&
4766 NTTPType = SubstType(NTTPType,
4768 NTTP->getLocation(),
4769 NTTP->getDeclName());
4773 NTTPType = CheckNonTypeTemplateParameterType(NTTPType,
4774 NTTP->getLocation());
4781 llvm_unreachable(
"Should never see a NULL template argument here");
4785 unsigned CurSFINAEErrors = NumSFINAEErrors;
4792 if (CurSFINAEErrors < NumSFINAEErrors)
4802 Converted.push_back(Result);
4836 Context, SS.getWithLocInContext(Context), TemplateKWLoc, NameInfo,
4848 E = CheckTemplateArgument(NTTP, NTTPType, E.
get(), Result);
4852 Converted.push_back(Result);
4879 Diag(SR.
getBegin(), diag::err_template_arg_nontype_ambig) << SR << T;
4881 Diag(SR.
getBegin(), diag::err_template_arg_must_be_expr) << SR;
4887 llvm_unreachable(
"Caller must expand template argument packs");
4910 TempParm, Converted,
4916 Params = SubstTemplateParams(Params, CurContext,
4935 llvm_unreachable(
"Should never see a NULL template argument here");
4939 if (CheckTemplateTemplateArgument(Params, Arg))
4950 << getLangOpts().CPlusPlus11;
4954 llvm_unreachable(
"Declaration argument with template template parameter");
4956 llvm_unreachable(
"Integral argument with template template parameter");
4958 llvm_unreachable(
"Null pointer argument with template template parameter");
4961 llvm_unreachable(
"Caller must expand template argument packs");
4980 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
4981 if (NTTP->isExpandedParameterPack())
4982 return NTTP->getNumExpansionTypes();
4986 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
4987 if (TTP->isExpandedParameterPack())
4988 return TTP->getNumExpansionTemplateParameters();
4995 template<
typename TemplateParmDecl>
4998 const TemplateParmDecl *D,
5003 ->getTemplateParameters()
5004 ->getParam(D->getIndex()));
5011 D->getDefaultArgumentLoc(), Modules,
5022 S.
Diag(Loc, diag::err_template_arg_list_different_arity)
5037 bool UpdateArgsWithConversions) {
5048 ->getTemplateParameters();
5057 bool isTemplateTemplateParameter = isa<TemplateTemplateParmDecl>(Template);
5059 unsigned ArgIdx = 0, NumArgs = NewArgs.
size();
5062 ParamEnd = Params->
end();
5063 Param != ParamEnd; ) {
5067 if (*Expansions == ArgumentPack.size()) {
5070 Converted.push_back(
5072 ArgumentPack.clear();
5077 }
else if (ArgIdx == NumArgs && !PartialTemplateArgs) {
5079 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
5081 << (int)getTemplateNameKindForDiagnostics(
TemplateName(Template))
5089 if (ArgIdx < NumArgs) {
5091 if (CheckTemplateArgument(*Param, NewArgs[ArgIdx], Template,
5092 TemplateLoc, RAngleLoc,
5093 ArgumentPack.size(), Converted))
5096 bool PackExpansionIntoNonPack =
5097 NewArgs[ArgIdx].getArgument().isPackExpansion() &&
5099 if (PackExpansionIntoNonPack && isa<TypeAliasTemplateDecl>(Template)) {
5103 Diag(NewArgs[ArgIdx].getLocation(),
5104 diag::err_alias_template_expansion_into_fixed_list)
5105 << NewArgs[ArgIdx].getSourceRange();
5106 Diag((*Param)->getLocation(), diag::note_template_param_here);
5113 if ((*Param)->isTemplateParameterPack()) {
5118 ArgumentPack.push_back(Converted.pop_back_val());
5127 if (PackExpansionIntoNonPack) {
5128 if (!ArgumentPack.empty()) {
5131 Converted.insert(Converted.end(),
5132 ArgumentPack.begin(), ArgumentPack.end());
5133 ArgumentPack.clear();
5136 while (ArgIdx < NumArgs) {
5137 Converted.push_back(NewArgs[ArgIdx].
getArgument());
5148 if (PartialTemplateArgs) {
5149 if ((*Param)->isTemplateParameterPack() && !ArgumentPack.empty())
5150 Converted.push_back(
5158 if ((*Param)->isTemplateParameterPack()) {
5160 "Should have dealt with this already");
5165 if (Param + 1 != ParamEnd)
5168 Converted.push_back(
5170 ArgumentPack.clear();
5201 = dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
5218 = cast<TemplateTemplateParmDecl>(*Param);
5244 if (Inst.isInvalid())
5248 if (CheckTemplateArgument(*Param, Arg, Template, TemplateLoc,
5249 RAngleLoc, 0, Converted))
5255 if (isTemplateTemplateParameter)
5267 if (ArgIdx < NumArgs && CurrentInstantiationScope &&
5268 CurrentInstantiationScope->getPartiallySubstitutedPack()) {
5270 Converted.push_back(NewArgs[ArgIdx++].getArgument());
5275 if (ArgIdx < NumArgs) {
5276 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
5278 << (int)getTemplateNameKindForDiagnostics(
TemplateName(Template))
5288 if (UpdateArgsWithConversions)
5289 TemplateArgs = std::move(NewArgs);
5295 class UnnamedLocalNoLinkageFinder
5296 :
public TypeVisitor<UnnamedLocalNoLinkageFinder, bool>
5304 UnnamedLocalNoLinkageFinder(
Sema &S,
SourceRange SR) : S(S), SR(SR) { }
5310 #define TYPE(Class, Parent) \ 5311 bool Visit##Class##Type(const Class##Type *); 5312 #define ABSTRACT_TYPE(Class, Parent) \ 5313 bool Visit##Class##Type(const Class##Type *) { return false; } 5314 #define NON_CANONICAL_TYPE(Class, Parent) \ 5315 bool Visit##Class##Type(const Class##Type *) { return false; } 5316 #include "clang/AST/TypeNodes.def" 5318 bool VisitTagDecl(
const TagDecl *Tag);
5323 bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(
const BuiltinType*) {
5327 bool UnnamedLocalNoLinkageFinder::VisitComplexType(
const ComplexType* T) {
5331 bool UnnamedLocalNoLinkageFinder::VisitPointerType(
const PointerType* T) {
5335 bool UnnamedLocalNoLinkageFinder::VisitBlockPointerType(
5340 bool UnnamedLocalNoLinkageFinder::VisitLValueReferenceType(
5345 bool UnnamedLocalNoLinkageFinder::VisitRValueReferenceType(
5350 bool UnnamedLocalNoLinkageFinder::VisitMemberPointerType(
5355 bool UnnamedLocalNoLinkageFinder::VisitConstantArrayType(
5360 bool UnnamedLocalNoLinkageFinder::VisitIncompleteArrayType(
5365 bool UnnamedLocalNoLinkageFinder::VisitVariableArrayType(
5370 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedArrayType(
5375 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedExtVectorType(
5380 bool UnnamedLocalNoLinkageFinder::VisitDependentAddressSpaceType(
5385 bool UnnamedLocalNoLinkageFinder::VisitVectorType(
const VectorType* T) {
5389 bool UnnamedLocalNoLinkageFinder::VisitDependentVectorType(
5394 bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(
const ExtVectorType* T) {
5398 bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
5408 bool UnnamedLocalNoLinkageFinder::VisitFunctionNoProtoType(
5413 bool UnnamedLocalNoLinkageFinder::VisitUnresolvedUsingType(
5418 bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(
const TypeOfExprType*) {
5422 bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(
const TypeOfType* T) {
5426 bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(
const DecltypeType*) {
5430 bool UnnamedLocalNoLinkageFinder::VisitUnaryTransformType(
5435 bool UnnamedLocalNoLinkageFinder::VisitAutoType(
const AutoType *T) {
5439 bool UnnamedLocalNoLinkageFinder::VisitDeducedTemplateSpecializationType(
5444 bool UnnamedLocalNoLinkageFinder::VisitRecordType(
const RecordType* T) {
5445 return VisitTagDecl(T->
getDecl());
5448 bool UnnamedLocalNoLinkageFinder::VisitEnumType(
const EnumType* T) {
5449 return VisitTagDecl(T->
getDecl());
5452 bool UnnamedLocalNoLinkageFinder::VisitTemplateTypeParmType(
5457 bool UnnamedLocalNoLinkageFinder::VisitSubstTemplateTypeParmPackType(
5462 bool UnnamedLocalNoLinkageFinder::VisitTemplateSpecializationType(
5467 bool UnnamedLocalNoLinkageFinder::VisitInjectedClassNameType(
5469 return VisitTagDecl(T->
getDecl());
5472 bool UnnamedLocalNoLinkageFinder::VisitDependentNameType(
5477 bool UnnamedLocalNoLinkageFinder::VisitDependentTemplateSpecializationType(
5482 bool UnnamedLocalNoLinkageFinder::VisitPackExpansionType(
5487 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectType(
const ObjCObjectType *) {
5491 bool UnnamedLocalNoLinkageFinder::VisitObjCInterfaceType(
5496 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectPointerType(
5501 bool UnnamedLocalNoLinkageFinder::VisitAtomicType(
const AtomicType* T) {
5505 bool UnnamedLocalNoLinkageFinder::VisitPipeType(
const PipeType* T) {
5509 bool UnnamedLocalNoLinkageFinder::VisitTagDecl(
const TagDecl *Tag) {
5511 S.
Diag(SR.getBegin(),
5513 diag::warn_cxx98_compat_template_arg_local_type :
5514 diag::ext_template_arg_local_type)
5520 S.
Diag(SR.getBegin(),
5522 diag::warn_cxx98_compat_template_arg_unnamed_type :
5523 diag::ext_template_arg_unnamed_type) << SR;
5531 bool UnnamedLocalNoLinkageFinder::VisitNestedNameSpecifier(
5548 llvm_unreachable(
"Invalid NestedNameSpecifier::Kind!");
5558 assert(ArgInfo &&
"invalid TypeSourceInfo");
5563 return Diag(SR.
getBegin(), diag::err_variably_modified_template_arg) << Arg;
5565 return Diag(SR.
getBegin(), diag::err_template_arg_overload_type) << SR;
5576 UnnamedLocalNoLinkageFinder Finder(*
this, SR);
5594 Decl *Entity =
nullptr) {
5600 if (Entity && Entity->hasAttr<DLLImportAttr>())
5605 "Incomplete parameter type in isNullPointerValueTemplateArgument!");
5618 EvalResult.
Diag = &Notes;
5626 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
5627 diag::note_invalid_subexpr_in_const_expr) {
5628 DiagLoc = Notes[0].first;
5632 S.
Diag(DiagLoc, diag::err_template_arg_not_address_constant)
5634 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
5635 S.
Diag(Notes[I].first, Notes[I].second);
5653 bool ObjCLifetimeConversion;
5656 ObjCLifetimeConversion))
5661 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
5670 std::string Code =
"static_cast<" + ParamType.
getAsString() +
">(";
5671 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_untyped_null_constant)
5690 bool ObjCLifetimeConversion;
5694 ObjCLifetimeConversion)) {
5699 if (!ParamRef->getPointeeType()->isFunctionType()) {
5709 unsigned ParamQuals = ParamRef->getPointeeType().getCVRQualifiers();
5712 if ((ParamQuals | ArgQuals) != ParamQuals) {
5714 diag::err_template_arg_ref_bind_ignores_quals)
5750 bool Invalid =
false;
5754 bool AddressTaken =
false;
5761 bool ExtWarnMSTemplateArg =
false;
5764 while (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(Arg)) {
5766 if (UnOpKind == UO_Deref)
5767 ExtWarnMSTemplateArg =
true;
5768 if (UnOpKind == UO_AddrOf || UnOpKind == UO_Deref) {
5771 FirstOpKind = UnOpKind;
5772 FirstOpLoc = UnOp->getOperatorLoc();
5778 if (ExtWarnMSTemplateArg)
5782 if (FirstOpKind == UO_AddrOf)
5783 AddressTaken =
true;
5787 assert(FirstOpKind == UO_Deref);
5810 bool ExtraParens =
false;
5811 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
5812 if (!Invalid && !ExtraParens) {
5815 ? diag::warn_cxx98_compat_template_arg_extra_parens
5816 : diag::ext_template_arg_extra_parens)
5821 Arg = Parens->getSubExpr();
5825 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
5829 if (UnOp->getOpcode() == UO_AddrOf) {
5830 Arg = UnOp->getSubExpr();
5831 AddressTaken =
true;
5832 AddrOpLoc = UnOp->getOperatorLoc();
5837 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
5849 S.
Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
5869 if (isa<CXXUuidofExpr>(Arg)) {
5871 ArgIn, Arg, ArgType))
5886 if (isa<FieldDecl>(Entity) || isa<IndirectFieldDecl>(Entity)) {
5894 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Entity)) {
5895 if (!Method->isStatic()) {
5907 if (!Func && !Var) {
5919 ? diag::warn_cxx98_compat_template_arg_object_internal
5920 : diag::ext_template_arg_object_internal)
5922 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
5924 }
else if (!Entity->hasLinkage()) {
5927 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
5942 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
5948 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
5957 if (Var->getType()->isReferenceType()) {
5965 if (Var->getTLSKind()) {
5968 S.
Diag(Var->getLocation(), diag::note_template_arg_refers_here);
5981 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
5987 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
5992 ArgType = Var->getType();
5995 if (Var->getType()->isArrayType()) {
6036 bool Invalid =
false;
6038 Expr *Arg = ResultArg;
6039 bool ObjCLifetimeConversion;
6051 bool ExtraParens =
false;
6052 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
6053 if (!Invalid && !ExtraParens) {
6056 ? diag::warn_cxx98_compat_template_arg_extra_parens
6057 : diag::ext_template_arg_extra_parens)
6062 Arg = Parens->getSubExpr();
6066 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6071 if (UnOp->getOpcode() == UO_AddrOf) {
6078 else if ((DRE = dyn_cast<DeclRefExpr>(Arg))) {
6081 if (isa<NonTypeTemplateParmDecl>(VD)) {
6103 S.
Diag(ResultArg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
6113 ObjCLifetimeConversion)) {
6120 S.
Diag(ResultArg->
getBeginLoc(), diag::err_template_arg_not_convertible)
6128 diag::err_template_arg_not_pointer_to_member_form)
6131 if (isa<FieldDecl>(DRE->
getDecl()) ||
6132 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
6133 isa<CXXMethodDecl>(DRE->
getDecl())) {
6134 assert((isa<FieldDecl>(DRE->
getDecl()) ||
6135 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
6136 !cast<CXXMethodDecl>(DRE->
getDecl())->isStatic()) &&
6137 "Only non-static member pointers can make it here");
6151 S.
Diag(Arg->
getBeginLoc(), diag::err_template_arg_not_pointer_to_member_form)
6178 auto *AT = dyn_cast<
AutoType>(ParamType);
6179 if (AT && AT->isDecltypeAuto()) {
6189 if (CTAK != CTAK_Specified)
6193 Arg, ParamType, Depth) == DAR_Failed) {
6195 diag::err_non_type_template_parm_type_deduction_failure)
6205 ParamType = CheckNonTypeTemplateParameterType(ParamType, Arg->
getExprLoc());
6206 if (ParamType.
isNull()) {
6214 "non-type template parameter type cannot be qualified");
6216 if (CTAK == CTAK_Deduced &&
6235 Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
6261 Arg, ParamType, Value, CCEK_TemplateArg);
6267 if (ArgResult.
get()->isValueDependent()) {
6290 diag::err_template_arg_member_ptr_base_derived_not_supported)
6298 : TemplateArgument(CanonParamType,
true);
6311 if (isa<CXXUuidofExpr>(E)) {
6323 VD && VD->getType()->isArrayType() &&
6331 Diag(StartLoc, diag::err_non_type_template_arg_subobject)
6336 "null reference should not be a constant expression");
6338 "non-null value of type nullptr_t?");
6340 : TemplateArgument(CanonParamType,
true);
6344 return Diag(StartLoc, diag::err_non_type_template_arg_addr_label_diff);
6352 llvm_unreachable(
"invalid kind for template argument");
6355 return ArgResult.
get();
6375 if (getLangOpts().CPlusPlus11) {
6391 if (ArgResult.
get()->isValueDependent()) {
6401 IntegerType = Enum->getDecl()->getIntegerType();
6402 Value = Value.extOrTrunc(Context.
getTypeSize(IntegerType));
6409 ExprResult ArgResult = DefaultLvalueConversion(Arg);
6412 Arg = ArgResult.
get();
6425 Diag(Arg->
getBeginLoc(), diag::err_template_arg_not_integral_or_enumeral)
6434 TmplArgICEDiagnoser(
QualType T) : T(T) { }
6438 S.
Diag(Loc, diag::err_template_arg_not_ice) << T << SR;
6440 } Diagnoser(ArgType);
6442 Arg = VerifyIntegerConstantExpression(Arg, &Value, Diagnoser,
6457 Arg = ImpCastExprToType(Arg, ParamType, CK_IntegralToBoolean).get();
6458 }
else if (IsIntegralPromotion(Arg, ArgType, ParamType) ||
6461 Arg = ImpCastExprToType(Arg, ParamType, CK_IntegralCast).get();
6487 unsigned AllowedBits = Context.
getTypeSize(IntegerType);
6488 if (Value.getBitWidth() != AllowedBits)
6489 Value = Value.extOrTrunc(AllowedBits);
6492 llvm::APSInt OldValue =
Value;
6496 unsigned AllowedBits = Context.
getTypeSize(IntegerType);
6497 if (Value.getBitWidth() != AllowedBits)
6498 Value = Value.extOrTrunc(AllowedBits);
6503 && (OldValue.isSigned() && OldValue.isNegative())) {
6505 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
6511 unsigned RequiredBits;
6513 RequiredBits = OldValue.getActiveBits();
6514 else if (OldValue.isUnsigned())
6515 RequiredBits = OldValue.getActiveBits() + 1;
6517 RequiredBits = OldValue.getMinSignedBits();
6518 if (RequiredBits > AllowedBits) {
6520 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
6561 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg, ParamType,
6567 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
6593 "Only object pointers allowed here");
6609 assert(ParamRefType->getPointeeType()->isIncompleteOrObjectType() &&
6610 "Only object references allowed here");
6613 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg,
6614 ParamRefType->getPointeeType(),
6620 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
6643 << Arg->
getType() << ParamType;
6651 Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
6683 assert(Name.
isDependent() &&
"Non-dependent template isn't a declaration?");
6702 if (!isa<ClassTemplateDecl>(Template) &&
6703 !isa<TemplateTemplateParmDecl>(Template) &&
6704 !isa<TypeAliasTemplateDecl>(Template) &&
6705 !isa<BuiltinTemplateDecl>(Template)) {
6706 assert(isa<FunctionTemplateDecl>(Template) &&
6707 "Only function templates are possible here");
6709 Diag(Template->
getLocation(), diag::note_template_arg_refers_here_func)
6716 if (getLangOpts().RelaxedTemplateTemplateArgs) {
6721 if (TemplateParameterListsAreEqual(
6723 TPL_TemplateTemplateArgumentMatch, Arg.
getLocation()))
6726 if (isTemplateTemplateParameterAtLeastAsSpecializedAs(Params, Template,
6735 TPL_TemplateTemplateArgumentMatch,
6760 return ImpCastExprToType(
6764 ? CK_NullToMemberPointer
6765 : CK_NullToPointer);
6768 "Only declaration template arguments permitted here");
6772 if (VD->getDeclContext()->isRecord() &&
6773 (isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD) ||
6774 isa<IndirectFieldDecl>(VD))) {
6793 if (isa<CXXMethodDecl>(VD) && cast<CXXMethodDecl>(VD)->isInstance())
6797 VD->getType().getNonReferenceType(),
6804 RefExpr = CreateBuiltinUnaryOp(Loc, UO_AddrOf, RefExpr.
get());
6809 bool ObjCLifetimeConversion;
6810 if (IsQualificationConversion(((
Expr*) RefExpr.
get())->getType(),
6812 ObjCLifetimeConversion))
6822 QualType T = VD->getType().getNonReferenceType();
6834 RefExpr = DefaultFunctionArrayConversion(RefExpr.
get());
6842 return CreateBuiltinUnaryOp(Loc, UO_AddrOf, RefExpr.
get());
6854 }
else if (isa<FunctionDecl>(VD)) {
6859 return BuildDeclRefExpr(VD, T, VK, Loc);
6873 "Operation is only valid for integral template arguments");
6883 T = ET->getDecl()->getIntegerType();
6910 if (OrigT->isEnumeralType()) {
6930 unsigned NextDiag = diag::err_template_param_different_kind;
6931 if (TemplateArgLoc.
isValid()) {
6932 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
6933 NextDiag = diag::note_template_param_different_kind;
6952 unsigned NextDiag = diag::err_template_parameter_pack_non_pack;
6953 if (TemplateArgLoc.
isValid()) {
6954 S.
Diag(TemplateArgLoc,
6955 diag::err_template_arg_template_params_mismatch);
6956 NextDiag = diag::note_template_parameter_pack_non_pack;
6959 unsigned ParamKind = isa<TemplateTypeParmDecl>(New)? 0
6960 : isa<NonTypeTemplateParmDecl>(New)? 1
6973 = dyn_cast<NonTypeTemplateParmDecl>(Old)) {
6981 (OldNTTP->getType()->isDependentType() ||
6987 unsigned NextDiag = diag::err_template_nontype_parm_different_type;
6988 if (TemplateArgLoc.
isValid()) {
6989 S.
Diag(TemplateArgLoc,
6990 diag::err_template_arg_template_params_mismatch);
6991 NextDiag = diag::note_template_nontype_parm_different_type;
6996 S.
Diag(OldNTTP->getLocation(),
6997 diag::note_template_nontype_parm_prev_declaration)
6998 << OldNTTP->getType();
7011 = dyn_cast<TemplateTemplateParmDecl>(Old)) {
7014 OldTTP->getTemplateParameters(),
7033 unsigned NextDiag = diag::err_template_param_list_different_arity;
7034 if (TemplateArgLoc.
isValid()) {
7035 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
7036 NextDiag = diag::note_template_param_list_different_arity;
7076 if (Old->
size() != New->
size() && Kind != TPL_TemplateTemplateArgumentMatch) {
7093 OldParmEnd = Old->
end();
7094 OldParm != OldParmEnd; ++OldParm) {
7095 if (Kind != TPL_TemplateTemplateArgumentMatch ||
7096 !(*OldParm)->isTemplateParameterPack()) {
7097 if (NewParm == NewParmEnd) {
7106 Kind, TemplateArgLoc))
7120 for (; NewParm != NewParmEnd; ++NewParm) {
7122 Kind, TemplateArgLoc))
7128 if (NewParm != NewParmEnd) {
7160 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
7174 if (RD->isLocalClass())
7176 diag::err_template_inside_local_class)
7184 diag::err_template_outside_namespace_or_class_scope)
7195 return Record->getTemplateSpecializationKind();
7196 if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(D))
7197 return Function->getTemplateSpecializationKind();
7198 if (
VarDecl *Var = dyn_cast<VarDecl>(D))
7199 return Var->getTemplateSpecializationKind();
7236 if (isa<ClassTemplateDecl>(Specialized))
7237 EntityKind = IsPartialSpecialization? 1 : 0;
7238 else if (isa<VarTemplateDecl>(Specialized))
7239 EntityKind = IsPartialSpecialization ? 3 : 2;
7240 else if (isa<FunctionTemplateDecl>(Specialized))
7242 else if (isa<CXXMethodDecl>(Specialized))
7244 else if (isa<VarDecl>(Specialized))
7246 else if (isa<RecordDecl>(Specialized))
7248 else if (isa<EnumDecl>(Specialized) && S.
getLangOpts().CPlusPlus11)
7251 S.
Diag(Loc, diag::err_template_spec_unknown_kind)
7261 S.
Diag(Loc, diag::err_template_spec_decl_function_scope)
7276 : DC->
Equals(SpecializedContext))) {
7277 if (isa<TranslationUnitDecl>(SpecializedContext))
7278 S.
Diag(Loc, diag::err_template_spec_redecl_global_scope)
7279 << EntityKind << Specialized;
7281 auto *ND = cast<NamedDecl>(SpecializedContext);
7282 int Diag = diag::err_template_spec_redecl_out_of_scope;
7284 Diag = diag::ext_ms_template_spec_redecl_out_of_scope;
7285 S.
Diag(Loc, Diag) << EntityKind << Specialized
7286 << ND << isa<CXXRecordDecl>(ND);
7289 S.
Diag(Specialized->getLocation(), diag::note_specialized_entity);
7303 DependencyChecker Checker(Depth,
true);
7304 Checker.TraverseStmt(E);
7305 if (Checker.MatchLoc.isInvalid())
7307 return Checker.MatchLoc;
7313 DependencyChecker Checker(Depth,
true);
7314 Checker.TraverseTypeLoc(TL);
7315 if (Checker.MatchLoc.isInvalid())
7317 return Checker.MatchLoc;
7325 for (
unsigned I = 0; I != NumArgs; ++I) {
7328 S, TemplateNameLoc, Param, Args[I].pack_begin(),
7329 Args[I].pack_size(), IsDefaultArgument))
7342 ArgExpr = Expansion->getPattern();
7346 ArgExpr = ICE->getSubExpr();
7356 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ArgExpr))
7357 if (isa<NonTypeTemplateParmDecl>(DRE->getDecl()))
7377 if (ParamUseRange.
isValid()) {
7378 if (IsDefaultArgument) {
7379 S.
Diag(TemplateNameLoc,
7380 diag::err_dependent_non_type_arg_in_partial_spec);
7382 diag::note_dependent_non_type_default_arg_in_partial_spec)
7386 diag::err_dependent_non_type_arg_in_partial_spec)
7394 if (ParamUseRange.
isValid()) {
7396 diag::err_dependent_typed_non_type_arg_in_partial_spec)
7399 << (IsDefaultArgument ? ParamUseRange :
SourceRange())
7429 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
7436 Param, &TemplateArgs[I],
7437 1, I >= NumExplicit))
7449 assert(TUK != TUK_Reference &&
"References are not specializations");
7456 ? TemplateParameterLists[0]->getTemplateLoc() : KWLoc;
7466 if (!ClassTemplate) {
7467 Diag(TemplateNameLoc, diag::err_not_class_template_specialization)
7473 bool isMemberSpecialization =
false;
7474 bool isPartialSpecialization =
false;
7480 bool Invalid =
false;
7482 MatchTemplateParametersToScopeSpecifier(
7483 KWLoc, TemplateNameLoc, SS, &TemplateId,
7484 TemplateParameterLists, TUK == TUK_Friend, isMemberSpecialization,
7489 if (TemplateParams && TemplateParams->
size() > 0) {
7490 isPartialSpecialization =
true;
7492 if (TUK == TUK_Friend) {
7493 Diag(KWLoc, diag::err_partial_specialization_friend)
7501 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
7504 if (TTP->hasDefaultArgument()) {
7505 Diag(TTP->getDefaultArgumentLoc(),
7506 diag::err_default_arg_in_partial_spec);
7507 TTP->removeDefaultArgument();
7510 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
7511 if (
Expr *DefArg = NTTP->getDefaultArgument()) {
7512 Diag(NTTP->getDefaultArgumentLoc(),
7513 diag::err_default_arg_in_partial_spec)
7514 << DefArg->getSourceRange();
7515 NTTP->removeDefaultArgument();
7521 diag::err_default_arg_in_partial_spec)
7527 }
else if (TemplateParams) {
7528 if (TUK == TUK_Friend)
7529 Diag(KWLoc, diag::err_template_spec_friend)
7535 assert(TUK == TUK_Friend &&
"should have a 'template<>' for this decl");
7541 assert(Kind !=
TTK_Enum &&
"Invalid enum tag in class template spec!");
7543 Kind, TUK == TUK_Definition, KWLoc,
7545 Diag(KWLoc, diag::err_use_with_wrong_tag)
7550 diag::note_previous_use);
7559 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
7560 if (DiagnoseUnexpandedParameterPack(TemplateArgs[I],
7561 UPPC_PartialSpecialization))
7567 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
7568 TemplateArgs,
false, Converted))
7573 if (isPartialSpecialization) {
7574 if (CheckTemplatePartialSpecializationArgs(TemplateNameLoc, ClassTemplate,
7575 TemplateArgs.
size(), Converted))
7580 bool InstantiationDependent;
7583 TemplateArgs.
arguments(), InstantiationDependent)) {
7584 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
7586 isPartialSpecialization =
false;
7590 void *InsertPos =
nullptr;
7593 if (isPartialSpecialization)
7603 if (TUK != TUK_Friend &&
7606 isPartialSpecialization))
7611 if (isPartialSpecialization) {
7627 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
7628 << 0 << (TUK == TUK_Definition)
7630 return CheckClassTemplate(S, TagSpec, TUK, KWLoc, SS,
7637 TemplateParameterLists.size() - 1,
7638 TemplateParameterLists.data());
7643 = cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl);
7647 KWLoc, TemplateNameLoc,
7655 if (TemplateParameterLists.size() > 1 && SS.
isSet()) {
7656 Partial->setTemplateParameterListsInfo(
7657 Context, TemplateParameterLists.drop_back(1));
7661 ClassTemplate->AddPartialSpecialization(Partial, InsertPos);
7662 Specialization = Partial;
7666 if (PrevPartial && PrevPartial->getInstantiatedFromMember())
7667 PrevPartial->setMemberSpecialization();
7669 CheckTemplatePartialSpecialization(Partial);
7676 KWLoc, TemplateNameLoc,
7681 if (TemplateParameterLists.size() > 0) {
7683 TemplateParameterLists);
7687 ClassTemplate->AddSpecialization(Specialization, InsertPos);
7689 if (CurContext->isDependentContext()) {
7692 CanonTemplate, Converted);
7716 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
7720 diag::note_instantiation_required_here)
7728 if (TUK != TUK_Friend)
7732 if (TUK == TUK_Definition) {
7735 if (Def && SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
7738 makeMergedDefinitionVisible(Hidden);
7741 Diag(TemplateNameLoc, diag::err_redefinition) << Specialization << Range;
7748 ProcessDeclAttributeList(S, Specialization, Attr);
7752 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip)) {
7753 AddAlignmentAttributesForRecord(Specialization);
7754 AddMsStructLayoutForRecord(Specialization);
7757 if (ModulePrivateLoc.
isValid())
7758 Diag(Specialization->
getLocation(), diag::err_module_private_specialization)
7759 << (isPartialSpecialization? 1 : 0)
7771 TemplateArgs, CanonType);
7772 if (TUK != TUK_Friend) {
7788 if (TUK == TUK_Definition && (!SkipBody || !SkipBody->
ShouldSkip))
7791 if (TUK == TUK_Friend) {
7797 CurContext->addDecl(Friend);
7802 CurContext->addDecl(Specialization);
7808 return Specialization;
7814 Decl *NewDecl = HandleDeclarator(S, D, TemplateParameterLists);
7815 ActOnDocumentableDecl(NewDecl);
7826 FD->setInlineSpecified(
false);
7837 for (
Decl *Prev = D; Prev && !PrevDiagLoc.
isValid();
7838 Prev = Prev->getPreviousDecl()) {
7839 PrevDiagLoc = Prev->getLocation();
7841 assert(PrevDiagLoc.
isValid() &&
7842 "Explicit instantiation without point of instantiation?");
7874 bool &HasNoEffect) {
7875 HasNoEffect =
false;
7882 "previous declaration must be implicit!");
7895 if (PrevPointOfInstantiation.
isInvalid()) {
7907 PrevPointOfInstantiation.
isValid()) &&
7908 "Explicit instantiation without point of instantiation?");
7922 Diag(NewLoc, diag::err_specialization_after_instantiation)
7924 Diag(PrevPointOfInstantiation, diag::note_instantiation_required_here)
7929 llvm_unreachable(
"The switch over PrevTSK must be exhaustive.");
7959 diag::err_explicit_instantiation_declaration_after_definition);
7965 diag::note_explicit_instantiation_definition_here);
7969 llvm_unreachable(
"Unexpected TemplateSpecializationKind!");
7985 Diag(NewLoc, diag::warn_explicit_instantiation_after_specialization)
7988 diag::note_previous_template_specialization);
8018 Diag(NewLoc, (getLangOpts().MSVCCompat)
8019 ? diag::ext_explicit_instantiation_duplicate
8020 : diag::err_explicit_instantiation_duplicate)
8023 diag::note_previous_explicit_instantiation);
8029 llvm_unreachable(
"Missing specialization/instantiation case?");
8055 enum DiscardReason { NotAFunctionTemplate, NotAMemberOfEnclosing };
8059 if (!isa<FunctionTemplateDecl>(D)) {
8061 DiscardedCandidates.push_back(std::make_pair(NotAFunctionTemplate, D));
8068 DiscardedCandidates.push_back(std::make_pair(NotAMemberOfEnclosing, D));
8074 if (Previous.
empty()) {
8076 diag::err_dependent_function_template_spec_no_match);
8077 for (
auto &
P : DiscardedCandidates)
8078 Diag(
P.second->getLocation(),
8079 diag::note_dependent_function_template_spec_discard_reason)
8085 ExplicitTemplateArgs);
8120 llvm::SmallDenseMap<FunctionDecl *, TemplateArgumentListInfo, 8>
8121 ConvertedTemplateArgs;
8143 if (OldMD && OldMD->
isConst()) {
8153 if (ExplicitTemplateArgs)
8154 Args = *ExplicitTemplateArgs;
8166 cast<FunctionTemplateDecl>(FunTmpl->getFirstDecl()),
8167 ExplicitTemplateArgs ? &Args :
nullptr, FT, Specialization,
8171 FailedCandidates.addCandidate().set(
8172 I.getPair(), FunTmpl->getTemplatedDecl(),
8183 if (LangOpts.CUDA &&
8184 IdentifyCUDATarget(Specialization,
8186 IdentifyCUDATarget(FD,
true)) {
8187 FailedCandidates.addCandidate().set(
8188 I.getPair(), FunTmpl->getTemplatedDecl(),
8194 if (ExplicitTemplateArgs)
8195 ConvertedTemplateArgs[Specialization] = std::move(Args);
8196 Candidates.
addDecl(Specialization, I.getAccess());
8203 if (QualifiedFriend && Candidates.
empty()) {
8208 for (
auto *OldND : Previous) {
8209 if (
auto *OldFD = dyn_cast<FunctionDecl>(OldND->getUnderlyingDecl()))
8210 NoteOverloadCandidate(OldND, OldFD, FD->
getType(),
false);
8212 FailedCandidates.NoteCandidates(*
this, FD->
getLocation());
8219 PDiag(diag::err_function_template_spec_no_match) << FD->
getDeclName(),
8220 PDiag(diag::err_function_template_spec_ambiguous)
8221 << FD->
getDeclName() << (ExplicitTemplateArgs !=
nullptr),
8222 PDiag(diag::note_function_template_spec_matched));
8224 if (Result == Candidates.
end())
8228 FunctionDecl *Specialization = cast<FunctionDecl>(*Result);
8232 assert(SpecInfo &&
"Function template specialization info missing?");
8270 bool HasNoEffect =
false;
8272 CheckSpecializationInstantiationRedecl(FD->
getLocation(),
8292 !Specialization->getCanonicalDecl()->isReferenced()) {
8295 Specialization->getCanonicalDecl() == Specialization &&
8296 "This must be the only existing declaration of this specialization");
8298 Specialization->setDeletedAsWritten(
false);
8302 MarkUnusedFileScopedDecl(Specialization);
8311 FD->setFunctionTemplateSpecialization(
8312 Specialization->getPrimaryTemplate(), TemplArgs,
nullptr,
8314 ExplicitTemplateArgs ? &ConvertedTemplateArgs[Specialization] :
nullptr);
8327 Previous.
addDecl(Specialization);
8347 assert(!isa<TemplateDecl>(Member) &&
"Only for non-template members");
8350 NamedDecl *FoundInstantiation =
nullptr;
8355 if (Previous.
empty()) {
8357 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(Member)) {
8360 NamedDecl *D = (*I)->getUnderlyingDecl();
8362 QualType Adjusted = Function->getType();
8363 if (!hasExplicitCallingConv(Adjusted))
8364 Adjusted = adjustCCAndNoReturn(Adjusted, Method->getType());
8367 if (Context.
hasSameType(Adjusted, Method->getType())) {
8368 FoundInstantiation = *I;
8369 Instantiation = Method;
8370 InstantiatedFrom = Method->getInstantiatedFromMemberFunction();
8371 MSInfo = Method->getMemberSpecializationInfo();
8376 }
else if (isa<VarDecl>(Member)) {
8382 Instantiation = PrevVar;
8386 }
else if (isa<RecordDecl>(Member)) {
8391 Instantiation = PrevRecord;
8395 }
else if (isa<EnumDecl>(Member)) {
8400 Instantiation = PrevEnum;
8406 if (!Instantiation) {
8420 if (InstantiatedFrom && isa<CXXMethodDecl>(Member)) {
8421 cast<CXXMethodDecl>(Member)->setInstantiationOfMemberFunction(
8422 cast<CXXMethodDecl>(InstantiatedFrom),
8424 }
else if (InstantiatedFrom && isa<CXXRecordDecl>(Member)) {
8425 cast<CXXRecordDecl>(Member)->setInstantiationOfMemberClass(
8426 cast<CXXRecordDecl>(InstantiatedFrom),
8431 Previous.
addDecl(FoundInstantiation);
8436 if (!InstantiatedFrom) {
8449 assert(MSInfo &&
"Member specialization info missing?");
8451 bool HasNoEffect =
false;
8452 if (CheckSpecializationInstantiationRedecl(Member->
getLocation(),
8469 if (
auto *MemberFunction = dyn_cast<FunctionDecl>(Member)) {
8470 FunctionDecl *InstantiationFunction = cast<FunctionDecl>(Instantiation);
8475 if (InstantiationFunction->
isDeleted()) {
8478 InstantiationFunction);
8484 MemberFunction->setInstantiationOfMemberFunction(
8486 }
else if (
auto *MemberVar = dyn_cast<VarDecl>(Member)) {
8487 MemberVar->setInstantiationOfStaticDataMember(
8489 }
else if (
auto *MemberClass = dyn_cast<CXXRecordDecl>(Member)) {
8490 MemberClass->setInstantiationOfMemberClass(
8492 }
else if (
auto *MemberEnum = dyn_cast<EnumDecl>(Member)) {
8493 MemberEnum->setInstantiationOfMemberEnum(
8496 llvm_unreachable(
"unknown member specialization kind");
8502 Previous.
addDecl(FoundInstantiation);
8511 template<
typename DeclT>
8522 OrigD->setLocation(Loc);
8528 if (Instantiation == Member)
8531 if (
auto *Function = dyn_cast<CXXMethodDecl>(Instantiation))
8533 else if (
auto *Var = dyn_cast<VarDecl>(Instantiation))
8535 else if (
auto *Record = dyn_cast<CXXRecordDecl>(Instantiation))
8537 else if (
auto *Enum = dyn_cast<EnumDecl>(Instantiation))
8540 llvm_unreachable(
"unknown member specialization kind");
8548 bool WasQualifiedName) {
8553 S.
Diag(InstLoc, diag::err_explicit_instantiation_in_class)
8566 if (WasQualifiedName) {
8567 if (CurContext->
Encloses(OrigContext))
8574 if (
NamespaceDecl *NS = dyn_cast<NamespaceDecl>(OrigContext)) {
8575 if (WasQualifiedName)
8578 diag::err_explicit_instantiation_out_of_scope :
8579 diag::warn_explicit_instantiation_out_of_scope_0x)
8584 diag::err_explicit_instantiation_unqualified_wrong_namespace :
8585 diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x)
8590 diag::err_explicit_instantiation_must_be_global :
8591 diag::warn_explicit_instantiation_must_be_global_0x)
8612 if (isa<TemplateSpecializationType>(T))
8622 auto *A = cast_or_null<InheritableAttr>(
getDLLAttr(Def));
8623 assert(A &&
"dllExportImportClassTemplateSpecialization called " 8624 "on Def without dllexport or dllimport");
8629 "delayed exports present at explicit instantiation");
8633 for (
auto &B : Def->
bases()) {
8634 if (
auto *BT = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
8635 B.getType()->getAsCXXRecordDecl()))
8656 "Invalid enum tag in class template explicit instantiation!");
8660 if (!ClassTemplate) {
8661 NonTagKind NTK = getNonTagTypeDeclKind(TD, Kind);
8662 Diag(TemplateNameLoc, diag::err_tag_reference_non_tag) << TD << NTK <<
Kind;
8670 Diag(KWLoc, diag::err_use_with_wrong_tag)
8675 diag::note_previous_use);
8690 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
8692 diag::warn_attribute_dllexport_explicit_instantiation_decl);
8693 Diag(AL.getLoc(), diag::note_attribute);
8700 diag::warn_attribute_dllexport_explicit_instantiation_decl);
8701 Diag(A->getLocation(), diag::note_attribute);
8707 bool DLLImportExplicitInstantiationDef =
false;
8714 if (AL.getKind() == ParsedAttr::AT_DLLImport)
8716 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
8724 DLLImportExplicitInstantiationDef =
true;
8730 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
8735 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
8736 TemplateArgs,
false, Converted))
8741 void *InsertPos =
nullptr;
8759 bool HasNoEffect =
false;
8761 if (CheckSpecializationInstantiationRedecl(TemplateNameLoc, TSK,
8762 PrevDecl, PrevDecl_TSK,
8777 Specialization = PrevDecl;
8783 DLLImportExplicitInstantiationDef) {
8785 HasNoEffect =
false;
8789 if (!Specialization) {
8795 KWLoc, TemplateNameLoc,
8801 if (!HasNoEffect && !PrevDecl) {
8803 ClassTemplate->AddSpecialization(Specialization, InsertPos);
8825 bool PreviouslyDLLExported = Specialization->
hasAttr<DLLExportAttr>();
8826 ProcessDeclAttributeList(S, Specialization, Attr);
8832 CurContext->addDecl(Specialization);
8838 return Specialization;
8849 = cast_or_null<ClassTemplateSpecializationDecl>(
8852 InstantiateClassTemplateSpecialization(TemplateNameLoc, Specialization, TSK);
8854 MarkVTableUsed(TemplateNameLoc, Specialization,
true);
8859 Def = cast_or_null<ClassTemplateSpecializationDecl>(
8867 DLLImportExplicitInstantiationDef)) {
8877 auto *A = cast<InheritableAttr>(
8879 A->setInherited(
true);
8887 bool NewlyDLLExported =
8888 !PreviouslyDLLExported && Specialization->
hasAttr<DLLExportAttr>();
8904 assert(Def == Specialization &&
8905 "Def and Specialization should match for implicit instantiation");
8912 InstantiateClassTemplateSpecializationMembers(TemplateNameLoc, Def, TSK);
8919 return Specialization;
8931 bool IsDependent =
false;
8933 KWLoc, SS, Name, NameLoc, Attr,
AS_none,
8939 assert(!IsDependent &&
"explicit instantiation of dependent name not yet handled");
8944 TagDecl *Tag = cast<TagDecl>(TagD);
8945 assert(!Tag->
isEnum() &&
"shouldn't see enumerations here");
8953 Diag(TemplateLoc, diag::err_explicit_instantiation_nontemplate_type)
8966 Diag(TemplateLoc, diag::ext_explicit_instantiation_without_qualified_id)
8991 bool HasNoEffect =
false;
8992 assert(MSInfo &&
"No member specialization information?");
8993 if (CheckSpecializationInstantiationRedecl(TemplateLoc, TSK,
9010 = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
9012 Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member)
9014 Diag(Pattern->getLocation(), diag::note_forward_declaration)
9018 if (InstantiateClass(NameLoc, Record, Def,
9019 getTemplateInstantiationArgs(Record),
9023 RecordDef = cast_or_null<CXXRecordDecl>(Record->
getDefinition());
9030 InstantiateClassMembers(NameLoc, RecordDef,
9031 getTemplateInstantiationArgs(Record), TSK);
9034 MarkVTableUsed(NameLoc, RecordDef,
true);
9054 diag::err_explicit_instantiation_requires_name)
9095 getLangOpts().CPlusPlus11 ?
9096 diag::err_explicit_instantiation_inline :
9097 diag::warn_explicit_instantiation_inline_0x)
9103 diag::err_explicit_instantiation_constexpr);
9138 if (!PrevTemplate) {
9145 Diag((*P)->getLocation(), diag::note_explicit_instantiation_here);
9152 diag::err_explicit_instantiation_data_member_not_instantiated)
9168 diag::err_auto_not_allowed_var_inst);
9177 diag::err_explicit_instantiation_without_template_id)
9179 Diag(PrevTemplate->getLocation(),
9180 diag::note_explicit_instantiation_here);
9188 DeclResult Res = CheckVarTemplateId(PrevTemplate, TemplateLoc,
9190 if (Res.isInvalid())
9195 Prev = cast<VarDecl>(Res.get());
9210 diag::ext_explicit_instantiation_without_qualified_id)
9219 bool HasNoEffect =
false;
9220 if (CheckSpecializationInstantiationRedecl(D.
getIdentifierLoc(), TSK, Prev,
9221 PrevTSK, POI, HasNoEffect))
9234 if (PrevTemplate && Prev && !Context.
hasSameType(Prev->getType(), R)) {
9236 diag::err_invalid_var_template_spec_type)
9237 << 0 << PrevTemplate << R << Prev->getType();
9238 Diag(PrevTemplate->getLocation(), diag::note_template_declared_here)
9239 << 2 << PrevTemplate->getDeclName();
9244 return (
Decl*)
nullptr;
9249 bool HasExplicitTemplateArgs =
false;
9253 HasExplicitTemplateArgs =
true;
9267 if (!HasExplicitTemplateArgs) {
9268 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Prev)) {
9269 QualType Adjusted = adjustCCAndNoReturn(R, Method->getType(),
9272 if (Method->getPrimaryTemplate()) {
9273 TemplateMatches.
addDecl(Method,
P.getAccess());
9276 assert(!NonTemplateMatch &&
"Multiple NonTemplateMatches");
9277 NonTemplateMatch = Method;
9291 (HasExplicitTemplateArgs ? &TemplateArgs
9293 R, Specialization, Info)) {
9295 FailedCandidates.addCandidate()
9307 if (LangOpts.CUDA &&
9308 IdentifyCUDATarget(Specialization,
9311 FailedCandidates.addCandidate().set(
9317 TemplateMatches.
addDecl(Specialization,
P.getAccess());
9321 if (!Specialization) {
9324 TemplateMatches.
begin(), TemplateMatches.
end(), FailedCandidates,
9326 PDiag(diag::err_explicit_instantiation_not_known) << Name,
9327 PDiag(diag::err_explicit_instantiation_ambiguous) << Name,
9328 PDiag(diag::note_explicit_instantiation_candidate));
9330 if (Result == TemplateMatches.
end())
9334 Specialization = cast<FunctionDecl>(*Result);
9344 if (FPT->hasExceptionSpec()) {
9346 diag::err_mismatched_exception_spec_explicit_instantiation;
9347 if (getLangOpts().MicrosoftExt)
9348 DiagID = diag::ext_mismatched_exception_spec_explicit_instantiation;
9349 bool Result = CheckEquivalentExceptionSpec(
9350 PDiag(DiagID) << Specialization->
getType(),
9351 PDiag(diag::note_explicit_instantiation_here),
9356 if (!getLangOpts().MicrosoftExt && Result)
9362 diag::err_explicit_instantiation_member_function_not_instantiated)
9366 Diag(Specialization->
getLocation(), diag::note_explicit_instantiation_here);
9372 PrevDecl = Specialization;
9375 bool HasNoEffect =
false;
9379 PrevDecl->getPointOfInstantiation(),
9386 return (
Decl*)
nullptr;
9394 Specialization->
hasAttr<DLLImportAttr>() &&
9403 Consumer.HandleTopLevelDecl(
DeclGroupRef(Specialization));
9419 diag::ext_explicit_instantiation_without_qualified_id)
9429 return (
Decl*)
nullptr;
9437 assert(Name &&
"Expected a name in a dependent tag");
9445 if (TUK == TUK_Declaration || TUK == TUK_Definition) {
9446 Diag(NameLoc, diag::err_dependent_tag_decl)
9447 << (TUK == TUK_Definition) << Kind << SS.
getRange();
9473 getLangOpts().CPlusPlus11 ?
9474 diag::warn_cxx98_compat_typename_outside_of_template :
9475 diag::ext_typename_outside_of_template)
9480 TypenameLoc, QualifierLoc, II, IdLoc);
9485 if (isa<DependentNameType>(T)) {
9497 return CreateParsedType(T, TSI);
9513 getLangOpts().CPlusPlus11 ?
9514 diag::warn_cxx98_compat_typename_outside_of_template :
9515 diag::ext_typename_outside_of_template)
9522 dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS,
false));
9523 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
9525 diag::ext_out_of_line_qualified_id_type_names_constructor)
9527 << (TemplateKWLoc.
isValid() ? 1 : 0 );
9533 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
9538 assert(DTN &&
"dependent template has non-dependent name?");
9541 DTN->getQualifier(),
9542 DTN->getIdentifier(),
9555 for (
unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
9560 QualType T = CheckTemplateIdType(Template, TemplateIILoc, TemplateArgs);
9572 for (
unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
9581 return CreateParsedType(T, TSI);
9590 if (!II.
isStr(
"type"))
9599 if (!EnableIfTSTLoc || EnableIfTSTLoc.
getNumArgs() == 0)
9612 if (!EnableIfII || !EnableIfII->
isStr(
"enable_if"))
9642 SS.
Adopt(QualifierLoc);
9660 if (RequireCompleteDeclContext(SS, Ctx))
9664 LookupResult Result(*
this, Name, IILoc, LookupOrdinaryName);
9665 LookupQualifiedName(Result, Ctx, SS);
9666 unsigned DiagID = 0;
9667 Decl *Referenced =
nullptr;
9673 Expr *Cond =
nullptr;
9674 if (
isEnableIf(QualifierLoc, II, CondRange, Cond)) {
9679 std::string FailedDescription;
9680 std::tie(FailedCond, FailedDescription) =
9681 findFailedBooleanCondition(Cond);
9684 diag::err_typename_nested_not_found_requirement)
9685 << FailedDescription
9690 Diag(CondRange.
getBegin(), diag::err_typename_nested_not_found_enable_if)
9691 << Ctx << CondRange;
9695 DiagID = diag::err_typename_nested_not_found;
9704 Diag(IILoc, diag::err_typename_refers_to_using_value_decl)
9705 << Name << Ctx << FullRange;
9709 Diag(Loc, diag::note_using_value_decl_missing_typename)
9739 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(Ctx);
9742 FoundRD->isInjectedClassName() &&
9744 Diag(IILoc, diag::ext_out_of_line_qualified_id_type_names_constructor)
9749 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
9759 if (getLangOpts().CPlusPlus17) {
9768 DiagID = diag::err_typename_nested_not_type;
9773 DiagID = diag::err_typename_nested_not_type;
9774 Referenced = *Result.
begin();
9785 Diag(IILoc, DiagID) << FullRange << Name << Ctx;
9794 class CurrentInstantiationRebuilder
9802 CurrentInstantiationRebuilder(
Sema &SemaRef,
9806 Loc(Loc), Entity(Entity) { }
9813 bool AlreadyTransformed(
QualType T) {
9828 this->Entity = Entity;
9870 CurrentInstantiationRebuilder Rebuilder(*
this, Loc, Name);
9871 return Rebuilder.TransformType(T);
9875 CurrentInstantiationRebuilder Rebuilder(*
this, E->
getExprLoc(),
9877 return Rebuilder.TransformExpr(E);
9888 = Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
9900 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
9904 if (isa<TemplateTypeParmDecl>(Param))
9909 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
9910 if (RebuildTemplateParamsInCurrentInstantiation(
9911 TTP->getTemplateParameters()))
9926 if (NewTSI->getType()->isUndeducedType()) {
9932 NewTSI = SubstAutoTypeSourceInfo(NewTSI, Context.
DependentTy);
9937 NTTP->
setType(NewTSI->getType());
9949 return getTemplateArgumentBindingsText(Params, Args.
data(), Args.
size());
9957 llvm::raw_svector_ostream Out(Str);
9959 if (!Params || Params->
size() == 0 || NumArgs == 0)
9960 return std::string();
9962 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
9972 Out <<
Id->getName();
9978 Args[I].
print(getPrintingPolicy(), Out);
9990 auto LPT = llvm::make_unique<LateParsedTemplate>();
9993 LPT->Toks.swap(Toks);
9995 LateParsedTemplateMap.insert(std::make_pair(FD, std::move(LPT)));
10010 if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(CurContext)) {
10039 class ExplicitSpecializationVisibilityChecker {
10046 : S(S), Loc(Loc) {}
10049 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
10050 return checkImpl(FD);
10051 if (
auto *RD = dyn_cast<CXXRecordDecl>(ND))
10052 return checkImpl(RD);
10053 if (
auto *VD = dyn_cast<VarDecl>(ND))
10054 return checkImpl(VD);
10055 if (
auto *ED = dyn_cast<EnumDecl>(ND))
10056 return checkImpl(ED);
10060 void diagnose(
NamedDecl *D,
bool IsPartialSpec) {
10063 const bool Recover =
true;
10068 if (Modules.empty())
10086 template<
typename SpecDecl>
10087 void checkImpl(SpecDecl *Spec) {
10088 bool IsHiddenExplicitSpecialization =
false;
10090 IsHiddenExplicitSpecialization =
10091 Spec->getMemberSpecializationInfo()
10095 checkInstantiated(Spec);
10098 if (IsHiddenExplicitSpecialization)
10099 diagnose(Spec->getMostRecentDecl(),
false);
10115 else if (
auto *TD =
10118 diagnose(TD,
true);
10123 void checkInstantiated(
VarDecl *RD) {
10131 else if (
auto *TD =
10134 diagnose(TD,
true);
10139 void checkInstantiated(
EnumDecl *FD) {}
10141 template<
typename TemplDecl>
10142 void checkTemplate(TemplDecl *TD) {
10143 if (TD->isMemberSpecialization()) {
10145 diagnose(TD->getMostRecentDecl(),
false);
10152 if (!getLangOpts().Modules)
10155 ExplicitSpecializationVisibilityChecker(*
this, Loc).check(Spec);
10163 if (!hasVisibleDeclaration(Spec, &Modules))
10164 diagnoseMissingImport(Loc, Spec, Spec->
getLocation(), Modules,
10165 MissingImportKind::PartialSpecialization,
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
ExprResult BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
Construct a new expression that refers to the given integral template argument with the given source-...
Defines the clang::ASTContext interface.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
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)
Represents a function declaration or definition.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
Name lookup found a set of overloaded functions that met the criteria.
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
static bool CheckTemplateArgumentIsCompatibleWithParameter(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *ArgIn, Expr *Arg, QualType ArgType)
Checks whether the given template argument is compatible with its template parameter.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
const TypeClass * getTypePtr() const
bool TemplateParameterListsAreEqual(TemplateParameterList *New, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
TemplateDeductionResult
Describes the result of template argument deduction.
void InstantiatedLocal(const Decl *D, Decl *Inst)
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that makes a template template argument into a pack expansion...
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
bool isMemberPointerType() const
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
static const TemplateArgument & getArgument(const TemplateArgument &A)
QualType getInjectedSpecializationType() const
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
llvm::PointerUnion3< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
void diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName, SourceLocation Less, SourceLocation Greater)
const TypeClass * getTypePtr() const
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
NestedNameSpecifierLoc getTemplateQualifierLoc() const
void addOuterTemplateArguments(const TemplateArgumentList *TemplateArgs)
Add a new outermost level to the multi-level template argument list.
void setLookupName(DeclarationName Name)
Sets the name to look up.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
void setRParenLoc(SourceLocation Loc)
Stmt - This represents one statement.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
Filter makeFilter()
Create a filter for this result set.
void setLAngleLoc(SourceLocation Loc)
void setExceptionSpecRange(SourceRange R)
We are matching the template parameter lists of two templates that might be redeclarations.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
Provides information about an attempted template argument deduction, whose success or failure was des...
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization)
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
static bool DiagnoseDefaultTemplateArgument(Sema &S, Sema::TemplateParamListContext TPC, SourceLocation ParamLoc, SourceRange DefArgRange)
Diagnose the presence of a default template argument on a template parameter, which is ill-formed in ...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
The name refers to a function template or a set of overloaded functions that includes at least one fu...
bool CheckTemplatePartialSpecializationArgs(SourceLocation Loc, TemplateDecl *PrimaryTemplate, unsigned NumExplicitArgs, ArrayRef< TemplateArgument > Args)
Check the non-type template arguments of a class template partial specialization according to C++ [te...
The name refers to a dependent template name:
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
Represents a qualified type name for which the type name is dependent.
void setObjCLifetime(ObjCLifetime type)
The template argument is an expression, and we've not resolved it to one of the other forms yet...
unsigned size() const
Retrieve the number of template arguments in this template argument list.
bool isEmpty() const
No scope specifier.
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params)
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments...
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
void erase()
Erase the last element returned from this iterator.
static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D)
Determine what kind of template specialization the given declaration is.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
bool isVariadic() const
Whether this function prototype is variadic.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
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.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
SourceLocation getBeginLoc() const LLVM_READONLY
void setTemplateKeywordLoc(SourceLocation Loc)
Declaration of a variable template.
TemplateParamListContext
The context in which we are checking a template parameter list.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Represent a C++ namespace.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Wrapper for source info for typedefs.
void setSpecializationKind(TemplateSpecializationKind TSK)
NamedDecl * getParam(unsigned Idx)
SourceLocation getEndLoc() const LLVM_READONLY
const TargetInfo & getTargetInfo() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
A container of type source information.
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 has a definition that does not need to be instantiated.
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation, NamedDecl *Instantiation, bool InstantiatedFromMember, const NamedDecl *Pattern, const NamedDecl *PatternDef, TemplateSpecializationKind TSK, bool Complain=true)
Determine whether we would be unable to instantiate this template (because it either has no definitio...
TSCS getThreadStorageClassSpec() const
static void StripImplicitInstantiation(NamedDecl *D)
Strips various properties off an implicit instantiation that has just been explicitly specialized...
Abstract base class used for diagnosing integer constant expression violations.
static NullPointerValueKind isNullPointerValueTemplateArgument(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *Arg, Decl *Entity=nullptr)
Determine whether the given template argument is a null pointer value of the appropriate type...
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs, SmallVectorImpl< TemplateArgument > &Converted, bool UpdateArgsWithConversions=true)
Check that the given template arguments can be be provided to the given template, converting the argu...
Represents a C++ constructor within a class.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
TemplateName SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs)
QualType getElementType() const
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
An identifier, stored as an IdentifierInfo*.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
bool CheckTemplateTemplateArgument(TemplateParameterList *Params, TemplateArgumentLoc &Arg)
Check a template argument against its corresponding template template parameter.
unsigned getDepth() const
Get the nesting depth of the template parameter.
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
RAII object that enters a new expression evaluation context.
Represents a variable declaration or definition.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
DeclarationName getLookupName() const
Gets the name to look up.
Information about one declarator, including the parsed type information and the identifier.
bool isEnumeralType() const
static SourceLocation DiagLocForExplicitInstantiation(NamedDecl *D, SourceLocation PointOfInstantiation)
Compute the diagnostic location for an explicit instantiation.
const T * getAs() const
Member-template getAs<specific type>'.
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Represents an empty template argument, e.g., one that has not been deduced.
Extra information about a function prototype.
TypeSpecifierType
Specifies the kind of type.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
Represents a C++17 deduced template specialization type.
Represents a variable template specialization, which refers to a variable template with a given set o...
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
ArrayRef< LValuePathEntry > getLValuePath() const
SourceLocation getLAngleLoc() const
static bool isTemplateArgumentTemplateParameter(const TemplateArgument &Arg, unsigned Depth, unsigned Index)
A namespace, stored as a NamespaceDecl*.
TypeLoc getNamedTypeLoc() const
bool isInvalidDecl() const
bool isChar32Type() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
TemplateArgumentLoc SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, Decl *Param, SmallVectorImpl< TemplateArgument > &Converted, bool &HasDefaultArg)
If the given template parameter has a default template argument, substitute into that default templat...
Describes how types, statements, expressions, and declarations should be printed. ...
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
bool isParameterPack() const
Whether this declaration is a parameter pack.
static Optional< unsigned > getExpandedPackSize(NamedDecl *Param)
Check whether the template parameter is a pack expansion, and if so, determine the number of paramete...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Represents a parameter to a function.
Represents the result of substituting a type for a template type parameter.
Defines the clang::Expr interface and subclasses for C++ expressions.
QualType getIntegralType() const
Retrieve the type of the integral value.
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier...
The collection of all-type qualifiers we support.
bool isLValueOnePastTheEnd() const
Information about a template-id annotation token.
bool isObjCObjectOrInterfaceType() const
const ValueDecl * getMemberPointerDecl() const
static void DiagnoseTemplateParameterListArityMismatch(Sema &S, TemplateParameterList *New, TemplateParameterList *Old, Sema::TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc)
Diagnose a known arity mismatch when comparing template argument lists.
static SourceRange findTemplateParameter(unsigned Depth, TypeLoc TL)
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
Represents a struct/union/class.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
Scope * getTemplateParamParent()
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
bool isWideCharType() const
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.
bool LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType, bool EnteringContext, bool &MemberOfUnknownSpecialization, SourceLocation TemplateKWLoc=SourceLocation())
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.
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
Returns the RecordDecl that actually defines this struct/union/class.
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
SourceLocation getBeginLoc() const LLVM_READONLY
NameKind getNameKind() const
Determine what kind of name this is.
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a templated declaration that would trigger an implicit instantiation.
static SourceRange findTemplateParameterInType(unsigned Depth, Expr *E)
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
SourceLocation getLocation() const
Retrieve the location of the template argument.
SourceLocation getLocation() const
OverloadedOperatorKind Operator
The kind of overloaded operator.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
void startDefinition()
Starts the definition of this tag declaration.
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
bool isReferenceType() const
void setElaboratedKeywordLoc(SourceLocation Loc)
The iterator over UnresolvedSets.
Represents the result of substituting a set of types for a template type parameter pack...
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
A non-type template parameter, stored as an expression.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
SourceLocation getRParenLoc() const
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)
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
LookupResultKind getResultKind() const
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
Perform semantic analysis for the given non-template member specialization.
static QualType checkBuiltinTemplateIdType(Sema &SemaRef, BuiltinTemplateDecl *BTD, const SmallVectorImpl< TemplateArgument > &Converted, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
void ClearStorageClassSpecs()
SourceLocation getBeginLoc() const LLVM_READONLY
The type of a non-type template parameter.
ParsedType getAsType() const
Retrieve the template type argument's type.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getTemplateLoc() const
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
A user-defined literal name, e.g., operator "" _i.
void setDefaultArgument(Expr *DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
bool isInvalidType() const
TypeSourceInfo * getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &Args, QualType Canon=QualType()) const
Provides information about a function template specialization, which is a FunctionDecl that has been ...
DeclClass * getAsSingle() const
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
NamedDecl * ActOnTemplateTemplateParameter(Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params, SourceLocation EllipsisLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg)
ActOnTemplateTemplateParameter - Called when a C++ template template parameter (e.g.
DeclResult ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS, TemplateTy Template, SourceLocation TemplateNameLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, const ParsedAttributesView &Attr)
ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, bool isAddressOfOperand, const TemplateArgumentListInfo *TemplateArgs)
ActOnDependentIdExpression - Handle a dependent id-expression that was just parsed.
static void maybeDiagnoseTemplateParameterShadow(Sema &SemaRef, Scope *S, SourceLocation Loc, IdentifierInfo *Name)
Represents a C++ unqualified-id that has been parsed.
bool isCompleteType(SourceLocation Loc, QualType T)
An rvalue reference type, per C++11 [dcl.ref].
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
void setNameLoc(SourceLocation Loc)
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.
SourceLocation getBeginLoc() const LLVM_READONLY
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
Represents a typeof (or typeof) expression (a GCC extension).
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack)
Represents a declaration of a type.
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.
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
const Type * getClass() const
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
CXXRecordDecl * getDecl() const
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
ActionResult< ParsedType > TypeResult
SourceLocation getTemplateEllipsisLoc() const
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
void setSpecializationKind(TemplateSpecializationKind TSK)
Scope - A scope is a transient data structure that is used while parsing the program.
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type...
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNoreturnSpecified() const
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
const LangOptions & getLangOpts() const
TemplateArgumentLoc getArgLoc(unsigned i) const
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Decl * ActOnTemplateDeclarator(Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization, retrieves the function from which it was instantiated.
Represents a C++ member access expression where the actual member referenced could not be resolved be...
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
void setLocalRangeBegin(SourceLocation L)
static bool CheckTemplateArgumentPointerToMember(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *&ResultArg, TemplateArgument &Converted)
Checks whether the given template argument is a pointer to member constant according to C++ [temp...
Represents a linkage specification.
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
NamedDecl *const * iterator
We are matching the template parameter lists of a template template argument against the template par...
static void SetNestedNameSpecifier(Sema &S, TagDecl *T, const CXXScopeSpec &SS)
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
SourceRange getSourceRange() const LLVM_READONLY
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
bool isExplicitSpecialization() const
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
unsigned getNumArgs() const
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
IdentifierInfo * getIdentifier() const
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location...
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
QualType getElementType() const
RAII object used to change the argument pack substitution index within a Sema object.
unsigned PrintCanonicalTypes
Whether to print types as written or canonically.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
Represents an extended vector type where either the type or size is dependent.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
We are matching the template parameter lists of two template template parameters as part of matching ...
DiagnosticsEngine & getDiagnostics() const
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
unsigned getFlags() const
getFlags - Return the flags for this scope.
void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD)
static Sema::TemplateDeductionResult DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, const TemplateArgument &Param, TemplateArgument Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
void print(const PrintingPolicy &Policy, raw_ostream &Out) const
Print this template argument to the given output stream.
bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg, SmallVectorImpl< TemplateArgument > &Converted)
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
Sema - This implements semantic analysis and AST building for C.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, SmallVectorImpl< TemplateArgument > &Converted, CheckTemplateArgumentKind CTAK=CTAK_Specified)
Check that the given template argument corresponds to the given template parameter.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
SourceLocation getBeginLoc() const LLVM_READONLY
bool hasLValuePath() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
static TypeSourceInfo * SubstDefaultTemplateArgument(Sema &SemaRef, TemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, TemplateTypeParmDecl *Param, SmallVectorImpl< TemplateArgument > &Converted)
Substitute template arguments into the default template argument for the given template type paramete...
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
static bool CheckNonTypeTemplatePartialSpecializationArgs(Sema &S, SourceLocation TemplateNameLoc, NonTypeTemplateParmDecl *Param, const TemplateArgument *Args, unsigned NumArgs, bool IsDefaultArgument)
Subroutine of Sema::CheckTemplatePartialSpecializationArgs that checks non-type template partial spec...
DeclarationNameTable DeclarationNames
Specifies that the expression should never be value-dependent.
bool CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, TemplateSpecializationKind NewTSK, NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK, SourceLocation PrevPtOfInstantiation, bool &SuppressNew)
Diagnose cases where we have an explicit template specialization before/after an explicit template in...
void addOuterRetainedLevel()
Add an outermost level that we are not substituting.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
SourceRange getRange() const
TemplateParameterListEqualKind
Enumeration describing how template parameter lists are compared for equality.
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams)
Check whether a template can be declared within this scope.
TypeSourceInfo * getTypeSourceInfo() const
void setTemplateNameLoc(SourceLocation Loc)
Represents an array type in C++ whose size is a value-dependent expression.
SourceLocation getBeginLoc() const
Get the begin source location.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, Optional< unsigned > NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
QualType getElementType() const
unsigned getFunctionScopeDepth() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
Defines the clang::LangOptions interface.
StringRef getKindName() const
DeclResult CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation TemplateNameLoc, const TemplateArgumentListInfo &TemplateArgs)
SourceLocation getLocalRangeEnd() const
LookupNameKind
Describes the kind of name lookup to perform.
QualType getPointeeType() const
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
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
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 CXXDependentScopeMemberExpr * Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
void setMemberSpecialization()
Note that this member template is a specialization.
bool wasNotFoundInCurrentInstantiation() const
Determine whether no result was found because we could not search into dependent base classes of the ...
void NoteAllFoundTemplates(TemplateName Name)
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack...
Represents a C++ template name within the type system.
Represents the type decltype(expr) (C++11).
SourceLocation getStorageClassSpecLoc() const
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this...
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
A namespace alias, stored as a NamespaceAliasDecl*.
bool isIdentifier() const
Determine whether this template name refers to an identifier.
void setLateTemplateParsed(bool ILT=true)
State that this templated function will be late parsed.
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined...
void propagateDLLAttrToBaseClassTemplate(CXXRecordDecl *Class, Attr *ClassAttr, ClassTemplateSpecializationDecl *BaseTemplateSpec, SourceLocation BaseLoc)
Perform propagation of DLL attributes from a derived class to a templated base class for MS compatibi...
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
bool isFunctionOrMethod() const
StorageClass
Storage classes.
SourceLocation getLocalRangeBegin() const
static bool isEnableIf(NestedNameSpecifierLoc NNS, const IdentifierInfo &II, SourceRange &CondRange, Expr *&Cond)
Determine whether this failed name lookup should be treated as being disabled by a usage of std::enab...
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
Declaration of an alias template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Data structure that captures multiple levels of template argument lists for use in template instantia...
void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
Represents a GCC generic vector type.
void setLocation(SourceLocation L)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization, retrieves the member specialization information.
An lvalue reference type, per C++11 [dcl.ref].
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
BuiltinTemplateKind getBuiltinTemplateKind() const
void setDescribedClassTemplate(ClassTemplateDecl *Template)
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
This template specialization was implicitly instantiated from a template.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A type, stored as a Type*.
static TemplateArgumentLoc translateTemplateArgument(Sema &SemaRef, const ParsedTemplateArgument &Arg)
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList *> TPLists)
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
SourceLocation getEndLoc() const LLVM_READONLY
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
bool hasVisibleMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine if there is a visible declaration of D that is a member specialization declaration (as oppo...
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
RecordDecl * getDecl() const
SourceLocation getNoreturnSpecLoc() const
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
const CXXScopeSpec & getScopeSpec() const
Retrieve the nested-name-specifier that precedes the template name in a template template argument...
DeclResult ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, TemplateIdAnnotation &TemplateId, const ParsedAttributesView &Attr, MultiTemplateParamsArg TemplateParameterLists, SkipBodyInfo *SkipBody=nullptr)
char * location_data() const
Retrieve the data associated with the source-location information.
static bool DiagnoseUnexpandedParameterPacks(Sema &S, TemplateTemplateParmDecl *TTP)
Check for unexpanded parameter packs within the template parameters of a template template parameter...
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template.
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...
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC, SkipBodyInfo *SkipBody=nullptr)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
const LValueBase getLValueBase() const
param_type_range param_types() const
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
void setLAngleLoc(SourceLocation Loc)
Represents the parsed form of a C++ template argument.
A stack object to be created when performing template instantiation.
ExtProtoInfo getExtProtoInfo() const
SCS getStorageClassSpec() const
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
ASTContext & getASTContext() const
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList *> FriendTypeTPLists=None)
static bool isSameAsPrimaryTemplate(TemplateParameterList *Params, ArrayRef< TemplateArgument > Args)
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
QualType getReturnType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
void setBraceRange(SourceRange R)
Attr * clone(ASTContext &C) const
static bool CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *ArgIn, TemplateArgument &Converted)
Checks whether the given template argument is the address of an object or function according to C++ [...
This names the __make_integer_seq BuiltinTemplateDecl.
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
DeclarationName getName() const
getName - Returns the embedded declaration name.
Represents the declaration of a struct/union/class/enum.
TemplateArgument getArgumentPack() const
void referenceDLLExportedClassMethods()
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc)
Build the type that describes a C++ typename specifier, e.g., "typename T::type". ...
bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name, SourceLocation NameLoc, ParsedTemplateTy *Template=nullptr)
Determine whether a particular identifier might be the name in a C++1z deduction-guide declaration...
QualType getElementType() const
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
ParsedAttr - Represents a syntactic attribute.
Represents a vector type where either the type or size is dependent.
Represents a dependent using declaration which was not marked with typename.
NamedDecl * ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, unsigned Depth, unsigned Position, SourceLocation EqualLoc, Expr *DefaultArg)
KindType getKind() const
Determine what kind of template argument we have.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
Represents a static or instance method of a struct/union/class.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isMemberPointer() const
Name lookup found an unresolvable value declaration and cannot yet complete.
static bool CheckTemplateSpecializationScope(Sema &S, NamedDecl *Specialized, NamedDecl *PrevDecl, SourceLocation Loc, bool IsPartialSpecialization)
Check whether a specialization is well-formed in the current context.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template...
TemplateNameKind ActOnDependentTemplateName(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool AllowInjectedClassName=false)
Form a dependent template name.
static bool hasVisibleDefaultArgument(Sema &S, const ParmDecl *D, llvm::SmallVectorImpl< Module *> *Modules)
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
void addDecl(NamedDecl *D)
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
void setPointOfInstantiation(SourceLocation Loc)
A class for iterating through a result set and possibly filtering out results.
ClassTemplateDecl * getMostRecentDecl()
void setElaboratedKeywordLoc(SourceLocation Loc)
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
No entity found met the criteria.
This template specialization was instantiated from a template due to an explicit instantiation defini...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
SourceLocation getRAngleLoc() const
EnumDecl * getDecl() const
A template type parameter, stored as a type.
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, Sema::TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
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.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
The injected class name of a C++ class template or class template partial specialization.
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.
The template argument is a pack expansion of a template name that was provided for a template templat...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
CXXScopeSpec SS
The nested-name-specifier that precedes the template name.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
Expr * getSourceExpression() const
QualType getUnderlyingType() const
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
AccessSpecifier getAccess() const
This is a scope that corresponds to the template parameters of a C++ template.
This template specialization was instantiated from a template due to an explicit instantiation declar...
bool isInvalid() const
Determine whether the given template argument is invalid.
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
The name of a declaration.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isBooleanType() const
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo &TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization...
Represents a C++11 pack expansion that produces a sequence of expressions.
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
static Expr * lookThroughRangesV3Condition(Preprocessor &PP, Expr *Cond)
A pointer to member type per C++ 8.3.3 - Pointers to members.
This names the __type_pack_element BuiltinTemplateDecl.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set...
TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS, const IdentifierInfo &II, SourceLocation IdLoc)
Called when the parser has parsed a C++ typename specifier, e.g., "typename T::type".
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
A type that was preceded by the 'template' keyword, stored as a Type*.
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
The name refers to a template whose specialization produces a type.
SourceLocation getBeginLoc() const LLVM_READONLY
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
bool isNull() const
Determine whether this template argument has no value.
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration...
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Expr * IgnoreParenImpCasts() LLVM_READONLY
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...
TypedefNameDecl * getTypedefNameDecl() const
static VarTemplatePartialSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos)
ParsedTemplateArgument ActOnTemplateTypeArgument(TypeResult ParsedType)
Convert a parsed type into a parsed template argument.
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
bool isFunctionType() const
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
ExtVectorType - Extended vector type.
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Wrapper for source info for record types.
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
SourceRange getTemplateParamsRange(TemplateParameterList const *const *Params, unsigned NumParams)
Retrieves the range of the given template parameter lists.
The template argument is a type.
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
QualType getUnderlyingType() const
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
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\, const ASTContext *Context=nullptr) 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
Get the name of identifier for this declaration as a StringRef.
Decl * SubstDecl(Decl *D, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs)
StringRef getImmediateMacroName(SourceLocation Loc)
Retrieve the name of the immediate macro expansion.
static Decl::Kind getKind(const Decl *D)
std::pair< Expr *, std::string > findFailedBooleanCondition(Expr *Cond)
Find the failed Boolean condition within a given Boolean constant expression, and describe it with a ...
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
SourceLocation getExplicitSpecLoc() const
static Expr * formAssociatedConstraints(TemplateParameterList *Params, FunctionDecl *FD)
[temp.constr.decl]p2: A template's associated constraints are defined as a single constraint-expressi...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
The name refers to a variable template whose specialization produces a variable.
SourceLocation getConstexprSpecLoc() const
QualType getAsType() const
Retrieve the type for a type template argument.
A reference to a declared variable, function, enum, etc.
Represents an extended address space qualifier where the input address space value is dependent...
Represents a type template specialization; the template must be a class template, a type alias templa...
NamedDecl * getMostRecentDecl()
bool isDeleted() const
Whether this function has been deleted.
bool isPointerType() const
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
SourceLocation getTemplateNameLoc() const
void setInheritedDefaultArgument(const ASTContext &C, TemplateTemplateParmDecl *Prev)
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, const TemplateArgumentListInfo &Args) const
TypeSourceInfo * SubstType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, bool AllowDeducedTST=false)
Perform substitution on the type T with a given set of template arguments.
bool isStaticDataMember() const
Determines whether this is a static data member.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc)
An l-value expression is a reference to an object with independent storage.
bool empty() const
Return true if no decls were found.
static bool DependsOnTemplateParameters(QualType T, TemplateParameterList *Params)
Determines whether a given type depends on the given parameter list.
Wrapper for template type parameters.
A trivial tuple used to represent a source range.
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
void setLexicalDeclContext(DeclContext *DC)
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
This represents a decl that may have a name.
A boolean literal, per ([C++ lex.bool] Boolean literals).
bool isTranslationUnit() const
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
void setAccess(AccessSpecifier AS)
A template template argument, stored as a template name.
Represents a C array with a specified size that is not an integer-constant-expression.
void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
Mark which template parameters can be deduced from a given template argument list.
void setTemplateNameLoc(SourceLocation Loc)
No keyword precedes the qualified type name.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
QualType getElementType() const
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
SourceLocation getNameLoc() const
Gets the location of the identifier.
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
SourceLocation getRAngleLoc() const
unsigned NumArgs
NumArgs - The number of template arguments.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
The global specifier '::'. There is no stored value.
static void noteNonDeducibleParameters(Sema &S, TemplateParameterList *TemplateParams, const llvm::SmallBitVector &DeducibleParams)
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
void setType(QualType newType)
SourceLocation getBegin() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
void setDeletedAsWritten(bool D=true)
bool isDependent() const
Determines whether this is a dependent template name.
Represents the canonical version of C arrays with a specified constant size.
Defines enum values for all the target-independent builtin functions.
Declaration of a template function.
bool IsInsideALocalClassWithinATemplateFunction()
void setElaboratedKeywordLoc(SourceLocation Loc)
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
SourceLocation getLocation() const
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type...
static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc, TemplateDecl *TD, const TemplateParmDecl *D, TemplateArgumentListInfo &Args)
Diagnose a missing template argument.
QualType getPointeeType() const
QualType getType() const
Return the type wrapped by this type source info.
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.