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) {
550 TemplateCandidateFilter() {
551 WantTypeSpecifiers =
false;
552 WantExpressionKeywords =
false;
553 WantRemainingKeywords =
false;
554 WantCXXNamedCasts =
true;
556 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
565 CorrectTypo(NameInfo, LookupKind, S, &SS,
566 llvm::make_unique<TemplateCandidateFilter>(),
567 CTK_ErrorRecovery, LookupCtx)) {
568 auto *ND = Corrected.getFoundDecl();
572 if (ND || Corrected.isKeyword()) {
574 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
575 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
577 diagnoseTypo(Corrected,
578 PDiag(diag::err_non_template_in_member_template_id_suggest)
579 << Name << LookupCtx << DroppedSpecifier
582 diagnoseTypo(Corrected,
583 PDiag(diag::err_non_template_in_template_id_suggest)
588 diag::note_non_template_in_template_id_found);
593 Diag(NameInfo.
getLoc(), diag::err_non_template_in_template_id)
596 Diag(Found->
getLocation(), diag::note_non_template_in_template_id_found);
606 bool isAddressOfOperand,
621 bool MightBeCxx11UnevalField =
622 getLangOpts().CPlusPlus11 && isUnevaluatedContext();
627 IsEnum = dyn_cast_or_null<EnumType>(NNS->getAsType());
629 if (!MightBeCxx11UnevalField && !isAddressOfOperand && !IsEnum &&
630 isa<CXXMethodDecl>(DC) && cast<CXXMethodDecl>(DC)->isInstance()) {
631 QualType ThisType = cast<CXXMethodDecl>(DC)->getThisType(Context);
635 NamedDecl *FirstQualifierInScope =
nullptr;
638 Context,
nullptr, ThisType,
true,
640 FirstQualifierInScope, NameInfo, TemplateArgs);
643 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
661 bool InstantiatedFromMember,
666 assert(isa<TagDecl>(Instantiation) || isa<FunctionDecl>(Instantiation) ||
667 isa<VarDecl>(Instantiation));
669 bool IsEntityBeingDefined =
false;
670 if (
const TagDecl *TD = dyn_cast_or_null<TagDecl>(PatternDef))
671 IsEntityBeingDefined = TD->isBeingDefined();
673 if (PatternDef && !IsEntityBeingDefined) {
675 if (!hasVisibleDefinition(const_cast<NamedDecl*>(PatternDef), &SuggestedDef,
678 bool Recover = Complain && !isSFINAEContext();
680 diagnoseMissingImport(PointOfInstantiation, SuggestedDef,
687 if (!Complain || (PatternDef && PatternDef->
isInvalidDecl()))
692 if (
TagDecl *TD = dyn_cast<TagDecl>(Instantiation))
695 Diag(PointOfInstantiation,
696 diag::err_template_instantiate_within_definition)
702 }
else if (InstantiatedFromMember) {
703 if (isa<FunctionDecl>(Instantiation)) {
704 Diag(PointOfInstantiation,
705 diag::err_explicit_instantiation_undefined_member)
708 Note = diag::note_explicit_instantiation_here;
710 assert(isa<TagDecl>(Instantiation) &&
"Must be a TagDecl!");
711 Diag(PointOfInstantiation,
712 diag::err_implicit_instantiate_member_undefined)
714 Note = diag::note_member_declared_at;
717 if (isa<FunctionDecl>(Instantiation)) {
718 Diag(PointOfInstantiation,
719 diag::err_explicit_instantiation_undefined_func_template)
721 Note = diag::note_explicit_instantiation_here;
722 }
else if (isa<TagDecl>(Instantiation)) {
723 Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
726 Note = diag::note_template_decl_here;
728 assert(isa<VarDecl>(Instantiation) &&
"Must be a VarDecl!");
729 if (isa<VarTemplateSpecializationDecl>(Instantiation)) {
730 Diag(PointOfInstantiation,
731 diag::err_explicit_instantiation_undefined_var_template)
735 Diag(PointOfInstantiation,
736 diag::err_explicit_instantiation_undefined_member)
739 Note = diag::note_explicit_instantiation_here;
762 if (getLangOpts().MicrosoftExt)
768 Diag(Loc, diag::err_template_param_shadow)
769 << cast<NamedDecl>(PrevDecl)->getDeclName();
777 if (
TemplateDecl *Temp = dyn_cast_or_null<TemplateDecl>(D)) {
778 D = Temp->getTemplatedDecl();
786 assert(
Kind == Template &&
787 "Only template template arguments can be pack expansions here");
788 assert(getAsTemplate().
get().containsUnexpandedParameterPack() &&
789 "Template template argument pack expansion without packs");
791 Result.EllipsisLoc = EllipsisLoc;
827 llvm_unreachable(
"Unhandled parsed template argument");
834 for (
unsigned I = 0,
Last = TemplateArgsIn.size(); I !=
Last; ++I)
854 QualType T = GetTypeFromParser(ParsedType.
get(), &TInfo);
857 assert(TInfo &&
"template argument with no location");
865 EllipsisLoc = PET.getEllipsisLoc();
866 TL = PET.getPatternLoc();
871 SS.
Adopt(ET.getQualifierLoc());
872 TL = ET.getNamedTypeLoc();
876 TemplateName Name = DTST.getTypePtr()->getTemplateName();
882 DTST.getTemplateNameLoc());
884 Result = Result.getTemplatePackExpansion(EllipsisLoc);
894 ParsedType.
get().getAsOpaquePtr(),
912 unsigned Depth,
unsigned Position,
916 "Template type parameter not in template parameter scope!");
922 bool IsParameterPack = EllipsisLoc.
isValid();
925 KeyLoc, Loc,
Depth, Position, ParamName,
926 Typename, IsParameterPack);
934 IdResolver.AddDecl(Param);
940 if (DefaultArg && IsParameterPack) {
941 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
942 DefaultArg =
nullptr;
948 GetTypeFromParser(DefaultArg, &DefaultTInfo);
950 assert(DefaultTInfo &&
"expected source information for type");
953 if (DiagnoseUnexpandedParameterPack(Loc, DefaultTInfo,
954 UPPC_DefaultArgument))
958 if (CheckTemplateArgument(Param, DefaultTInfo)) {
982 TSI = SubstAutoTypeSourceInfo(TSI, Context.
DependentTy);
985 return CheckNonTypeTemplateParameterType(TSI->
getType(), Loc);
993 Diag(Loc, diag::err_variably_modified_nontype_template_param)
1031 Diag(Loc, diag::err_template_nontype_parm_bad_type)
1045 auto CheckValidDeclSpecifiers = [
this, &D] {
1059 Diag(Loc, diag::err_invalid_decl_specifier_in_nontype_parm)
1096 CheckValidDeclSpecifiers();
1100 diag::warn_cxx14_compat_template_nontype_parm_auto_type)
1105 "Non-type template parameter not in template parameter scope!");
1106 bool Invalid =
false;
1120 Depth, Position, ParamName, T,
1121 IsParameterPack, TInfo);
1133 IdResolver.AddDecl(Param);
1139 if (Default && IsParameterPack) {
1140 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1147 if (DiagnoseUnexpandedParameterPack(Default, UPPC_DefaultArgument))
1152 CheckTemplateArgument(Param, Param->
getType(), Default, Converted);
1157 Default = DefaultRes.
get();
1179 "Template template parameter not in template parameter scope!");
1182 bool IsParameterPack = EllipsisLoc.
isValid();
1186 Depth, Position, IsParameterPack,
1196 IdResolver.AddDecl(Param);
1199 if (Params->
size() == 0) {
1208 if (IsParameterPack && !Default.
isInvalid()) {
1209 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1224 Diag(DefaultArg.
getLocation(), diag::err_template_arg_not_valid_template)
1230 if (DiagnoseUnexpandedParameterPack(DefaultArg.
getLocation(),
1232 UPPC_DefaultArgument))
1251 Expr *RequiresClause) {
1253 Diag(ExportLoc, diag::warn_template_export_unsupported);
1256 Context, TemplateLoc, LAngleLoc,
1257 llvm::makeArrayRef(Params.data(), Params.size()),
1258 RAngleLoc, RequiresClause);
1273 assert(TemplateParams && TemplateParams->
size() > 0 &&
1274 "No template parameters");
1275 assert(TUK != TUK_Reference &&
"Can only declare or define class templates");
1276 bool Invalid =
false;
1279 if (CheckTemplateDeclScope(S, TemplateParams))
1283 assert(Kind !=
TTK_Enum &&
"can't build template of enumerated type");
1287 Diag(KWLoc, diag::err_template_unnamed_class);
1296 (SS.
isEmpty() && TUK == TUK_Friend)
1297 ? LookupTagName : LookupOrdinaryName,
1298 forRedeclarationInCurContext());
1300 SemanticContext = computeDeclContext(SS,
true);
1301 if (!SemanticContext) {
1305 Diag(NameLoc, TUK == TUK_Friend
1306 ? diag::warn_template_qualified_friend_ignored
1307 : diag::err_template_qualified_declarator_no_match)
1309 return TUK != TUK_Friend;
1312 if (RequireCompleteDeclContext(SS, SemanticContext))
1320 if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams))
1322 }
else if (TUK != TUK_Friend && TUK != TUK_Reference)
1323 diagnoseQualifiedDeclaration(SS, SemanticContext, Name, NameLoc,
false);
1325 LookupQualifiedName(
Previous, SemanticContext);
1327 SemanticContext = CurContext;
1333 if (TUK != TUK_Friend &&
1334 DiagnoseClassNameShadow(SemanticContext,
1346 PrevDecl = (*
Previous.begin())->getUnderlyingDecl();
1350 DiagnoseTemplateParameterShadow(NameLoc, PrevDecl);
1358 dyn_cast_or_null<ClassTemplateDecl>(PrevDecl);
1363 if (!PrevClassTemplate && PrevDecl && isa<CXXRecordDecl>(PrevDecl) &&
1364 cast<CXXRecordDecl>(PrevDecl)->isInjectedClassName()) {
1367 = cast<CXXRecordDecl>(PrevDecl)->getDescribedClassTemplate();
1368 if (!PrevClassTemplate && isa<ClassTemplateSpecializationDecl>(PrevDecl)) {
1370 = cast<ClassTemplateSpecializationDecl>(PrevDecl)
1371 ->getSpecializedTemplate();
1375 if (TUK == TUK_Friend) {
1394 PrevDecl = PrevClassTemplate =
nullptr;
1395 SemanticContext = OutermostContext;
1399 Previous.clear(LookupOrdinaryName);
1403 LookupQualifiedName(
Previous, LookupContext);
1409 PrevDecl = (*
Previous.begin())->getUnderlyingDecl();
1412 }
else if (PrevDecl &&
1413 !isDeclInScope(
Previous.getRepresentativeDecl(), SemanticContext,
1415 PrevDecl = PrevClassTemplate =
nullptr;
1417 if (
auto *Shadow = dyn_cast_or_null<UsingShadowDecl>(
1418 PrevDecl ?
Previous.getRepresentativeDecl() :
nullptr)) {
1420 !(PrevClassTemplate &&
1423 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
1424 Diag(Shadow->getTargetDecl()->getLocation(),
1425 diag::note_using_decl_target);
1426 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl) << 0;
1428 PrevDecl = PrevClassTemplate =
nullptr;
1435 if (PrevClassTemplate) {
1439 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
1440 !TemplateParameterListsAreEqual(TemplateParams,
1448 const bool RedeclACMismatch = [&] {
1449 if (!(CurAC || PrevAC))
1451 if (CurAC && PrevAC) {
1452 llvm::FoldingSetNodeID CurACInfo, PrevACInfo;
1453 CurAC->
Profile(CurACInfo, Context,
true);
1454 PrevAC->
Profile(PrevACInfo, Context,
true);
1455 if (CurACInfo == PrevACInfo)
1461 if (RedeclACMismatch) {
1463 diag::err_template_different_associated_constraints);
1465 diag::note_template_prev_declaration) << 0;
1475 if (!isAcceptableTagRedeclaration(PrevRecordDecl, Kind,
1476 TUK == TUK_Definition, KWLoc, Name)) {
1477 Diag(KWLoc, diag::err_use_with_wrong_tag)
1485 if (TUK == TUK_Definition) {
1490 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);
1500 Diag(NameLoc, diag::err_redefinition) << Name;
1501 Diag(Def->getLocation(), diag::note_previous_definition);
1507 }
else if (PrevDecl) {
1513 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
1522 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
1523 CheckTemplateParameterList(
1527 (SS.
isSet() && SemanticContext && SemanticContext->
isRecord() &&
1529 ? TPC_ClassTemplateMember
1530 : TUK == TUK_Friend ? TPC_FriendClassTemplate
1531 : 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) {
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)
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);
1664 class ExtractTypeForDeductionGuide
1668 ExtractTypeForDeductionGuide(
Sema &SemaRef) : Base(SemaRef) {}
1673 return TransformType(
1681 struct ConvertConstructorToDeductionGuideTransform {
1682 ConvertConstructorToDeductionGuideTransform(
Sema &S,
1684 : SemaRef(S), Template(Template) {}
1718 AllParams.reserve(TemplateParams->
size() + InnerParams->
size());
1719 AllParams.insert(AllParams.begin(),
1720 TemplateParams->
begin(), TemplateParams->
end());
1721 SubstArgs.reserve(InnerParams->
size());
1729 NamedDecl *NewParam = transformTemplateParameter(Param, Args);
1732 AllParams.push_back(NewParam);
1737 SemaRef.
Context, InnerParams->getTemplateLoc(),
1738 InnerParams->getLAngleLoc(), AllParams, InnerParams->getRAngleLoc(),
1748 Args.addOuterRetainedLevel();
1753 assert(FPTL &&
"no prototype for constructor declaration");
1760 QualType NewType = transformFunctionProtoType(TLB, FPTL, Params, Args);
1765 return buildDeductionGuide(TemplateParams, CD->
isExplicit(), NewTInfo,
1778 DeductionGuideName, EPI);
1786 for (
auto T : ParamTypes) {
1788 SemaRef.
Context, DC, Loc, Loc,
nullptr, T,
1791 FPTL.
setParam(Params.size(), NewParam);
1792 Params.push_back(NewParam);
1805 if (
auto *TTP = dyn_cast<TemplateTypeParmDecl>(TemplateParam)) {
1809 SemaRef.
Context, DC, TTP->getLocStart(), TTP->getLocation(),
1810 0, Depth1IndexAdjustment + TTP->getIndex(),
1811 TTP->getIdentifier(), TTP->wasDeclaredWithTypename(),
1812 TTP->isParameterPack());
1813 if (TTP->hasDefaultArgument()) {
1815 SemaRef.
SubstType(TTP->getDefaultArgumentInfo(), Args,
1816 TTP->getDefaultArgumentLoc(), TTP->getDeclName());
1817 if (InstantiatedDefaultArg)
1818 NewTTP->setDefaultArgument(InstantiatedDefaultArg);
1825 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(TemplateParam))
1826 return transformTemplateParameterImpl(TTP, Args);
1828 return transformTemplateParameterImpl(
1829 cast<NonTypeTemplateParmDecl>(TemplateParam), Args);
1831 template<
typename TemplateParmDecl>
1833 transformTemplateParameterImpl(TemplateParmDecl *OldParam,
1838 cast_or_null<TemplateParmDecl>(SemaRef.
SubstDecl(OldParam, DC, Args));
1839 assert(NewParam->getDepth() == 0 &&
"unexpected template param depth");
1840 NewParam->setPosition(NewParam->getPosition() + Depth1IndexAdjustment);
1853 ParmVarDecl *NewParam = transformFunctionTypeParam(OldParam, Args);
1856 ParamTypes.push_back(NewParam->
getType());
1857 Params.push_back(NewParam);
1879 ReturnType, ParamTypes, TL.
getLocStart(), DeductionGuideName, EPI);
1889 for (
unsigned I = 0, E = NewTL.
getNumParams(); I != E; ++I)
1904 SemaRef.
SubstType(PackTL.getPatternLoc(), Args,
1906 if (!NewDI)
return nullptr;
1909 PackTL.getTypePtr()->getNumExpansions());
1920 NewDI = ExtractTypeForDeductionGuide(SemaRef).transform(NewDI);
1956 Name, TInfo->
getType(), TInfo, LocEnd);
1958 Guide->setParams(Params);
1960 for (
auto *Param : Params)
1961 Param->setDeclContext(Guide);
1964 SemaRef.
Context, DC, Loc, DeductionGuideName, TemplateParams, Guide);
1965 GuideTemplate->setImplicit();
1966 Guide->setDescribedFunctionTemplate(GuideTemplate);
1968 if (isa<CXXRecordDecl>(DC)) {
1974 return GuideTemplate;
1985 ConvertConstructorToDeductionGuideTransform Transform(
1986 *
this, cast<ClassTemplateDecl>(Template));
1987 if (!isCompleteType(Loc, Transform.DeducedType))
1992 auto Existing = DC->
lookup(Transform.DeductionGuideName);
1993 for (
auto *D : Existing)
1994 if (D->isImplicit())
2005 if (BuildingDeductionGuides.
isInvalid())
2012 bool AddedAny =
false;
2013 for (
NamedDecl *D : LookupConstructors(Transform.Primary)) {
2014 D = D->getUnderlyingDecl();
2015 if (D->isInvalidDecl() || D->isImplicit())
2017 D = cast<NamedDecl>(D->getCanonicalDecl());
2021 dyn_cast_or_null<CXXConstructorDecl>(FTD ? FTD->getTemplatedDecl() : D);
2024 if (!CD || (!FTD && CD->isFunctionTemplateSpecialization()))
2027 Transform.transformConstructor(FTD, CD);
2036 Transform.buildSimpleDeductionGuide(None);
2040 cast<CXXDeductionGuideDecl>(
2041 cast<FunctionTemplateDecl>(
2042 Transform.buildSimpleDeductionGuide(Transform.DeducedType))
2043 ->getTemplatedDecl())
2044 ->setIsCopyDeductionCandidate();
2072 diag::warn_cxx98_compat_template_parameter_default_in_function_template
2073 : diag::ext_template_parameter_default_in_function_template)
2082 S.
Diag(ParamLoc, diag::err_template_parameter_default_template_member)
2091 S.
Diag(ParamLoc, diag::err_template_parameter_default_friend_template)
2100 llvm_unreachable(
"Invalid TemplateParamListContext!");
2113 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
2116 if (!NTTP->isParameterPack() &&
2118 NTTP->getTypeSourceInfo(),
2126 = dyn_cast<TemplateTemplateParmDecl>(P))
2159 bool Invalid =
false;
2167 bool SawDefaultArgument =
false;
2173 OldParam = OldParams->
begin();
2175 bool RemoveDefaultArguments =
false;
2177 NewParamEnd = NewParams->
end();
2178 NewParam != NewParamEnd; ++NewParam) {
2180 bool RedundantDefaultArg =
false;
2185 bool MissingDefaultArg =
false;
2188 bool SawParameterPack =
false;
2191 = dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
2193 if (NewTypeParm->hasDefaultArgument() &&
2195 NewTypeParm->getLocation(),
2196 NewTypeParm->getDefaultArgumentInfo()->getTypeLoc()
2198 NewTypeParm->removeDefaultArgument();
2202 = OldParams? cast<TemplateTypeParmDecl>(*OldParam) :
nullptr;
2203 if (NewTypeParm->isParameterPack()) {
2204 assert(!NewTypeParm->hasDefaultArgument() &&
2205 "Parameter packs can't have a default argument!");
2206 SawParameterPack =
true;
2208 NewTypeParm->hasDefaultArgument()) {
2210 NewDefaultLoc = NewTypeParm->getDefaultArgumentLoc();
2211 SawDefaultArgument =
true;
2212 RedundantDefaultArg =
true;
2213 PreviousDefaultArgLoc = NewDefaultLoc;
2217 NewTypeParm->setInheritedDefaultArgument(Context, OldTypeParm);
2219 }
else if (NewTypeParm->hasDefaultArgument()) {
2220 SawDefaultArgument =
true;
2221 PreviousDefaultArgLoc = NewTypeParm->getDefaultArgumentLoc();
2222 }
else if (SawDefaultArgument)
2223 MissingDefaultArg =
true;
2225 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
2227 if (!NewNonTypeParm->isParameterPack() &&
2228 DiagnoseUnexpandedParameterPack(NewNonTypeParm->getLocation(),
2229 NewNonTypeParm->getTypeSourceInfo(),
2230 UPPC_NonTypeTemplateParameterType)) {
2236 if (NewNonTypeParm->hasDefaultArgument() &&
2238 NewNonTypeParm->getLocation(),
2239 NewNonTypeParm->getDefaultArgument()->getSourceRange())) {
2240 NewNonTypeParm->removeDefaultArgument();
2245 = OldParams? cast<NonTypeTemplateParmDecl>(*OldParam) :
nullptr;
2246 if (NewNonTypeParm->isParameterPack()) {
2247 assert(!NewNonTypeParm->hasDefaultArgument() &&
2248 "Parameter packs can't have a default argument!");
2249 if (!NewNonTypeParm->isPackExpansion())
2250 SawParameterPack =
true;
2252 NewNonTypeParm->hasDefaultArgument()) {
2254 NewDefaultLoc = NewNonTypeParm->getDefaultArgumentLoc();
2255 SawDefaultArgument =
true;
2256 RedundantDefaultArg =
true;
2257 PreviousDefaultArgLoc = NewDefaultLoc;
2261 NewNonTypeParm->setInheritedDefaultArgument(Context, OldNonTypeParm);
2263 }
else if (NewNonTypeParm->hasDefaultArgument()) {
2264 SawDefaultArgument =
true;
2265 PreviousDefaultArgLoc = NewNonTypeParm->getDefaultArgumentLoc();
2266 }
else if (SawDefaultArgument)
2267 MissingDefaultArg =
true;
2270 = cast<TemplateTemplateParmDecl>(*NewParam);
2287 = OldParams? cast<TemplateTemplateParmDecl>(*OldParam) :
nullptr;
2290 "Parameter packs can't have a default argument!");
2292 SawParameterPack =
true;
2293 }
else if (OldTemplateParm &&
2298 SawDefaultArgument =
true;
2299 RedundantDefaultArg =
true;
2300 PreviousDefaultArgLoc = NewDefaultLoc;
2305 PreviousDefaultArgLoc
2308 SawDefaultArgument =
true;
2309 PreviousDefaultArgLoc
2311 }
else if (SawDefaultArgument)
2312 MissingDefaultArg =
true;
2318 if (SawParameterPack && (NewParam + 1) != NewParamEnd &&
2319 (TPC == TPC_ClassTemplate || TPC == TPC_VarTemplate ||
2320 TPC == TPC_TypeAliasTemplate)) {
2321 Diag((*NewParam)->getLocation(),
2322 diag::err_template_param_pack_must_be_last_template_parameter);
2326 if (RedundantDefaultArg) {
2330 Diag(NewDefaultLoc, diag::err_template_param_default_arg_redefinition);
2331 Diag(OldDefaultLoc, diag::note_template_param_prev_default_arg);
2333 }
else if (MissingDefaultArg && TPC != TPC_FunctionTemplate) {
2339 Diag((*NewParam)->getLocation(),
2340 diag::err_template_param_default_arg_missing);
2341 Diag(PreviousDefaultArgLoc, diag::note_template_param_prev_default_arg);
2343 RemoveDefaultArguments =
true;
2354 if (RemoveDefaultArguments) {
2356 NewParamEnd = NewParams->
end();
2357 NewParam != NewParamEnd; ++NewParam) {
2359 TTP->removeDefaultArgument();
2361 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
2362 NTTP->removeDefaultArgument();
2364 cast<TemplateTemplateParmDecl>(*NewParam)->removeDefaultArgument();
2384 bool IgnoreNonTypeDependent;
2389 DependencyChecker(
unsigned Depth,
bool IgnoreNonTypeDependent)
2390 :
Depth(Depth), IgnoreNonTypeDependent(IgnoreNonTypeDependent),
2394 : IgnoreNonTypeDependent(IgnoreNonTypeDependent), Match(
false) {
2397 Depth = PD->getDepth();
2399 dyn_cast<NonTypeTemplateParmDecl>(ND)) {
2400 Depth = PD->getDepth();
2402 Depth = cast<TemplateTemplateParmDecl>(ND)->getDepth();
2407 if (ParmDepth >= Depth) {
2415 bool TraverseStmt(
Stmt *S, DataRecursionQueue *Q =
nullptr) {
2420 if (
auto *E = dyn_cast_or_null<Expr>(S))
2421 if (IgnoreNonTypeDependent && !E->isTypeDependent())
2423 return super::TraverseStmt(S, Q);
2426 bool TraverseTypeLoc(
TypeLoc TL) {
2427 if (IgnoreNonTypeDependent && !TL.
isNull() &&
2430 return super::TraverseTypeLoc(TL);
2439 return IgnoreNonTypeDependent || !Matches(T->
getDepth());
2445 if (Matches(PD->getDepth()))
2447 return super::TraverseTemplateName(N);
2452 dyn_cast<NonTypeTemplateParmDecl>(E->
getDecl()))
2453 if (Matches(PD->getDepth(), E->
getExprLoc()))
2455 return super::VisitDeclRefExpr(E);
2477 DependencyChecker Checker(Params,
false);
2478 Checker.TraverseType(T);
2479 return Checker.Match;
2489 if (
const Type *CurType = NNS->getAsType()) {
2495 NNSLoc = NNSLoc.getPrefix();
2538 bool &IsMemberSpecialization,
bool &Invalid) {
2539 IsMemberSpecialization =
false;
2549 = dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS,
true)))
2561 NestedTypes.push_back(T);
2567 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
2568 if (!isa<ClassTemplatePartialSpecializationDecl>(Spec) &&
2570 ExplicitSpecLoc = Spec->getLocation();
2573 }
else if (Record->getTemplateSpecializationKind()
2575 ExplicitSpecLoc = Record->getLocation();
2588 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
2589 if (
TypeDecl *
Parent = dyn_cast<TypeDecl>(Template->getDeclContext()))
2634 std::reverse(NestedTypes.begin(), NestedTypes.end());
2642 bool SawNonEmptyTemplateParameterList =
false;
2644 auto CheckExplicitSpecialization = [&](
SourceRange Range,
bool Recovery) {
2645 if (SawNonEmptyTemplateParameterList) {
2646 Diag(DeclLoc, diag::err_specialize_member_of_template)
2647 << !Recovery << Range;
2649 IsMemberSpecialization =
false;
2656 auto DiagnoseMissingExplicitSpecialization = [&] (
SourceRange Range) {
2658 if (CheckExplicitSpecialization(Range,
true))
2663 if (!ParamLists.empty())
2664 ExpectedTemplateLoc = ParamLists[0]->getTemplateLoc();
2666 ExpectedTemplateLoc = DeclStartLoc;
2668 Diag(DeclLoc, diag::err_template_spec_needs_header)
2675 for (
unsigned TypeIdx = 0, NumTypes = NestedTypes.size(); TypeIdx != NumTypes;
2677 T = NestedTypes[TypeIdx];
2680 bool NeedEmptyTemplateHeader =
false;
2683 bool NeedNonemptyTemplateHeader =
false;
2696 = dyn_cast<ClassTemplatePartialSpecializationDecl>(Record)) {
2697 ExpectedTemplateParams = Partial->getTemplateParameters();
2698 NeedNonemptyTemplateHeader =
true;
2699 }
else if (Record->isDependentType()) {
2700 if (Record->getDescribedClassTemplate()) {
2701 ExpectedTemplateParams = Record->getDescribedClassTemplate()
2702 ->getTemplateParameters();
2703 NeedNonemptyTemplateHeader =
true;
2706 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
2712 NeedEmptyTemplateHeader =
true;
2715 }
else if (Record->getTemplateSpecializationKind()) {
2716 if (Record->getTemplateSpecializationKind()
2718 TypeIdx == NumTypes - 1)
2719 IsMemberSpecialization =
true;
2725 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
2726 ExpectedTemplateParams = Template->getTemplateParameters();
2727 NeedNonemptyTemplateHeader =
true;
2732 NeedNonemptyTemplateHeader =
false;
2742 if (ParamIdx < ParamLists.size()) {
2743 if (ParamLists[ParamIdx]->size() == 0) {
2744 if (CheckExplicitSpecialization(ParamLists[ParamIdx]->
getSourceRange(),
2748 SawNonEmptyTemplateParameterList =
true;
2751 if (NeedEmptyTemplateHeader) {
2754 if (TypeIdx == NumTypes - 1)
2755 IsMemberSpecialization =
true;
2757 if (ParamIdx < ParamLists.size()) {
2758 if (ParamLists[ParamIdx]->size() > 0) {
2760 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
2761 diag::err_template_param_list_matches_nontemplate)
2763 <<
SourceRange(ParamLists[ParamIdx]->getLAngleLoc(),
2764 ParamLists[ParamIdx]->getRAngleLoc())
2776 if (DiagnoseMissingExplicitSpecialization(
2783 if (NeedNonemptyTemplateHeader) {
2789 if (ParamIdx < ParamLists.size() &&
2791 ExpectedTemplateParams =
nullptr;
2796 if (ParamIdx < ParamLists.size()) {
2798 if (ExpectedTemplateParams &&
2799 !TemplateParameterListsAreEqual(ParamLists[ParamIdx],
2800 ExpectedTemplateParams,
2801 true, TPL_TemplateMatch))
2805 CheckTemplateParameterList(ParamLists[ParamIdx],
nullptr,
2806 TPC_ClassTemplateMember))
2813 Diag(DeclLoc, diag::err_template_spec_needs_template_parameters)
2824 if (ParamIdx >= ParamLists.size()) {
2825 if (TemplateId && !IsFriend) {
2841 if (ParamIdx < ParamLists.size() - 1) {
2842 bool HasAnyExplicitSpecHeader =
false;
2843 bool AllExplicitSpecHeaders =
true;
2844 for (
unsigned I = ParamIdx, E = ParamLists.size() - 1; I != E; ++I) {
2845 if (ParamLists[I]->size() == 0)
2846 HasAnyExplicitSpecHeader =
true;
2848 AllExplicitSpecHeaders =
false;
2851 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
2852 AllExplicitSpecHeaders ? diag::warn_template_spec_extra_headers
2853 : diag::err_template_spec_extra_headers)
2854 <<
SourceRange(ParamLists[ParamIdx]->getTemplateLoc(),
2855 ParamLists[ParamLists.size() - 2]->getRAngleLoc());
2860 if (ExplicitSpecLoc.isValid() && HasAnyExplicitSpecHeader)
2861 Diag(ExplicitSpecLoc,
2862 diag::note_explicit_template_spec_does_not_need_header)
2863 << NestedTypes.back();
2868 if (!AllExplicitSpecHeaders)
2879 if (ParamLists.back()->size() == 0 &&
2880 CheckExplicitSpecialization(ParamLists[ParamIdx]->
getSourceRange(),
2886 return ParamLists.back();
2891 Diag(Template->getLocation(), diag::note_template_declared_here)
2892 << (isa<FunctionTemplateDecl>(Template)
2894 : isa<ClassTemplateDecl>(Template)
2896 : isa<VarTemplateDecl>(Template)
2898 : isa<TypeAliasTemplateDecl>(Template) ? 3 : 4)
2899 << Template->getDeclName();
2907 Diag((*I)->getLocation(), diag::note_template_declared_here)
2908 << 0 << (*I)->getDeclName();
2927 if (!Converted[1].getAsType()->isIntegralType(Context)) {
2928 SemaRef.
Diag(TemplateArgs[1].getLocation(),
2929 diag::err_integer_sequence_integral_element_type);
2938 SemaRef.
Diag(TemplateArgs[2].getLocation(),
2939 diag::err_integer_sequence_negative_length);
2947 SyntheticTemplateArgs.
addArgument(TemplateArgs[1]);
2949 for (llvm::APSInt I(NumArgs.getBitWidth(), NumArgs.isUnsigned());
2953 TA, ArgTy, TemplateArgs[2].getLocation()));
2958 TemplateLoc, SyntheticTemplateArgs);
2965 assert(Converted.size() == 2 &&
2966 "__type_pack_element should be given an index and a parameter pack");
2970 llvm::APSInt Index = IndexArg.getAsIntegral();
2971 assert(Index >= 0 &&
"the index used with __type_pack_element should be of " 2972 "type std::size_t, and hence be non-negative");
2973 if (Index >= Ts.pack_size()) {
2974 SemaRef.
Diag(TemplateArgs[0].getLocation(),
2975 diag::err_type_pack_element_out_of_bounds);
2980 auto Nth = std::next(Ts.pack_begin(), Index.getExtValue());
2981 return Nth->getAsType();
2983 llvm_unreachable(
"unexpected BuiltinTemplateDecl!");
2988 return AliasTemplate->
getName().equals(
"enable_if_t");
3000 if (BinOp->getOpcode() == BO_LAnd) {
3008 Terms.push_back(Clause);
3017 if (!BinOp)
return Cond;
3019 if (BinOp->getOpcode() != BO_LOr)
return Cond;
3022 Expr *LHS = BinOp->getLHS();
3024 if (!InnerBinOp)
return Cond;
3026 if (InnerBinOp->getOpcode() != BO_EQ ||
3027 !isa<IntegerLiteral>(InnerBinOp->getRHS()))
3037 if (MacroName ==
"CONCEPT_REQUIRES" || MacroName ==
"CONCEPT_REQUIRES_")
3038 return BinOp->getRHS();
3043 std::pair<Expr *, std::string>
3052 Expr *FailedCond =
nullptr;
3053 for (
Expr *Term : Terms) {
3057 if (isa<CXXBoolLiteralExpr>(TermAsWritten) ||
3058 isa<IntegerLiteral>(TermAsWritten))
3067 if (Term->EvaluateAsBooleanCondition(Succeeded, Context) &&
3069 FailedCond = TermAsWritten;
3075 if (!AllowTopLevelCond)
3076 return {
nullptr,
"" };
3081 std::string Description;
3083 llvm::raw_string_ostream Out(Description);
3084 FailedCond->
printPretty(Out,
nullptr, getPrintingPolicy());
3086 return { FailedCond, Description };
3105 if (!Template || isa<FunctionTemplateDecl>(Template) ||
3106 isa<VarTemplateDecl>(Template)) {
3112 Diag(TemplateLoc, diag::err_template_id_not_a_type)
3114 NoteAllFoundTemplates(Name);
3121 if (CheckTemplateArgumentList(Template, TemplateLoc, TemplateArgs,
3127 bool InstantiationDependent =
false;
3129 dyn_cast<TypeAliasTemplateDecl>(Template)) {
3141 unsigned Depth = AliasTemplate->getTemplateParameters()->getDepth();
3142 for (
unsigned I = 0; I <
Depth; ++I)
3151 TemplateArgLists, AliasTemplate->getLocation(),
3152 AliasTemplate->getDeclName());
3153 if (CanonType.
isNull()) {
3158 if (
auto DeductionInfo = isSFINAEContext()) {
3159 if (*DeductionInfo &&
3160 (*DeductionInfo)->hasSFINAEDiagnostic() &&
3161 (*DeductionInfo)->peekSFINAEDiagnostic().second.getDiagID() ==
3162 diag::err_typename_nested_not_found_enable_if &&
3163 TemplateArgs[0].getArgument().getKind()
3166 std::string FailedDescription;
3167 std::tie(FailedCond, FailedDescription) =
3168 findFailedBooleanCondition(
3169 TemplateArgs[0].getSourceExpression(),
3175 (*DeductionInfo)->takeSFINAEDiagnostic(OldDiag);
3179 (*DeductionInfo)->addSFINAEDiagnostic(
3181 PDiag(diag::err_typename_nested_not_found_requirement)
3182 << FailedDescription
3192 TemplateArgs, InstantiationDependent)) {
3208 if (isa<ClassTemplateDecl>(Template)) {
3211 if (Ctx->isFileContext())
break;
3215 if (!Record)
continue;
3219 if (!isa<ClassTemplatePartialSpecializationDecl>(Record) &&
3226 QualType Injected = cast<InjectedClassNameType>(ICNT)
3227 ->getInjectedSpecializationType();
3240 = dyn_cast<ClassTemplateDecl>(Template)) {
3243 void *InsertPos =
nullptr;
3245 = ClassTemplate->findSpecialization(Converted, InsertPos);
3251 ClassTemplate->getTemplatedDecl()->getTagKind(),
3252 ClassTemplate->getDeclContext(),
3253 ClassTemplate->getTemplatedDecl()->getLocStart(),
3254 ClassTemplate->getLocation(),
3256 Converted,
nullptr);
3257 ClassTemplate->AddSpecialization(Decl, InsertPos);
3258 if (ClassTemplate->isOutOfLine())
3265 InstantiateAttrsForDecl(TemplateArgLists, ClassTemplate->getTemplatedDecl(),
3270 (void)DiagnoseUseOfDecl(Decl, TemplateLoc);
3273 assert(isa<RecordType>(CanonType) &&
3274 "type of non-dependent specialization is not a RecordType");
3275 }
else if (
auto *BTD = dyn_cast<BuiltinTemplateDecl>(Template)) {
3293 bool IsCtorOrDtorName,
bool IsClassName) {
3297 if (!IsCtorOrDtorName && !IsClassName && SS.
isSet()) {
3298 DeclContext *LookupCtx = computeDeclContext(SS,
false);
3306 if (!LookupCtx && isDependentScopeSpecifier(SS)) {
3313 return ActOnTypenameType(
nullptr,
SourceLocation(), SS, TemplateKWLoc,
3314 TemplateD, TemplateII, TemplateIILoc, LAngleLoc,
3315 TemplateArgsIn, RAngleLoc);
3322 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
3323 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
3326 ? diag::err_out_of_line_qualified_id_type_names_constructor
3327 : diag::ext_out_of_line_qualified_id_type_names_constructor)
3337 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
3342 DTN->getQualifier(),
3343 DTN->getIdentifier(),
3355 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
3360 QualType Result = CheckTemplateIdType(Template, TemplateIILoc, TemplateArgs);
3361 if (Result.isNull())
3372 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
3403 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
3412 DTN->getQualifier(),
3413 DTN->getIdentifier(),
3426 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
3437 Diag(TemplateLoc, diag::err_tag_reference_non_tag)
3438 << TAT << NTK_TypeAliasTemplate << TagKind;
3439 Diag(TAT->getLocation(), diag::note_declared_at);
3442 QualType Result = CheckTemplateIdType(Template, TemplateLoc, TemplateArgs);
3443 if (Result.isNull())
3451 assert(Id &&
"templated class must have an identifier");
3453 if (!isAcceptableTagRedeclaration(D, TagKind, TUK == TUK_Definition,
3455 Diag(TagLoc, diag::err_use_with_wrong_tag)
3470 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
3479 return CreateParsedType(Result, TLB.getTypeSourceInfo(Context, Result));
3519 dyn_cast_or_null<TemplateTemplateParmDecl>(
3523 llvm_unreachable(
"unexpected kind of template argument");
3528 if (Params->
size() != Args.size())
3533 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
3560 return TemplateArgs;
3563 template<
typename PartialSpecDecl>
3565 if (Partial->getDeclContext()->isDependentContext())
3574 auto *Template = Partial->getSpecializedTemplate();
3575 S.
Diag(Partial->getLocation(),
3576 diag::ext_partial_spec_not_more_specialized_than_primary)
3577 << isa<VarTemplateDecl>(Template);
3579 if (Info.hasSFINAEDiagnostic()) {
3582 Info.takeSFINAEDiagnostic(Diag);
3586 diag::note_partial_spec_not_more_specialized_than_primary)
3590 S.
Diag(Template->getLocation(), diag::note_template_decl_here);
3595 const llvm::SmallBitVector &DeducibleParams) {
3596 for (
unsigned I = 0, N = DeducibleParams.size(); I != N; ++I) {
3597 if (!DeducibleParams[I]) {
3610 template<
typename PartialSpecDecl>
3612 PartialSpecDecl *Partial) {
3625 auto *TemplateParams = Partial->getTemplateParameters();
3626 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
3628 TemplateParams->getDepth(), DeducibleParams);
3630 if (!DeducibleParams.all()) {
3631 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
3632 S.
Diag(Partial->getLocation(), diag::ext_partial_specs_not_deducible)
3633 << isa<VarTemplatePartialSpecializationDecl>(Partial)
3634 << (NumNonDeducible > 1)
3636 Partial->getTemplateArgsAsWritten()->RAngleLoc);
3657 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
3658 MarkDeducedTemplateParameters(TD, DeducibleParams);
3659 for (
unsigned I = 0; I != TemplateParams->size(); ++I) {
3661 auto *Param = TemplateParams->getParam(I);
3663 DeducibleParams[I] =
true;
3666 if (!DeducibleParams.all()) {
3667 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
3668 Diag(TD->
getLocation(), diag::err_deduction_guide_template_not_deducible)
3669 << (NumNonDeducible > 1);
3680 "Variable template specialization is declared with a template it.");
3697 FnTemplate = *OTS->begin();
3704 << IsPartialSpecialization;
3708 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
3709 if (DiagnoseUnexpandedParameterPack(TemplateArgs[I],
3710 UPPC_PartialSpecialization))
3716 if (CheckTemplateArgumentList(VarTemplate, TemplateNameLoc, TemplateArgs,
3722 if (IsPartialSpecialization) {
3723 if (CheckTemplatePartialSpecializationArgs(TemplateNameLoc, VarTemplate,
3724 TemplateArgs.
size(), Converted))
3729 bool InstantiationDependent;
3733 InstantiationDependent)) {
3734 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
3736 IsPartialSpecialization =
false;
3745 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
3747 << (SC !=
SC_Extern && !CurContext->isRecord())
3755 void *InsertPos =
nullptr;
3758 if (IsPartialSpecialization)
3770 IsPartialSpecialization))
3778 Specialization = PrevDecl;
3781 }
else if (IsPartialSpecialization) {
3784 cast_or_null<VarTemplatePartialSpecializationDecl>(PrevDecl);
3788 TemplateNameLoc, TemplateParams, VarTemplate, DI->
getType(), DI, SC,
3789 Converted, TemplateArgs);
3792 VarTemplate->AddPartialSpecialization(Partial, InsertPos);
3793 Specialization = Partial;
3800 CheckTemplatePartialSpecialization(Partial);
3805 Context, VarTemplate->
getDeclContext(), TemplateKWLoc, TemplateNameLoc,
3806 VarTemplate, DI->
getType(), DI, SC, Converted);
3810 VarTemplate->AddSpecialization(Specialization, InsertPos);
3831 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
3835 diag::note_instantiation_required_here)
3848 CurContext->addDecl(Specialization);
3856 LookupResult PrevSpec(*
this, GetNameForDeclarator(D), LookupOrdinaryName,
3857 forRedeclarationInCurContext());
3872 return Specialization;
3878 struct PartialSpecMatchResult {
3888 assert(Template &&
"A variable template id without template?");
3892 if (CheckTemplateArgumentList(
3893 Template, TemplateNameLoc,
3894 const_cast<TemplateArgumentListInfo &>(TemplateArgs),
false,
3900 void *InsertPos =
nullptr;
3902 Converted, InsertPos)) {
3903 checkSpecializationVisibility(TemplateNameLoc, Spec);
3916 bool AmbiguousPartialSpec =
false;
3917 typedef PartialSpecMatchResult MatchResult;
3932 bool InstantiationDependent =
false;
3934 TemplateArgs, InstantiationDependent)) {
3939 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
3952 Matched.push_back(PartialSpecMatchResult());
3953 Matched.back().Partial = Partial;
3954 Matched.back().Args = Info.take();
3958 if (Matched.size() >= 1) {
3960 if (Matched.size() == 1) {
3973 PEnd = Matched.end();
3975 if (getMoreSpecializedPartialSpecialization(
P->Partial, Best->Partial,
3976 PointOfInstantiation) ==
3984 PEnd = Matched.end();
3986 if (
P != Best && getMoreSpecializedPartialSpecialization(
3987 P->Partial, Best->Partial,
3988 PointOfInstantiation) != Best->Partial) {
3989 AmbiguousPartialSpec =
true;
3996 InstantiationPattern = Best->Partial;
3997 InstantiationArgs = Best->Args;
4010 Template, InstantiationPattern, *InstantiationArgs, TemplateArgs,
4011 Converted, TemplateNameLoc, InsertPos );
4015 if (AmbiguousPartialSpec) {
4018 Diag(PointOfInstantiation, diag::err_partial_spec_ordering_ambiguous)
4022 for (MatchResult
P : Matched)
4023 Diag(
P.Partial->getLocation(), diag::note_partial_spec_match)
4024 << getTemplateArgumentBindingsText(
P.Partial->getTemplateParameters(),
4030 dyn_cast<VarTemplatePartialSpecializationDecl>(InstantiationPattern))
4033 checkSpecializationVisibility(TemplateNameLoc, Decl);
4035 assert(Decl &&
"No variable template specialization?");
4056 return BuildDeclarationNameExpr(SS, NameInfo, Var,
4057 nullptr, TemplateArgs);
4062 Diag(Loc, diag::err_template_missing_args)
4063 << (int)getTemplateNameKindForDiagnostics(Name) << Name;
4065 Diag(TD->getLocation(), diag::note_template_decl_here)
4066 << TD->getTemplateParameters()->getSourceRange();
4086 assert(!R.
empty() &&
"empty lookup results when building templateid");
4087 assert(!R.
isAmbiguous() &&
"ambiguous lookup when building templateid");
4091 if (!TemplateArgs && !isa<FunctionTemplateDecl>(TD)) {
4097 auto AnyDependentArguments = [&]() ->
bool {
4098 bool InstantiationDependent;
4099 return TemplateArgs &&
4101 *TemplateArgs, InstantiationDependent);
4108 TemplateKWLoc, TemplateArgs);
4119 RequiresADL, TemplateArgs,
4132 assert(TemplateArgs || TemplateKWLoc.
isValid());
4134 if (!(DC = computeDeclContext(SS,
false)) ||
4135 DC->isDependentContext() ||
4136 RequireCompleteDeclContext(SS, DC))
4137 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
4139 bool MemberOfUnknownSpecialization;
4142 false, MemberOfUnknownSpecialization,
4156 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_class_template)
4159 Diag(Temp->getLocation(), diag::note_referenced_class_template);
4163 return BuildTemplateIdExpr(SS, TemplateKWLoc, R,
false, TemplateArgs);
4178 bool EnteringContext,
4180 bool AllowInjectedClassName) {
4183 getLangOpts().CPlusPlus11 ?
4184 diag::warn_cxx98_compat_template_outside_of_template :
4185 diag::ext_template_outside_of_template)
4190 LookupCtx = computeDeclContext(SS, EnteringContext);
4191 if (!LookupCtx && ObjectType)
4192 LookupCtx = computeDeclContext(ObjectType.
get());
4210 bool MemberOfUnknownSpecialization;
4212 ObjectType, EnteringContext, Result,
4213 MemberOfUnknownSpecialization);
4222 LookupOrdinaryName);
4224 if (!LookupTemplateName(R, S, SS, ObjectType.get(), EnteringContext,
4225 MOUS, TemplateKWLoc))
4232 if (!AllowInjectedClassName && SS.
isSet() && LookupRD &&
4245 diag::ext_out_of_line_qualified_id_type_names_constructor)
4267 llvm_unreachable(
"literal operator id cannot have a dependent scope");
4274 diag::err_template_kw_refers_to_non_template)
4275 << GetNameFromUnqualifiedId(Name).getName()
4303 diagnoseMissingTemplateArguments(Name, SR.
getEnd());
4313 SS.
Adopt(ArgExpr->getQualifierLoc());
4314 NameInfo = ArgExpr->getNameInfo();
4316 dyn_cast<DependentScopeDeclRefExpr>(Arg.
getAsExpr())) {
4317 SS.
Adopt(ArgExpr->getQualifierLoc());
4318 NameInfo = ArgExpr->getNameInfo();
4320 dyn_cast<CXXDependentScopeMemberExpr>(Arg.
getAsExpr())) {
4321 if (ArgExpr->isImplicitAccess()) {
4322 SS.
Adopt(ArgExpr->getQualifierLoc());
4323 NameInfo = ArgExpr->getMemberNameInfo();
4328 LookupResult Result(*
this, NameInfo, LookupOrdinaryName);
4329 LookupParsedName(Result, CurScope, &SS);
4336 Diag(Loc, getLangOpts().MSVCCompat
4337 ? diag::ext_ms_template_type_arg_missing_typename
4338 : diag::err_template_arg_must_be_type_suggest)
4368 Diag(SR.
getBegin(), diag::err_template_arg_must_be_type) << SR;
4375 if (CheckTemplateArgument(Param, TSI))
4384 if (getLangOpts().ObjCAutoRefCount &&
4430 Param, Template, Converted,
4440 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4445 SemaRef.
SubstType(ArgType, TemplateArgLists,
4482 Param, Template, Converted,
4492 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4544 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
4574 bool &HasDefaultArg) {
4575 HasDefaultArg =
false;
4581 HasDefaultArg =
true;
4594 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
4598 HasDefaultArg =
true;
4612 = cast<TemplateTemplateParmDecl>(Param);
4616 HasDefaultArg =
true;
4639 if (ETLoc.getTypePtr()->getKeyword() !=
ETK_None)
4642 QualLoc = ETLoc.getQualifierLoc();
4643 TLoc = ETLoc.getNamedTypeLoc();
4650 QualLoc, InjLoc.getNameLoc());
4658 dyn_cast<ClassTemplateSpecializationDecl>(RecLoc.getDecl()))
4660 QualLoc, RecLoc.getNameLoc());
4696 unsigned ArgumentPackIndex,
4701 return CheckTemplateTypeArgument(TTP, Arg, Converted);
4708 QualType NTTPType = NTTP->getType();
4709 if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack())
4710 NTTPType = NTTP->getExpansionType(ArgumentPackIndex);
4715 !isa<TemplateTemplateParmDecl>(Template) &&
4726 NTTPType = SubstType(NTTPType,
4728 NTTP->getLocation(),
4729 NTTP->getDeclName());
4733 NTTPType = CheckNonTypeTemplateParameterType(NTTPType,
4734 NTTP->getLocation());
4741 llvm_unreachable(
"Should never see a NULL template argument here");
4745 unsigned CurSFINAEErrors = NumSFINAEErrors;
4752 if (CurSFINAEErrors < NumSFINAEErrors)
4762 Converted.push_back(Result);
4796 Context, SS.getWithLocInContext(Context), TemplateKWLoc, NameInfo,
4808 E = CheckTemplateArgument(NTTP, NTTPType, E.
get(), Result);
4812 Converted.push_back(Result);
4839 Diag(SR.
getBegin(), diag::err_template_arg_nontype_ambig) << SR << T;
4841 Diag(SR.
getBegin(), diag::err_template_arg_must_be_expr) << SR;
4847 llvm_unreachable(
"Caller must expand template argument packs");
4870 TempParm, Converted,
4876 Params = SubstTemplateParams(Params, CurContext,
4895 llvm_unreachable(
"Should never see a NULL template argument here");
4899 if (CheckTemplateTemplateArgument(Params, Arg))
4910 << getLangOpts().CPlusPlus11;
4914 llvm_unreachable(
"Declaration argument with template template parameter");
4916 llvm_unreachable(
"Integral argument with template template parameter");
4918 llvm_unreachable(
"Null pointer argument with template template parameter");
4921 llvm_unreachable(
"Caller must expand template argument packs");
4940 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
4941 if (NTTP->isExpandedParameterPack())
4942 return NTTP->getNumExpansionTypes();
4946 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
4947 if (TTP->isExpandedParameterPack())
4948 return TTP->getNumExpansionTemplateParameters();
4955 template<
typename TemplateParmDecl>
4958 const TemplateParmDecl *D,
4963 ->getTemplateParameters()
4964 ->getParam(D->getIndex()));
4971 D->getDefaultArgumentLoc(), Modules,
4982 S.
Diag(Loc, diag::err_template_arg_list_different_arity)
4997 bool UpdateArgsWithConversions) {
5008 ->getTemplateParameters();
5017 bool isTemplateTemplateParameter = isa<TemplateTemplateParmDecl>(Template);
5019 unsigned ArgIdx = 0, NumArgs = NewArgs.
size();
5022 ParamEnd = Params->
end();
5023 Param != ParamEnd; ) {
5027 if (*Expansions == ArgumentPack.size()) {
5030 Converted.push_back(
5032 ArgumentPack.clear();
5037 }
else if (ArgIdx == NumArgs && !PartialTemplateArgs) {
5039 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
5041 << (int)getTemplateNameKindForDiagnostics(
TemplateName(Template))
5049 if (ArgIdx < NumArgs) {
5051 if (CheckTemplateArgument(*Param, NewArgs[ArgIdx], Template,
5052 TemplateLoc, RAngleLoc,
5053 ArgumentPack.size(), Converted))
5056 bool PackExpansionIntoNonPack =
5057 NewArgs[ArgIdx].getArgument().isPackExpansion() &&
5059 if (PackExpansionIntoNonPack && isa<TypeAliasTemplateDecl>(Template)) {
5063 Diag(NewArgs[ArgIdx].getLocation(),
5064 diag::err_alias_template_expansion_into_fixed_list)
5065 << NewArgs[ArgIdx].getSourceRange();
5066 Diag((*Param)->getLocation(), diag::note_template_param_here);
5073 if ((*Param)->isTemplateParameterPack()) {
5078 ArgumentPack.push_back(Converted.pop_back_val());
5087 if (PackExpansionIntoNonPack) {
5088 if (!ArgumentPack.empty()) {
5091 Converted.insert(Converted.end(),
5092 ArgumentPack.begin(), ArgumentPack.end());
5093 ArgumentPack.clear();
5096 while (ArgIdx < NumArgs) {
5097 Converted.push_back(NewArgs[ArgIdx].
getArgument());
5108 if (PartialTemplateArgs) {
5109 if ((*Param)->isTemplateParameterPack() && !ArgumentPack.empty())
5110 Converted.push_back(
5118 if ((*Param)->isTemplateParameterPack()) {
5120 "Should have dealt with this already");
5125 if (Param + 1 != ParamEnd)
5128 Converted.push_back(
5130 ArgumentPack.clear();
5161 = dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
5178 = cast<TemplateTemplateParmDecl>(*Param);
5204 if (Inst.isInvalid())
5208 if (CheckTemplateArgument(*Param, Arg, Template, TemplateLoc,
5209 RAngleLoc, 0, Converted))
5215 if (isTemplateTemplateParameter)
5227 if (ArgIdx < NumArgs && CurrentInstantiationScope &&
5228 CurrentInstantiationScope->getPartiallySubstitutedPack()) {
5230 Converted.push_back(NewArgs[ArgIdx++].getArgument());
5235 if (ArgIdx < NumArgs) {
5236 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
5238 << (int)getTemplateNameKindForDiagnostics(
TemplateName(Template))
5248 if (UpdateArgsWithConversions)
5249 TemplateArgs = std::move(NewArgs);
5255 class UnnamedLocalNoLinkageFinder
5256 :
public TypeVisitor<UnnamedLocalNoLinkageFinder, bool>
5264 UnnamedLocalNoLinkageFinder(
Sema &S,
SourceRange SR) : S(S), SR(SR) { }
5270 #define TYPE(Class, Parent) \ 5271 bool Visit##Class##Type(const Class##Type *); 5272 #define ABSTRACT_TYPE(Class, Parent) \ 5273 bool Visit##Class##Type(const Class##Type *) { return false; } 5274 #define NON_CANONICAL_TYPE(Class, Parent) \ 5275 bool Visit##Class##Type(const Class##Type *) { return false; } 5276 #include "clang/AST/TypeNodes.def" 5278 bool VisitTagDecl(
const TagDecl *Tag);
5283 bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(
const BuiltinType*) {
5287 bool UnnamedLocalNoLinkageFinder::VisitComplexType(
const ComplexType* T) {
5291 bool UnnamedLocalNoLinkageFinder::VisitPointerType(
const PointerType* T) {
5295 bool UnnamedLocalNoLinkageFinder::VisitBlockPointerType(
5300 bool UnnamedLocalNoLinkageFinder::VisitLValueReferenceType(
5305 bool UnnamedLocalNoLinkageFinder::VisitRValueReferenceType(
5310 bool UnnamedLocalNoLinkageFinder::VisitMemberPointerType(
5315 bool UnnamedLocalNoLinkageFinder::VisitConstantArrayType(
5320 bool UnnamedLocalNoLinkageFinder::VisitIncompleteArrayType(
5325 bool UnnamedLocalNoLinkageFinder::VisitVariableArrayType(
5330 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedArrayType(
5335 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedExtVectorType(
5340 bool UnnamedLocalNoLinkageFinder::VisitDependentAddressSpaceType(
5345 bool UnnamedLocalNoLinkageFinder::VisitVectorType(
const VectorType* T) {
5349 bool UnnamedLocalNoLinkageFinder::VisitDependentVectorType(
5354 bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(
const ExtVectorType* T) {
5358 bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
5368 bool UnnamedLocalNoLinkageFinder::VisitFunctionNoProtoType(
5373 bool UnnamedLocalNoLinkageFinder::VisitUnresolvedUsingType(
5378 bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(
const TypeOfExprType*) {
5382 bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(
const TypeOfType* T) {
5386 bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(
const DecltypeType*) {
5390 bool UnnamedLocalNoLinkageFinder::VisitUnaryTransformType(
5395 bool UnnamedLocalNoLinkageFinder::VisitAutoType(
const AutoType *T) {
5399 bool UnnamedLocalNoLinkageFinder::VisitDeducedTemplateSpecializationType(
5404 bool UnnamedLocalNoLinkageFinder::VisitRecordType(
const RecordType* T) {
5405 return VisitTagDecl(T->
getDecl());
5408 bool UnnamedLocalNoLinkageFinder::VisitEnumType(
const EnumType* T) {
5409 return VisitTagDecl(T->
getDecl());
5412 bool UnnamedLocalNoLinkageFinder::VisitTemplateTypeParmType(
5417 bool UnnamedLocalNoLinkageFinder::VisitSubstTemplateTypeParmPackType(
5422 bool UnnamedLocalNoLinkageFinder::VisitTemplateSpecializationType(
5427 bool UnnamedLocalNoLinkageFinder::VisitInjectedClassNameType(
5429 return VisitTagDecl(T->
getDecl());
5432 bool UnnamedLocalNoLinkageFinder::VisitDependentNameType(
5437 bool UnnamedLocalNoLinkageFinder::VisitDependentTemplateSpecializationType(
5442 bool UnnamedLocalNoLinkageFinder::VisitPackExpansionType(
5447 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectType(
const ObjCObjectType *) {
5451 bool UnnamedLocalNoLinkageFinder::VisitObjCInterfaceType(
5456 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectPointerType(
5461 bool UnnamedLocalNoLinkageFinder::VisitAtomicType(
const AtomicType* T) {
5465 bool UnnamedLocalNoLinkageFinder::VisitPipeType(
const PipeType* T) {
5469 bool UnnamedLocalNoLinkageFinder::VisitTagDecl(
const TagDecl *Tag) {
5471 S.
Diag(SR.getBegin(),
5473 diag::warn_cxx98_compat_template_arg_local_type :
5474 diag::ext_template_arg_local_type)
5480 S.
Diag(SR.getBegin(),
5482 diag::warn_cxx98_compat_template_arg_unnamed_type :
5483 diag::ext_template_arg_unnamed_type) << SR;
5491 bool UnnamedLocalNoLinkageFinder::VisitNestedNameSpecifier(
5508 llvm_unreachable(
"Invalid NestedNameSpecifier::Kind!");
5518 assert(ArgInfo &&
"invalid TypeSourceInfo");
5523 return Diag(SR.
getBegin(), diag::err_variably_modified_template_arg) << Arg;
5525 return Diag(SR.
getBegin(), diag::err_template_arg_overload_type) << SR;
5536 UnnamedLocalNoLinkageFinder Finder(*
this, SR);
5554 Decl *Entity =
nullptr) {
5560 if (Entity && Entity->hasAttr<DLLImportAttr>())
5565 "Incomplete parameter type in isNullPointerValueTemplateArgument!");
5578 EvalResult.
Diag = &Notes;
5586 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
5587 diag::note_invalid_subexpr_in_const_expr) {
5588 DiagLoc = Notes[0].first;
5592 S.
Diag(DiagLoc, diag::err_template_arg_not_address_constant)
5594 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
5595 S.
Diag(Notes[I].first, Notes[I].second);
5613 bool ObjCLifetimeConversion;
5616 ObjCLifetimeConversion))
5621 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
5630 std::string Code =
"static_cast<" + ParamType.
getAsString() +
">(";
5631 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_untyped_null_constant)
5650 bool ObjCLifetimeConversion;
5654 ObjCLifetimeConversion)) {
5659 if (!ParamRef->getPointeeType()->isFunctionType()) {
5669 unsigned ParamQuals = ParamRef->getPointeeType().getCVRQualifiers();
5672 if ((ParamQuals | ArgQuals) != ParamQuals) {
5674 diag::err_template_arg_ref_bind_ignores_quals)
5710 bool Invalid =
false;
5714 bool AddressTaken =
false;
5721 bool ExtWarnMSTemplateArg =
false;
5724 while (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(Arg)) {
5726 if (UnOpKind == UO_Deref)
5727 ExtWarnMSTemplateArg =
true;
5728 if (UnOpKind == UO_AddrOf || UnOpKind == UO_Deref) {
5731 FirstOpKind = UnOpKind;
5732 FirstOpLoc = UnOp->getOperatorLoc();
5738 if (ExtWarnMSTemplateArg)
5742 if (FirstOpKind == UO_AddrOf)
5743 AddressTaken =
true;
5747 assert(FirstOpKind == UO_Deref);
5770 bool ExtraParens =
false;
5771 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
5772 if (!Invalid && !ExtraParens) {
5775 ? diag::warn_cxx98_compat_template_arg_extra_parens
5776 : diag::ext_template_arg_extra_parens)
5781 Arg = Parens->getSubExpr();
5785 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
5789 if (UnOp->getOpcode() == UO_AddrOf) {
5790 Arg = UnOp->getSubExpr();
5791 AddressTaken =
true;
5792 AddrOpLoc = UnOp->getOperatorLoc();
5797 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
5809 S.
Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
5829 if (isa<CXXUuidofExpr>(Arg)) {
5831 ArgIn, Arg, ArgType))
5846 if (isa<FieldDecl>(Entity) || isa<IndirectFieldDecl>(Entity)) {
5854 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Entity)) {
5855 if (!Method->isStatic()) {
5867 if (!Func && !Var) {
5878 diag::warn_cxx98_compat_template_arg_object_internal :
5879 diag::ext_template_arg_object_internal)
5881 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
5883 }
else if (!Entity->hasLinkage()) {
5886 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
5901 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
5907 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
5916 if (Var->getType()->isReferenceType()) {
5918 diag::err_template_arg_reference_var)
5925 if (Var->getTLSKind()) {
5928 S.
Diag(Var->getLocation(), diag::note_template_arg_refers_here);
5941 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
5947 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
5952 ArgType = Var->getType();
5955 if (Var->getType()->isArrayType()) {
5997 bool Invalid =
false;
5999 Expr *Arg = ResultArg;
6000 bool ObjCLifetimeConversion;
6012 bool ExtraParens =
false;
6013 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
6014 if (!Invalid && !ExtraParens) {
6017 diag::warn_cxx98_compat_template_arg_extra_parens :
6018 diag::ext_template_arg_extra_parens)
6023 Arg = Parens->getSubExpr();
6027 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6032 if (UnOp->getOpcode() == UO_AddrOf) {
6039 else if ((DRE = dyn_cast<DeclRefExpr>(Arg))) {
6042 if (isa<NonTypeTemplateParmDecl>(VD)) {
6064 S.
Diag(ResultArg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
6074 ObjCLifetimeConversion)) {
6081 S.
Diag(ResultArg->
getLocStart(), diag::err_template_arg_not_convertible)
6089 diag::err_template_arg_not_pointer_to_member_form)
6092 if (isa<FieldDecl>(DRE->
getDecl()) ||
6093 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
6094 isa<CXXMethodDecl>(DRE->
getDecl())) {
6095 assert((isa<FieldDecl>(DRE->
getDecl()) ||
6096 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
6097 !cast<CXXMethodDecl>(DRE->
getDecl())->isStatic()) &&
6098 "Only non-static member pointers can make it here");
6113 diag::err_template_arg_not_pointer_to_member_form)
6140 auto *AT = dyn_cast<
AutoType>(ParamType);
6141 if (AT && AT->isDecltypeAuto()) {
6151 if (CTAK != CTAK_Specified)
6155 Arg, ParamType, Depth) == DAR_Failed) {
6157 diag::err_non_type_template_parm_type_deduction_failure)
6167 ParamType = CheckNonTypeTemplateParameterType(ParamType, Arg->
getExprLoc());
6168 if (ParamType.
isNull()) {
6176 "non-type template parameter type cannot be qualified");
6178 if (CTAK == CTAK_Deduced &&
6197 Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
6223 Arg, ParamType, Value, CCEK_TemplateArg);
6229 if (ArgResult.
get()->isValueDependent()) {
6252 diag::err_template_arg_member_ptr_base_derived_not_supported)
6260 : TemplateArgument(CanonParamType,
true);
6273 if (isa<CXXUuidofExpr>(E)) {
6285 VD && VD->getType()->isArrayType() &&
6293 Diag(StartLoc, diag::err_non_type_template_arg_subobject)
6298 "null reference should not be a constant expression");
6300 "non-null value of type nullptr_t?");
6302 : TemplateArgument(CanonParamType,
true);
6306 return Diag(StartLoc, diag::err_non_type_template_arg_addr_label_diff);
6314 llvm_unreachable(
"invalid kind for template argument");
6317 return ArgResult.
get();
6337 if (getLangOpts().CPlusPlus11) {
6353 if (ArgResult.
get()->isValueDependent()) {
6363 IntegerType = Enum->getDecl()->getIntegerType();
6364 Value = Value.extOrTrunc(Context.
getTypeSize(IntegerType));
6371 ExprResult ArgResult = DefaultLvalueConversion(Arg);
6374 Arg = ArgResult.
get();
6388 diag::err_template_arg_not_integral_or_enumeral)
6397 TmplArgICEDiagnoser(
QualType T) : T(T) { }
6401 S.
Diag(Loc, diag::err_template_arg_not_ice) << T << SR;
6403 } Diagnoser(ArgType);
6405 Arg = VerifyIntegerConstantExpression(Arg, &Value, Diagnoser,
6420 Arg = ImpCastExprToType(Arg, ParamType, CK_IntegralToBoolean).get();
6421 }
else if (IsIntegralPromotion(Arg, ArgType, ParamType) ||
6424 Arg = ImpCastExprToType(Arg, ParamType, CK_IntegralCast).get();
6428 diag::err_template_arg_not_convertible)
6451 unsigned AllowedBits = Context.
getTypeSize(IntegerType);
6452 if (Value.getBitWidth() != AllowedBits)
6453 Value = Value.extOrTrunc(AllowedBits);
6456 llvm::APSInt OldValue =
Value;
6460 unsigned AllowedBits = Context.
getTypeSize(IntegerType);
6461 if (Value.getBitWidth() != AllowedBits)
6462 Value = Value.extOrTrunc(AllowedBits);
6467 && (OldValue.isSigned() && OldValue.isNegative())) {
6469 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
6475 unsigned RequiredBits;
6477 RequiredBits = OldValue.getActiveBits();
6478 else if (OldValue.isUnsigned())
6479 RequiredBits = OldValue.getActiveBits() + 1;
6481 RequiredBits = OldValue.getMinSignedBits();
6482 if (RequiredBits > AllowedBits) {
6484 diag::warn_template_arg_too_large)
6485 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
6526 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg, ParamType,
6532 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
6558 "Only object pointers allowed here");
6574 assert(ParamRefType->getPointeeType()->isIncompleteOrObjectType() &&
6575 "Only object references allowed here");
6578 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg,
6579 ParamRefType->getPointeeType(),
6585 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
6608 << Arg->
getType() << ParamType;
6616 Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
6648 assert(Name.
isDependent() &&
"Non-dependent template isn't a declaration?");
6667 if (!isa<ClassTemplateDecl>(Template) &&
6668 !isa<TemplateTemplateParmDecl>(Template) &&
6669 !isa<TypeAliasTemplateDecl>(Template) &&
6670 !isa<BuiltinTemplateDecl>(Template)) {
6671 assert(isa<FunctionTemplateDecl>(Template) &&
6672 "Only function templates are possible here");
6674 Diag(Template->
getLocation(), diag::note_template_arg_refers_here_func)
6681 if (getLangOpts().RelaxedTemplateTemplateArgs) {
6686 if (TemplateParameterListsAreEqual(
6688 TPL_TemplateTemplateArgumentMatch, Arg.
getLocation()))
6691 if (isTemplateTemplateParameterAtLeastAsSpecializedAs(Params, Template,
6700 TPL_TemplateTemplateArgumentMatch,
6725 return ImpCastExprToType(
6729 ? CK_NullToMemberPointer
6730 : CK_NullToPointer);
6733 "Only declaration template arguments permitted here");
6737 if (VD->getDeclContext()->isRecord() &&
6738 (isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD) ||
6739 isa<IndirectFieldDecl>(VD))) {
6758 if (isa<CXXMethodDecl>(VD) && cast<CXXMethodDecl>(VD)->isInstance())
6762 VD->getType().getNonReferenceType(),
6769 RefExpr = CreateBuiltinUnaryOp(Loc, UO_AddrOf, RefExpr.
get());
6774 bool ObjCLifetimeConversion;
6775 if (IsQualificationConversion(((
Expr*) RefExpr.
get())->getType(),
6777 ObjCLifetimeConversion))
6787 QualType T = VD->getType().getNonReferenceType();
6799 RefExpr = DefaultFunctionArrayConversion(RefExpr.
get());
6807 return CreateBuiltinUnaryOp(Loc, UO_AddrOf, RefExpr.
get());
6819 }
else if (isa<FunctionDecl>(VD)) {
6824 return BuildDeclRefExpr(VD, T, VK, Loc);
6838 "Operation is only valid for integral template arguments");
6848 T = ET->getDecl()->getIntegerType();
6875 if (OrigT->isEnumeralType()) {
6895 unsigned NextDiag = diag::err_template_param_different_kind;
6896 if (TemplateArgLoc.
isValid()) {
6897 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
6898 NextDiag = diag::note_template_param_different_kind;
6917 unsigned NextDiag = diag::err_template_parameter_pack_non_pack;
6918 if (TemplateArgLoc.
isValid()) {
6919 S.
Diag(TemplateArgLoc,
6920 diag::err_template_arg_template_params_mismatch);
6921 NextDiag = diag::note_template_parameter_pack_non_pack;
6924 unsigned ParamKind = isa<TemplateTypeParmDecl>(New)? 0
6925 : isa<NonTypeTemplateParmDecl>(New)? 1
6938 = dyn_cast<NonTypeTemplateParmDecl>(Old)) {
6946 (OldNTTP->getType()->isDependentType() ||
6952 unsigned NextDiag = diag::err_template_nontype_parm_different_type;
6953 if (TemplateArgLoc.
isValid()) {
6954 S.
Diag(TemplateArgLoc,
6955 diag::err_template_arg_template_params_mismatch);
6956 NextDiag = diag::note_template_nontype_parm_different_type;
6961 S.
Diag(OldNTTP->getLocation(),
6962 diag::note_template_nontype_parm_prev_declaration)
6963 << OldNTTP->getType();
6976 = dyn_cast<TemplateTemplateParmDecl>(Old)) {
6979 OldTTP->getTemplateParameters(),
6998 unsigned NextDiag = diag::err_template_param_list_different_arity;
6999 if (TemplateArgLoc.
isValid()) {
7000 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
7001 NextDiag = diag::note_template_param_list_different_arity;
7041 if (Old->
size() != New->
size() && Kind != TPL_TemplateTemplateArgumentMatch) {
7058 OldParmEnd = Old->
end();
7059 OldParm != OldParmEnd; ++OldParm) {
7060 if (Kind != TPL_TemplateTemplateArgumentMatch ||
7061 !(*OldParm)->isTemplateParameterPack()) {
7062 if (NewParm == NewParmEnd) {
7071 Kind, TemplateArgLoc))
7085 for (; NewParm != NewParmEnd; ++NewParm) {
7087 Kind, TemplateArgLoc))
7093 if (NewParm != NewParmEnd) {
7125 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
7139 if (RD->isLocalClass())
7141 diag::err_template_inside_local_class)
7149 diag::err_template_outside_namespace_or_class_scope)
7160 return Record->getTemplateSpecializationKind();
7161 if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(D))
7162 return Function->getTemplateSpecializationKind();
7163 if (
VarDecl *Var = dyn_cast<VarDecl>(D))
7164 return Var->getTemplateSpecializationKind();
7201 if (isa<ClassTemplateDecl>(Specialized))
7202 EntityKind = IsPartialSpecialization? 1 : 0;
7203 else if (isa<VarTemplateDecl>(Specialized))
7204 EntityKind = IsPartialSpecialization ? 3 : 2;
7205 else if (isa<FunctionTemplateDecl>(Specialized))
7207 else if (isa<CXXMethodDecl>(Specialized))
7209 else if (isa<VarDecl>(Specialized))
7211 else if (isa<RecordDecl>(Specialized))
7213 else if (isa<EnumDecl>(Specialized) && S.
getLangOpts().CPlusPlus11)
7216 S.
Diag(Loc, diag::err_template_spec_unknown_kind)
7226 S.
Diag(Loc, diag::err_template_spec_decl_function_scope)
7241 : DC->
Equals(SpecializedContext))) {
7242 if (isa<TranslationUnitDecl>(SpecializedContext))
7243 S.
Diag(Loc, diag::err_template_spec_redecl_global_scope)
7244 << EntityKind << Specialized;
7246 auto *ND = cast<NamedDecl>(SpecializedContext);
7247 int Diag = diag::err_template_spec_redecl_out_of_scope;
7249 Diag = diag::ext_ms_template_spec_redecl_out_of_scope;
7250 S.
Diag(Loc, Diag) << EntityKind << Specialized
7251 << ND << isa<CXXRecordDecl>(ND);
7254 S.
Diag(Specialized->getLocation(), diag::note_specialized_entity);
7268 DependencyChecker Checker(Depth,
true);
7269 Checker.TraverseStmt(E);
7270 if (Checker.MatchLoc.isInvalid())
7272 return Checker.MatchLoc;
7278 DependencyChecker Checker(Depth,
true);
7279 Checker.TraverseTypeLoc(TL);
7280 if (Checker.MatchLoc.isInvalid())
7282 return Checker.MatchLoc;
7290 for (
unsigned I = 0; I != NumArgs; ++I) {
7293 S, TemplateNameLoc, Param, Args[I].pack_begin(),
7294 Args[I].pack_size(), IsDefaultArgument))
7307 ArgExpr = Expansion->getPattern();
7311 ArgExpr = ICE->getSubExpr();
7321 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ArgExpr))
7322 if (isa<NonTypeTemplateParmDecl>(DRE->getDecl()))
7342 if (ParamUseRange.
isValid()) {
7343 if (IsDefaultArgument) {
7344 S.
Diag(TemplateNameLoc,
7345 diag::err_dependent_non_type_arg_in_partial_spec);
7347 diag::note_dependent_non_type_default_arg_in_partial_spec)
7351 diag::err_dependent_non_type_arg_in_partial_spec)
7359 if (ParamUseRange.
isValid()) {
7361 diag::err_dependent_typed_non_type_arg_in_partial_spec)
7364 << (IsDefaultArgument ? ParamUseRange :
SourceRange())
7394 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
7401 Param, &TemplateArgs[I],
7402 1, I >= NumExplicit))
7414 assert(TUK != TUK_Reference &&
"References are not specializations");
7421 ? TemplateParameterLists[0]->getTemplateLoc() : KWLoc;
7431 if (!ClassTemplate) {
7432 Diag(TemplateNameLoc, diag::err_not_class_template_specialization)
7438 bool isMemberSpecialization =
false;
7439 bool isPartialSpecialization =
false;
7445 bool Invalid =
false;
7447 MatchTemplateParametersToScopeSpecifier(
7448 KWLoc, TemplateNameLoc, SS, &TemplateId,
7449 TemplateParameterLists, TUK == TUK_Friend, isMemberSpecialization,
7454 if (TemplateParams && TemplateParams->
size() > 0) {
7455 isPartialSpecialization =
true;
7457 if (TUK == TUK_Friend) {
7458 Diag(KWLoc, diag::err_partial_specialization_friend)
7466 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
7469 if (TTP->hasDefaultArgument()) {
7470 Diag(TTP->getDefaultArgumentLoc(),
7471 diag::err_default_arg_in_partial_spec);
7472 TTP->removeDefaultArgument();
7475 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
7476 if (
Expr *DefArg = NTTP->getDefaultArgument()) {
7477 Diag(NTTP->getDefaultArgumentLoc(),
7478 diag::err_default_arg_in_partial_spec)
7479 << DefArg->getSourceRange();
7480 NTTP->removeDefaultArgument();
7486 diag::err_default_arg_in_partial_spec)
7492 }
else if (TemplateParams) {
7493 if (TUK == TUK_Friend)
7494 Diag(KWLoc, diag::err_template_spec_friend)
7500 assert(TUK == TUK_Friend &&
"should have a 'template<>' for this decl");
7506 assert(Kind !=
TTK_Enum &&
"Invalid enum tag in class template spec!");
7508 Kind, TUK == TUK_Definition, KWLoc,
7510 Diag(KWLoc, diag::err_use_with_wrong_tag)
7515 diag::note_previous_use);
7524 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
7525 if (DiagnoseUnexpandedParameterPack(TemplateArgs[I],
7526 UPPC_PartialSpecialization))
7532 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
7533 TemplateArgs,
false, Converted))
7538 if (isPartialSpecialization) {
7539 if (CheckTemplatePartialSpecializationArgs(TemplateNameLoc, ClassTemplate,
7540 TemplateArgs.
size(), Converted))
7545 bool InstantiationDependent;
7548 TemplateArgs.
arguments(), InstantiationDependent)) {
7549 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
7551 isPartialSpecialization =
false;
7555 void *InsertPos =
nullptr;
7558 if (isPartialSpecialization)
7568 if (TUK != TUK_Friend &&
7571 isPartialSpecialization))
7576 if (isPartialSpecialization) {
7592 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
7593 << 0 << (TUK == TUK_Definition)
7595 return CheckClassTemplate(S, TagSpec, TUK, KWLoc, SS,
7602 TemplateParameterLists.size() - 1,
7603 TemplateParameterLists.data());
7608 = cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl);
7612 KWLoc, TemplateNameLoc,
7620 if (TemplateParameterLists.size() > 1 && SS.
isSet()) {
7621 Partial->setTemplateParameterListsInfo(
7622 Context, TemplateParameterLists.drop_back(1));
7626 ClassTemplate->AddPartialSpecialization(Partial, InsertPos);
7627 Specialization = Partial;
7631 if (PrevPartial && PrevPartial->getInstantiatedFromMember())
7632 PrevPartial->setMemberSpecialization();
7634 CheckTemplatePartialSpecialization(Partial);
7641 KWLoc, TemplateNameLoc,
7646 if (TemplateParameterLists.size() > 0) {
7648 TemplateParameterLists);
7652 ClassTemplate->AddSpecialization(Specialization, InsertPos);
7654 if (CurContext->isDependentContext()) {
7657 CanonTemplate, Converted);
7681 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
7685 diag::note_instantiation_required_here)
7693 if (TUK != TUK_Friend)
7697 if (TUK == TUK_Definition) {
7700 if (Def && SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
7702 makeMergedDefinitionVisible(Hidden);
7704 TUK = TUK_Declaration;
7707 Diag(TemplateNameLoc, diag::err_redefinition) << Specialization << Range;
7714 ProcessDeclAttributeList(S, Specialization, Attr);
7718 if (TUK == TUK_Definition) {
7719 AddAlignmentAttributesForRecord(Specialization);
7720 AddMsStructLayoutForRecord(Specialization);
7723 if (ModulePrivateLoc.
isValid())
7724 Diag(Specialization->
getLocation(), diag::err_module_private_specialization)
7725 << (isPartialSpecialization? 1 : 0)
7737 TemplateArgs, CanonType);
7738 if (TUK != TUK_Friend) {
7754 if (TUK == TUK_Definition)
7757 if (TUK == TUK_Friend) {
7763 CurContext->addDecl(Friend);
7768 CurContext->addDecl(Specialization);
7770 return Specialization;
7776 Decl *NewDecl = HandleDeclarator(S, D, TemplateParameterLists);
7777 ActOnDocumentableDecl(NewDecl);
7788 FD->setInlineSpecified(
false);
7799 for (
Decl *Prev = D; Prev && !PrevDiagLoc.
isValid();
7800 Prev = Prev->getPreviousDecl()) {
7801 PrevDiagLoc = Prev->getLocation();
7803 assert(PrevDiagLoc.
isValid() &&
7804 "Explicit instantiation without point of instantiation?");
7836 bool &HasNoEffect) {
7837 HasNoEffect =
false;
7844 "previous declaration must be implicit!");
7857 if (PrevPointOfInstantiation.
isInvalid()) {
7869 PrevPointOfInstantiation.
isValid()) &&
7870 "Explicit instantiation without point of instantiation?");
7884 Diag(NewLoc, diag::err_specialization_after_instantiation)
7886 Diag(PrevPointOfInstantiation, diag::note_instantiation_required_here)
7891 llvm_unreachable(
"The switch over PrevTSK must be exhaustive.");
7921 diag::err_explicit_instantiation_declaration_after_definition);
7927 diag::note_explicit_instantiation_definition_here);
7946 Diag(NewLoc, diag::warn_explicit_instantiation_after_specialization)
7949 diag::note_previous_template_specialization);
7979 Diag(NewLoc, (getLangOpts().MSVCCompat)
7980 ? diag::ext_explicit_instantiation_duplicate
7981 : diag::err_explicit_instantiation_duplicate)
7984 diag::note_previous_explicit_instantiation);
7990 llvm_unreachable(
"Missing specialization/instantiation case?");
8016 enum DiscardReason { NotAFunctionTemplate, NotAMemberOfEnclosing };
8020 if (!isa<FunctionTemplateDecl>(D)) {
8022 DiscardedCandidates.push_back(std::make_pair(NotAFunctionTemplate, D));
8029 DiscardedCandidates.push_back(std::make_pair(NotAMemberOfEnclosing, D));
8035 if (Previous.
empty()) {
8037 diag::err_dependent_function_template_spec_no_match);
8038 for (
auto &
P : DiscardedCandidates)
8039 Diag(
P.second->getLocation(),
8040 diag::note_dependent_function_template_spec_discard_reason)
8046 ExplicitTemplateArgs);
8077 llvm::SmallDenseMap<FunctionDecl *, TemplateArgumentListInfo, 8>
8078 ConvertedTemplateArgs;
8100 if (OldMD && OldMD->
isConst()) {
8110 if (ExplicitTemplateArgs)
8111 Args = *ExplicitTemplateArgs;
8123 cast<FunctionTemplateDecl>(FunTmpl->getFirstDecl()),
8124 ExplicitTemplateArgs ? &Args :
nullptr, FT, Specialization,
8128 FailedCandidates.addCandidate().set(
8129 I.getPair(), FunTmpl->getTemplatedDecl(),
8140 if (LangOpts.CUDA &&
8141 IdentifyCUDATarget(Specialization,
8143 IdentifyCUDATarget(FD,
true)) {
8144 FailedCandidates.addCandidate().set(
8145 I.getPair(), FunTmpl->getTemplatedDecl(),
8151 if (ExplicitTemplateArgs)
8152 ConvertedTemplateArgs[Specialization] = std::move(Args);
8153 Candidates.
addDecl(Specialization, I.getAccess());
8159 Candidates.
begin(), Candidates.
end(), FailedCandidates,
8161 PDiag(diag::err_function_template_spec_no_match) << FD->
getDeclName(),
8162 PDiag(diag::err_function_template_spec_ambiguous)
8163 << FD->
getDeclName() << (ExplicitTemplateArgs !=
nullptr),
8164 PDiag(diag::note_function_template_spec_matched));
8166 if (Result == Candidates.
end())
8170 FunctionDecl *Specialization = cast<FunctionDecl>(*Result);
8174 assert(SpecInfo &&
"Function template specialization info missing?");
8212 bool HasNoEffect =
false;
8214 CheckSpecializationInstantiationRedecl(FD->
getLocation(),
8234 !Specialization->getCanonicalDecl()->isReferenced()) {
8237 Specialization->getCanonicalDecl() == Specialization &&
8238 "This must be the only existing declaration of this specialization");
8240 Specialization->setDeletedAsWritten(
false);
8244 MarkUnusedFileScopedDecl(Specialization);
8253 FD->setFunctionTemplateSpecialization(
8254 Specialization->getPrimaryTemplate(), TemplArgs,
nullptr,
8256 ExplicitTemplateArgs ? &ConvertedTemplateArgs[Specialization] :
nullptr);
8269 Previous.
addDecl(Specialization);
8289 assert(!isa<TemplateDecl>(Member) &&
"Only for non-template members");
8292 NamedDecl *FoundInstantiation =
nullptr;
8297 if (Previous.
empty()) {
8299 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(Member)) {
8302 NamedDecl *D = (*I)->getUnderlyingDecl();
8304 QualType Adjusted = Function->getType();
8305 if (!hasExplicitCallingConv(Adjusted))
8306 Adjusted = adjustCCAndNoReturn(Adjusted, Method->getType());
8307 if (Context.
hasSameType(Adjusted, Method->getType())) {
8308 FoundInstantiation = *I;
8309 Instantiation = Method;
8310 InstantiatedFrom = Method->getInstantiatedFromMemberFunction();
8311 MSInfo = Method->getMemberSpecializationInfo();
8316 }
else if (isa<VarDecl>(Member)) {
8322 Instantiation = PrevVar;
8326 }
else if (isa<RecordDecl>(Member)) {
8331 Instantiation = PrevRecord;
8335 }
else if (isa<EnumDecl>(Member)) {
8340 Instantiation = PrevEnum;
8346 if (!Instantiation) {
8360 if (InstantiatedFrom && isa<CXXMethodDecl>(Member)) {
8361 cast<CXXMethodDecl>(Member)->setInstantiationOfMemberFunction(
8362 cast<CXXMethodDecl>(InstantiatedFrom),
8364 }
else if (InstantiatedFrom && isa<CXXRecordDecl>(Member)) {
8365 cast<CXXRecordDecl>(Member)->setInstantiationOfMemberClass(
8366 cast<CXXRecordDecl>(InstantiatedFrom),
8371 Previous.
addDecl(FoundInstantiation);
8376 if (!InstantiatedFrom) {
8389 assert(MSInfo &&
"Member specialization info missing?");
8391 bool HasNoEffect =
false;
8392 if (CheckSpecializationInstantiationRedecl(Member->
getLocation(),
8409 if (
auto *MemberFunction = dyn_cast<FunctionDecl>(Member)) {
8410 FunctionDecl *InstantiationFunction = cast<FunctionDecl>(Instantiation);
8415 if (InstantiationFunction->
isDeleted()) {
8418 InstantiationFunction);
8424 MemberFunction->setInstantiationOfMemberFunction(
8426 }
else if (
auto *MemberVar = dyn_cast<VarDecl>(Member)) {
8427 MemberVar->setInstantiationOfStaticDataMember(
8429 }
else if (
auto *MemberClass = dyn_cast<CXXRecordDecl>(Member)) {
8430 MemberClass->setInstantiationOfMemberClass(
8432 }
else if (
auto *MemberEnum = dyn_cast<EnumDecl>(Member)) {
8433 MemberEnum->setInstantiationOfMemberEnum(
8436 llvm_unreachable(
"unknown member specialization kind");
8442 Previous.
addDecl(FoundInstantiation);
8451 template<
typename DeclT>
8462 OrigD->setLocation(Loc);
8468 if (Instantiation == Member)
8471 if (
auto *Function = dyn_cast<CXXMethodDecl>(Instantiation))
8473 else if (
auto *Var = dyn_cast<VarDecl>(Instantiation))
8475 else if (
auto *Record = dyn_cast<CXXRecordDecl>(Instantiation))
8477 else if (
auto *Enum = dyn_cast<EnumDecl>(Instantiation))
8480 llvm_unreachable(
"unknown member specialization kind");
8488 bool WasQualifiedName) {
8493 S.
Diag(InstLoc, diag::err_explicit_instantiation_in_class)
8506 if (WasQualifiedName) {
8507 if (CurContext->
Encloses(OrigContext))
8514 if (
NamespaceDecl *NS = dyn_cast<NamespaceDecl>(OrigContext)) {
8515 if (WasQualifiedName)
8518 diag::err_explicit_instantiation_out_of_scope :
8519 diag::warn_explicit_instantiation_out_of_scope_0x)
8524 diag::err_explicit_instantiation_unqualified_wrong_namespace :
8525 diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x)
8530 diag::err_explicit_instantiation_must_be_global :
8531 diag::warn_explicit_instantiation_must_be_global_0x)
8552 if (isa<TemplateSpecializationType>(T))
8562 auto *A = cast_or_null<InheritableAttr>(
getDLLAttr(Def));
8563 assert(A &&
"dllExportImportClassTemplateSpecialization called " 8564 "on Def without dllexport or dllimport");
8569 "delayed exports present at explicit instantiation");
8573 for (
auto &B : Def->
bases()) {
8574 if (
auto *BT = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
8575 B.getType()->getAsCXXRecordDecl()))
8596 "Invalid enum tag in class template explicit instantiation!");
8600 if (!ClassTemplate) {
8601 NonTagKind NTK = getNonTagTypeDeclKind(TD, Kind);
8602 Diag(TemplateNameLoc, diag::err_tag_reference_non_tag) << TD << NTK <<
Kind;
8610 Diag(KWLoc, diag::err_use_with_wrong_tag)
8615 diag::note_previous_use);
8630 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
8632 diag::warn_attribute_dllexport_explicit_instantiation_decl);
8633 Diag(AL.getLoc(), diag::note_attribute);
8640 diag::warn_attribute_dllexport_explicit_instantiation_decl);
8641 Diag(A->getLocation(), diag::note_attribute);
8647 bool DLLImportExplicitInstantiationDef =
false;
8654 if (AL.getKind() == ParsedAttr::AT_DLLImport)
8656 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
8664 DLLImportExplicitInstantiationDef =
true;
8670 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
8675 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
8676 TemplateArgs,
false, Converted))
8681 void *InsertPos =
nullptr;
8699 bool HasNoEffect =
false;
8701 if (CheckSpecializationInstantiationRedecl(TemplateNameLoc, TSK,
8702 PrevDecl, PrevDecl_TSK,
8717 Specialization = PrevDecl;
8723 DLLImportExplicitInstantiationDef) {
8725 HasNoEffect =
false;
8729 if (!Specialization) {
8735 KWLoc, TemplateNameLoc,
8741 if (!HasNoEffect && !PrevDecl) {
8743 ClassTemplate->AddSpecialization(Specialization, InsertPos);
8765 bool PreviouslyDLLExported = Specialization->
hasAttr<DLLExportAttr>();
8766 ProcessDeclAttributeList(S, Specialization, Attr);
8772 CurContext->addDecl(Specialization);
8778 return Specialization;
8789 = cast_or_null<ClassTemplateSpecializationDecl>(
8792 InstantiateClassTemplateSpecialization(TemplateNameLoc, Specialization, TSK);
8794 MarkVTableUsed(TemplateNameLoc, Specialization,
true);
8799 Def = cast_or_null<ClassTemplateSpecializationDecl>(
8807 DLLImportExplicitInstantiationDef)) {
8817 auto *A = cast<InheritableAttr>(
8819 A->setInherited(
true);
8827 bool NewlyDLLExported =
8828 !PreviouslyDLLExported && Specialization->
hasAttr<DLLExportAttr>();
8844 assert(Def == Specialization &&
8845 "Def and Specialization should match for implicit instantiation");
8852 InstantiateClassTemplateSpecializationMembers(TemplateNameLoc, Def, TSK);
8859 return Specialization;
8871 bool IsDependent =
false;
8873 KWLoc, SS, Name, NameLoc, Attr,
AS_none,
8879 assert(!IsDependent &&
"explicit instantiation of dependent name not yet handled");
8884 TagDecl *Tag = cast<TagDecl>(TagD);
8885 assert(!Tag->
isEnum() &&
"shouldn't see enumerations here");
8893 Diag(TemplateLoc, diag::err_explicit_instantiation_nontemplate_type)
8906 Diag(TemplateLoc, diag::ext_explicit_instantiation_without_qualified_id)
8931 bool HasNoEffect =
false;
8932 assert(MSInfo &&
"No member specialization information?");
8933 if (CheckSpecializationInstantiationRedecl(TemplateLoc, TSK,
8950 = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
8952 Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member)
8954 Diag(Pattern->getLocation(), diag::note_forward_declaration)
8958 if (InstantiateClass(NameLoc, Record, Def,
8959 getTemplateInstantiationArgs(Record),
8963 RecordDef = cast_or_null<CXXRecordDecl>(Record->
getDefinition());
8970 InstantiateClassMembers(NameLoc, RecordDef,
8971 getTemplateInstantiationArgs(Record), TSK);
8974 MarkVTableUsed(NameLoc, RecordDef,
true);
8994 diag::err_explicit_instantiation_requires_name)
9036 getLangOpts().CPlusPlus11 ?
9037 diag::err_explicit_instantiation_inline :
9038 diag::warn_explicit_instantiation_inline_0x)
9044 diag::err_explicit_instantiation_constexpr);
9079 if (!PrevTemplate) {
9086 Diag((*P)->getLocation(), diag::note_explicit_instantiation_here);
9093 diag::err_explicit_instantiation_data_member_not_instantiated)
9109 diag::err_auto_not_allowed_var_inst);
9118 diag::err_explicit_instantiation_without_template_id)
9120 Diag(PrevTemplate->getLocation(),
9121 diag::note_explicit_instantiation_here);
9129 DeclResult Res = CheckVarTemplateId(PrevTemplate, TemplateLoc,
9131 if (Res.isInvalid())
9136 Prev = cast<VarDecl>(Res.get());
9151 diag::ext_explicit_instantiation_without_qualified_id)
9160 bool HasNoEffect =
false;
9161 if (CheckSpecializationInstantiationRedecl(D.
getIdentifierLoc(), TSK, Prev,
9162 PrevTSK, POI, HasNoEffect))
9177 if (PrevTemplate && Prev && !Context.
hasSameType(Prev->getType(), R)) {
9179 diag::err_invalid_var_template_spec_type)
9180 << 0 << PrevTemplate << R << Prev->getType();
9181 Diag(PrevTemplate->getLocation(), diag::note_template_declared_here)
9182 << 2 << PrevTemplate->getDeclName();
9187 return (
Decl*)
nullptr;
9192 bool HasExplicitTemplateArgs =
false;
9196 HasExplicitTemplateArgs =
true;
9210 if (!HasExplicitTemplateArgs) {
9211 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Prev)) {
9212 QualType Adjusted = adjustCCAndNoReturn(R, Method->getType(),
9215 if (Method->getPrimaryTemplate()) {
9216 TemplateMatches.
addDecl(Method,
P.getAccess());
9219 assert(!NonTemplateMatch &&
"Multiple NonTemplateMatches");
9220 NonTemplateMatch = Method;
9234 (HasExplicitTemplateArgs ? &TemplateArgs
9236 R, Specialization, Info)) {
9238 FailedCandidates.addCandidate()
9250 if (LangOpts.CUDA &&
9251 IdentifyCUDATarget(Specialization,
9254 FailedCandidates.addCandidate().set(
9260 TemplateMatches.
addDecl(Specialization,
P.getAccess());
9264 if (!Specialization) {
9267 TemplateMatches.
begin(), TemplateMatches.
end(), FailedCandidates,
9269 PDiag(diag::err_explicit_instantiation_not_known) << Name,
9270 PDiag(diag::err_explicit_instantiation_ambiguous) << Name,
9271 PDiag(diag::note_explicit_instantiation_candidate));
9273 if (Result == TemplateMatches.
end())
9277 Specialization = cast<FunctionDecl>(*Result);
9287 if (FPT->hasExceptionSpec()) {
9289 diag::err_mismatched_exception_spec_explicit_instantiation;
9290 if (getLangOpts().MicrosoftExt)
9291 DiagID = diag::ext_mismatched_exception_spec_explicit_instantiation;
9292 bool Result = CheckEquivalentExceptionSpec(
9293 PDiag(DiagID) << Specialization->
getType(),
9294 PDiag(diag::note_explicit_instantiation_here),
9299 if (!getLangOpts().MicrosoftExt && Result)
9305 diag::err_explicit_instantiation_member_function_not_instantiated)
9309 Diag(Specialization->
getLocation(), diag::note_explicit_instantiation_here);
9315 PrevDecl = Specialization;
9318 bool HasNoEffect =
false;
9322 PrevDecl->getPointOfInstantiation(),
9329 return (
Decl*)
nullptr;
9337 Specialization->
hasAttr<DLLImportAttr>() &&
9346 Consumer.HandleTopLevelDecl(
DeclGroupRef(Specialization));
9362 diag::ext_explicit_instantiation_without_qualified_id)
9372 return (
Decl*)
nullptr;
9380 assert(Name &&
"Expected a name in a dependent tag");
9388 if (TUK == TUK_Declaration || TUK == TUK_Definition) {
9389 Diag(NameLoc, diag::err_dependent_tag_decl)
9390 << (TUK == TUK_Definition) << Kind << SS.
getRange();
9416 getLangOpts().CPlusPlus11 ?
9417 diag::warn_cxx98_compat_typename_outside_of_template :
9418 diag::ext_typename_outside_of_template)
9423 TypenameLoc, QualifierLoc, II, IdLoc);
9428 if (isa<DependentNameType>(T)) {
9440 return CreateParsedType(T, TSI);
9456 getLangOpts().CPlusPlus11 ?
9457 diag::warn_cxx98_compat_typename_outside_of_template :
9458 diag::ext_typename_outside_of_template)
9465 dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS,
false));
9466 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
9468 diag::ext_out_of_line_qualified_id_type_names_constructor)
9470 << (TemplateKWLoc.
isValid() ? 1 : 0 );
9476 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
9481 assert(DTN &&
"dependent template has non-dependent name?");
9484 DTN->getQualifier(),
9485 DTN->getIdentifier(),
9498 for (
unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
9503 QualType T = CheckTemplateIdType(Template, TemplateIILoc, TemplateArgs);
9515 for (
unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
9524 return CreateParsedType(T, TSI);
9533 if (!II.
isStr(
"type"))
9542 if (!EnableIfTSTLoc || EnableIfTSTLoc.
getNumArgs() == 0)
9555 if (!EnableIfII || !EnableIfII->
isStr(
"enable_if"))
9585 SS.
Adopt(QualifierLoc);
9603 if (RequireCompleteDeclContext(SS, Ctx))
9607 LookupResult Result(*
this, Name, IILoc, LookupOrdinaryName);
9608 LookupQualifiedName(Result, Ctx, SS);
9609 unsigned DiagID = 0;
9610 Decl *Referenced =
nullptr;
9616 Expr *Cond =
nullptr;
9617 if (
isEnableIf(QualifierLoc, II, CondRange, Cond)) {
9622 std::string FailedDescription;
9623 std::tie(FailedCond, FailedDescription) =
9624 findFailedBooleanCondition(Cond,
true);
9627 diag::err_typename_nested_not_found_requirement)
9628 << FailedDescription
9633 Diag(CondRange.
getBegin(), diag::err_typename_nested_not_found_enable_if)
9634 << Ctx << CondRange;
9638 DiagID = diag::err_typename_nested_not_found;
9647 Diag(IILoc, diag::err_typename_refers_to_using_value_decl)
9648 << Name << Ctx << FullRange;
9652 Diag(Loc, diag::note_using_value_decl_missing_typename)
9682 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(Ctx);
9685 FoundRD->isInjectedClassName() &&
9687 Diag(IILoc, diag::ext_out_of_line_qualified_id_type_names_constructor)
9692 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
9702 if (getLangOpts().CPlusPlus17) {
9711 DiagID = diag::err_typename_nested_not_type;
9716 DiagID = diag::err_typename_nested_not_type;
9717 Referenced = *Result.
begin();
9728 Diag(IILoc, DiagID) << FullRange << Name << Ctx;
9737 class CurrentInstantiationRebuilder
9745 CurrentInstantiationRebuilder(
Sema &SemaRef,
9749 Loc(Loc), Entity(Entity) { }
9756 bool AlreadyTransformed(
QualType T) {
9771 this->Entity = Entity;
9813 CurrentInstantiationRebuilder Rebuilder(*
this, Loc, Name);
9814 return Rebuilder.TransformType(T);
9818 CurrentInstantiationRebuilder Rebuilder(*
this, E->
getExprLoc(),
9820 return Rebuilder.TransformExpr(E);
9831 = Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
9843 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
9847 if (isa<TemplateTypeParmDecl>(Param))
9852 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
9853 if (RebuildTemplateParamsInCurrentInstantiation(
9854 TTP->getTemplateParameters()))
9871 NTTP->
setType(NewTSI->getType());
9883 return getTemplateArgumentBindingsText(Params, Args.
data(), Args.
size());
9891 llvm::raw_svector_ostream Out(Str);
9893 if (!Params || Params->
size() == 0 || NumArgs == 0)
9894 return std::string();
9896 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
9906 Out <<
Id->getName();
9912 Args[I].
print(getPrintingPolicy(), Out);
9924 auto LPT = llvm::make_unique<LateParsedTemplate>();
9927 LPT->Toks.swap(Toks);
9929 LateParsedTemplateMap.insert(std::make_pair(FD, std::move(LPT)));
9944 if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(CurContext)) {
9973 class ExplicitSpecializationVisibilityChecker {
9983 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
9984 return checkImpl(FD);
9985 if (
auto *RD = dyn_cast<CXXRecordDecl>(ND))
9986 return checkImpl(RD);
9987 if (
auto *VD = dyn_cast<VarDecl>(ND))
9988 return checkImpl(VD);
9989 if (
auto *ED = dyn_cast<EnumDecl>(ND))
9990 return checkImpl(ED);
9994 void diagnose(
NamedDecl *D,
bool IsPartialSpec) {
9997 const bool Recover =
true;
10002 if (Modules.empty())
10020 template<
typename SpecDecl>
10021 void checkImpl(SpecDecl *Spec) {
10022 bool IsHiddenExplicitSpecialization =
false;
10024 IsHiddenExplicitSpecialization =
10025 Spec->getMemberSpecializationInfo()
10029 checkInstantiated(Spec);
10032 if (IsHiddenExplicitSpecialization)
10033 diagnose(Spec->getMostRecentDecl(),
false);
10049 else if (
auto *TD =
10052 diagnose(TD,
true);
10057 void checkInstantiated(
VarDecl *RD) {
10065 else if (
auto *TD =
10068 diagnose(TD,
true);
10073 void checkInstantiated(
EnumDecl *FD) {}
10075 template<
typename TemplDecl>
10076 void checkTemplate(TemplDecl *TD) {
10077 if (TD->isMemberSpecialization()) {
10079 diagnose(TD->getMostRecentDecl(),
false);
10086 if (!getLangOpts().Modules)
10089 ExplicitSpecializationVisibilityChecker(*
this, Loc).check(Spec);
10097 if (!hasVisibleDeclaration(Spec, &Modules))
10098 diagnoseMissingImport(Loc, Spec, Spec->
getLocation(), Modules,
10099 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.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
const TypeClass * getTypePtr() const
bool TemplateParameterListsAreEqual(TemplateParameterList *New, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
TemplateDeductionResult
Describes the result of template argument deduction.
void InstantiatedLocal(const Decl *D, Decl *Inst)
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that makes a template template argument into a pack expansion...
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
bool isMemberPointerType() const
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
static const TemplateArgument & getArgument(const TemplateArgument &A)
QualType getInjectedSpecializationType() const
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
llvm::PointerUnion3< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
void diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName, SourceLocation Less, SourceLocation Greater)
const TypeClass * getTypePtr() const
static CXXDependentScopeMemberExpr * Create(const ASTContext &C, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
NestedNameSpecifierLoc getTemplateQualifierLoc() const
void addOuterTemplateArguments(const TemplateArgumentList *TemplateArgs)
Add a new outermost level to the multi-level template argument list.
void setLookupName(DeclarationName Name)
Sets the name to look up.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
static UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
void setRParenLoc(SourceLocation Loc)
Stmt - This represents one statement.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
Filter makeFilter()
Create a filter for this result set.
void setLAngleLoc(SourceLocation Loc)
void setExceptionSpecRange(SourceRange R)
We are matching the template parameter lists of two templates that might be redeclarations.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
Provides information about an attempted template argument deduction, whose success or failure was des...
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
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.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Defines the C++ template declaration subclasses.
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
Represents a C++11 auto or C++14 decltype(auto) type.
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
static SourceRange getRangeOfTypeInNestedNameSpecifier(ASTContext &Context, QualType T, const CXXScopeSpec &SS)
Expr * getAsExpr() const
Retrieve the non-type template argument's expression.
ParenExpr - This represents a parethesized expression, e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
TemplateParameterList * MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, ArrayRef< TemplateParameterList *> ParamLists, bool IsFriend, bool &IsMemberSpecialization, bool &Invalid)
Match the given template parameter lists to the given scope specifier, returning the template paramet...
The base class of the type hierarchy.
void setTemplateKeywordLoc(SourceLocation Loc)
Declaration of a variable template.
TemplateParamListContext
The context in which we are checking a template parameter list.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
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)
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
SourceLocation getLocEnd() const LLVM_READONLY
static void StripImplicitInstantiation(NamedDecl *D)
Strips various properties off an implicit instantiation that has just been explicitly specialized...
Abstract base class used for diagnosing integer constant expression violations.
static NullPointerValueKind isNullPointerValueTemplateArgument(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *Arg, Decl *Entity=nullptr)
Determine whether the given template argument is a null pointer value of the appropriate type...
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs, SmallVectorImpl< TemplateArgument > &Converted, bool UpdateArgsWithConversions=true)
Check that the given template arguments can be be provided to the given template, converting the argu...
Represents a C++ constructor within a class.
TemplateName SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs)
QualType getElementType() const
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
An identifier, stored as an IdentifierInfo*.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
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...
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
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)
SourceLocation getLocStart() const LLVM_READONLY
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
LookupResultKind getResultKind() const
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
Perform semantic analysis for the given non-template member specialization.
static QualType checkBuiltinTemplateIdType(Sema &SemaRef, BuiltinTemplateDecl *BTD, const SmallVectorImpl< TemplateArgument > &Converted, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
void ClearStorageClassSpecs()
The type of a non-type template parameter.
ParsedType getAsType() const
Retrieve the template type argument's type.
SourceRange getSourceRange() const LLVM_READONLY
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.
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
Represents a typeof (or typeof) expression (a GCC extension).
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack)
SourceLocation getLocStart() const LLVM_READONLY
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)
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, const ASTContext *Context=nullptr) const
Scope - A scope is a transient data structure that is used while parsing the program.
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type...
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNoreturnSpecified() const
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
const LangOptions & getLangOpts() const
TemplateArgumentLoc getArgLoc(unsigned i) const
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Decl * ActOnTemplateDeclarator(Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization, retrieves the function from which it was instantiated.
Represents a C++ member access expression where the actual member referenced could not be resolved be...
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
void setLocalRangeBegin(SourceLocation L)
static bool CheckTemplateArgumentPointerToMember(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *&ResultArg, TemplateArgument &Converted)
Checks whether the given template argument is a pointer to member constant according to C++ [temp...
Represents a linkage specification.
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
SourceLocation getLocStart() const LLVM_READONLY
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
NamedDecl *const * iterator
We are matching the template parameter lists of a template template argument against the template par...
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
SourceRange getSourceRange() const LLVM_READONLY
bool isExplicitSpecialization() const
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
unsigned getNumArgs() const
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
IdentifierInfo * getIdentifier() const
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location...
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
QualType getElementType() const
RAII object used to change the argument pack substitution index within a Sema object.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
Represents an extended vector type where either the type or size is dependent.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
We are matching the template parameter lists of two template template parameters as part of matching ...
DiagnosticsEngine & getDiagnostics() const
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
unsigned getFlags() const
getFlags - Return the flags for this scope.
void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD)
static Sema::TemplateDeductionResult DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, const TemplateArgument &Param, TemplateArgument Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
void print(const PrintingPolicy &Policy, raw_ostream &Out) const
Print this template argument to the given output stream.
bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg, SmallVectorImpl< TemplateArgument > &Converted)
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
Sema - This implements semantic analysis and AST building for C.
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 getLocStart() const LLVM_READONLY
bool hasLValuePath() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
static TypeSourceInfo * SubstDefaultTemplateArgument(Sema &SemaRef, TemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, TemplateTypeParmDecl *Param, SmallVectorImpl< TemplateArgument > &Converted)
Substitute template arguments into the default template argument for the given template type paramete...
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
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.
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 ...
Expr - This represents one expression.
Defines the clang::LangOptions interface.
StringRef getKindName() const
DeclResult CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation TemplateNameLoc, const TemplateArgumentListInfo &TemplateArgs)
SourceLocation getLocalRangeEnd() const
LookupNameKind
Describes the kind of name lookup to perform.
QualType getPointeeType() const
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos, QualType CanonInjectedType, ClassTemplatePartialSpecializationDecl *PrevDecl)
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
bool isExplicitSpecified() const
Expr * getAssociatedConstraints() const
QualType getCanonicalTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args) const
Declaration of a template type parameter.
unsigned getIndex() const
DeclContext * getEntity() const
This file defines the classes used to store parsed information about declaration-specifiers and decla...
const T * castAs() const
Member-template castAs<specific type>.
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
bool isChar16Type() const
SourceLocation getThreadStorageClassSpecLoc() const
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
bool isNullPtrType() const
bool isFileContext() const
SourceLocation getBeginLoc() const
DeclContext * getDeclContext()
CXXRecordDecl * getDefinition() const
bool isConstexprSpecified() const
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
void setMemberSpecialization()
Note that this member template is a specialization.
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.
static DependentScopeDeclRefExpr * Create(const ASTContext &C, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Represents the type decltype(expr) (C++11).
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given function template specialization.
SourceLocation getStorageClassSpecLoc() const
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this...
A namespace alias, stored as a NamespaceAliasDecl*.
bool isIdentifier() const
Determine whether this template name refers to an identifier.
void setLateTemplateParsed(bool ILT=true)
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined...
void propagateDLLAttrToBaseClassTemplate(CXXRecordDecl *Class, Attr *ClassAttr, ClassTemplateSpecializationDecl *BaseTemplateSpec, SourceLocation BaseLoc)
Perform propagation of DLL attributes from a derived class to a templated base class for MS compatibi...
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
bool isFunctionOrMethod() const
StorageClass
Storage classes.
SourceLocation getLocalRangeBegin() const
static bool isEnableIf(NestedNameSpecifierLoc NNS, const IdentifierInfo &II, SourceRange &CondRange, Expr *&Cond)
Determine whether this failed name lookup should be treated as being disabled by a usage of std::enab...
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
Declaration of an alias template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Data structure that captures multiple levels of template argument lists for use in template instantia...
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...
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
bool hasVisibleMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine if there is a visible declaration of D that is a member specialization declaration (as oppo...
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
RecordDecl * getDecl() const
SourceLocation getNoreturnSpecLoc() const
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
std::pair< Expr *, std::string > findFailedBooleanCondition(Expr *Cond, bool AllowTopLevelCond)
Find the failed Boolean condition within a given Boolean constant expression, and describe it with a ...
const CXXScopeSpec & getScopeSpec() const
Retrieve the nested-name-specifier that precedes the template name in a template template argument...
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...
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template apply...
Assigning into this object requires the old value to be released and the new value to be retained...
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
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...
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
void setBraceRange(SourceRange R)
Attr * clone(ASTContext &C) const
static bool CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *ArgIn, TemplateArgument &Converted)
Checks whether the given template argument is the address of an object or function according to C++ [...
This names the __make_integer_seq BuiltinTemplateDecl.
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
static void SetNestedNameSpecifier(TagDecl *T, const CXXScopeSpec &SS)
DeclarationName getName() const
getName - Returns the embedded declaration name.
Represents the declaration of a struct/union/class/enum.
TemplateArgument getArgumentPack() const
void referenceDLLExportedClassMethods()
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc)
Build the type that describes a C++ typename specifier, e.g., "typename T::type". ...
bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name, SourceLocation NameLoc, ParsedTemplateTy *Template=nullptr)
Determine whether a particular identifier might be the name in a C++1z deduction-guide declaration...
ASTContext & getASTContext() const LLVM_READONLY
SourceLocation getLocStart() const LLVM_READONLY
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.
void setElaboratedKeywordLoc(SourceLocation Loc)
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
SourceLocation getLocEnd() const LLVM_READONLY
No entity found met the criteria.
This template specialization was instantiated from a template due to an explicit instantiation defini...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
SourceLocation getRAngleLoc() const
EnumDecl * getDecl() const
A template type parameter, stored as a type.
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, Sema::TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
SourceLocation getInlineSpecLoc() const
ArrayRef< ParmVarDecl * > getParams() const
void checkPartialSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a template specialization that would select a partial specialization.
static TemplateArgumentLoc convertTypeTemplateArgumentToTemplate(TypeLoc TLoc)
Convert a template-argument that we parsed as a type into a template, if possible.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void addArgument(const TemplateArgumentLoc &Loc)
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl, Expr *AssociatedConstraints=nullptr)
Create a class template node.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
The injected class name of a C++ class template or class template partial specialization.
A qualified reference to a name whose declaration cannot yet be resolved.
QualType getPointeeType() const
Represents a pack expansion of types.
SourceLocation getLocation() const
A POD class for pairing a NamedDecl* with an access specifier.
void setLParenLoc(SourceLocation Loc)
void setTemplateKeywordLoc(SourceLocation Loc)
static void checkTemplatePartialSpecialization(Sema &S, PartialSpecDecl *Partial)
StringRef getName() const
Return the actual identifier string.
TypeResult ActOnTagTemplateIdType(TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc)
Parsed an elaborated-type-specifier that refers to a template-id, such as class T::template apply<U>...
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template...
Represents a template argument.
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
TagTypeKind
The kind of a tag type.
bool hasVisibleExplicitSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine if there is a visible declaration of D that is an explicit specialization declaration for a...
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
The name does not refer to a template.
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
void setMemberSpecialization()
Note that this member template is a specialization.
bool isNull() const
Determine whether this template name is NULL.
bool RebuildTemplateParamsInCurrentInstantiation(TemplateParameterList *Params)
Rebuild the template parameters now that we know we're in a current instantiation.
void removeDefaultArgument()
Removes the default argument of this template parameter.
Dataflow Directional Tag Classes.
bool isExplicit() const
Whether this function is explicit.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
bool isValid() const
Return true if this is a valid SourceLocation object.
ParsedTemplateTy getAsTemplate() const
Retrieve the template template argument's template name.
SourceLocation getLocStart() const LLVM_READONLY
const TemplateArgument & getArgument() const
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization, retrieves the member specialization information.
ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
NestedNameSpecifier * getQualifier() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
EvalResult is a struct with detailed info about an evaluated expression.
The base class of all kinds of template declarations (e.g., class, function, etc.).
bool hasUnnamedOrLocalType() const
Whether this type is or contains a local or unnamed type.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
QualType getType() const
Get the type for which this source info wrapper provides information.
SourceLocation getLocStart() const LLVM_READONLY
The template argument is a pack expansion of a template name that was provided for a template templat...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
CXXScopeSpec SS
The nested-name-specifier that precedes the template name.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
Expr * getSourceExpression() const
QualType getUnderlyingType() const
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
AccessSpecifier getAccess() const
This is a scope that corresponds to the template parameters of a C++ template.
This template specialization was instantiated from a template due to an explicit instantiation declar...
bool isInvalid() const
Determine whether the given template argument is invalid.
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
DeclarationName - The name of a declaration.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isBooleanType() const
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo &TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization...
Represents a C++11 pack expansion that produces a sequence of expressions.
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
SourceLocation getLocStart() const LLVM_READONLY
static Expr * lookThroughRangesV3Condition(Preprocessor &PP, Expr *Cond)
A pointer to member type per C++ 8.3.3 - Pointers to members.
This names the __type_pack_element BuiltinTemplateDecl.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set...
TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS, const IdentifierInfo &II, SourceLocation IdLoc)
Called when the parser has parsed a C++ typename specifier, e.g., "typename T::type".
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
A type that was preceded by the 'template' keyword, stored as a Type*.
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
The name refers to a template whose specialization produces a type.
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
bool isNull() const
Determine whether this template argument has no value.
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration...
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
unsigned getNumParams() const
void setNameLoc(SourceLocation Loc)
Represents a pointer to an Objective C object.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
Name lookup found a single declaration that met the criteria.
static void completeMemberSpecializationImpl(Sema &S, DeclT *OrigD, SourceLocation Loc)
Complete the explicit specialization of a member of a class template by updating the instantiated mem...
NamedDecl * ActOnTypeParameter(Scope *S, bool Typename, SourceLocation EllipsisLoc, SourceLocation KeyLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedType DefaultArg)
ActOnTypeParameter - Called when a C++ template type parameter (e.g., "typename T") has been parsed...
const UnresolvedSetImpl & asUnresolvedSet() const
bool HasSideEffects
Whether the evaluated expression has side effects.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
ParsedTemplateArgument getTemplatePackExpansion(SourceLocation EllipsisLoc) const
Retrieve a pack expansion of the given template template argument.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Determine what kind of template instantiation this function represents.
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
QualType getCanonicalTypeInternal() const
SourceLocation getVirtualSpecLoc() const
This template specialization was declared or defined by an explicit specialization (C++ [temp...
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
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)
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.
void clear()
Clears out any current state.
bool IsInsideALocalClassWithinATemplateFunction()
void setElaboratedKeywordLoc(SourceLocation Loc)
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
SourceLocation getLocation() const
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type...
static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc, TemplateDecl *TD, const TemplateParmDecl *D, TemplateArgumentListInfo &Args)
Diagnose a missing template argument.
QualType getPointeeType() const
QualType getType() const
Return the type wrapped by this type source info.
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
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.