31 #include "llvm/ADT/SmallBitVector.h"
32 #include "llvm/ADT/SmallString.h"
33 #include "llvm/ADT/StringExtras.h"
34 using namespace clang;
42 return SourceRange(Ps[0]->getTemplateLoc(), Ps[N-1]->getRAngleLoc());
50 bool AllowFunctionTemplates) {
53 if (isa<TemplateDecl>(D)) {
54 if (!AllowFunctionTemplates && isa<FunctionTemplateDecl>(D))
72 if (Record->isInjectedClassName()) {
73 Record = cast<CXXRecordDecl>(Record->getDeclContext());
74 if (Record->getDescribedClassTemplate())
75 return Record->getDescribedClassTemplate();
78 = dyn_cast<ClassTemplateSpecializationDecl>(Record))
79 return Spec->getSpecializedTemplate();
89 bool AllowFunctionTemplates) {
91 llvm::SmallPtrSet<ClassTemplateDecl *, 8> ClassTemplates;
96 AllowFunctionTemplates);
99 else if (Repl != Orig) {
110 if (!ClassTemplates.insert(ClassTmpl).second) {
127 bool AllowFunctionTemplates) {
137 bool hasTemplateKeyword,
140 bool EnteringContext,
142 bool &MemberOfUnknownSpecialization) {
143 assert(getLangOpts().
CPlusPlus &&
"No template names in C!");
146 MemberOfUnknownSpecialization =
false;
169 LookupTemplateName(R, S, SS, ObjectType, EnteringContext,
170 MemberOfUnknownSpecialization);
172 if (R.isAmbiguous()) {
174 R.suppressDiagnostics();
184 unsigned ResultCount = R.end() - R.begin();
185 if (ResultCount > 1) {
192 R.suppressDiagnostics();
194 TemplateDecl *TD = cast<TemplateDecl>((*R.begin())->getUnderlyingDecl());
199 hasTemplateKeyword, TD);
204 if (isa<FunctionTemplateDecl>(TD)) {
208 R.suppressDiagnostics();
210 assert(isa<ClassTemplateDecl>(TD) || isa<TemplateTemplateParmDecl>(TD) ||
211 isa<TypeAliasTemplateDecl>(TD) || isa<VarTemplateDecl>(TD));
217 TemplateResult = TemplateTy::make(Template);
230 if (!SS || !SS->
isSet() || !isDependentScopeSpecifier(*SS) ||
231 computeDeclContext(*SS))
237 Diag(IILoc, diag::err_template_kw_missing)
249 bool EnteringContext,
250 bool &MemberOfUnknownSpecialization) {
252 MemberOfUnknownSpecialization =
false;
254 bool isDependent =
false;
255 if (!ObjectType.
isNull()) {
258 assert(!SS.
isSet() &&
"ObjectType and scope specifier cannot coexist");
259 LookupCtx = computeDeclContext(ObjectType);
263 "Caller should have completed object type");
270 }
else if (SS.
isSet()) {
273 LookupCtx = computeDeclContext(SS, EnteringContext);
274 isDependent = isDependentScopeSpecifier(SS);
277 if (LookupCtx && RequireCompleteDeclContext(SS, LookupCtx))
281 bool ObjectTypeSearchedInScope =
false;
282 bool AllowFunctionTemplatesInLookup =
true;
288 LookupQualifiedName(Found, LookupCtx);
299 if (S) LookupName(Found, S);
300 ObjectTypeSearchedInScope =
true;
301 AllowFunctionTemplatesInLookup =
false;
303 }
else if (isDependent && (!S || ObjectType.
isNull())) {
306 MemberOfUnknownSpecialization =
true;
310 LookupName(Found, S);
313 AllowFunctionTemplatesInLookup =
false;
316 if (Found.
empty() && !isDependent) {
321 auto FilterCCC = llvm::make_unique<CorrectionCandidateCallback>();
322 FilterCCC->WantTypeSpecifiers =
false;
323 FilterCCC->WantExpressionKeywords =
false;
324 FilterCCC->WantRemainingKeywords =
false;
325 FilterCCC->WantCXXNamedCasts =
true;
328 std::move(FilterCCC), CTK_ErrorRecovery, LookupCtx)) {
330 if (Corrected.getCorrectionDecl())
331 Found.
addDecl(Corrected.getCorrectionDecl());
332 FilterAcceptableTemplateNames(Found);
333 if (!Found.
empty()) {
335 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
336 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
338 diagnoseTypo(Corrected, PDiag(diag::err_no_member_template_suggest)
339 << Name << LookupCtx << DroppedSpecifier
342 diagnoseTypo(Corrected, PDiag(diag::err_no_template_suggest) << Name);
350 FilterAcceptableTemplateNames(Found, AllowFunctionTemplatesInLookup);
353 MemberOfUnknownSpecialization =
true;
357 if (S && !ObjectType.
isNull() && !ObjectTypeSearchedInScope &&
358 !getLangOpts().CPlusPlus11) {
367 LookupName(FoundOuter, S);
368 FilterAcceptableTemplateNames(FoundOuter,
false);
370 if (FoundOuter.empty()) {
374 FoundOuter.isAmbiguous()) {
387 diag::ext_nested_name_member_ref_lookup_ambiguous)
391 diag::note_ambig_member_ref_object_type)
393 Diag(FoundOuter.getFoundDecl()->getLocation(),
394 diag::note_ambig_member_ref_scope);
410 bool isAddressOfOperand,
414 if (!isAddressOfOperand &&
415 isa<CXXMethodDecl>(DC) &&
416 cast<CXXMethodDecl>(DC)->isInstance()) {
421 NamedDecl *FirstQualifierInScope =
nullptr;
424 Context,
nullptr, ThisType,
true,
426 FirstQualifierInScope, NameInfo, TemplateArgs);
429 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
450 if (getLangOpts().MicrosoftExt)
456 Diag(Loc, diag::err_template_param_shadow)
457 << cast<NamedDecl>(PrevDecl)->getDeclName();
466 if (
TemplateDecl *Temp = dyn_cast_or_null<TemplateDecl>(D)) {
467 D = Temp->getTemplatedDecl();
475 assert(
Kind == Template &&
476 "Only template template arguments can be pack expansions here");
477 assert(getAsTemplate().
get().containsUnexpandedParameterPack() &&
478 "Template template argument pack expansion without packs");
480 Result.EllipsisLoc = EllipsisLoc;
516 llvm_unreachable(
"Unhandled parsed template argument");
523 for (
unsigned I = 0,
Last = TemplateArgsIn.size(); I !=
Last; ++I)
555 "Template type parameter not in template parameter scope!");
556 bool Invalid =
false;
562 bool IsParameterPack = EllipsisLoc.
isValid();
566 Typename, IsParameterPack);
576 IdResolver.AddDecl(Param);
582 if (DefaultArg && IsParameterPack) {
583 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
590 GetTypeFromParser(DefaultArg, &DefaultTInfo);
592 assert(DefaultTInfo &&
"expected source information for type");
595 if (DiagnoseUnexpandedParameterPack(Loc, DefaultTInfo,
596 UPPC_DefaultArgument))
600 if (CheckTemplateArgument(Param, DefaultTInfo)) {
621 Diag(Loc, diag::err_variably_modified_nontype_template_param)
657 Diag(Loc, diag::err_template_nontype_parm_bad_type)
672 "Non-type template parameter not in template parameter scope!");
673 bool Invalid =
false;
688 IsParameterPack, TInfo);
700 IdResolver.AddDecl(Param);
706 if (Default && IsParameterPack) {
707 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
714 if (DiagnoseUnexpandedParameterPack(Default, UPPC_DefaultArgument))
719 CheckTemplateArgument(Param, Param->
getType(), Default, Converted);
724 Default = DefaultRes.
get();
746 "Template template parameter not in template parameter scope!");
749 bool IsParameterPack = EllipsisLoc.
isValid();
763 IdResolver.AddDecl(Param);
766 if (Params->
size() == 0) {
775 if (IsParameterPack && !Default.
isInvalid()) {
776 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
791 Diag(DefaultArg.
getLocation(), diag::err_template_arg_not_class_template)
797 if (DiagnoseUnexpandedParameterPack(DefaultArg.
getLocation(),
799 UPPC_DefaultArgument))
815 Decl **Params,
unsigned NumParams,
818 Diag(ExportLoc, diag::warn_template_export_unsupported);
838 unsigned NumOuterTemplateParamLists,
841 assert(TemplateParams && TemplateParams->
size() > 0 &&
842 "No template parameters");
843 assert(TUK != TUK_Reference &&
"Can only declare or define class templates");
844 bool Invalid =
false;
847 if (CheckTemplateDeclScope(S, TemplateParams))
851 assert(Kind !=
TTK_Enum &&
"can't build template of enumerated type");
855 Diag(KWLoc, diag::err_template_unnamed_class);
864 (SS.
isEmpty() && TUK == TUK_Friend)
865 ? LookupTagName : LookupOrdinaryName,
868 SemanticContext = computeDeclContext(SS,
true);
869 if (!SemanticContext) {
873 Diag(NameLoc, TUK == TUK_Friend
874 ? diag::warn_template_qualified_friend_ignored
875 : diag::err_template_qualified_declarator_no_match)
877 return TUK != TUK_Friend;
880 if (RequireCompleteDeclContext(SS, SemanticContext))
888 if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams))
890 }
else if (TUK != TUK_Friend && TUK != TUK_Reference)
891 diagnoseQualifiedDeclaration(SS, SemanticContext, Name, NameLoc);
893 LookupQualifiedName(Previous, SemanticContext);
895 SemanticContext = CurContext;
901 if (TUK != TUK_Friend &&
902 DiagnoseClassNameShadow(SemanticContext,
906 LookupName(Previous, S);
913 if (Previous.
begin() != Previous.
end())
914 PrevDecl = (*Previous.
begin())->getUnderlyingDecl();
919 = dyn_cast_or_null<ClassTemplateDecl>(PrevDecl);
924 if (!PrevClassTemplate && PrevDecl && isa<CXXRecordDecl>(PrevDecl) &&
925 cast<CXXRecordDecl>(PrevDecl)->isInjectedClassName()) {
928 = cast<CXXRecordDecl>(PrevDecl)->getDescribedClassTemplate();
929 if (!PrevClassTemplate && isa<ClassTemplateSpecializationDecl>(PrevDecl)) {
931 = cast<ClassTemplateSpecializationDecl>(PrevDecl)
932 ->getSpecializedTemplate();
936 if (TUK == TUK_Friend) {
955 PrevDecl = PrevClassTemplate =
nullptr;
956 SemanticContext = OutermostContext;
960 Previous.
clear(LookupOrdinaryName);
964 LookupQualifiedName(Previous, LookupContext);
969 if (Previous.
begin() != Previous.
end())
970 PrevDecl = (*Previous.
begin())->getUnderlyingDecl();
973 }
else if (PrevDecl &&
976 PrevDecl = PrevClassTemplate =
nullptr;
978 if (
auto *Shadow = dyn_cast_or_null<UsingShadowDecl>(
981 !(PrevClassTemplate &&
984 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
985 Diag(Shadow->getTargetDecl()->getLocation(),
986 diag::note_using_decl_target);
987 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl) << 0;
989 PrevDecl = PrevClassTemplate =
nullptr;
993 if (PrevClassTemplate) {
997 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
998 !TemplateParameterListsAreEqual(TemplateParams,
1010 if (!isAcceptableTagRedeclaration(PrevRecordDecl, Kind,
1011 TUK == TUK_Definition, KWLoc, Name)) {
1012 Diag(KWLoc, diag::err_use_with_wrong_tag)
1020 if (TUK == TUK_Definition) {
1025 if (SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
1027 auto *Tmpl = cast<CXXRecordDecl>(Hidden)->getDescribedClassTemplate();
1028 assert(Tmpl &&
"original definition of a class template is not a "
1030 makeMergedDefinitionVisible(Hidden, KWLoc);
1031 makeMergedDefinitionVisible(Tmpl, KWLoc);
1035 Diag(NameLoc, diag::err_redefinition) << Name;
1036 Diag(Def->getLocation(), diag::note_previous_definition);
1044 DiagnoseTemplateParameterShadow(NameLoc, PrevDecl);
1047 }
else if (PrevDecl) {
1053 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
1062 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
1063 CheckTemplateParameterList(
1067 (SS.
isSet() && SemanticContext && SemanticContext->
isRecord() &&
1069 ? TPC_ClassTemplateMember
1070 : TUK == TUK_Friend ? TPC_FriendClassTemplate
1071 : TPC_ClassTemplate))
1077 if (!SS.
isInvalid() && !Invalid && !PrevClassTemplate) {
1078 Diag(NameLoc, TUK == TUK_Friend ? diag::err_friend_decl_does_not_match
1079 : diag::err_member_decl_does_not_match)
1080 << Name << SemanticContext <<
true << SS.
getRange();
1091 if (NumOuterTemplateParamLists > 0)
1093 NumOuterTemplateParamLists,
1094 OuterTemplateParamLists);
1098 if (TUK == TUK_Definition) {
1099 AddAlignmentAttributesForRecord(NewClass);
1100 AddMsStructLayoutForRecord(NewClass);
1106 NewClass, PrevClassTemplate);
1109 if (ModulePrivateLoc.
isValid())
1115 assert(T->
isDependentType() &&
"Class template type is not dependent?");
1120 if (PrevClassTemplate &&
1126 SetMemberAccessSpecifier(NewTemplate, PrevClassTemplate, AS);
1132 if (TUK == TUK_Definition)
1136 ProcessDeclAttributeList(S, NewClass, Attr);
1138 if (PrevClassTemplate)
1141 AddPushedVisibilityAttribute(NewClass);
1143 if (TUK != TUK_Friend) {
1148 PushOnScopeChains(NewTemplate, Outer);
1158 if (!CurContext->isDependentContext()) {
1161 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
1162 PushOnScopeChains(NewTemplate, EnclosingScope,
1169 CurContext->addDecl(Friend);
1177 ActOnDocumentableDecl(NewTemplate);
1207 diag::warn_cxx98_compat_template_parameter_default_in_function_template
1208 : diag::ext_template_parameter_default_in_function_template)
1217 S.
Diag(ParamLoc, diag::err_template_parameter_default_template_member)
1226 S.
Diag(ParamLoc, diag::err_template_parameter_default_friend_template)
1235 llvm_unreachable(
"Invalid TemplateParamListContext!");
1248 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
1251 if (!NTTP->isParameterPack() &&
1253 NTTP->getTypeSourceInfo(),
1261 = dyn_cast<TemplateTemplateParmDecl>(P))
1294 bool Invalid =
false;
1302 bool SawDefaultArgument =
false;
1308 OldParam = OldParams->
begin();
1310 bool RemoveDefaultArguments =
false;
1312 NewParamEnd = NewParams->
end();
1313 NewParam != NewParamEnd; ++NewParam) {
1315 bool RedundantDefaultArg =
false;
1320 bool MissingDefaultArg =
false;
1323 bool SawParameterPack =
false;
1326 = dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
1328 if (NewTypeParm->hasDefaultArgument() &&
1330 NewTypeParm->getLocation(),
1331 NewTypeParm->getDefaultArgumentInfo()->getTypeLoc()
1333 NewTypeParm->removeDefaultArgument();
1337 = OldParams? cast<TemplateTypeParmDecl>(*OldParam) :
nullptr;
1338 if (NewTypeParm->isParameterPack()) {
1339 assert(!NewTypeParm->hasDefaultArgument() &&
1340 "Parameter packs can't have a default argument!");
1341 SawParameterPack =
true;
1343 NewTypeParm->hasDefaultArgument()) {
1345 NewDefaultLoc = NewTypeParm->getDefaultArgumentLoc();
1346 SawDefaultArgument =
true;
1347 RedundantDefaultArg =
true;
1348 PreviousDefaultArgLoc = NewDefaultLoc;
1352 NewTypeParm->setInheritedDefaultArgument(
Context, OldTypeParm);
1354 }
else if (NewTypeParm->hasDefaultArgument()) {
1355 SawDefaultArgument =
true;
1356 PreviousDefaultArgLoc = NewTypeParm->getDefaultArgumentLoc();
1357 }
else if (SawDefaultArgument)
1358 MissingDefaultArg =
true;
1360 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
1362 if (!NewNonTypeParm->isParameterPack() &&
1363 DiagnoseUnexpandedParameterPack(NewNonTypeParm->getLocation(),
1364 NewNonTypeParm->getTypeSourceInfo(),
1365 UPPC_NonTypeTemplateParameterType)) {
1371 if (NewNonTypeParm->hasDefaultArgument() &&
1373 NewNonTypeParm->getLocation(),
1374 NewNonTypeParm->getDefaultArgument()->getSourceRange())) {
1375 NewNonTypeParm->removeDefaultArgument();
1380 = OldParams? cast<NonTypeTemplateParmDecl>(*OldParam) :
nullptr;
1381 if (NewNonTypeParm->isParameterPack()) {
1382 assert(!NewNonTypeParm->hasDefaultArgument() &&
1383 "Parameter packs can't have a default argument!");
1384 if (!NewNonTypeParm->isPackExpansion())
1385 SawParameterPack =
true;
1387 NewNonTypeParm->hasDefaultArgument()) {
1389 NewDefaultLoc = NewNonTypeParm->getDefaultArgumentLoc();
1390 SawDefaultArgument =
true;
1391 RedundantDefaultArg =
true;
1392 PreviousDefaultArgLoc = NewDefaultLoc;
1396 NewNonTypeParm->setInheritedDefaultArgument(
Context, OldNonTypeParm);
1398 }
else if (NewNonTypeParm->hasDefaultArgument()) {
1399 SawDefaultArgument =
true;
1400 PreviousDefaultArgLoc = NewNonTypeParm->getDefaultArgumentLoc();
1401 }
else if (SawDefaultArgument)
1402 MissingDefaultArg =
true;
1405 = cast<TemplateTemplateParmDecl>(*NewParam);
1422 = OldParams? cast<TemplateTemplateParmDecl>(*OldParam) :
nullptr;
1425 "Parameter packs can't have a default argument!");
1427 SawParameterPack =
true;
1428 }
else if (OldTemplateParm &&
1433 SawDefaultArgument =
true;
1434 RedundantDefaultArg =
true;
1435 PreviousDefaultArgLoc = NewDefaultLoc;
1440 PreviousDefaultArgLoc
1443 SawDefaultArgument =
true;
1444 PreviousDefaultArgLoc
1446 }
else if (SawDefaultArgument)
1447 MissingDefaultArg =
true;
1453 if (SawParameterPack && (NewParam + 1) != NewParamEnd &&
1454 (TPC == TPC_ClassTemplate || TPC == TPC_VarTemplate ||
1455 TPC == TPC_TypeAliasTemplate)) {
1456 Diag((*NewParam)->getLocation(),
1457 diag::err_template_param_pack_must_be_last_template_parameter);
1461 if (RedundantDefaultArg) {
1465 Diag(NewDefaultLoc, diag::err_template_param_default_arg_redefinition);
1466 Diag(OldDefaultLoc, diag::note_template_param_prev_default_arg);
1468 }
else if (MissingDefaultArg && TPC != TPC_FunctionTemplate) {
1474 Diag((*NewParam)->getLocation(),
1475 diag::err_template_param_default_arg_missing);
1476 Diag(PreviousDefaultArgLoc, diag::note_template_param_prev_default_arg);
1478 RemoveDefaultArguments =
true;
1489 if (RemoveDefaultArguments) {
1491 NewParamEnd = NewParams->
end();
1492 NewParam != NewParamEnd; ++NewParam) {
1494 TTP->removeDefaultArgument();
1496 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
1497 NTTP->removeDefaultArgument();
1499 cast<TemplateTemplateParmDecl>(*NewParam)->removeDefaultArgument();
1517 DependencyChecker(
unsigned Depth) : Depth(Depth), Match(
false) {}
1522 Depth = PD->getDepth();
1524 dyn_cast<NonTypeTemplateParmDecl>(ND)) {
1525 Depth = PD->getDepth();
1527 Depth = cast<TemplateTemplateParmDecl>(ND)->getDepth();
1532 if (ParmDepth >=
Depth) {
1553 return super::TraverseTemplateName(N);
1558 dyn_cast<NonTypeTemplateParmDecl>(E->
getDecl()))
1561 return super::VisitDeclRefExpr(E);
1583 DependencyChecker Checker(Params);
1584 Checker.TraverseType(T);
1585 return Checker.Match;
1595 if (
const Type *CurType = NNS->getAsType()) {
1601 NNSLoc = NNSLoc.getPrefix();
1643 bool &IsExplicitSpecialization,
bool &Invalid) {
1644 IsExplicitSpecialization =
false;
1654 = dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS,
true)))
1666 NestedTypes.push_back(T);
1672 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
1673 if (!isa<ClassTemplatePartialSpecializationDecl>(Spec) &&
1675 ExplicitSpecLoc = Spec->getLocation();
1678 }
else if (Record->getTemplateSpecializationKind()
1680 ExplicitSpecLoc = Record->getLocation();
1684 if (
TypeDecl *Parent = dyn_cast<TypeDecl>(Record->getParent()))
1693 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
1694 if (
TypeDecl *Parent = dyn_cast<TypeDecl>(Template->getDeclContext()))
1739 std::reverse(NestedTypes.begin(), NestedTypes.end());
1747 bool SawNonEmptyTemplateParameterList =
false;
1749 auto CheckExplicitSpecialization = [&](
SourceRange Range,
bool Recovery) {
1750 if (SawNonEmptyTemplateParameterList) {
1751 Diag(DeclLoc, diag::err_specialize_member_of_template)
1752 << !Recovery << Range;
1754 IsExplicitSpecialization =
false;
1761 auto DiagnoseMissingExplicitSpecialization = [&] (
SourceRange Range) {
1763 if (CheckExplicitSpecialization(Range,
true))
1768 if (!ParamLists.empty())
1769 ExpectedTemplateLoc = ParamLists[0]->getTemplateLoc();
1771 ExpectedTemplateLoc = DeclStartLoc;
1773 Diag(DeclLoc, diag::err_template_spec_needs_header)
1779 unsigned ParamIdx = 0;
1780 for (
unsigned TypeIdx = 0, NumTypes = NestedTypes.size(); TypeIdx != NumTypes;
1782 T = NestedTypes[TypeIdx];
1785 bool NeedEmptyTemplateHeader =
false;
1788 bool NeedNonemptyTemplateHeader =
false;
1801 = dyn_cast<ClassTemplatePartialSpecializationDecl>(Record)) {
1802 ExpectedTemplateParams = Partial->getTemplateParameters();
1803 NeedNonemptyTemplateHeader =
true;
1804 }
else if (Record->isDependentType()) {
1805 if (Record->getDescribedClassTemplate()) {
1806 ExpectedTemplateParams = Record->getDescribedClassTemplate()
1807 ->getTemplateParameters();
1808 NeedNonemptyTemplateHeader =
true;
1811 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
1817 NeedEmptyTemplateHeader =
true;
1820 }
else if (Record->getTemplateSpecializationKind()) {
1821 if (Record->getTemplateSpecializationKind()
1823 TypeIdx == NumTypes - 1)
1824 IsExplicitSpecialization =
true;
1830 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
1831 ExpectedTemplateParams = Template->getTemplateParameters();
1832 NeedNonemptyTemplateHeader =
true;
1837 NeedNonemptyTemplateHeader =
false;
1847 if (ParamIdx < ParamLists.size()) {
1848 if (ParamLists[ParamIdx]->size() == 0) {
1849 if (CheckExplicitSpecialization(ParamLists[ParamIdx]->getSourceRange(),
1853 SawNonEmptyTemplateParameterList =
true;
1856 if (NeedEmptyTemplateHeader) {
1859 if (TypeIdx == NumTypes - 1)
1860 IsExplicitSpecialization =
true;
1862 if (ParamIdx < ParamLists.size()) {
1863 if (ParamLists[ParamIdx]->size() > 0) {
1865 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
1866 diag::err_template_param_list_matches_nontemplate)
1868 <<
SourceRange(ParamLists[ParamIdx]->getLAngleLoc(),
1869 ParamLists[ParamIdx]->getRAngleLoc())
1881 if (DiagnoseMissingExplicitSpecialization(
1888 if (NeedNonemptyTemplateHeader) {
1894 if (ParamIdx < ParamLists.size() &&
1896 ExpectedTemplateParams =
nullptr;
1901 if (ParamIdx < ParamLists.size()) {
1903 if (ExpectedTemplateParams &&
1904 !TemplateParameterListsAreEqual(ParamLists[ParamIdx],
1905 ExpectedTemplateParams,
1906 true, TPL_TemplateMatch))
1910 CheckTemplateParameterList(ParamLists[ParamIdx],
nullptr,
1911 TPC_ClassTemplateMember))
1918 Diag(DeclLoc, diag::err_template_spec_needs_template_parameters)
1929 if (ParamIdx >= ParamLists.size()) {
1930 if (TemplateId && !IsFriend) {
1933 IsExplicitSpecialization =
true;
1947 if (ParamIdx < ParamLists.size() - 1) {
1948 bool HasAnyExplicitSpecHeader =
false;
1949 bool AllExplicitSpecHeaders =
true;
1950 for (
unsigned I = ParamIdx, E = ParamLists.size() - 1; I != E; ++I) {
1951 if (ParamLists[I]->size() == 0)
1952 HasAnyExplicitSpecHeader =
true;
1954 AllExplicitSpecHeaders =
false;
1957 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
1958 AllExplicitSpecHeaders ? diag::warn_template_spec_extra_headers
1959 : diag::err_template_spec_extra_headers)
1960 <<
SourceRange(ParamLists[ParamIdx]->getTemplateLoc(),
1961 ParamLists[ParamLists.size() - 2]->getRAngleLoc());
1966 if (ExplicitSpecLoc.
isValid() && HasAnyExplicitSpecHeader)
1967 Diag(ExplicitSpecLoc,
1968 diag::note_explicit_template_spec_does_not_need_header)
1969 << NestedTypes.back();
1974 if (!AllExplicitSpecHeaders)
1985 if (ParamLists.back()->size() == 0 &&
1986 CheckExplicitSpecialization(ParamLists[ParamIdx]->getSourceRange(),
1992 return ParamLists.back();
1997 Diag(Template->getLocation(), diag::note_template_declared_here)
1998 << (isa<FunctionTemplateDecl>(Template)
2000 : isa<ClassTemplateDecl>(Template)
2002 : isa<VarTemplateDecl>(Template)
2004 : isa<TypeAliasTemplateDecl>(Template) ? 3 : 4)
2005 << Template->getDeclName();
2013 Diag((*I)->getLocation(), diag::note_template_declared_here)
2014 << 0 << (*I)->getDeclName();
2036 if (!Template || isa<FunctionTemplateDecl>(Template) ||
2037 isa<VarTemplateDecl>(Template)) {
2043 Diag(TemplateLoc, diag::err_template_id_not_a_type)
2045 NoteAllFoundTemplates(Name);
2052 if (CheckTemplateArgumentList(Template, TemplateLoc, TemplateArgs,
2058 bool InstantiationDependent =
false;
2060 dyn_cast<TypeAliasTemplateDecl>(Template)) {
2067 Converted.data(), Converted.size());
2072 unsigned Depth = AliasTemplate->getTemplateParameters()->getDepth();
2073 for (
unsigned I = 0; I <
Depth; ++I)
2074 TemplateArgLists.addOuterTemplateArguments(
None);
2082 TemplateArgLists, AliasTemplate->getLocation(),
2083 AliasTemplate->getDeclName());
2088 TemplateArgs, InstantiationDependent)) {
2113 if (isa<ClassTemplateDecl>(Template)) {
2116 if (Ctx->isFileContext())
break;
2120 if (!Record)
continue;
2124 if (!isa<ClassTemplatePartialSpecializationDecl>(Record) &&
2131 QualType Injected = cast<InjectedClassNameType>(ICNT)
2132 ->getInjectedSpecializationType();
2145 = dyn_cast<ClassTemplateDecl>(Template)) {
2148 void *InsertPos =
nullptr;
2150 = ClassTemplate->findSpecialization(Converted, InsertPos);
2156 ClassTemplate->getTemplatedDecl()->getTagKind(),
2157 ClassTemplate->getDeclContext(),
2158 ClassTemplate->getTemplatedDecl()->getLocStart(),
2159 ClassTemplate->getLocation(),
2162 Converted.size(),
nullptr);
2163 ClassTemplate->AddSpecialization(Decl, InsertPos);
2164 if (ClassTemplate->isOutOfLine())
2169 (void)DiagnoseUseOfDecl(Decl, TemplateLoc);
2172 assert(isa<RecordType>(CanonType) &&
2173 "type of non-dependent specialization is not a RecordType");
2188 bool IsCtorOrDtorName) {
2196 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
2201 DTN->getQualifier(),
2202 DTN->getIdentifier(),
2214 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
2219 QualType Result = CheckTemplateIdType(Template, TemplateLoc, TemplateArgs);
2232 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
2263 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
2272 DTN->getQualifier(),
2273 DTN->getIdentifier(),
2286 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
2297 Diag(TemplateLoc, diag::err_tag_reference_non_tag) << 4;
2298 Diag(TAT->getLocation(), diag::note_declared_at);
2301 QualType Result = CheckTemplateIdType(Template, TemplateLoc, TemplateArgs);
2310 assert(Id &&
"templated class must have an identifier");
2312 if (!isAcceptableTagRedeclaration(D, TagKind, TUK == TUK_Definition,
2314 Diag(TagLoc, diag::err_use_with_wrong_tag)
2329 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
2348 bool IsPartialSpecialization);
2382 dyn_cast_or_null<TemplateTemplateParmDecl>(
2386 llvm_unreachable(
"unexpected kind of template argument");
2391 if (Params->
size() != Args.size())
2396 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
2423 return TemplateArgs;
2429 bool IsPartialSpecialization) {
2432 "Variable template specialization is declared with a template it.");
2449 FnTemplate = *OTS->begin();
2456 << IsPartialSpecialization;
2460 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
2461 if (DiagnoseUnexpandedParameterPack(TemplateArgs[I],
2462 UPPC_PartialSpecialization))
2468 if (CheckTemplateArgumentList(VarTemplate, TemplateNameLoc, TemplateArgs,
2478 Converted.data(), Converted.size());
2480 if (Inst.isInvalid())
2493 if (IsPartialSpecialization) {
2496 TemplateArgs.
size(), Converted))
2499 bool InstantiationDependent;
2503 InstantiationDependent)) {
2504 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
2506 IsPartialSpecialization =
false;
2515 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
2517 << (SC !=
SC_Extern && !CurContext->isRecord())
2525 void *InsertPos =
nullptr;
2528 if (IsPartialSpecialization)
2540 IsPartialSpecialization))
2548 Specialization = PrevDecl;
2551 }
else if (IsPartialSpecialization) {
2554 cast_or_null<VarTemplatePartialSpecializationDecl>(PrevDecl);
2558 TemplateNameLoc, TemplateParams, VarTemplate, DI->
getType(), DI, SC,
2559 Converted.data(), Converted.size(), TemplateArgs);
2562 VarTemplate->AddPartialSpecialization(Partial, InsertPos);
2563 Specialization = Partial;
2574 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
2576 TemplateParams->getDepth(), DeducibleParams);
2578 if (!DeducibleParams.all()) {
2579 unsigned NumNonDeducible =
2580 DeducibleParams.size() - DeducibleParams.count();
2581 Diag(TemplateNameLoc, diag::warn_partial_specs_not_deducible)
2582 << 1 << (NumNonDeducible > 1)
2584 for (
unsigned I = 0, N = DeducibleParams.size(); I != N; ++I) {
2585 if (!DeducibleParams[I]) {
2586 NamedDecl *Param = cast<NamedDecl>(TemplateParams->getParam(I));
2601 VarTemplate, DI->
getType(), DI, SC, Converted.data(), Converted.size());
2605 VarTemplate->AddSpecialization(Specialization, InsertPos);
2626 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
2630 diag::note_instantiation_required_here)
2643 CurContext->addDecl(Specialization);
2651 LookupResult PrevSpec(*
this, GetNameForDeclarator(D), LookupOrdinaryName,
2667 return Specialization;
2673 struct PartialSpecMatchResult {
2683 assert(Template &&
"A variable template id without template?");
2687 if (CheckTemplateArgumentList(
2688 Template, TemplateNameLoc,
2689 const_cast<TemplateArgumentListInfo &>(TemplateArgs),
false,
2695 void *InsertPos =
nullptr;
2697 Converted, InsertPos))
2707 Converted.data(), Converted.size());
2709 bool AmbiguousPartialSpec =
false;
2710 typedef PartialSpecMatchResult MatchResult;
2724 bool InstantiationDependent =
false;
2726 TemplateArgs, InstantiationDependent)) {
2731 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
2743 Matched.push_back(PartialSpecMatchResult());
2744 Matched.back().Partial = Partial;
2745 Matched.back().Args = Info.take();
2749 if (Matched.size() >= 1) {
2751 if (Matched.size() == 1) {
2764 PEnd = Matched.end();
2766 if (getMoreSpecializedPartialSpecialization(
P->Partial, Best->Partial,
2767 PointOfInstantiation) ==
2775 PEnd = Matched.end();
2777 if (
P != Best && getMoreSpecializedPartialSpecialization(
2778 P->Partial, Best->Partial,
2779 PointOfInstantiation) != Best->Partial) {
2780 AmbiguousPartialSpec =
true;
2787 InstantiationPattern = Best->Partial;
2788 InstantiationArgs = Best->Args;
2801 Template, InstantiationPattern, *InstantiationArgs, TemplateArgs,
2802 Converted, TemplateNameLoc, InsertPos );
2806 if (AmbiguousPartialSpec) {
2809 Diag(PointOfInstantiation, diag::err_partial_spec_ordering_ambiguous)
2814 PEnd = Matched.end();
2816 Diag(
P->Partial->getLocation(), diag::note_partial_spec_match)
2817 << getTemplateArgumentBindingsText(
2818 P->Partial->getTemplateParameters(), *
P->Args);
2823 dyn_cast<VarTemplatePartialSpecializationDecl>(InstantiationPattern))
2826 assert(Decl &&
"No variable template specialization?");
2847 return BuildDeclarationNameExpr(SS, NameInfo, Var,
2848 nullptr, TemplateArgs);
2867 assert(!R.
empty() &&
"empty lookup results when building templateid");
2868 assert(!R.
isAmbiguous() &&
"ambiguous lookup when building templateid");
2871 bool InstantiationDependent;
2874 *TemplateArgs, InstantiationDependent)) {
2877 TemplateKWLoc, TemplateArgs);
2888 RequiresADL, TemplateArgs,
2901 assert(TemplateArgs || TemplateKWLoc.
isValid());
2903 if (!(DC = computeDeclContext(SS,
false)) ||
2904 DC->isDependentContext() ||
2905 RequireCompleteDeclContext(SS, DC))
2906 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
2908 bool MemberOfUnknownSpecialization;
2910 LookupTemplateName(R, (
Scope*)
nullptr, SS,
QualType(),
false,
2911 MemberOfUnknownSpecialization);
2917 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_non_template)
2923 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_class_template)
2926 Diag(Temp->getLocation(), diag::note_referenced_class_template);
2930 return BuildTemplateIdExpr(SS, TemplateKWLoc, R,
false, TemplateArgs);
2945 bool EnteringContext,
2949 getLangOpts().CPlusPlus11 ?
2950 diag::warn_cxx98_compat_template_outside_of_template :
2951 diag::ext_template_outside_of_template)
2956 LookupCtx = computeDeclContext(SS, EnteringContext);
2957 if (!LookupCtx && ObjectType)
2958 LookupCtx = computeDeclContext(ObjectType.
get());
2976 bool MemberOfUnknownSpecialization;
2978 ObjectType, EnteringContext, Result,
2979 MemberOfUnknownSpecialization);
2981 isa<CXXRecordDecl>(LookupCtx) &&
2982 (!cast<CXXRecordDecl>(LookupCtx)->hasDefinition() ||
2983 cast<CXXRecordDecl>(LookupCtx)->hasAnyDependentBases())) {
2987 diag::err_template_kw_refers_to_non_template)
2988 << GetNameFromUnqualifiedId(Name).getName()
3012 llvm_unreachable(
"literal operator id cannot have a dependent scope");
3019 diag::err_template_kw_refers_to_non_template)
3020 << GetNameFromUnqualifiedId(Name).getName()
3061 SS.
Adopt(ArgExpr->getQualifierLoc());
3062 NameInfo = ArgExpr->getNameInfo();
3064 dyn_cast<DependentScopeDeclRefExpr>(Arg.
getAsExpr())) {
3065 SS.
Adopt(ArgExpr->getQualifierLoc());
3066 NameInfo = ArgExpr->getNameInfo();
3068 dyn_cast<CXXDependentScopeMemberExpr>(Arg.
getAsExpr())) {
3069 if (ArgExpr->isImplicitAccess()) {
3070 SS.
Adopt(ArgExpr->getQualifierLoc());
3071 NameInfo = ArgExpr->getMemberNameInfo();
3077 LookupParsedName(Result, CurScope, &SS);
3084 Diag(Loc, getLangOpts().MSVCCompat
3085 ? diag::ext_ms_template_type_arg_missing_typename
3086 : diag::err_template_arg_must_be_type_suggest)
3115 Diag(SR.
getBegin(), diag::err_template_arg_must_be_type) << SR;
3122 if (CheckTemplateArgument(Param, TSI))
3131 if (getLangOpts().ObjCAutoRefCount &&
3170 SmallVectorImpl<TemplateArgument> &Converted) {
3177 Template, Converted,
3183 Converted.data(), Converted.size());
3188 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
3189 TemplateArgLists.addOuterTemplateArguments(
None);
3193 SemaRef.
SubstType(ArgType, TemplateArgLists,
3228 SmallVectorImpl<TemplateArgument> &Converted) {
3230 Template, Converted,
3236 Converted.data(), Converted.size());
3241 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
3242 TemplateArgLists.addOuterTemplateArguments(
None);
3280 SmallVectorImpl<TemplateArgument> &Converted,
3288 Converted.data(), Converted.size());
3293 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
3294 TemplateArgLists.addOuterTemplateArguments(
None);
3323 bool &HasDefaultArg) {
3324 HasDefaultArg =
false;
3330 HasDefaultArg =
true;
3343 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
3347 HasDefaultArg =
true;
3361 = cast<TemplateTemplateParmDecl>(Param);
3365 HasDefaultArg =
true;
3412 unsigned ArgumentPackIndex,
3417 return CheckTemplateTypeArgument(TTP, Arg, Converted);
3424 QualType NTTPType = NTTP->getType();
3425 if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack())
3426 NTTPType = NTTP->getExpansionType(ArgumentPackIndex);
3429 !isa<TemplateTemplateParmDecl>(Template) &&
3439 Converted.data(), Converted.size());
3440 NTTPType = SubstType(NTTPType,
3442 NTTP->getLocation(),
3443 NTTP->getDeclName());
3446 if (!NTTPType.isNull())
3447 NTTPType = CheckNonTypeTemplateParameterType(NTTPType,
3448 NTTP->getLocation());
3449 if (NTTPType.isNull())
3455 llvm_unreachable(
"Should never see a NULL template argument here");
3472 Converted.push_back(Result);
3506 Context, SS.getWithLocInContext(
Context), TemplateKWLoc, NameInfo,
3518 E = CheckTemplateArgument(NTTP, NTTPType, E.
get(), Result);
3522 Converted.push_back(Result);
3549 Diag(SR.
getBegin(), diag::err_template_arg_nontype_ambig) << SR << T;
3551 Diag(SR.
getBegin(), diag::err_template_arg_must_be_expr) << SR;
3557 llvm_unreachable(
"Caller must expand template argument packs");
3574 TempParm, Converted,
3580 Converted.data(), Converted.size());
3581 TempParm = cast_or_null<TemplateTemplateParmDecl>(
3582 SubstDecl(TempParm, CurContext,
3590 llvm_unreachable(
"Should never see a NULL template argument here");
3594 if (CheckTemplateArgument(TempParm, Arg, ArgumentPackIndex))
3605 << getLangOpts().CPlusPlus11;
3609 llvm_unreachable(
"Declaration argument with template template parameter");
3611 llvm_unreachable(
"Integral argument with template template parameter");
3613 llvm_unreachable(
"Null pointer argument with template template parameter");
3616 llvm_unreachable(
"Caller must expand template argument packs");
3627 unsigned NumParams = Params->
size();
3628 unsigned NumArgs = TemplateArgs.
size();
3631 if (NumArgs > NumParams)
3632 Range =
SourceRange(TemplateArgs[NumParams].getLocation(),
3634 S.
Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
3635 << (NumArgs > NumParams)
3636 << (isa<ClassTemplateDecl>(Template)? 0 :
3637 isa<FunctionTemplateDecl>(Template)? 1 :
3638 isa<TemplateTemplateParmDecl>(Template)? 2 : 3)
3639 << Template << Range;
3658 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
3659 if (NTTP->isExpandedParameterPack())
3660 return NTTP->getNumExpansionTypes();
3664 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
3665 if (TTP->isExpandedParameterPack())
3666 return TTP->getNumExpansionTemplateParameters();
3673 template<
typename TemplateParmDecl>
3676 const TemplateParmDecl *D,
3681 ->getTemplateParameters()
3682 ->getParam(D->getIndex()));
3689 D->getDefaultArgumentLoc(), Modules,
3706 bool PartialTemplateArgs,
3722 bool isTemplateTemplateParameter = isa<TemplateTemplateParmDecl>(Template);
3724 unsigned ArgIdx = 0, NumArgs = NewArgs.
size();
3727 ParamEnd = Params->
end();
3728 Param != ParamEnd; ) {
3732 if (*Expansions == ArgumentPack.size()) {
3735 Converted.push_back(
3737 ArgumentPack.data(),
3738 ArgumentPack.size()));
3739 ArgumentPack.clear();
3744 }
else if (ArgIdx == NumArgs && !PartialTemplateArgs) {
3746 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
3748 << (isa<ClassTemplateDecl>(Template)? 0 :
3749 isa<FunctionTemplateDecl>(Template)? 1 :
3750 isa<TemplateTemplateParmDecl>(Template)? 2 : 3)
3758 if (ArgIdx < NumArgs) {
3760 if (CheckTemplateArgument(*Param, NewArgs[ArgIdx], Template,
3761 TemplateLoc, RAngleLoc,
3762 ArgumentPack.size(), Converted))
3765 bool PackExpansionIntoNonPack =
3766 NewArgs[ArgIdx].getArgument().isPackExpansion() &&
3768 if (PackExpansionIntoNonPack && isa<TypeAliasTemplateDecl>(Template)) {
3772 Diag(NewArgs[ArgIdx].getLocation(),
3773 diag::err_alias_template_expansion_into_fixed_list)
3774 << NewArgs[ArgIdx].getSourceRange();
3775 Diag((*Param)->getLocation(), diag::note_template_param_here);
3782 if ((*Param)->isTemplateParameterPack()) {
3787 ArgumentPack.push_back(Converted.pop_back_val());
3796 if (PackExpansionIntoNonPack) {
3797 if (!ArgumentPack.empty()) {
3800 Converted.insert(Converted.end(),
3801 ArgumentPack.begin(), ArgumentPack.end());
3802 ArgumentPack.clear();
3805 while (ArgIdx < NumArgs) {
3806 Converted.push_back(NewArgs[ArgIdx].getArgument());
3817 if (PartialTemplateArgs) {
3818 if ((*Param)->isTemplateParameterPack() && !ArgumentPack.empty())
3820 ArgumentPack.data(),
3821 ArgumentPack.size()));
3828 if ((*Param)->isTemplateParameterPack()) {
3830 "Should have dealt with this already");
3835 if (Param + 1 != ParamEnd)
3839 ArgumentPack.data(),
3840 ArgumentPack.size()));
3841 ArgumentPack.clear();
3872 = dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
3889 = cast<TemplateTemplateParmDecl>(*Param);
3917 if (CheckTemplateArgument(*Param, Arg, Template, TemplateLoc,
3918 RAngleLoc, 0, Converted))
3924 if (isTemplateTemplateParameter)
3936 if (ArgIdx < NumArgs && CurrentInstantiationScope &&
3937 CurrentInstantiationScope->getPartiallySubstitutedPack()) {
3938 while (ArgIdx < NumArgs && NewArgs[ArgIdx].getArgument().isPackExpansion())
3939 Converted.push_back(NewArgs[ArgIdx++].getArgument());
3944 if (ArgIdx < NumArgs)
3949 TemplateArgs = NewArgs;
3955 class UnnamedLocalNoLinkageFinder
3956 :
public TypeVisitor<UnnamedLocalNoLinkageFinder, bool>
3970 #define TYPE(Class, Parent) \
3971 bool Visit##Class##Type(const Class##Type *);
3972 #define ABSTRACT_TYPE(Class, Parent) \
3973 bool Visit##Class##Type(const Class##Type *) { return false; }
3974 #define NON_CANONICAL_TYPE(Class, Parent) \
3975 bool Visit##Class##Type(const Class##Type *) { return false; }
3976 #include "clang/AST/TypeNodes.def"
3978 bool VisitTagDecl(
const TagDecl *Tag);
3983 bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(
const BuiltinType*) {
3987 bool UnnamedLocalNoLinkageFinder::VisitComplexType(
const ComplexType* T) {
3991 bool UnnamedLocalNoLinkageFinder::VisitPointerType(
const PointerType* T) {
3995 bool UnnamedLocalNoLinkageFinder::VisitBlockPointerType(
4000 bool UnnamedLocalNoLinkageFinder::VisitLValueReferenceType(
4005 bool UnnamedLocalNoLinkageFinder::VisitRValueReferenceType(
4010 bool UnnamedLocalNoLinkageFinder::VisitMemberPointerType(
4015 bool UnnamedLocalNoLinkageFinder::VisitConstantArrayType(
4020 bool UnnamedLocalNoLinkageFinder::VisitIncompleteArrayType(
4025 bool UnnamedLocalNoLinkageFinder::VisitVariableArrayType(
4030 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedArrayType(
4035 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedExtVectorType(
4040 bool UnnamedLocalNoLinkageFinder::VisitVectorType(
const VectorType* T) {
4044 bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(
const ExtVectorType* T) {
4048 bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
4058 bool UnnamedLocalNoLinkageFinder::VisitFunctionNoProtoType(
4063 bool UnnamedLocalNoLinkageFinder::VisitUnresolvedUsingType(
4068 bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(
const TypeOfExprType*) {
4072 bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(
const TypeOfType* T) {
4076 bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(
const DecltypeType*) {
4080 bool UnnamedLocalNoLinkageFinder::VisitUnaryTransformType(
4085 bool UnnamedLocalNoLinkageFinder::VisitAutoType(
const AutoType *T) {
4089 bool UnnamedLocalNoLinkageFinder::VisitRecordType(
const RecordType* T) {
4090 return VisitTagDecl(T->
getDecl());
4093 bool UnnamedLocalNoLinkageFinder::VisitEnumType(
const EnumType* T) {
4094 return VisitTagDecl(T->
getDecl());
4097 bool UnnamedLocalNoLinkageFinder::VisitTemplateTypeParmType(
4102 bool UnnamedLocalNoLinkageFinder::VisitSubstTemplateTypeParmPackType(
4107 bool UnnamedLocalNoLinkageFinder::VisitTemplateSpecializationType(
4112 bool UnnamedLocalNoLinkageFinder::VisitInjectedClassNameType(
4114 return VisitTagDecl(T->
getDecl());
4117 bool UnnamedLocalNoLinkageFinder::VisitDependentNameType(
4122 bool UnnamedLocalNoLinkageFinder::VisitDependentTemplateSpecializationType(
4127 bool UnnamedLocalNoLinkageFinder::VisitPackExpansionType(
4132 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectType(
const ObjCObjectType *) {
4136 bool UnnamedLocalNoLinkageFinder::VisitObjCInterfaceType(
4141 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectPointerType(
4146 bool UnnamedLocalNoLinkageFinder::VisitAtomicType(
const AtomicType* T) {
4150 bool UnnamedLocalNoLinkageFinder::VisitTagDecl(
const TagDecl *Tag) {
4152 S.
Diag(SR.getBegin(),
4154 diag::warn_cxx98_compat_template_arg_local_type :
4155 diag::ext_template_arg_local_type)
4161 S.
Diag(SR.getBegin(),
4163 diag::warn_cxx98_compat_template_arg_unnamed_type :
4164 diag::ext_template_arg_unnamed_type) << SR;
4172 bool UnnamedLocalNoLinkageFinder::VisitNestedNameSpecifier(
4189 llvm_unreachable(
"Invalid NestedNameSpecifier::Kind!");
4200 assert(ArgInfo &&
"invalid TypeSourceInfo");
4205 return Diag(SR.
getBegin(), diag::err_variably_modified_template_arg) << Arg;
4207 return Diag(SR.
getBegin(), diag::err_template_arg_overload_type) << SR;
4218 if (LangOpts.CPlusPlus11)
4220 !Diags.isIgnored(diag::warn_cxx98_compat_template_arg_unnamed_type,
4222 !Diags.isIgnored(diag::warn_cxx98_compat_template_arg_local_type,
4228 UnnamedLocalNoLinkageFinder
Finder(*
this, SR);
4260 EvalResult.
Diag = &Notes;
4268 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
4269 diag::note_invalid_subexpr_in_const_expr) {
4270 DiagLoc = Notes[0].first;
4274 S.
Diag(DiagLoc, diag::err_template_arg_not_address_constant)
4275 << Arg->
getType() << Arg->getSourceRange();
4276 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
4277 S.
Diag(Notes[I].first, Notes[I].second);
4295 bool ObjCLifetimeConversion;
4298 ObjCLifetimeConversion))
4303 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
4304 << Arg->
getType() << ParamType << Arg->getSourceRange();
4312 std::string Code =
"static_cast<" + ParamType.
getAsString() +
">(";
4313 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_untyped_null_constant)
4332 bool ObjCLifetimeConversion;
4336 ObjCLifetimeConversion)) {
4341 if (!ParamRef->getPointeeType()->isFunctionType()) {
4351 unsigned ParamQuals = ParamRef->getPointeeType().getCVRQualifiers();
4354 if ((ParamQuals | ArgQuals) != ParamQuals) {
4355 S.
Diag(Arg->getLocStart(),
4356 diag::err_template_arg_ref_bind_ignores_quals)
4357 << ParamType << Arg->
getType() << Arg->getSourceRange();
4371 S.
Diag(Arg->getLocStart(), diag::err_template_arg_no_ref_bind)
4372 << ParamType << ArgIn->
getType() << Arg->getSourceRange();
4374 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_convertible)
4375 << ArgIn->
getType() << ParamType << Arg->getSourceRange();
4392 bool Invalid =
false;
4396 bool AddressTaken =
false;
4403 bool ExtWarnMSTemplateArg =
false;
4406 while (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(Arg)) {
4409 ExtWarnMSTemplateArg =
true;
4413 FirstOpKind = UnOpKind;
4414 FirstOpLoc = UnOp->getOperatorLoc();
4420 if (ExtWarnMSTemplateArg)
4421 S.
Diag(ArgIn->getLocStart(), diag::ext_ms_deref_template_argument)
4422 << ArgIn->getSourceRange();
4425 AddressTaken =
true;
4430 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)
4431 << Arg->getSourceRange();
4452 bool ExtraParens =
false;
4453 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
4454 if (!Invalid && !ExtraParens) {
4455 S.
Diag(Arg->getLocStart(),
4457 ? diag::warn_cxx98_compat_template_arg_extra_parens
4458 : diag::ext_template_arg_extra_parens)
4459 << Arg->getSourceRange();
4463 Arg = Parens->getSubExpr();
4467 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
4472 Arg = UnOp->getSubExpr();
4473 AddressTaken =
true;
4474 AddrOpLoc = UnOp->getOperatorLoc();
4479 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
4491 if (Entity && Entity->hasAttr<DLLImportAttr>())
4497 S.
Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
4517 if (isa<CXXUuidofExpr>(Arg)) {
4519 ArgIn, Arg, ArgType))
4527 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)
4528 << Arg->getSourceRange();
4534 if (isa<FieldDecl>(Entity) || isa<IndirectFieldDecl>(Entity)) {
4535 S.
Diag(Arg->getLocStart(), diag::err_template_arg_field)
4536 << Entity << Arg->getSourceRange();
4542 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Entity)) {
4543 if (!Method->isStatic()) {
4544 S.
Diag(Arg->getLocStart(), diag::err_template_arg_method)
4545 << Method << Arg->getSourceRange();
4555 if (!Func && !Var) {
4557 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_object_or_func)
4558 << Arg->getSourceRange();
4566 diag::warn_cxx98_compat_template_arg_object_internal :
4567 diag::ext_template_arg_object_internal)
4568 << !Func << Entity << Arg->getSourceRange();
4569 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
4571 }
else if (!Entity->hasLinkage()) {
4572 S.
Diag(Arg->getLocStart(), diag::err_template_arg_object_no_linkage)
4573 << !Func << Entity << Arg->getSourceRange();
4574 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
4589 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
4595 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
4604 if (Var->getType()->isReferenceType()) {
4605 S.
Diag(Arg->getLocStart(),
4606 diag::err_template_arg_reference_var)
4607 << Var->getType() << Arg->getSourceRange();
4613 if (Var->getTLSKind()) {
4614 S.
Diag(Arg->getLocStart(), diag::err_template_arg_thread_local)
4615 << Arg->getSourceRange();
4616 S.
Diag(Var->getLocation(), diag::note_template_arg_refers_here);
4629 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
4635 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
4640 ArgType = Var->getType();
4643 if (Var->getType()->isArrayType()) {
4652 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_address_of)
4658 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_address_of)
4685 bool Invalid =
false;
4688 Expr *Arg = ResultArg;
4693 S.
Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
4703 bool ObjCLifetimeConversion;
4706 false, ObjCLifetimeConversion)) {
4713 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_convertible)
4714 << Arg->
getType() << ParamType << Arg->getSourceRange();
4721 Arg = Cast->getSubExpr();
4733 bool ExtraParens =
false;
4734 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
4735 if (!Invalid && !ExtraParens) {
4736 S.
Diag(Arg->getLocStart(),
4738 diag::warn_cxx98_compat_template_arg_extra_parens :
4739 diag::ext_template_arg_extra_parens)
4740 << Arg->getSourceRange();
4744 Arg = Parens->getSubExpr();
4748 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
4760 else if ((DRE = dyn_cast<DeclRefExpr>(Arg))) {
4762 if (VD->getType()->isMemberPointerType()) {
4763 if (isa<NonTypeTemplateParmDecl>(VD)) {
4767 VD = cast<ValueDecl>(VD->getCanonicalDecl());
4779 return S.
Diag(Arg->getLocStart(),
4780 diag::err_template_arg_not_pointer_to_member_form)
4781 << Arg->getSourceRange();
4783 if (isa<FieldDecl>(DRE->
getDecl()) ||
4784 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
4785 isa<CXXMethodDecl>(DRE->
getDecl())) {
4786 assert((isa<FieldDecl>(DRE->
getDecl()) ||
4787 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
4788 !cast<CXXMethodDecl>(DRE->
getDecl())->isStatic()) &&
4789 "Only non-static member pointers can make it here");
4803 S.
Diag(Arg->getLocStart(),
4804 diag::err_template_arg_not_pointer_to_member_form)
4805 << Arg->getSourceRange();
4833 "non-type template parameter type cannot be qualified");
4835 if (CTAK == CTAK_Deduced &&
4845 Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
4865 Arg, ParamType, Value, CCEK_TemplateArg);
4886 Diag(Arg->getLocStart(),
4887 diag::err_template_arg_member_ptr_base_derived_not_supported)
4889 << Arg->getSourceRange();
4895 : TemplateArgument(CanonParamType,
true);
4908 if (isa<CXXUuidofExpr>(E)) {
4912 Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)
4913 << Arg->getSourceRange();
4920 VD && VD->getType()->isArrayType() &&
4928 Diag(StartLoc, diag::err_non_type_template_arg_subobject)
4933 "null reference should not be a constant expression");
4935 "non-null value of type nullptr_t?");
4937 : TemplateArgument(CanonParamType,
true);
4941 return Diag(StartLoc, diag::err_non_type_template_arg_addr_label_diff);
4949 llvm_unreachable(
"invalid kind for template argument");
4952 return ArgResult.
get();
4972 if (getLangOpts().CPlusPlus11) {
5000 IntegerType = Enum->getDecl()->getIntegerType();
5008 ExprResult ArgResult = DefaultLvalueConversion(Arg);
5011 Arg = ArgResult.
get();
5025 Diag(Arg->getLocStart(),
5026 diag::err_template_arg_not_integral_or_enumeral)
5027 << ArgType << Arg->getSourceRange();
5035 TmplArgICEDiagnoser(
QualType T) : T(T) { }
5039 S.
Diag(Loc, diag::err_template_arg_not_ice) << T << SR;
5041 } Diagnoser(ArgType);
5043 Arg = VerifyIntegerConstantExpression(Arg, &Value, Diagnoser,
5059 }
else if (IsIntegralPromotion(Arg, ArgType, ParamType) ||
5065 Diag(Arg->getLocStart(),
5066 diag::err_template_arg_not_convertible)
5067 << Arg->
getType() << ParamType << Arg->getSourceRange();
5090 if (Value.getBitWidth() != AllowedBits)
5091 Value = Value.extOrTrunc(AllowedBits);
5094 llvm::APSInt OldValue =
Value;
5099 if (Value.getBitWidth() != AllowedBits)
5100 Value = Value.extOrTrunc(AllowedBits);
5105 && (OldValue.isSigned() && OldValue.isNegative())) {
5106 Diag(Arg->getLocStart(), diag::warn_template_arg_negative)
5107 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
5108 << Arg->getSourceRange();
5113 unsigned RequiredBits;
5115 RequiredBits = OldValue.getActiveBits();
5116 else if (OldValue.isUnsigned())
5117 RequiredBits = OldValue.getActiveBits() + 1;
5119 RequiredBits = OldValue.getMinSignedBits();
5120 if (RequiredBits > AllowedBits) {
5121 Diag(Arg->getLocStart(),
5122 diag::warn_template_arg_too_large)
5123 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
5124 << Arg->getSourceRange();
5164 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg, ParamType,
5167 if (DiagnoseUseOfDecl(Fn, Arg->getLocStart()))
5170 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
5196 "Only object pointers allowed here");
5212 assert(ParamRefType->getPointeeType()->isIncompleteOrObjectType() &&
5213 "Only object references allowed here");
5216 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg,
5217 ParamRefType->getPointeeType(),
5220 if (DiagnoseUseOfDecl(Fn, Arg->getLocStart()))
5223 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
5246 << Arg->
getType() << ParamType;
5254 Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
5278 unsigned ArgumentPackIndex) {
5283 assert(Name.
isDependent() &&
"Non-dependent template isn't a declaration?");
5299 if (!isa<ClassTemplateDecl>(Template) &&
5300 !isa<TemplateTemplateParmDecl>(Template) &&
5301 !isa<TypeAliasTemplateDecl>(Template)) {
5302 assert(isa<FunctionTemplateDecl>(Template) &&
5303 "Only function templates are possible here");
5305 Diag(Template->
getLocation(), diag::note_template_arg_refers_here_func)
5316 TPL_TemplateTemplateArgumentMatch,
5341 return ImpCastExprToType(
5349 "Only declaration template arguments permitted here");
5353 if (VD->getDeclContext()->isRecord() &&
5354 (isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD) ||
5355 isa<IndirectFieldDecl>(VD))) {
5374 if (isa<CXXMethodDecl>(VD) && cast<CXXMethodDecl>(VD)->isInstance())
5378 VD->getType().getNonReferenceType(),
5385 RefExpr = CreateBuiltinUnaryOp(Loc,
UO_AddrOf, RefExpr.
get());
5390 bool ObjCLifetimeConversion;
5391 if (IsQualificationConversion(((
Expr*) RefExpr.
get())->getType(),
5393 ObjCLifetimeConversion))
5403 QualType T = VD->getType().getNonReferenceType();
5414 RefExpr = DefaultFunctionArrayConversion(RefExpr.
get());
5422 return CreateBuiltinUnaryOp(Loc,
UO_AddrOf, RefExpr.
get());
5434 }
else if (isa<FunctionDecl>(VD)) {
5439 return BuildDeclRefExpr(VD, T, VK, Loc);
5453 "Operation is only valid for integral template arguments");
5463 T = ET->getDecl()->getIntegerType();
5488 if (OrigT->isEnumeralType()) {
5508 unsigned NextDiag = diag::err_template_param_different_kind;
5509 if (TemplateArgLoc.
isValid()) {
5510 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
5511 NextDiag = diag::note_template_param_different_kind;
5530 unsigned NextDiag = diag::err_template_parameter_pack_non_pack;
5531 if (TemplateArgLoc.
isValid()) {
5532 S.
Diag(TemplateArgLoc,
5533 diag::err_template_arg_template_params_mismatch);
5534 NextDiag = diag::note_template_parameter_pack_non_pack;
5537 unsigned ParamKind = isa<TemplateTypeParmDecl>(New)? 0
5538 : isa<NonTypeTemplateParmDecl>(New)? 1
5551 = dyn_cast<NonTypeTemplateParmDecl>(Old)) {
5559 (OldNTTP->getType()->isDependentType() ||
5565 unsigned NextDiag = diag::err_template_nontype_parm_different_type;
5566 if (TemplateArgLoc.
isValid()) {
5567 S.
Diag(TemplateArgLoc,
5568 diag::err_template_arg_template_params_mismatch);
5569 NextDiag = diag::note_template_nontype_parm_different_type;
5574 S.
Diag(OldNTTP->getLocation(),
5575 diag::note_template_nontype_parm_prev_declaration)
5576 << OldNTTP->getType();
5589 = dyn_cast<TemplateTemplateParmDecl>(Old)) {
5592 OldTTP->getTemplateParameters(),
5611 unsigned NextDiag = diag::err_template_param_list_different_arity;
5612 if (TemplateArgLoc.
isValid()) {
5613 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
5614 NextDiag = diag::note_template_param_list_different_arity;
5654 if (Old->
size() != New->
size() && Kind != TPL_TemplateTemplateArgumentMatch) {
5671 OldParmEnd = Old->
end();
5672 OldParm != OldParmEnd; ++OldParm) {
5673 if (Kind != TPL_TemplateTemplateArgumentMatch ||
5674 !(*OldParm)->isTemplateParameterPack()) {
5675 if (NewParm == NewParmEnd) {
5684 Kind, TemplateArgLoc))
5698 for (; NewParm != NewParmEnd; ++NewParm) {
5700 Kind, TemplateArgLoc))
5706 if (NewParm != NewParmEnd) {
5738 while (Ctx && isa<LinkageSpecDecl>(Ctx))
5750 if (RD->isLocalClass())
5752 diag::err_template_inside_local_class)
5760 diag::err_template_outside_namespace_or_class_scope)
5771 return Record->getTemplateSpecializationKind();
5772 if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(D))
5773 return Function->getTemplateSpecializationKind();
5774 if (
VarDecl *Var = dyn_cast<VarDecl>(D))
5775 return Var->getTemplateSpecializationKind();
5808 bool IsPartialSpecialization) {
5812 if (isa<ClassTemplateDecl>(Specialized))
5813 EntityKind = IsPartialSpecialization? 1 : 0;
5814 else if (isa<VarTemplateDecl>(Specialized))
5815 EntityKind = IsPartialSpecialization ? 3 : 2;
5816 else if (isa<FunctionTemplateDecl>(Specialized))
5818 else if (isa<CXXMethodDecl>(Specialized))
5820 else if (isa<VarDecl>(Specialized))
5822 else if (isa<RecordDecl>(Specialized))
5824 else if (isa<EnumDecl>(Specialized) && S.
getLangOpts().CPlusPlus11)
5827 S.
Diag(Loc, diag::err_template_spec_unknown_kind)
5847 S.
Diag(Loc, diag::err_template_spec_decl_function_scope)
5858 S.
Diag(Loc, diag::ext_function_specialization_in_class)
5861 S.
Diag(Loc, diag::err_template_spec_decl_class_scope)
5871 S.
Diag(Loc, diag::err_template_spec_decl_class_scope)
5891 if (!DC->
Encloses(SpecializedContext) &&
5892 !(isa<FunctionTemplateDecl>(Specialized) ||
5893 isa<FunctionDecl>(Specialized) ||
5894 isa<VarTemplateDecl>(Specialized) ||
5895 isa<VarDecl>(Specialized))) {
5896 if (isa<TranslationUnitDecl>(SpecializedContext))
5897 S.
Diag(Loc, diag::err_template_spec_redecl_global_scope)
5898 << EntityKind << Specialized;
5899 else if (isa<NamespaceDecl>(SpecializedContext)) {
5900 int Diag = diag::err_template_spec_redecl_out_of_scope;
5902 Diag = diag::ext_ms_template_spec_redecl_out_of_scope;
5903 S.
Diag(Loc, Diag) << EntityKind << Specialized
5904 << cast<NamedDecl>(SpecializedContext);
5906 llvm_unreachable(
"unexpected namespace context for specialization");
5908 S.
Diag(Specialized->getLocation(), diag::note_specialized_entity);
5909 }
else if ((!PrevDecl ||
5928 bool IsCPlusPlus11Extension = DC->
Encloses(SpecializedContext);
5929 if (isa<TranslationUnitDecl>(SpecializedContext)) {
5930 assert(!IsCPlusPlus11Extension &&
5931 "DC encloses TU but isn't in enclosing namespace set");
5932 S.
Diag(Loc, diag::err_template_spec_decl_out_of_scope_global)
5933 << EntityKind << Specialized;
5934 }
else if (isa<NamespaceDecl>(SpecializedContext)) {
5936 if (!IsCPlusPlus11Extension)
5937 Diag = diag::err_template_spec_decl_out_of_scope;
5939 Diag = diag::ext_template_spec_decl_out_of_scope;
5941 Diag = diag::warn_cxx98_compat_template_spec_decl_out_of_scope;
5943 << EntityKind << Specialized << cast<NamedDecl>(SpecializedContext);
5956 DependencyChecker Checker(Depth);
5957 Checker.TraverseStmt(E);
5958 if (Checker.Match && Checker.MatchLoc.isInvalid())
5959 return E->getSourceRange();
5960 return Checker.MatchLoc;
5966 DependencyChecker Checker(Depth);
5967 Checker.TraverseTypeLoc(TL);
5968 if (Checker.Match && Checker.MatchLoc.isInvalid())
5970 return Checker.MatchLoc;
5978 for (
unsigned I = 0; I != NumArgs; ++I) {
5981 S, TemplateNameLoc, Param, Args[I].pack_begin(),
5982 Args[I].pack_size(), IsDefaultArgument))
5995 ArgExpr = Expansion->getPattern();
5999 ArgExpr = ICE->getSubExpr();
6009 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ArgExpr))
6010 if (isa<NonTypeTemplateParmDecl>(DRE->getDecl()))
6022 if (ParamUseRange.
isValid()) {
6023 if (IsDefaultArgument) {
6024 S.
Diag(TemplateNameLoc,
6025 diag::err_dependent_non_type_arg_in_partial_spec);
6027 diag::note_dependent_non_type_default_arg_in_partial_spec)
6031 diag::err_dependent_non_type_arg_in_partial_spec)
6051 if (ParamUseRange.
isValid()) {
6052 S.
Diag(IsDefaultArgument ? TemplateNameLoc : ArgExpr->getLocStart(),
6053 diag::err_dependent_typed_non_type_arg_in_partial_spec)
6054 << Param->
getType() << ParamUseRange;
6056 << (IsDefaultArgument ? ParamUseRange :
SourceRange());
6078 SmallVectorImpl<TemplateArgument> &TemplateArgs) {
6081 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
6088 S, TemplateNameLoc, Param, &ArgList[I], 1, I >= NumExplicit))
6103 TemplateParameterLists,
6105 assert(TUK != TUK_Reference &&
"References are not specializations");
6112 ? TemplateParameterLists[0]->getTemplateLoc() : KWLoc;
6122 if (!ClassTemplate) {
6123 Diag(TemplateNameLoc, diag::err_not_class_template_specialization)
6129 bool isExplicitSpecialization =
false;
6130 bool isPartialSpecialization =
false;
6136 bool Invalid =
false;
6138 MatchTemplateParametersToScopeSpecifier(
6139 KWLoc, TemplateNameLoc, SS, &TemplateId,
6140 TemplateParameterLists, TUK == TUK_Friend, isExplicitSpecialization,
6145 if (TemplateParams && TemplateParams->
size() > 0) {
6146 isPartialSpecialization =
true;
6148 if (TUK == TUK_Friend) {
6149 Diag(KWLoc, diag::err_partial_specialization_friend)
6157 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
6160 if (TTP->hasDefaultArgument()) {
6161 Diag(TTP->getDefaultArgumentLoc(),
6162 diag::err_default_arg_in_partial_spec);
6163 TTP->removeDefaultArgument();
6166 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
6167 if (
Expr *DefArg = NTTP->getDefaultArgument()) {
6168 Diag(NTTP->getDefaultArgumentLoc(),
6169 diag::err_default_arg_in_partial_spec)
6170 << DefArg->getSourceRange();
6171 NTTP->removeDefaultArgument();
6177 diag::err_default_arg_in_partial_spec)
6183 }
else if (TemplateParams) {
6184 if (TUK == TUK_Friend)
6185 Diag(KWLoc, diag::err_template_spec_friend)
6191 isExplicitSpecialization =
true;
6193 assert(TUK == TUK_Friend &&
"should have a 'template<>' for this decl");
6199 assert(Kind !=
TTK_Enum &&
"Invalid enum tag in class template spec!");
6201 Kind, TUK == TUK_Definition, KWLoc,
6203 Diag(KWLoc, diag::err_use_with_wrong_tag)
6208 diag::note_previous_use);
6217 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
6218 if (DiagnoseUnexpandedParameterPack(TemplateArgs[I],
6219 UPPC_PartialSpecialization))
6225 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
6226 TemplateArgs,
false, Converted))
6231 if (isPartialSpecialization) {
6234 TemplateArgs.
size(), Converted))
6237 bool InstantiationDependent;
6241 TemplateArgs.
size(),
6242 InstantiationDependent)) {
6243 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
6245 isPartialSpecialization =
false;
6249 void *InsertPos =
nullptr;
6252 if (isPartialSpecialization)
6262 if (TUK != TUK_Friend &&
6265 isPartialSpecialization))
6270 if (isPartialSpecialization) {
6284 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
6285 << 0 << (TUK == TUK_Definition)
6287 return CheckClassTemplate(S, TagSpec, TUK, KWLoc, SS,
6294 TemplateParameterLists.size() - 1,
6295 TemplateParameterLists.data());
6300 = cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl);
6304 KWLoc, TemplateNameLoc,
6313 if (TemplateParameterLists.size() > 1 && SS.
isSet()) {
6314 Partial->setTemplateParameterListsInfo(
Context,
6315 TemplateParameterLists.size() - 1,
6316 TemplateParameterLists.data());
6320 ClassTemplate->AddPartialSpecialization(Partial, InsertPos);
6321 Specialization = Partial;
6332 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
6334 TemplateParams->getDepth(),
6337 if (!DeducibleParams.all()) {
6338 unsigned NumNonDeducible = DeducibleParams.size()-DeducibleParams.count();
6339 Diag(TemplateNameLoc, diag::warn_partial_specs_not_deducible)
6340 << 0 << (NumNonDeducible > 1)
6342 for (
unsigned I = 0, N = DeducibleParams.size(); I != N; ++I) {
6343 if (!DeducibleParams[I]) {
6344 NamedDecl *Param = cast<NamedDecl>(TemplateParams->getParam(I));
6347 diag::note_partial_spec_unused_parameter)
6351 diag::note_partial_spec_unused_parameter)
6362 KWLoc, TemplateNameLoc,
6368 if (TemplateParameterLists.size() > 0) {
6370 TemplateParameterLists.size(),
6371 TemplateParameterLists.data());
6375 ClassTemplate->AddSpecialization(Specialization, InsertPos);
6398 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
6402 diag::note_instantiation_required_here)
6410 if (TUK != TUK_Friend)
6414 if (TUK == TUK_Definition) {
6417 if (Def && SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
6419 makeMergedDefinitionVisible(Hidden, KWLoc);
6421 TUK = TUK_Declaration;
6424 Diag(TemplateNameLoc, diag::err_redefinition)
6433 ProcessDeclAttributeList(S, Specialization, Attr);
6437 if (TUK == TUK_Definition) {
6438 AddAlignmentAttributesForRecord(Specialization);
6439 AddMsStructLayoutForRecord(Specialization);
6442 if (ModulePrivateLoc.
isValid())
6443 Diag(Specialization->
getLocation(), diag::err_module_private_specialization)
6444 << (isPartialSpecialization? 1 : 0)
6456 TemplateArgs, CanonType);
6457 if (TUK != TUK_Friend) {
6473 if (TUK == TUK_Definition)
6476 if (TUK == TUK_Friend) {
6482 CurContext->addDecl(Friend);
6487 CurContext->addDecl(Specialization);
6489 return Specialization;
6495 Decl *NewDecl = HandleDeclarator(S, D, TemplateParameterLists);
6496 ActOnDocumentableDecl(NewDecl);
6503 assert(getCurFunctionDecl() ==
nullptr &&
"Function parsing confused");
6513 Decl *DP = HandleDeclarator(ParentScope, D,
6514 TemplateParameterLists);
6515 return ActOnStartOfFunctionDef(FnBodyScope, DP);
6525 FD->setInlineSpecified(
false);
6536 for (
Decl *Prev = D; Prev && !PrevDiagLoc.
isValid();
6537 Prev = Prev->getPreviousDecl()) {
6538 PrevDiagLoc = Prev->getLocation();
6540 assert(PrevDiagLoc.
isValid() &&
6541 "Explicit instantiation without point of instantiation?");
6573 bool &HasNoEffect) {
6574 HasNoEffect =
false;
6581 "previous declaration must be implicit!");
6594 if (PrevPointOfInstantiation.
isInvalid()) {
6605 PrevPointOfInstantiation.
isValid()) &&
6606 "Explicit instantiation without point of instantiation?");
6620 Diag(NewLoc, diag::err_specialization_after_instantiation)
6622 Diag(PrevPointOfInstantiation, diag::note_instantiation_required_here)
6656 diag::err_explicit_instantiation_declaration_after_definition);
6662 diag::note_explicit_instantiation_definition_here);
6686 diag::warn_cxx98_compat_explicit_instantiation_after_specialization :
6687 diag::ext_explicit_instantiation_after_specialization)
6690 diag::note_previous_template_specialization);
6720 Diag(NewLoc, (getLangOpts().MSVCCompat)
6721 ? diag::ext_explicit_instantiation_duplicate
6722 : diag::err_explicit_instantiation_duplicate)
6725 diag::note_previous_explicit_instantiation);
6731 llvm_unreachable(
"Missing specialization/instantiation case?");
6759 if (!isa<FunctionTemplateDecl>(D) ||
6767 if (Previous.
empty())
return true;
6770 ExplicitTemplateArgs);
6807 if (!FDLookupContext->InEnclosingNamespaceSetOf(
6820 if (OldMD && OldMD->
isConst()) {
6839 cast<FunctionTemplateDecl>(FunTmpl->getFirstDecl()),
6840 ExplicitTemplateArgs, FT, Specialization, Info)) {
6843 FailedCandidates.addCandidate()
6844 .set(FunTmpl->getTemplatedDecl(),
6851 Candidates.
addDecl(Specialization, I.getAccess());
6857 Candidates.
begin(), Candidates.
end(), FailedCandidates,
6859 PDiag(diag::err_function_template_spec_no_match) << FD->
getDeclName(),
6860 PDiag(diag::err_function_template_spec_ambiguous)
6861 << FD->
getDeclName() << (ExplicitTemplateArgs !=
nullptr),
6862 PDiag(diag::note_function_template_spec_matched));
6864 if (Result == Candidates.
end())
6868 FunctionDecl *Specialization = cast<FunctionDecl>(*Result);
6872 assert(SpecInfo &&
"Function template specialization info missing?");
6906 bool HasNoEffect =
false;
6908 CheckSpecializationInstantiationRedecl(FD->
getLocation(),
6920 MarkUnusedFileScopedDecl(Specialization);
6929 FD->setFunctionTemplateSpecialization(Specialization->getPrimaryTemplate(),
6932 ExplicitTemplateArgs);
6937 Previous.
addDecl(Specialization);
6957 assert(!isa<TemplateDecl>(Member) &&
"Only for non-template members");
6964 if (Previous.
empty()) {
6966 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(Member)) {
6971 QualType Adjusted = Function->getType();
6972 if (!hasExplicitCallingConv(Adjusted))
6973 Adjusted = adjustCCAndNoReturn(Adjusted, Method->getType());
6975 Instantiation = Method;
6976 InstantiatedFrom = Method->getInstantiatedFromMemberFunction();
6977 MSInfo = Method->getMemberSpecializationInfo();
6982 }
else if (isa<VarDecl>(Member)) {
6987 Instantiation = PrevVar;
6991 }
else if (isa<RecordDecl>(Member)) {
6995 Instantiation = PrevRecord;
6999 }
else if (isa<EnumDecl>(Member)) {
7003 Instantiation = PrevEnum;
7009 if (!Instantiation) {
7020 if (InstantiatedFrom && isa<CXXMethodDecl>(Member)) {
7021 cast<CXXMethodDecl>(Member)->setInstantiationOfMemberFunction(
7022 cast<CXXMethodDecl>(InstantiatedFrom),
7024 }
else if (InstantiatedFrom && isa<CXXRecordDecl>(Member)) {
7025 cast<CXXRecordDecl>(Member)->setInstantiationOfMemberClass(
7026 cast<CXXRecordDecl>(InstantiatedFrom),
7031 Previous.
addDecl(Instantiation);
7036 if (!InstantiatedFrom) {
7049 assert(MSInfo &&
"Member specialization info missing?");
7051 bool HasNoEffect =
false;
7052 if (CheckSpecializationInstantiationRedecl(Member->
getLocation(),
7071 if (isa<FunctionDecl>(Member)) {
7072 FunctionDecl *InstantiationFunction = cast<FunctionDecl>(Instantiation);
7080 cast<FunctionDecl>(Member)->setInstantiationOfMemberFunction(
7081 cast<CXXMethodDecl>(InstantiatedFrom),
7083 MarkUnusedFileScopedDecl(InstantiationFunction);
7084 }
else if (isa<VarDecl>(Member)) {
7085 VarDecl *InstantiationVar = cast<VarDecl>(Instantiation);
7093 cast<VarDecl>(Member)->setInstantiationOfStaticDataMember(
7095 MarkUnusedFileScopedDecl(InstantiationVar);
7096 }
else if (isa<CXXRecordDecl>(Member)) {
7097 CXXRecordDecl *InstantiationClass = cast<CXXRecordDecl>(Instantiation);
7105 cast<CXXRecordDecl>(Member)->setInstantiationOfMemberClass(
7106 cast<CXXRecordDecl>(InstantiatedFrom),
7109 assert(isa<EnumDecl>(Member) &&
"Only member enums remain");
7110 EnumDecl *InstantiationEnum = cast<EnumDecl>(Instantiation);
7118 cast<EnumDecl>(Member)->setInstantiationOfMemberEnum(
7125 Previous.
addDecl(Instantiation);
7134 bool WasQualifiedName) {
7139 S.
Diag(InstLoc, diag::err_explicit_instantiation_in_class)
7152 if (WasQualifiedName) {
7153 if (CurContext->
Encloses(OrigContext))
7160 if (
NamespaceDecl *NS = dyn_cast<NamespaceDecl>(OrigContext)) {
7161 if (WasQualifiedName)
7164 diag::err_explicit_instantiation_out_of_scope :
7165 diag::warn_explicit_instantiation_out_of_scope_0x)
7170 diag::err_explicit_instantiation_unqualified_wrong_namespace :
7171 diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x)
7176 diag::err_explicit_instantiation_must_be_global :
7177 diag::warn_explicit_instantiation_must_be_global_0x)
7198 if (isa<TemplateSpecializationType>(T))
7225 "Invalid enum tag in class template explicit instantiation!");
7227 if (isa<TypeAliasTemplateDecl>(TD)) {
7228 Diag(KWLoc, diag::err_tag_reference_non_tag) <<
Kind;
7230 diag::note_previous_use);
7239 Diag(KWLoc, diag::err_use_with_wrong_tag)
7244 diag::note_previous_use);
7259 if (A->getKind() == AttributeList::AT_DLLExport) {
7261 diag::warn_attribute_dllexport_explicit_instantiation_decl);
7262 Diag(A->getLoc(), diag::note_attribute);
7269 diag::warn_attribute_dllexport_explicit_instantiation_decl);
7270 Diag(A->getLocation(), diag::note_attribute);
7276 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
7281 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
7282 TemplateArgs,
false, Converted))
7287 void *InsertPos =
nullptr;
7305 bool HasNoEffect =
false;
7307 if (CheckSpecializationInstantiationRedecl(TemplateNameLoc, TSK,
7308 PrevDecl, PrevDecl_TSK,
7323 Specialization = PrevDecl;
7329 if (!Specialization) {
7335 KWLoc, TemplateNameLoc,
7342 if (!HasNoEffect && !PrevDecl) {
7344 ClassTemplate->AddSpecialization(Specialization, InsertPos);
7367 ProcessDeclAttributeList(S, Specialization, Attr);
7373 CurContext->addDecl(Specialization);
7379 return Specialization;
7390 = cast_or_null<ClassTemplateSpecializationDecl>(
7393 InstantiateClassTemplateSpecialization(TemplateNameLoc, Specialization, TSK);
7395 MarkVTableUsed(TemplateNameLoc, Specialization,
true);
7400 Def = cast_or_null<ClassTemplateSpecializationDecl>(
7417 auto *A = cast<InheritableAttr>(
7419 A->setInherited(
true);
7421 checkClassLevelDLLAttribute(Def);
7424 for (
auto &B : Def->
bases()) {
7425 if (
auto *BT = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
7426 B.getType()->getAsCXXRecordDecl()))
7427 propagateDLLAttrToBaseClassTemplate(Def, A, BT, B.
getLocStart());
7432 InstantiateClassTemplateSpecializationMembers(TemplateNameLoc, Def, TSK);
7437 return Specialization;
7453 bool IsDependent =
false;
7455 KWLoc, SS, Name, NameLoc, Attr,
AS_none,
7460 assert(!IsDependent &&
"explicit instantiation of dependent name not yet handled");
7465 TagDecl *Tag = cast<TagDecl>(TagD);
7466 assert(!Tag->
isEnum() &&
"shouldn't see enumerations here");
7474 Diag(TemplateLoc, diag::err_explicit_instantiation_nontemplate_type)
7487 Diag(TemplateLoc, diag::ext_explicit_instantiation_without_qualified_id)
7512 bool HasNoEffect =
false;
7513 assert(MSInfo &&
"No member specialization information?");
7514 if (CheckSpecializationInstantiationRedecl(TemplateLoc, TSK,
7531 = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
7533 Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member)
7535 Diag(Pattern->getLocation(), diag::note_forward_declaration)
7539 if (InstantiateClass(NameLoc, Record, Def,
7540 getTemplateInstantiationArgs(Record),
7544 RecordDef = cast_or_null<CXXRecordDecl>(Record->
getDefinition());
7551 InstantiateClassMembers(NameLoc, RecordDef,
7552 getTemplateInstantiationArgs(Record), TSK);
7555 MarkVTableUsed(NameLoc, RecordDef,
true);
7575 diag::err_explicit_instantiation_requires_name)
7617 getLangOpts().CPlusPlus11 ?
7618 diag::err_explicit_instantiation_inline :
7619 diag::warn_explicit_instantiation_inline_0x)
7625 diag::err_explicit_instantiation_constexpr);
7652 if (!PrevTemplate) {
7659 Diag((*P)->getLocation(), diag::note_explicit_instantiation_here);
7666 diag::err_explicit_instantiation_data_member_not_instantiated)
7682 diag::err_auto_not_allowed_var_inst);
7691 diag::err_explicit_instantiation_without_template_id)
7693 Diag(PrevTemplate->getLocation(),
7694 diag::note_explicit_instantiation_here);
7702 DeclResult Res = CheckVarTemplateId(PrevTemplate, TemplateLoc,
7704 if (Res.isInvalid())
7709 Prev = cast<VarDecl>(Res.get());
7724 diag::ext_explicit_instantiation_without_qualified_id)
7733 bool HasNoEffect =
false;
7734 if (CheckSpecializationInstantiationRedecl(D.
getIdentifierLoc(), TSK, Prev,
7735 PrevTSK, POI, HasNoEffect))
7745 ProcessDeclAttributeList(S, Prev,
Attr);
7754 diag::err_invalid_var_template_spec_type)
7755 << 0 << PrevTemplate << R << Prev->getType();
7756 Diag(PrevTemplate->getLocation(), diag::note_template_declared_here)
7757 << 2 << PrevTemplate->getDeclName();
7762 return (
Decl*)
nullptr;
7767 bool HasExplicitTemplateArgs =
false;
7771 HasExplicitTemplateArgs =
true;
7784 if (!HasExplicitTemplateArgs) {
7785 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Prev)) {
7786 QualType Adjusted = adjustCCAndNoReturn(R, Method->getType());
7790 Matches.
addDecl(Method,
P.getAccess());
7805 (HasExplicitTemplateArgs ? &TemplateArgs
7807 R, Specialization, Info)) {
7809 FailedCandidates.addCandidate()
7816 Matches.
addDecl(Specialization,
P.getAccess());
7821 Matches.
begin(), Matches.
end(), FailedCandidates,
7823 PDiag(diag::err_explicit_instantiation_not_known) << Name,
7824 PDiag(diag::err_explicit_instantiation_ambiguous) << Name,
7825 PDiag(diag::note_explicit_instantiation_candidate));
7827 if (Result == Matches.
end())
7831 FunctionDecl *Specialization = cast<FunctionDecl>(*Result);
7840 if (FPT->hasExceptionSpec()) {
7842 diag::err_mismatched_exception_spec_explicit_instantiation;
7843 if (getLangOpts().MicrosoftExt)
7844 DiagID = diag::ext_mismatched_exception_spec_explicit_instantiation;
7845 bool Result = CheckEquivalentExceptionSpec(
7846 PDiag(DiagID) << Specialization->
getType(),
7847 PDiag(diag::note_explicit_instantiation_here),
7852 if (!getLangOpts().MicrosoftExt && Result)
7858 diag::err_explicit_instantiation_member_function_not_instantiated)
7862 Diag(Specialization->
getLocation(), diag::note_explicit_instantiation_here);
7868 PrevDecl = Specialization;
7871 bool HasNoEffect =
false;
7875 PrevDecl->getPointOfInstantiation(),
7882 return (
Decl*)
nullptr;
7888 ProcessDeclAttributeList(S, Specialization, Attr);
7893 Consumer.HandleTopLevelDecl(
DeclGroupRef(Specialization));
7909 diag::ext_explicit_instantiation_without_qualified_id)
7919 return (
Decl*)
nullptr;
7927 assert(Name &&
"Expected a name in a dependent tag");
7935 if (TUK == TUK_Declaration || TUK == TUK_Definition) {
7936 Diag(NameLoc, diag::err_dependent_tag_decl)
7937 << (TUK == TUK_Definition) << Kind << SS.
getRange();
7963 getLangOpts().CPlusPlus11 ?
7964 diag::warn_cxx98_compat_typename_outside_of_template :
7965 diag::ext_typename_outside_of_template)
7970 TypenameLoc, QualifierLoc, II, IdLoc);
7975 if (isa<DependentNameType>(T)) {
7987 return CreateParsedType(T, TSI);
8002 getLangOpts().CPlusPlus11 ?
8003 diag::warn_cxx98_compat_typename_outside_of_template :
8004 diag::ext_typename_outside_of_template)
8009 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
8014 assert(DTN &&
"dependent template has non-dependent name?");
8017 DTN->getQualifier(),
8018 DTN->getIdentifier(),
8031 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
8036 QualType T = CheckTemplateIdType(Template, TemplateNameLoc, TemplateArgs);
8048 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
8057 return CreateParsedType(T, TSI);
8066 if (!II.
isStr(
"type"))
8075 if (!EnableIfTSTLoc || EnableIfTSTLoc.
getNumArgs() == 0)
8078 cast<TemplateSpecializationType>(EnableIfTSTLoc.
getTypePtr());
8088 EnableIfDecl->getDeclName().getAsIdentifierInfo();
8089 if (!EnableIfII || !EnableIfII->
isStr(
"enable_if"))
8106 SS.
Adopt(QualifierLoc);
8124 if (RequireCompleteDeclContext(SS, Ctx))
8129 LookupQualifiedName(Result, Ctx, SS);
8130 unsigned DiagID = 0;
8131 Decl *Referenced =
nullptr;
8137 if (
isEnableIf(QualifierLoc, II, CondRange)) {
8138 Diag(CondRange.
getBegin(), diag::err_typename_nested_not_found_enable_if)
8139 << Ctx << CondRange;
8143 DiagID = diag::err_typename_nested_not_found;
8152 Diag(IILoc, diag::err_typename_refers_to_using_value_decl)
8153 << Name << Ctx << FullRange;
8157 Diag(Loc, diag::note_using_value_decl_missing_typename)
8174 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
8180 DiagID = diag::err_typename_nested_not_type;
8185 DiagID = diag::err_typename_nested_not_type;
8186 Referenced = *Result.
begin();
8197 Diag(IILoc, DiagID) << FullRange << Name << Ctx;
8206 class CurrentInstantiationRebuilder
8214 CurrentInstantiationRebuilder(
Sema &SemaRef,
8218 Loc(Loc), Entity(Entity) { }
8225 bool AlreadyTransformed(
QualType T) {
8240 this->Entity = Entity;
8282 CurrentInstantiationRebuilder Rebuilder(*
this, Loc, Name);
8283 return Rebuilder.TransformType(T);
8287 CurrentInstantiationRebuilder Rebuilder(*
this, E->
getExprLoc(),
8289 return Rebuilder.TransformExpr(E);
8300 = Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
8312 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
8316 if (isa<TemplateTypeParmDecl>(Param))
8321 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
8322 if (RebuildTemplateParamsInCurrentInstantiation(
8323 TTP->getTemplateParameters()))
8340 NTTP->
setType(NewTSI->getType());
8352 return getTemplateArgumentBindingsText(Params, Args.
data(), Args.
size());
8360 llvm::raw_svector_ostream Out(Str);
8362 if (!Params || Params->
size() == 0 || NumArgs == 0)
8363 return std::string();
8365 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
8375 Out << Id->getName();
8381 Args[I].
print(getPrintingPolicy(), Out);
8396 LPT->
Toks.swap(Toks);
8398 LateParsedTemplateMap.insert(std::make_pair(FD, LPT));
8413 if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(CurContext)) {
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
unsigned getFlags() const
bool isObjCObjectOrInterfaceType() const
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType) const
ExprResult BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
Construct a new expression that refers to the given integral template argument with the given source-...
Defines the clang::ASTContext interface.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
The null pointer literal (C++11 [lex.nullptr])
IdKind getKind() const
Determine what kind of name we have.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
Name lookup found a set of overloaded functions that met the criteria.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
DeclResult ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, TemplateIdAnnotation &TemplateId, AttributeList *Attr, MultiTemplateParamsArg TemplateParameterLists, SkipBodyInfo *SkipBody=nullptr)
bool isTransparentContext() const
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
static bool CheckTemplateArgumentIsCompatibleWithParameter(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *ArgIn, Expr *Arg, QualType ArgType)
Checks whether the given template argument is compatible with its template parameter.
bool isTemplateParameter() const
bool isNullPtrType() const
unsigned getDepth() const
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
bool TemplateParameterListsAreEqual(TemplateParameterList *New, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
Represents the dependent type named by a dependently-scoped typename using declaration, e.g. using typename Base<T>::foo; Template instantiation turns these into the underlying type.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
Simple class containing the result of Sema::CorrectTypo.
TemplateDeductionResult
Describes the result of template argument deduction.
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
bool isMemberPointerType() const
bool isSuppressingDiagnostics() const
Determines whether this lookup is suppressing diagnostics.
static bool isEnableIf(NestedNameSpecifierLoc NNS, const IdentifierInfo &II, SourceRange &CondRange)
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)
IdentifierInfo * getIdentifier() const
void addOuterTemplateArguments(const TemplateArgumentList *TemplateArgs)
Add a new outermost level to the multi-level template argument list.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
void setLookupName(DeclarationName Name)
Sets the name to look up.
SourceLocation TemplateNameLoc
ParsedType getAsType() const
Retrieve the template type argument's type.
static UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
DeclClass * getAsSingle() const
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
Filter makeFilter()
Create a filter for this result set.
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
void setLAngleLoc(SourceLocation Loc)
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
We are matching the template parameter lists of two templates that might be redeclarations.
TypeLoc getNamedTypeLoc() const
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
Provides information about an attempted template argument deduction, whose success or failure was des...
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
static bool DiagnoseDefaultTemplateArgument(Sema &S, Sema::TemplateParamListContext TPC, SourceLocation ParamLoc, SourceRange DefArgRange)
Diagnose the presence of a default template argument on a template parameter, which is ill-formed in ...
const Scope * getParent() const
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
Represents a qualified type name for which the type name is dependent.
void setObjCLifetime(ObjCLifetime type)
CXXRecordDecl * getDecl() const
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params)
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments...
void erase()
Erase the last element returned from this iterator.
static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D)
Determine what kind of template specialization the given declaration is.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
QualType getUnderlyingType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, NamedDecl **Params, unsigned NumParams, SourceLocation RAngleLoc)
bool isChar16Type() const
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Defines the C++ template declaration subclasses.
void setModulePrivate(bool MP=true)
Specify whether this declaration was marked as being private to the module in which it was defined...
Represents a C++11 auto or C++1y decltype(auto) type.
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
bool isEnumeralType() const
static SourceRange getRangeOfTypeInNestedNameSpecifier(ASTContext &Context, QualType T, const CXXScopeSpec &SS)
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
SCS getStorageClassSpec() const
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
std::string getAsString() const
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
QualType getPointeeType() const
IdentifierInfo * getAsIdentifierInfo() const
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, const TemplateArgument *Args, unsigned NumArgs, ClassTemplateSpecializationDecl *PrevDecl)
bool isMemberPointer() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
void setTemplateKeywordLoc(SourceLocation Loc)
Declaration of a variable template.
TemplateParamListContext
The context in which we are checking a template parameter list.
NamespaceDecl - Represent a C++ namespace.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
bool hasLValuePath() const
void setSpecializationKind(TemplateSpecializationKind TSK)
NamedDecl * getParam(unsigned Idx)
SourceLocation getInlineSpecLoc() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
bool isBooleanType() const
A container of type source information.
unsigned getIndex() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
static void StripImplicitInstantiation(NamedDecl *D)
Strips various properties off an implicit instantiation that has just been explicitly specialized...
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList * > FriendTypeTPLists=None)
Abstract base class used for diagnosing integer constant expression violations.
TemplateName SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs)
static bool CheckTemplatePartialSpecializationArgs(Sema &S, SourceLocation NameLoc, TemplateParameterList *TemplateParams, unsigned ExplicitArgs, SmallVectorImpl< TemplateArgument > &TemplateArgs)
Check the non-type template arguments of a class template partial specialization according to C++ [te...
const TemplateArgumentLoc * getArgumentArray() const
An identifier, stored as an IdentifierInfo*.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
RAII object that enters a new expression evaluation context.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
Information about one declarator, including the parsed type information and the identifier.
static SourceLocation DiagLocForExplicitInstantiation(NamedDecl *D, SourceLocation PointOfInstantiation)
Compute the diagnostic location for an explicit instantiation.
static TemplateArgument CreatePackCopy(ASTContext &Context, const TemplateArgument *Args, unsigned NumArgs)
Create a new template argument pack by copying the given set of template arguments.
Represents an empty template argument, e.g., one that has not been deduced.
ExtProtoInfo - Extra information about a function prototype.
AccessSpecifier getAccess() const
SourceLocation getLocation() const
Retrieve the location of the template argument.
TypeSpecifierType
Specifies the kind of type.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Represents a variable template specialization, which refers to a variable template with a given set o...
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
static bool isTemplateArgumentTemplateParameter(const TemplateArgument &Arg, unsigned Depth, unsigned Index)
A namespace, stored as a NamespaceDecl*.
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...
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, Decl **Params, unsigned NumParams, SourceLocation RAngleLoc)
static Optional< unsigned > getExpandedPackSize(NamedDecl *Param)
Check whether the template parameter is a pack expansion, and if so, determine the number of paramete...
Represents the result of substituting a type for a template type parameter.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
Defines the clang::Expr interface and subclasses for C++ expressions.
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
bool isEmpty() const
No scope specifier.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier...
Information about a template-id annotation token.
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
static void DiagnoseTemplateParameterListArityMismatch(Sema &S, TemplateParameterList *New, TemplateParameterList *Old, Sema::TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc)
Diagnose a known arity mismatch when comparing template argument lists.
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
Base wrapper for a particular "section" of type source info.
Expr * IgnoreImpCasts() LLVM_READONLY
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool OdrUse)
Perform marking for a reference to an arbitrary declaration. It marks the declaration referenced...
static bool hasVisibleDefaultArgument(Sema &S, const ParmDecl *D, llvm::SmallVectorImpl< Module * > *Modules)
Scope * getTemplateParamParent()
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
QualType getElementType() const
DeclarationName getName() const
getName - Returns the embedded declaration name.
Represents a class template specialization, which refers to a class template with a given set of temp...
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
OpaquePtr< QualType > ParsedType
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl)
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
void replace(NamedDecl *D)
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
AttributeList * getList() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
CXXRecordDecl * getPreviousDecl()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
Represents a dependent template name that cannot be resolved prior to template instantiation.
NestedNameSpecifierLoc SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const MultiLevelTemplateArgumentList &TemplateArgs)
unsigned getNumArgs() const
ArrayRef< QualType > getParamTypes() const
static NamedDecl * isAcceptableTemplateName(ASTContext &Context, NamedDecl *Orig, bool AllowFunctionTemplates)
Determine whether the declaration found is acceptable as the name of a template and, if so, return that template declaration. Otherwise, returns NULL.
bool isIdentifier() const
Determine whether this template name refers to an identifier.
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
const CXXScopeSpec & getCXXScopeSpec() const
bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD, const TemplateArgumentListInfo &ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given dependent function template specialization.
Decl * ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, unsigned Depth, unsigned Position, SourceLocation EqualLoc, Expr *DefaultArg)
bool isReferenceType() const
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
SourceLocation getLocation() const
Fetches the primary location of the argument.
OverloadedOperatorKind Operator
The kind of overloaded operator.
TypeResult ActOnTemplateIdType(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false)
void startDefinition()
Starts the definition of this tag declaration.
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
bool isChar32Type() const
CXXRecordDecl * getDefinition() const
bool isTranslationUnit() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
void setElaboratedKeywordLoc(SourceLocation Loc)
TagKind getTagKind() const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Represents the result of substituting a set of types for a template type parameter pack...
A non-type template parameter, stored as an expression.
bool hasAnyAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true)
SourceLocation getLocStart() const LLVM_READONLY
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
Perform semantic analysis for the given non-template member specialization.
void ClearStorageClassSpecs()
The type of a non-type template parameter.
TypeSourceInfo * getTypeSourceInfo() const
SourceRange getSourceRange() const LLVM_READONLY
Fetches the full source range of the argument.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
SourceLocation getTemplateEllipsisLoc() const
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
QualType getUnderlyingType() const
void setDefaultArgument(Expr *DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, bool isAddressOfOperand, const TemplateArgumentListInfo *TemplateArgs)
static void maybeDiagnoseTemplateParameterShadow(Sema &SemaRef, Scope *S, SourceLocation Loc, IdentifierInfo *Name)
bool isNull() const
Determine whether this template name is NULL.
Represents a C++ unqualified-id that has been parsed.
TemplateArgument getArgumentPack() const
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt)
param_type_range param_types() const
SourceLocation getLAngleLoc() const
SmallVectorImpl< PartialDiagnosticAt > * Diag
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
Represents the results of name lookup.
const TargetInfo & getTargetInfo() const
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For an enumeration member that was instantiated from a member enumeration of a templated class...
void setRAngleLoc(SourceLocation Loc)
APValue Val
Val - This is the value the expression can be folded to.
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
QualType getReturnType() const
void FilterAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true)
const ValueDecl * getMemberPointerDecl() const
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
ParsedTemplateTy getAsTemplate() const
Retrieve the template template argument's template name.
KindType getKind() const
Determine what kind of template argument we have.
bool isObjCLifetimeType() const
TypeOfExprType (GCC extension).
NestedNameSpecifierLoc getTemplateQualifierLoc() const
char * location_data() const
Retrieve the data associated with the source-location information.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack)
SourceLocation getLocStart() const LLVM_READONLY
void setRedeclaration(bool Val)
bool isValueDependent() const
RecordDecl * getDecl() const
static bool MatchTemplateParameterKind(Sema &S, NamedDecl *New, NamedDecl *Old, bool Complain, Sema::TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc)
Match two template parameters within template parameter lists.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
Expr * IgnoreParenCasts() LLVM_READONLY
void setSpecializationKind(TemplateSpecializationKind TSK)
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
SourceLocation getRAngleLoc() const
Represents a C++ nested-name-specifier or a global scope specifier.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Def If non-NULL, and the type refers to some kind of declaration that can be completed (such as a C s...
SourceLocation getTemplateNameLoc() const
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember()
Retrieve the member class template partial specialization from which this particular class template p...
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Decl * ActOnTemplateDeclarator(Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs, SmallVectorImpl< TemplateArgument > &Converted)
Check that the given template arguments can be be provided to the given template, converting the argu...
Represents a C++ member access expression where the actual member referenced could not be resolved be...
A class that does preorder depth-first traversal on the entire Clang AST and visits each node...
static bool CheckTemplateArgumentPointerToMember(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *&ResultArg, TemplateArgument &Converted)
Checks whether the given template argument is a pointer to member constant according to C++ [temp...
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
ParsedTemplateArgument getTemplatePackExpansion(SourceLocation EllipsisLoc) const
Retrieve a pack expansion of the given template template argument.
const SourceRange & getSourceRange() const LLVM_READONLY
SourceLocation getLocStart() const LLVM_READONLY
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access. Does not test the acceptance criteria...
We are matching the template parameter lists of a template template argument against the template par...
Decl * ActOnTypeParameter(Scope *S, bool Typename, SourceLocation EllipsisLoc, SourceLocation KeyLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedType DefaultArg)
QualType getCanonicalTypeInternal() const
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name. Otherwise, returns NULL.
const UnresolvedSetImpl & asUnresolvedSet() const
bool isDefined(const FunctionDecl *&Definition) const
TyLocType push(QualType T)
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
EnumDecl * getDecl() const
We are matching the template parameter lists of two template template parameters as part of matching ...
QualType getTemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs, QualType Canon=QualType()) const
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
TemplateName getUnderlying() const
bool isTemplateParameterPack() const
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
static Sema::TemplateDeductionResult DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, const TemplateArgument &Param, TemplateArgument Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
QualType getValueType() const
QualType getInjectedSpecializationType() const
bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg, SmallVectorImpl< TemplateArgument > &Converted)
DeclSpec & getMutableDeclSpec()
Sema - This implements semantic analysis and AST building for C.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, SmallVectorImpl< TemplateArgument > &Converted, CheckTemplateArgumentKind CTAK=CTAK_Specified)
Check that the given template argument corresponds to the given template parameter.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
SourceLocation getLocStart() const LLVM_READONLY
Qualifiers::ObjCLifetime getObjCLifetime() const
getObjCLifetime - Returns lifetime attribute of this type.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const
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...
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...
SourceLocation getTypeSpecStartLoc() const
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization, retrieves the member specialization information.
TemplateParameterListEqualKind
Enumeration describing how template parameter lists are compared for equality.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams)
Check whether a template can be declared within this scope.
QualType getPointeeType() const
void setTemplateNameLoc(SourceLocation Loc)
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, const TemplateArgumentListInfo &Args) const
bool isSignedIntegerOrEnumerationType() const
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
QualType getPointeeType() const
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
Defines the clang::LangOptions interface.
DeclResult CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation TemplateNameLoc, const TemplateArgumentListInfo &TemplateArgs)
DeclarationName getLookupName() const
Gets the name to look up.
StringRef getName() const
Return the actual identifier string.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e. the class which was looked into to find these result...
Declaration of a template type parameter.
SourceLocation getNameLoc() const
This file defines the classes used to store parsed information about declaration-specifiers and decla...
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl, ClassTemplateDecl *PrevDecl)
Create a class template node.
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that makes a template template argument into a pack expansion...
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
void setInvalidDecl(bool Invalid=true)
TranslationUnitDecl * getTranslationUnitDecl() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup. Asserts that one was found.
SourceLocation getLocation() const
ArgKind getKind() const
Return the kind of stored template argument.
ExtProtoInfo getExtProtoInfo() const
DeclContext * getDeclContext()
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
void setMemberSpecialization()
Note that this member template is a specialization.
void NoteAllFoundTemplates(TemplateName Name)
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)
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given function template specialization.
TypeSourceInfo * getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &Args, QualType Canon=QualType()) const
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
A namespace alias, stored as a NamespaceAliasDecl*.
void setLateTemplateParsed(bool ILT=true)
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
bool isConstexprSpecified() const
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
TemplateNameKind
Specifies the kind of template name that an identifier refers to. Be careful when changing this: this...
QualType getType() const
Get the type for which this source info wrapper provides information.
StorageClass
Storage classes.
ClassTemplateDecl * getInstantiatedFromMemberTemplate()
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
const SourceRange & getRange() const
bool isDependentType() const
bool isFunctionOrMethod() const
Declaration of an alias template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, const TemplateArgument *Args, unsigned NumArgs, const TemplateArgumentListInfo &ArgInfos, QualType CanonInjectedType, ClassTemplatePartialSpecializationDecl *PrevDecl)
Data structure that captures multiple levels of template argument lists for use in template instantia...
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
void setLocation(SourceLocation L)
DeclarationName getDeclName() const
Represents a reference to a non-type template parameter that has been substituted with a template arg...
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization)
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
QualType getElementType() const
The result type of a method or function.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration. Return null if the results were absent...
bool hasNameForLinkage() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
SourceLocation getStorageClassSpecLoc() const
RecordDecl * getDefinition() const
A type, stored as a Type*.
bool isUnsignedIntegerOrEnumerationType() const
static TemplateArgumentLoc translateTemplateArgument(Sema &SemaRef, const ParsedTemplateArgument &Arg)
TypeSourceInfo * getTypeSourceInfo() const
QualType getReplacementType() const
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
const TypeClass * getTypePtr() const
bool isLValueOnePastTheEnd() const
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
bool hasUnnamedOrLocalType() const
Whether this type is or contains a local or unnamed type.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
static void MarkUsedTemplateParameters(ASTContext &Ctx, QualType T, bool OnlyDeduced, unsigned Level, llvm::SmallBitVector &Deduced)
Mark the template parameters that are used by the given type.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
static bool DiagnoseUnexpandedParameterPacks(Sema &S, TemplateTemplateParmDecl *TTP)
Check for unexpanded parameter packs within the template parameters of a template template parameter...
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
TemplateArgumentLoc getArgLoc(unsigned i) const
DeclContext * getEntity() const
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
ASTMatchFinder *const Finder
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
static NullPointerValueKind isNullPointerValueTemplateArgument(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *Arg)
Determine whether the given template argument is a null pointer value of the appropriate type...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
void setLAngleLoc(SourceLocation Loc)
Represents the parsed form of a C++ template argument.
A stack object to be created when performing template instantiation.
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
static bool isSameAsPrimaryTemplate(TemplateParameterList *Params, ArrayRef< TemplateArgument > Args)
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
Expr * getAsExpr() const
Retrieve the non-type template argument's expression.
const Type * getTypePtr() const
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
QualType getElementType() const
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
TypeOfType (GCC extension).
An overloaded operator name, e.g., operator+.
static bool CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *ArgIn, TemplateArgument &Converted)
Checks whether the given template argument is the address of an object or function according to C++ [...
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
bool isValid() const
Return true if this is a valid SourceLocation object.
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
static void SetNestedNameSpecifier(TagDecl *T, const CXXScopeSpec &SS)
TagDecl - Represents the declaration of a struct/union/class/enum.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc)
Build the type that describes a C++ typename specifier, e.g., "typename T::type". ...
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template apply...
ASTContext & getASTContext() const LLVM_READONLY
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
ValueKind getKind() const
Represents a dependent using declaration which was not marked with typename.
Represents a static or instance method of a struct/union/class.
unsigned getDepth() const
Retrieve the depth of the template parameter.
void print(const PrintingPolicy &Policy, raw_ostream &Out) const
Print this template argument to the given output stream.
SourceLocation getNameLoc() const
QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc)
Check that the type of a non-type template parameter is well-formed.
void set(Decl *Spec, DeductionFailureInfo Info)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
Name lookup found an unresolvable value declaration and cannot yet complete. This only happens in C++...
static bool CheckTemplateSpecializationScope(Sema &S, NamedDecl *Specialized, NamedDecl *PrevDecl, SourceLocation Loc, bool IsPartialSpecialization)
Check whether a specialization is well-formed in the current context.
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template...
SourceLocation getConstexprSpecLoc() const
bool isTemplateParamScope() const
void addDecl(NamedDecl *D)
void setPointOfInstantiation(SourceLocation Loc)
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setElaboratedKeywordLoc(SourceLocation Loc)
SourceLocation getBegin() const
bool isTypeDependent() const
SourceLocation getBeginLoc() const
const SourceRange & getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
No entity found met the criteria.
bool isFileContext() const
A template type parameter, stored as a type.
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization, returns the templated static data member from which it was instantiated.
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, Sema::TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
Attr * clone(ASTContext &C) const
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
QualType getType() const
Return the type wrapped by this type source info.
void addArgument(const TemplateArgumentLoc &Loc)
void setTemplateParameterListsInfo(ASTContext &Context, unsigned NumTPLists, TemplateParameterList **TPLists)
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
SourceLocation getExprLoc() const LLVM_READONLY
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
The injected class name of a C++ class template or class template partial specialization. Used to record that a type was spelled with a bare identifier rather than as a template-id; the equivalent for non-templated classes is just RecordType.
QualType getPointeeType() const
A qualified reference to a name whose declaration cannot yet be resolved.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
Represents a pack expansion of types.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
void setTemplateKeywordLoc(SourceLocation Loc)
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>...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template...
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Decl * ActOnTemplateTemplateParameter(Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params, SourceLocation EllipsisLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg)
Represents a template argument.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
QualType getAsType() const
Retrieve the type for a type template argument.
TagTypeKind
The kind of a tag type.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
The name does not refer to a template.
const CXXScopeSpec & getScopeSpec() const
Retrieve the nested-name-specifier that precedes the template name in a template template argument...
void setMemberSpecialization()
Note that this member template is a specialization.
bool RebuildTemplateParamsInCurrentInstantiation(TemplateParameterList *Params)
Rebuild the template parameters now that we know we're in a current instantiation.
void removeDefaultArgument()
Removes the default argument of this template parameter.
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type. Can only be called on array an...
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
EvalResult is a struct with detailed info about an evaluated expression.
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
bool isDependent() const
Determines whether this is a dependent template name.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
SourceLocation getLocStart() const LLVM_READONLY
TemplateSpecializationKind getTemplateSpecializationKind() const
If this enumeration is a member of a specialization of a templated class, determine what kind of temp...
CXXScopeSpec SS
The nested-name-specifier that precedes the template name.
TemplateName getCanonicalTemplateName(TemplateName Name) const
Retrieves the "canonical" template name that refers to a given template.
bool isInvalidDecl() const
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
This is a scope that corresponds to the template parameters of a C++ template. Template parameter sco...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo &TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization...
Represents a C++11 pack expansion that produces a sequence of expressions.
std::string getAsString(ASTContext &Ctx, QualType Ty) const
bool isThisDeclarationADefinition() const
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set...
bool isSingleResult() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS, const IdentifierInfo &II, SourceLocation IdLoc)
Called when the parser has parsed a C++ typename specifier, e.g., "typename T::type".
ExprResult DefaultFunctionArrayConversion(Expr *E)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
A type that was preceded by the 'template' keyword, stored as a Type*.
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration...
bool isWideCharType() const
unsigned getDepth() const
Get the nesting depth of the template parameter.
QualType getNonReferenceType() const
void setNameLoc(SourceLocation Loc)
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
static VarTemplatePartialSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, const TemplateArgument *Args, unsigned NumArgs, const TemplateArgumentListInfo &ArgInfos)
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
Name lookup found a single declaration that met the criteria. getFoundDecl() will return this declara...
bool empty() const
Return true if no decls were found.
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember()
Retrieve the member variable template partial specialization from which this particular variable temp...
ArrayRef< LValuePathEntry > getLValuePath() const
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, const TemplateArgument *Args, unsigned NumArgs)
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Determine what kind of template instantiation this function represents.
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member. If the point of instantiation is an invalid...
static SourceRange findTemplateParameter(unsigned Depth, Expr *E)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
unsigned getNumArgs() const
QualType getIntegralType() const
Retrieve the type of the integral value.
void setTypeSourceInfo(TypeSourceInfo *TI)
void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK)
Specify that this variable is an instantiation of the static data member VD.
void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl, bool NeedDefinition, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
bool isFunctionType() const
TemplateParameterList * MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, ArrayRef< TemplateParameterList * > ParamLists, bool IsFriend, bool &IsExplicitSpecialization, bool &Invalid)
Match the given template parameter lists to the given scope specifier, returning the template paramet...
DeclContext * getRedeclContext()
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isInvalid() const
Determine whether the given template argument is invalid.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
SourceRange getTemplateParamsRange(TemplateParameterList const *const *Params, unsigned NumParams)
Retrieves the range of the given template parameter lists.
DeclResult ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS, TemplateTy Template, SourceLocation TemplateNameLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, AttributeList *Attr)
The template argument is a type.
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
ActionResult< ParsedType > TypeResult
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
const TypeClass * getTypePtr() const
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
NestedNameSpecifier * getQualifier() const
bool isInlineSpecified() const
A template-id, e.g., f<int>.
bool isStaticDataMember() const
Determines whether this is a static data member.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
static bool ScopeSpecifierHasTemplateId(const CXXScopeSpec &SS)
Determine whether the given scope specifier has a template-id in it.
void setInstantiationOf(VarTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this variable template specialization is actually an instantiation of the given variable te...
void setDescribedClassTemplate(ClassTemplateDecl *Template)
QualType getPointeeType() const
This is a scope that can contain a declaration. Some scopes just contain loop constructs but don't co...
IdentifierInfo * getIdentifier() const
A template argument list.
const Type * getClass() const
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
TemplateNameKind ActOnDependentTemplateName(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template)
Form a dependent template name.
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
SourceLocation getIdentifierLoc() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
const LValueBase getLValueBase() const
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
A user-defined literal name, e.g., operator "" _i.
Decl * D
The template function declaration to be late parsed.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member...
void setConstexpr(bool IC)
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
Provides information a specialization of a member of a class template, which may be a member function...
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
A structure for storing the information associated with an overloaded template name.
ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Decl * ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
Location information for a TemplateArgument.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Declaration of a class template.
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
LookupResultKind getResultKind() const
DeclResult ActOnVarTemplateSpecialization(Scope *S, Declarator &D, TypeSourceInfo *DI, SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, StorageClass SC, bool IsPartialSpecialization)
static TemplateArgumentListInfo makeTemplateArgumentListInfo(Sema &S, TemplateIdAnnotation &TemplateId)
Convert the parser's template argument list representation into our form.
Defines the clang::TargetInfo interface.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
void setRAngleLoc(SourceLocation Loc)
static bool CheckExplicitInstantiationScope(Sema &S, NamedDecl *D, SourceLocation InstLoc, bool WasQualifiedName)
Check the scope of an explicit instantiation.
static Decl::Kind getKind(const Decl *D)
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
void LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType, bool EnteringContext, bool &MemberOfUnknownSpecialization)
bool isValid() const
A scope specifier is present, and it refers to a real scope.
A reference to a declared variable, function, enum, etc. [C99 6.5.1p2].
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization, retrieves the member specialization information.
Represents a type template specialization; the template must be a class template, a type alias templa...
NamedDecl * getMostRecentDecl()
SourceLocation getRAngleLoc() const
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
QualType getElementType() const
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
void setMemberSpecialization()
Note that this member template is a specialization.
void setInheritedDefaultArgument(const ASTContext &C, TemplateTemplateParmDecl *Prev)
static bool diagnoseArityMismatch(Sema &S, TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
Diagnose an arity mismatch in the.
Contains a late templated function. Will be parsed at the end of the translation unit, used by Sema & Parser.
void suppressDiagnostics()
AttributeList * getNext() const
An l-value expression is a reference to an object with independent storage.
static bool anyDependentTemplateArguments(const TemplateArgumentLoc *Args, unsigned NumArgs, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
static bool DependsOnTemplateParameters(QualType T, TemplateParameterList *Params)
StringRef getKindName() const
Wrapper for template type parameters.
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
bool isParameterPack() const
Whether this declaration is a parameter pack.
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
void setLexicalDeclContext(DeclContext *DC)
bool isInvalidType() const
A boolean literal, per ([C++ lex.bool] Boolean literals).
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization, retrieves the function from which it was instantiated.
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
void setAccess(AccessSpecifier AS)
A template template argument, stored as a template name.
void setTemplateNameLoc(SourceLocation Loc)
No keyword precedes the qualified type name.
bool isNull() const
isNull - Return true if this QualType doesn't point to a type yet.
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user. This will be a class template spe...
unsigned NumArgs
NumArgs - The number of template arguments.
The global specifier '::'. There is no stored value.
void setType(QualType newType)
const TemplateArgument & getArgument() const
SourceRange getSourceRange() const LLVM_READONLY
Declaration of a template function.
void clear()
Clears out any current state.
bool IsInsideALocalClassWithinATemplateFunction()
void setElaboratedKeywordLoc(SourceLocation Loc)
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc, TemplateDecl *TD, const TemplateParmDecl *D, TemplateArgumentListInfo &Args)
Diagnose a missing template argument.
A single template declaration.
void setRBraceLoc(SourceLocation L)
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
ParsedTemplateTy Template
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
NamedDecl *const * iterator
const DeclSpec & getDeclSpec() const
TypeSourceInfo * SubstType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity)
Perform substitution on the type T with a given set of template arguments.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isPointerType() const
SourceLocation getTemplateLoc() const
bool isIncompleteOrObjectType() const
QualType getDeducedType() const
Get the type deduced for this auto type, or null if it's either not been deduced or was deduced to a ...