32 #include "llvm/ADT/SmallBitVector.h"
33 #include "llvm/ADT/SmallString.h"
34 #include "llvm/ADT/StringExtras.h"
37 using namespace clang;
45 return SourceRange(Ps[0]->getTemplateLoc(), Ps[N-1]->getRAngleLoc());
53 bool AllowFunctionTemplates) {
56 if (isa<TemplateDecl>(D)) {
57 if (!AllowFunctionTemplates && isa<FunctionTemplateDecl>(D))
75 if (Record->isInjectedClassName()) {
76 Record = cast<CXXRecordDecl>(Record->getDeclContext());
77 if (Record->getDescribedClassTemplate())
78 return Record->getDescribedClassTemplate();
81 = dyn_cast<ClassTemplateSpecializationDecl>(Record))
82 return Spec->getSpecializedTemplate();
92 bool AllowFunctionTemplates) {
94 llvm::SmallPtrSet<ClassTemplateDecl *, 8> ClassTemplates;
99 AllowFunctionTemplates);
102 else if (Repl != Orig) {
113 if (!ClassTemplates.insert(ClassTmpl).second) {
130 bool AllowFunctionTemplates) {
140 bool hasTemplateKeyword,
143 bool EnteringContext,
145 bool &MemberOfUnknownSpecialization) {
146 assert(getLangOpts().
CPlusPlus &&
"No template names in C!");
149 MemberOfUnknownSpecialization =
false;
172 LookupTemplateName(R, S, SS, ObjectType, EnteringContext,
173 MemberOfUnknownSpecialization);
175 if (R.isAmbiguous()) {
177 R.suppressDiagnostics();
187 unsigned ResultCount = R.end() - R.begin();
188 if (ResultCount > 1) {
195 R.suppressDiagnostics();
197 TemplateDecl *TD = cast<TemplateDecl>((*R.begin())->getUnderlyingDecl());
202 hasTemplateKeyword, TD);
207 if (isa<FunctionTemplateDecl>(TD)) {
211 R.suppressDiagnostics();
213 assert(isa<ClassTemplateDecl>(TD) || isa<TemplateTemplateParmDecl>(TD) ||
214 isa<TypeAliasTemplateDecl>(TD) || isa<VarTemplateDecl>(TD) ||
215 isa<BuiltinTemplateDecl>(TD));
221 TemplateResult = TemplateTy::make(Template);
234 if (!SS || !SS->
isSet() || !isDependentScopeSpecifier(*SS) ||
235 computeDeclContext(*SS))
241 Diag(IILoc, diag::err_template_kw_missing)
253 bool EnteringContext,
254 bool &MemberOfUnknownSpecialization) {
256 MemberOfUnknownSpecialization =
false;
258 bool isDependent =
false;
259 if (!ObjectType.
isNull()) {
262 assert(!SS.
isSet() &&
"ObjectType and scope specifier cannot coexist");
263 LookupCtx = computeDeclContext(ObjectType);
267 "Caller should have completed object type");
274 }
else if (SS.
isSet()) {
277 LookupCtx = computeDeclContext(SS, EnteringContext);
278 isDependent = isDependentScopeSpecifier(SS);
281 if (LookupCtx && RequireCompleteDeclContext(SS, LookupCtx))
285 bool ObjectTypeSearchedInScope =
false;
286 bool AllowFunctionTemplatesInLookup =
true;
292 LookupQualifiedName(Found, LookupCtx);
303 if (S) LookupName(Found, S);
304 ObjectTypeSearchedInScope =
true;
305 AllowFunctionTemplatesInLookup =
false;
307 }
else if (isDependent && (!S || ObjectType.
isNull())) {
310 MemberOfUnknownSpecialization =
true;
314 LookupName(Found, S);
317 AllowFunctionTemplatesInLookup =
false;
320 if (Found.
empty() && !isDependent) {
325 auto FilterCCC = llvm::make_unique<CorrectionCandidateCallback>();
326 FilterCCC->WantTypeSpecifiers =
false;
327 FilterCCC->WantExpressionKeywords =
false;
328 FilterCCC->WantRemainingKeywords =
false;
329 FilterCCC->WantCXXNamedCasts =
true;
332 std::move(FilterCCC), CTK_ErrorRecovery, LookupCtx)) {
334 if (
auto *ND = Corrected.getFoundDecl())
336 FilterAcceptableTemplateNames(Found);
337 if (!Found.
empty()) {
339 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
340 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
342 diagnoseTypo(Corrected, PDiag(diag::err_no_member_template_suggest)
343 << Name << LookupCtx << DroppedSpecifier
346 diagnoseTypo(Corrected, PDiag(diag::err_no_template_suggest) << Name);
354 FilterAcceptableTemplateNames(Found, AllowFunctionTemplatesInLookup);
357 MemberOfUnknownSpecialization =
true;
361 if (S && !ObjectType.
isNull() && !ObjectTypeSearchedInScope &&
362 !getLangOpts().CPlusPlus11) {
371 LookupName(FoundOuter, S);
372 FilterAcceptableTemplateNames(FoundOuter,
false);
374 if (FoundOuter.empty()) {
378 FoundOuter.isAmbiguous()) {
389 != FoundOuter.getFoundDecl()->getCanonicalDecl()) {
391 diag::ext_nested_name_member_ref_lookup_ambiguous)
395 diag::note_ambig_member_ref_object_type)
397 Diag(FoundOuter.getFoundDecl()->getLocation(),
398 diag::note_ambig_member_ref_scope);
414 bool isAddressOfOperand,
429 bool MightBeCxx11UnevalField =
430 getLangOpts().CPlusPlus11 && isUnevaluatedContext();
432 if (!MightBeCxx11UnevalField && !isAddressOfOperand &&
433 isa<CXXMethodDecl>(DC) && cast<CXXMethodDecl>(DC)->isInstance()) {
438 NamedDecl *FirstQualifierInScope =
nullptr;
441 Context,
nullptr, ThisType,
true,
443 FirstQualifierInScope, NameInfo, TemplateArgs);
446 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
464 assert(PrevDecl->isTemplateParameter() &&
"Not a template parameter");
467 if (getLangOpts().MicrosoftExt)
473 Diag(Loc, diag::err_template_param_shadow)
474 << cast<NamedDecl>(PrevDecl)->getDeclName();
475 Diag(PrevDecl->getLocation(), diag::note_template_param_here);
482 if (
TemplateDecl *Temp = dyn_cast_or_null<TemplateDecl>(D)) {
483 D = Temp->getTemplatedDecl();
491 assert(
Kind == Template &&
492 "Only template template arguments can be pack expansions here");
493 assert(getAsTemplate().
get().containsUnexpandedParameterPack() &&
494 "Template template argument pack expansion without packs");
496 Result.EllipsisLoc = EllipsisLoc;
532 llvm_unreachable(
"Unhandled parsed template argument");
539 for (
unsigned I = 0,
Last = TemplateArgsIn.size();
I !=
Last; ++
I)
549 if (PrevDecl && PrevDecl->isTemplateParameter())
571 "Template type parameter not in template parameter scope!");
577 bool IsParameterPack = EllipsisLoc.
isValid();
581 Typename, IsParameterPack);
589 IdResolver.AddDecl(Param);
595 if (DefaultArg && IsParameterPack) {
596 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
597 DefaultArg =
nullptr;
603 GetTypeFromParser(DefaultArg, &DefaultTInfo);
605 assert(DefaultTInfo &&
"expected source information for type");
608 if (DiagnoseUnexpandedParameterPack(Loc, DefaultTInfo,
609 UPPC_DefaultArgument))
613 if (CheckTemplateArgument(Param, DefaultTInfo)) {
614 Param->setInvalidDecl();
634 Diag(Loc, diag::err_variably_modified_nontype_template_param)
670 Diag(Loc, diag::err_template_nontype_parm_bad_type)
685 "Non-type template parameter not in template parameter scope!");
686 bool Invalid =
false;
701 IsParameterPack, TInfo);
705 Param->setInvalidDecl();
713 IdResolver.AddDecl(Param);
719 if (Default && IsParameterPack) {
720 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
727 if (DiagnoseUnexpandedParameterPack(Default, UPPC_DefaultArgument))
732 CheckTemplateArgument(Param, Param->
getType(), Default, Converted);
734 Param->setInvalidDecl();
737 Default = DefaultRes.
get();
759 "Template template parameter not in template parameter scope!");
762 bool IsParameterPack = EllipsisLoc.
isValid();
776 IdResolver.AddDecl(Param);
779 if (Params->
size() == 0) {
780 Diag(Param->getLocation(), diag::err_template_template_parm_no_parms)
782 Param->setInvalidDecl();
788 if (IsParameterPack && !Default.
isInvalid()) {
789 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
804 Diag(DefaultArg.
getLocation(), diag::err_template_arg_not_valid_template)
810 if (DiagnoseUnexpandedParameterPack(DefaultArg.
getLocation(),
812 UPPC_DefaultArgument))
831 Expr *RequiresClause) {
833 Diag(ExportLoc, diag::warn_template_export_unsupported);
837 Context, TemplateLoc, LAngleLoc,
838 llvm::makeArrayRef((
NamedDecl *
const *)Params.data(), Params.size()),
855 unsigned NumOuterTemplateParamLists,
858 assert(TemplateParams && TemplateParams->
size() > 0 &&
859 "No template parameters");
860 assert(TUK != TUK_Reference &&
"Can only declare or define class templates");
861 bool Invalid =
false;
864 if (CheckTemplateDeclScope(S, TemplateParams))
868 assert(Kind !=
TTK_Enum &&
"can't build template of enumerated type");
872 Diag(KWLoc, diag::err_template_unnamed_class);
881 (SS.
isEmpty() && TUK == TUK_Friend)
882 ? LookupTagName : LookupOrdinaryName,
885 SemanticContext = computeDeclContext(SS,
true);
886 if (!SemanticContext) {
890 Diag(NameLoc, TUK == TUK_Friend
891 ? diag::warn_template_qualified_friend_ignored
892 : diag::err_template_qualified_declarator_no_match)
894 return TUK != TUK_Friend;
897 if (RequireCompleteDeclContext(SS, SemanticContext))
905 if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams))
907 }
else if (TUK != TUK_Friend && TUK != TUK_Reference)
908 diagnoseQualifiedDeclaration(SS, SemanticContext, Name, NameLoc);
910 LookupQualifiedName(Previous, SemanticContext);
912 SemanticContext = CurContext;
918 if (TUK != TUK_Friend &&
919 DiagnoseClassNameShadow(SemanticContext,
923 LookupName(Previous, S);
930 if (Previous.
begin() != Previous.
end())
931 PrevDecl = (*Previous.
begin())->getUnderlyingDecl();
933 if (PrevDecl && PrevDecl->isTemplateParameter()) {
935 DiagnoseTemplateParameterShadow(NameLoc, PrevDecl);
943 = dyn_cast_or_null<ClassTemplateDecl>(PrevDecl);
948 if (!PrevClassTemplate && PrevDecl && isa<CXXRecordDecl>(PrevDecl) &&
949 cast<CXXRecordDecl>(PrevDecl)->isInjectedClassName()) {
950 PrevDecl = cast<CXXRecordDecl>(PrevDecl->getDeclContext());
952 = cast<CXXRecordDecl>(PrevDecl)->getDescribedClassTemplate();
953 if (!PrevClassTemplate && isa<ClassTemplateSpecializationDecl>(PrevDecl)) {
955 = cast<ClassTemplateSpecializationDecl>(PrevDecl)
956 ->getSpecializedTemplate();
960 if (TUK == TUK_Friend) {
972 (OutermostContext->
Equals(PrevDecl->getDeclContext()) ||
973 OutermostContext->
Encloses(PrevDecl->getDeclContext()))) {
974 SemanticContext = PrevDecl->getDeclContext();
979 PrevDecl = PrevClassTemplate =
nullptr;
980 SemanticContext = OutermostContext;
984 Previous.
clear(LookupOrdinaryName);
988 LookupQualifiedName(Previous, LookupContext);
993 if (Previous.
begin() != Previous.
end())
994 PrevDecl = (*Previous.
begin())->getUnderlyingDecl();
997 }
else if (PrevDecl &&
1000 PrevDecl = PrevClassTemplate =
nullptr;
1002 if (
auto *Shadow = dyn_cast_or_null<UsingShadowDecl>(
1005 !(PrevClassTemplate &&
1006 PrevClassTemplate->getDeclContext()->getRedeclContext()->Equals(
1008 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
1009 Diag(Shadow->getTargetDecl()->getLocation(),
1010 diag::note_using_decl_target);
1011 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl) << 0;
1013 PrevDecl = PrevClassTemplate =
nullptr;
1017 if (PrevClassTemplate) {
1021 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
1022 !TemplateParameterListsAreEqual(TemplateParams,
1034 if (!isAcceptableTagRedeclaration(PrevRecordDecl, Kind,
1035 TUK == TUK_Definition, KWLoc, Name)) {
1036 Diag(KWLoc, diag::err_use_with_wrong_tag)
1039 Diag(PrevRecordDecl->getLocation(), diag::note_previous_use);
1044 if (TUK == TUK_Definition) {
1049 if (SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
1051 auto *Tmpl = cast<CXXRecordDecl>(Hidden)->getDescribedClassTemplate();
1052 assert(Tmpl &&
"original definition of a class template is not a "
1054 makeMergedDefinitionVisible(Hidden, KWLoc);
1055 makeMergedDefinitionVisible(Tmpl, KWLoc);
1059 Diag(NameLoc, diag::err_redefinition) <<
Name;
1060 Diag(Def->getLocation(), diag::note_previous_definition);
1066 }
else if (PrevDecl) {
1072 Diag(NameLoc, diag::err_redefinition_different_kind) <<
Name;
1073 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
1081 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
1082 CheckTemplateParameterList(
1086 (SS.
isSet() && SemanticContext && SemanticContext->
isRecord() &&
1088 ? TPC_ClassTemplateMember
1089 : TUK == TUK_Friend ? TPC_FriendClassTemplate
1090 : TPC_ClassTemplate))
1096 if (!SS.
isInvalid() && !Invalid && !PrevClassTemplate) {
1097 Diag(NameLoc, TUK == TUK_Friend ? diag::err_friend_decl_does_not_match
1098 : diag::err_member_decl_does_not_match)
1099 << Name << SemanticContext <<
true << SS.
getRange();
1110 if (NumOuterTemplateParamLists > 0)
1112 Context, llvm::makeArrayRef(OuterTemplateParamLists,
1113 NumOuterTemplateParamLists));
1117 if (TUK == TUK_Definition) {
1118 AddAlignmentAttributesForRecord(NewClass);
1119 AddMsStructLayoutForRecord(NewClass);
1125 NewClass, PrevClassTemplate);
1128 if (ModulePrivateLoc.
isValid())
1129 NewTemplate->setModulePrivate();
1134 assert(T->
isDependentType() &&
"Class template type is not dependent?");
1139 if (PrevClassTemplate &&
1144 if (!Invalid && TUK != TUK_Friend && NewTemplate->getDeclContext()->isRecord())
1145 SetMemberAccessSpecifier(NewTemplate, PrevClassTemplate, AS);
1148 NewClass->setLexicalDeclContext(CurContext);
1149 NewTemplate->setLexicalDeclContext(CurContext);
1151 if (TUK == TUK_Definition)
1155 ProcessDeclAttributeList(S, NewClass, Attr);
1157 if (PrevClassTemplate)
1160 AddPushedVisibilityAttribute(NewClass);
1162 if (TUK != TUK_Friend) {
1167 PushOnScopeChains(NewTemplate, Outer);
1169 if (PrevClassTemplate && PrevClassTemplate->getAccess() !=
AS_none) {
1170 NewTemplate->setAccess(PrevClassTemplate->getAccess());
1171 NewClass->setAccess(PrevClassTemplate->getAccess());
1174 NewTemplate->setObjectOfFriendDecl();
1177 if (!CurContext->isDependentContext()) {
1180 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
1181 PushOnScopeChains(NewTemplate, EnclosingScope,
1186 Context, CurContext, NewClass->getLocation(), NewTemplate, FriendLoc);
1188 CurContext->addDecl(Friend);
1192 NewTemplate->setInvalidDecl();
1193 NewClass->setInvalidDecl();
1196 ActOnDocumentableDecl(NewTemplate);
1226 diag::warn_cxx98_compat_template_parameter_default_in_function_template
1227 : diag::ext_template_parameter_default_in_function_template)
1236 S.
Diag(ParamLoc, diag::err_template_parameter_default_template_member)
1245 S.
Diag(ParamLoc, diag::err_template_parameter_default_friend_template)
1254 llvm_unreachable(
"Invalid TemplateParamListContext!");
1267 for (
unsigned I = 0, N = Params->
size();
I != N; ++
I) {
1270 if (!NTTP->isParameterPack() &&
1272 NTTP->getTypeSourceInfo(),
1280 = dyn_cast<TemplateTemplateParmDecl>(P))
1313 bool Invalid =
false;
1321 bool SawDefaultArgument =
false;
1327 OldParam = OldParams->
begin();
1329 bool RemoveDefaultArguments =
false;
1331 NewParamEnd = NewParams->
end();
1332 NewParam != NewParamEnd; ++NewParam) {
1334 bool RedundantDefaultArg =
false;
1339 bool MissingDefaultArg =
false;
1342 bool SawParameterPack =
false;
1345 = dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
1347 if (NewTypeParm->hasDefaultArgument() &&
1349 NewTypeParm->getLocation(),
1350 NewTypeParm->getDefaultArgumentInfo()->getTypeLoc()
1352 NewTypeParm->removeDefaultArgument();
1356 = OldParams? cast<TemplateTypeParmDecl>(*OldParam) :
nullptr;
1357 if (NewTypeParm->isParameterPack()) {
1358 assert(!NewTypeParm->hasDefaultArgument() &&
1359 "Parameter packs can't have a default argument!");
1360 SawParameterPack =
true;
1362 NewTypeParm->hasDefaultArgument()) {
1364 NewDefaultLoc = NewTypeParm->getDefaultArgumentLoc();
1365 SawDefaultArgument =
true;
1366 RedundantDefaultArg =
true;
1367 PreviousDefaultArgLoc = NewDefaultLoc;
1371 NewTypeParm->setInheritedDefaultArgument(
Context, OldTypeParm);
1373 }
else if (NewTypeParm->hasDefaultArgument()) {
1374 SawDefaultArgument =
true;
1375 PreviousDefaultArgLoc = NewTypeParm->getDefaultArgumentLoc();
1376 }
else if (SawDefaultArgument)
1377 MissingDefaultArg =
true;
1379 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
1381 if (!NewNonTypeParm->isParameterPack() &&
1382 DiagnoseUnexpandedParameterPack(NewNonTypeParm->getLocation(),
1383 NewNonTypeParm->getTypeSourceInfo(),
1384 UPPC_NonTypeTemplateParameterType)) {
1390 if (NewNonTypeParm->hasDefaultArgument() &&
1392 NewNonTypeParm->getLocation(),
1393 NewNonTypeParm->getDefaultArgument()->getSourceRange())) {
1394 NewNonTypeParm->removeDefaultArgument();
1399 = OldParams? cast<NonTypeTemplateParmDecl>(*OldParam) :
nullptr;
1400 if (NewNonTypeParm->isParameterPack()) {
1401 assert(!NewNonTypeParm->hasDefaultArgument() &&
1402 "Parameter packs can't have a default argument!");
1403 if (!NewNonTypeParm->isPackExpansion())
1404 SawParameterPack =
true;
1406 NewNonTypeParm->hasDefaultArgument()) {
1408 NewDefaultLoc = NewNonTypeParm->getDefaultArgumentLoc();
1409 SawDefaultArgument =
true;
1410 RedundantDefaultArg =
true;
1411 PreviousDefaultArgLoc = NewDefaultLoc;
1415 NewNonTypeParm->setInheritedDefaultArgument(
Context, OldNonTypeParm);
1417 }
else if (NewNonTypeParm->hasDefaultArgument()) {
1418 SawDefaultArgument =
true;
1419 PreviousDefaultArgLoc = NewNonTypeParm->getDefaultArgumentLoc();
1420 }
else if (SawDefaultArgument)
1421 MissingDefaultArg =
true;
1424 = cast<TemplateTemplateParmDecl>(*NewParam);
1435 NewTemplateParm->getLocation(),
1441 = OldParams? cast<TemplateTemplateParmDecl>(*OldParam) :
nullptr;
1444 "Parameter packs can't have a default argument!");
1446 SawParameterPack =
true;
1447 }
else if (OldTemplateParm &&
1452 SawDefaultArgument =
true;
1453 RedundantDefaultArg =
true;
1454 PreviousDefaultArgLoc = NewDefaultLoc;
1459 PreviousDefaultArgLoc
1462 SawDefaultArgument =
true;
1463 PreviousDefaultArgLoc
1465 }
else if (SawDefaultArgument)
1466 MissingDefaultArg =
true;
1472 if (SawParameterPack && (NewParam + 1) != NewParamEnd &&
1473 (TPC == TPC_ClassTemplate || TPC == TPC_VarTemplate ||
1474 TPC == TPC_TypeAliasTemplate)) {
1475 Diag((*NewParam)->getLocation(),
1476 diag::err_template_param_pack_must_be_last_template_parameter);
1480 if (RedundantDefaultArg) {
1484 Diag(NewDefaultLoc, diag::err_template_param_default_arg_redefinition);
1485 Diag(OldDefaultLoc, diag::note_template_param_prev_default_arg);
1487 }
else if (MissingDefaultArg && TPC != TPC_FunctionTemplate) {
1493 Diag((*NewParam)->getLocation(),
1494 diag::err_template_param_default_arg_missing);
1495 Diag(PreviousDefaultArgLoc, diag::note_template_param_prev_default_arg);
1497 RemoveDefaultArguments =
true;
1508 if (RemoveDefaultArguments) {
1510 NewParamEnd = NewParams->
end();
1511 NewParam != NewParamEnd; ++NewParam) {
1513 TTP->removeDefaultArgument();
1515 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
1516 NTTP->removeDefaultArgument();
1518 cast<TemplateTemplateParmDecl>(*NewParam)->removeDefaultArgument();
1536 DependencyChecker(
unsigned Depth) : Depth(Depth), Match(
false) {}
1541 Depth = PD->getDepth();
1543 dyn_cast<NonTypeTemplateParmDecl>(ND)) {
1544 Depth = PD->getDepth();
1546 Depth = cast<TemplateTemplateParmDecl>(ND)->getDepth();
1551 if (ParmDepth >=
Depth) {
1572 return super::TraverseTemplateName(N);
1577 dyn_cast<NonTypeTemplateParmDecl>(E->
getDecl()))
1580 return super::VisitDeclRefExpr(E);
1602 DependencyChecker Checker(Params);
1603 Checker.TraverseType(T);
1604 return Checker.Match;
1614 if (
const Type *CurType = NNS->getAsType()) {
1620 NNSLoc = NNSLoc.getPrefix();
1662 bool &IsExplicitSpecialization,
bool &Invalid) {
1663 IsExplicitSpecialization =
false;
1673 = dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS,
true)))
1685 NestedTypes.push_back(T);
1691 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
1692 if (!isa<ClassTemplatePartialSpecializationDecl>(Spec) &&
1694 ExplicitSpecLoc = Spec->getLocation();
1697 }
else if (Record->getTemplateSpecializationKind()
1699 ExplicitSpecLoc = Record->getLocation();
1703 if (
TypeDecl *Parent = dyn_cast<TypeDecl>(Record->getParent()))
1712 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
1713 if (
TypeDecl *Parent = dyn_cast<TypeDecl>(Template->getDeclContext()))
1758 std::reverse(NestedTypes.begin(), NestedTypes.end());
1766 bool SawNonEmptyTemplateParameterList =
false;
1768 auto CheckExplicitSpecialization = [&](
SourceRange Range,
bool Recovery) {
1769 if (SawNonEmptyTemplateParameterList) {
1770 Diag(DeclLoc, diag::err_specialize_member_of_template)
1771 << !Recovery << Range;
1773 IsExplicitSpecialization =
false;
1780 auto DiagnoseMissingExplicitSpecialization = [&] (
SourceRange Range) {
1782 if (CheckExplicitSpecialization(Range,
true))
1787 if (!ParamLists.empty())
1788 ExpectedTemplateLoc = ParamLists[0]->getTemplateLoc();
1790 ExpectedTemplateLoc = DeclStartLoc;
1792 Diag(DeclLoc, diag::err_template_spec_needs_header)
1798 unsigned ParamIdx = 0;
1799 for (
unsigned TypeIdx = 0, NumTypes = NestedTypes.size(); TypeIdx != NumTypes;
1801 T = NestedTypes[TypeIdx];
1804 bool NeedEmptyTemplateHeader =
false;
1807 bool NeedNonemptyTemplateHeader =
false;
1820 = dyn_cast<ClassTemplatePartialSpecializationDecl>(Record)) {
1821 ExpectedTemplateParams = Partial->getTemplateParameters();
1822 NeedNonemptyTemplateHeader =
true;
1823 }
else if (Record->isDependentType()) {
1824 if (Record->getDescribedClassTemplate()) {
1825 ExpectedTemplateParams = Record->getDescribedClassTemplate()
1826 ->getTemplateParameters();
1827 NeedNonemptyTemplateHeader =
true;
1830 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
1836 NeedEmptyTemplateHeader =
true;
1839 }
else if (Record->getTemplateSpecializationKind()) {
1840 if (Record->getTemplateSpecializationKind()
1842 TypeIdx == NumTypes - 1)
1843 IsExplicitSpecialization =
true;
1849 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
1850 ExpectedTemplateParams = Template->getTemplateParameters();
1851 NeedNonemptyTemplateHeader =
true;
1856 NeedNonemptyTemplateHeader =
false;
1866 if (ParamIdx < ParamLists.size()) {
1867 if (ParamLists[ParamIdx]->size() == 0) {
1868 if (CheckExplicitSpecialization(ParamLists[ParamIdx]->
getSourceRange(),
1872 SawNonEmptyTemplateParameterList =
true;
1875 if (NeedEmptyTemplateHeader) {
1878 if (TypeIdx == NumTypes - 1)
1879 IsExplicitSpecialization =
true;
1881 if (ParamIdx < ParamLists.size()) {
1882 if (ParamLists[ParamIdx]->size() > 0) {
1884 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
1885 diag::err_template_param_list_matches_nontemplate)
1887 <<
SourceRange(ParamLists[ParamIdx]->getLAngleLoc(),
1888 ParamLists[ParamIdx]->getRAngleLoc())
1900 if (DiagnoseMissingExplicitSpecialization(
1907 if (NeedNonemptyTemplateHeader) {
1913 if (ParamIdx < ParamLists.size() &&
1915 ExpectedTemplateParams =
nullptr;
1920 if (ParamIdx < ParamLists.size()) {
1922 if (ExpectedTemplateParams &&
1923 !TemplateParameterListsAreEqual(ParamLists[ParamIdx],
1924 ExpectedTemplateParams,
1925 true, TPL_TemplateMatch))
1929 CheckTemplateParameterList(ParamLists[ParamIdx],
nullptr,
1930 TPC_ClassTemplateMember))
1937 Diag(DeclLoc, diag::err_template_spec_needs_template_parameters)
1948 if (ParamIdx >= ParamLists.size()) {
1949 if (TemplateId && !IsFriend) {
1952 IsExplicitSpecialization =
true;
1966 if (ParamIdx < ParamLists.size() - 1) {
1967 bool HasAnyExplicitSpecHeader =
false;
1968 bool AllExplicitSpecHeaders =
true;
1969 for (
unsigned I = ParamIdx, E = ParamLists.size() - 1;
I !=
E; ++
I) {
1970 if (ParamLists[
I]->size() == 0)
1971 HasAnyExplicitSpecHeader =
true;
1973 AllExplicitSpecHeaders =
false;
1976 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
1977 AllExplicitSpecHeaders ? diag::warn_template_spec_extra_headers
1978 : diag::err_template_spec_extra_headers)
1979 <<
SourceRange(ParamLists[ParamIdx]->getTemplateLoc(),
1980 ParamLists[ParamLists.size() - 2]->getRAngleLoc());
1985 if (ExplicitSpecLoc.
isValid() && HasAnyExplicitSpecHeader)
1986 Diag(ExplicitSpecLoc,
1987 diag::note_explicit_template_spec_does_not_need_header)
1988 << NestedTypes.back();
1993 if (!AllExplicitSpecHeaders)
2004 if (ParamLists.back()->size() == 0 &&
2005 CheckExplicitSpecialization(ParamLists[ParamIdx]->
getSourceRange(),
2011 return ParamLists.back();
2016 Diag(Template->getLocation(), diag::note_template_declared_here)
2017 << (isa<FunctionTemplateDecl>(Template)
2019 : isa<ClassTemplateDecl>(Template)
2021 : isa<VarTemplateDecl>(Template)
2023 : isa<TypeAliasTemplateDecl>(Template) ? 3 : 4)
2024 << Template->getDeclName();
2032 Diag((*I)->getLocation(), diag::note_template_declared_here)
2033 << 0 << (*I)->getDeclName();
2041 const SmallVectorImpl<TemplateArgument> &Converted,
2052 if (!Converted[1].getAsType()->isIntegralType(Context)) {
2053 SemaRef.
Diag(TemplateArgs[1].getLocation(),
2054 diag::err_integer_sequence_integral_element_type);
2063 SemaRef.
Diag(TemplateArgs[2].getLocation(),
2064 diag::err_integer_sequence_negative_length);
2072 SyntheticTemplateArgs.
addArgument(TemplateArgs[1]);
2074 for (llvm::APSInt
I(NumArgs.getBitWidth(), NumArgs.isUnsigned());
2078 TA, TemplateArgs[2].getLocation())
2086 TemplateLoc, SyntheticTemplateArgs);
2093 assert(Converted.size() == 2 &&
2094 "__type_pack_element should be given an index and a parameter pack");
2099 assert(Index >= 0 &&
"the index used with __type_pack_element should be of "
2100 "type std::size_t, and hence be non-negative");
2101 if (Index >= Ts.pack_size()) {
2102 SemaRef.
Diag(TemplateArgs[0].getLocation(),
2103 diag::err_type_pack_element_out_of_bounds);
2108 auto Nth = std::next(Ts.pack_begin(), Index.getExtValue());
2109 return Nth->getAsType();
2111 llvm_unreachable(
"unexpected BuiltinTemplateDecl!");
2130 if (!Template || isa<FunctionTemplateDecl>(Template) ||
2131 isa<VarTemplateDecl>(Template)) {
2137 Diag(TemplateLoc, diag::err_template_id_not_a_type)
2139 NoteAllFoundTemplates(Name);
2146 if (CheckTemplateArgumentList(Template, TemplateLoc, TemplateArgs,
2152 bool InstantiationDependent =
false;
2154 dyn_cast<TypeAliasTemplateDecl>(Template)) {
2157 if (Pattern->isInvalidDecl())
2166 unsigned Depth = AliasTemplate->getTemplateParameters()->getDepth();
2167 for (
unsigned I = 0;
I <
Depth; ++
I)
2176 TemplateArgLists, AliasTemplate->getLocation(),
2177 AliasTemplate->getDeclName());
2182 TemplateArgs, InstantiationDependent)) {
2206 if (isa<ClassTemplateDecl>(Template)) {
2209 if (Ctx->isFileContext())
break;
2213 if (!Record)
continue;
2217 if (!isa<ClassTemplatePartialSpecializationDecl>(Record) &&
2224 QualType Injected = cast<InjectedClassNameType>(ICNT)
2225 ->getInjectedSpecializationType();
2238 = dyn_cast<ClassTemplateDecl>(Template)) {
2241 void *InsertPos =
nullptr;
2243 = ClassTemplate->findSpecialization(Converted, InsertPos);
2249 ClassTemplate->getTemplatedDecl()->getTagKind(),
2250 ClassTemplate->getDeclContext(),
2251 ClassTemplate->getTemplatedDecl()->getLocStart(),
2252 ClassTemplate->getLocation(),
2254 Converted,
nullptr);
2255 ClassTemplate->AddSpecialization(Decl, InsertPos);
2256 if (ClassTemplate->isOutOfLine())
2257 Decl->setLexicalDeclContext(ClassTemplate->getLexicalDeclContext());
2261 (void)DiagnoseUseOfDecl(Decl, TemplateLoc);
2264 assert(isa<RecordType>(CanonType) &&
2265 "type of non-dependent specialization is not a RecordType");
2266 }
else if (
auto *BTD = dyn_cast<BuiltinTemplateDecl>(Template)) {
2283 bool IsCtorOrDtorName) {
2291 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
2296 DTN->getQualifier(),
2297 DTN->getIdentifier(),
2314 QualType Result = CheckTemplateIdType(Template, TemplateLoc, TemplateArgs);
2327 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
2358 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
2367 DTN->getQualifier(),
2368 DTN->getIdentifier(),
2392 Diag(TemplateLoc, diag::err_tag_reference_non_tag) << 4;
2393 Diag(TAT->getLocation(), diag::note_declared_at);
2396 QualType Result = CheckTemplateIdType(Template, TemplateLoc, TemplateArgs);
2405 assert(Id &&
"templated class must have an identifier");
2407 if (!isAcceptableTagRedeclaration(D, TagKind, TUK == TUK_Definition,
2409 Diag(TagLoc, diag::err_use_with_wrong_tag)
2412 Diag(D->getLocation(), diag::note_previous_use);
2424 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
2443 bool IsPartialSpecialization);
2477 dyn_cast_or_null<TemplateTemplateParmDecl>(
2481 llvm_unreachable(
"unexpected kind of template argument");
2486 if (Params->
size() != Args.size())
2491 for (
unsigned I = 0, N = Args.size();
I != N; ++
I) {
2496 if (Params->
getParam(
I)->isParameterPack()) {
2518 return TemplateArgs;
2524 bool IsPartialSpecialization) {
2527 "Variable template specialization is declared with a template it.");
2544 FnTemplate = *OTS->begin();
2551 << IsPartialSpecialization;
2555 for (
unsigned I = 0, N = TemplateArgs.
size();
I != N; ++
I)
2556 if (DiagnoseUnexpandedParameterPack(TemplateArgs[
I],
2557 UPPC_PartialSpecialization))
2563 if (CheckTemplateArgumentList(VarTemplate, TemplateNameLoc, TemplateArgs,
2569 if (IsPartialSpecialization) {
2572 TemplateArgs.
size(), Converted))
2575 bool InstantiationDependent;
2579 InstantiationDependent)) {
2580 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
2582 IsPartialSpecialization =
false;
2591 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
2593 << (SC !=
SC_Extern && !CurContext->isRecord())
2601 void *InsertPos =
nullptr;
2604 if (IsPartialSpecialization)
2616 IsPartialSpecialization))
2624 Specialization = PrevDecl;
2625 Specialization->setLocation(TemplateNameLoc);
2627 }
else if (IsPartialSpecialization) {
2630 cast_or_null<VarTemplatePartialSpecializationDecl>(PrevDecl);
2633 Context, VarTemplate->getDeclContext(), TemplateKWLoc,
2634 TemplateNameLoc, TemplateParams, VarTemplate, DI->
getType(), DI, SC,
2635 Converted, TemplateArgs);
2638 VarTemplate->AddPartialSpecialization(Partial, InsertPos);
2639 Specialization = Partial;
2650 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
2652 TemplateParams->getDepth(), DeducibleParams);
2654 if (!DeducibleParams.all()) {
2655 unsigned NumNonDeducible =
2656 DeducibleParams.size() - DeducibleParams.count();
2657 Diag(TemplateNameLoc, diag::warn_partial_specs_not_deducible)
2658 << 1 << (NumNonDeducible > 1)
2660 for (
unsigned I = 0, N = DeducibleParams.size(); I != N; ++
I) {
2661 if (!DeducibleParams[I]) {
2662 NamedDecl *Param = cast<NamedDecl>(TemplateParams->getParam(I));
2664 Diag(Param->getLocation(), diag::note_partial_spec_unused_parameter)
2667 Diag(Param->getLocation(), diag::note_partial_spec_unused_parameter)
2676 Context, VarTemplate->getDeclContext(), TemplateKWLoc, TemplateNameLoc,
2677 VarTemplate, DI->
getType(), DI, SC, Converted);
2681 VarTemplate->AddSpecialization(Specialization, InsertPos);
2702 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
2706 diag::note_instantiation_required_here)
2714 Specialization->setLexicalDeclContext(CurContext);
2719 CurContext->addDecl(Specialization);
2727 LookupResult PrevSpec(*
this, GetNameForDeclarator(D), LookupOrdinaryName,
2733 Specialization->setAccess(VarTemplate->getAccess());
2743 return Specialization;
2749 struct PartialSpecMatchResult {
2759 assert(Template &&
"A variable template id without template?");
2763 if (CheckTemplateArgumentList(
2764 Template, TemplateNameLoc,
2765 const_cast<TemplateArgumentListInfo &>(TemplateArgs),
false,
2771 void *InsertPos =
nullptr;
2773 Converted, InsertPos)) {
2774 checkSpecializationVisibility(TemplateNameLoc, Spec);
2787 bool AmbiguousPartialSpec =
false;
2788 typedef PartialSpecMatchResult MatchResult;
2803 bool InstantiationDependent =
false;
2805 TemplateArgs, InstantiationDependent)) {
2810 for (
unsigned I = 0, N = PartialSpecs.size();
I != N; ++
I) {
2823 Matched.push_back(PartialSpecMatchResult());
2824 Matched.back().Partial = Partial;
2825 Matched.back().Args = Info.take();
2829 if (Matched.size() >= 1) {
2831 if (Matched.size() == 1) {
2844 PEnd = Matched.end();
2846 if (getMoreSpecializedPartialSpecialization(
P->Partial, Best->Partial,
2847 PointOfInstantiation) ==
2855 PEnd = Matched.end();
2857 if (
P != Best && getMoreSpecializedPartialSpecialization(
2858 P->Partial, Best->Partial,
2859 PointOfInstantiation) != Best->Partial) {
2860 AmbiguousPartialSpec =
true;
2867 InstantiationPattern = Best->Partial;
2868 InstantiationArgs = Best->Args;
2881 Template, InstantiationPattern, *InstantiationArgs, TemplateArgs,
2882 Converted, TemplateNameLoc, InsertPos );
2886 if (AmbiguousPartialSpec) {
2888 Decl->setInvalidDecl();
2889 Diag(PointOfInstantiation, diag::err_partial_spec_ordering_ambiguous)
2894 PEnd = Matched.end();
2896 Diag(
P->Partial->getLocation(), diag::note_partial_spec_match)
2897 << getTemplateArgumentBindingsText(
2898 P->Partial->getTemplateParameters(), *
P->Args);
2903 dyn_cast<VarTemplatePartialSpecializationDecl>(InstantiationPattern))
2906 checkSpecializationVisibility(TemplateNameLoc, Decl);
2908 assert(Decl &&
"No variable template specialization?");
2929 return BuildDeclarationNameExpr(SS, NameInfo, Var,
2930 nullptr, TemplateArgs);
2949 assert(!R.
empty() &&
"empty lookup results when building templateid");
2950 assert(!R.
isAmbiguous() &&
"ambiguous lookup when building templateid");
2953 bool InstantiationDependent;
2956 *TemplateArgs, InstantiationDependent)) {
2959 TemplateKWLoc, TemplateArgs);
2970 RequiresADL, TemplateArgs,
2983 assert(TemplateArgs || TemplateKWLoc.
isValid());
2985 if (!(DC = computeDeclContext(SS,
false)) ||
2986 DC->isDependentContext() ||
2987 RequireCompleteDeclContext(SS, DC))
2988 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
2990 bool MemberOfUnknownSpecialization;
2992 LookupTemplateName(R, (
Scope*)
nullptr, SS,
QualType(),
false,
2993 MemberOfUnknownSpecialization);
2999 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_non_template)
3005 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_class_template)
3008 Diag(Temp->getLocation(), diag::note_referenced_class_template);
3012 return BuildTemplateIdExpr(SS, TemplateKWLoc, R,
false, TemplateArgs);
3027 bool EnteringContext,
3031 getLangOpts().CPlusPlus11 ?
3032 diag::warn_cxx98_compat_template_outside_of_template :
3033 diag::ext_template_outside_of_template)
3038 LookupCtx = computeDeclContext(SS, EnteringContext);
3039 if (!LookupCtx && ObjectType)
3040 LookupCtx = computeDeclContext(ObjectType.
get());
3058 bool MemberOfUnknownSpecialization;
3060 ObjectType, EnteringContext, Result,
3061 MemberOfUnknownSpecialization);
3063 isa<CXXRecordDecl>(LookupCtx) &&
3064 (!cast<CXXRecordDecl>(LookupCtx)->hasDefinition() ||
3065 cast<CXXRecordDecl>(LookupCtx)->hasAnyDependentBases())) {
3069 diag::err_template_kw_refers_to_non_template)
3070 << GetNameFromUnqualifiedId(Name).getName()
3094 llvm_unreachable(
"literal operator id cannot have a dependent scope");
3101 diag::err_template_kw_refers_to_non_template)
3102 << GetNameFromUnqualifiedId(Name).getName()
3132 Diag(
Decl->getLocation(), diag::note_template_decl_here);
3143 SS.
Adopt(ArgExpr->getQualifierLoc());
3144 NameInfo = ArgExpr->getNameInfo();
3146 dyn_cast<DependentScopeDeclRefExpr>(Arg.
getAsExpr())) {
3147 SS.
Adopt(ArgExpr->getQualifierLoc());
3148 NameInfo = ArgExpr->getNameInfo();
3150 dyn_cast<CXXDependentScopeMemberExpr>(Arg.
getAsExpr())) {
3151 if (ArgExpr->isImplicitAccess()) {
3152 SS.
Adopt(ArgExpr->getQualifierLoc());
3153 NameInfo = ArgExpr->getMemberNameInfo();
3159 LookupParsedName(Result, CurScope, &SS);
3166 Diag(Loc, getLangOpts().MSVCCompat
3167 ? diag::ext_ms_template_type_arg_missing_typename
3168 : diag::err_template_arg_must_be_type_suggest)
3170 Diag(Param->getLocation(), diag::note_template_param_here);
3197 Diag(SR.
getBegin(), diag::err_template_arg_must_be_type) << SR;
3198 Diag(Param->getLocation(), diag::note_template_param_here);
3204 if (CheckTemplateArgument(Param, TSI))
3213 if (getLangOpts().ObjCAutoRefCount &&
3252 SmallVectorImpl<TemplateArgument> &Converted) {
3259 Template, Converted,
3269 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
3274 SemaRef.
SubstType(ArgType, TemplateArgLists,
3309 SmallVectorImpl<TemplateArgument> &Converted) {
3311 Template, Converted,
3321 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
3360 SmallVectorImpl<TemplateArgument> &Converted,
3372 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
3402 bool &HasDefaultArg) {
3403 HasDefaultArg =
false;
3409 HasDefaultArg =
true;
3422 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
3426 HasDefaultArg =
true;
3440 = cast<TemplateTemplateParmDecl>(Param);
3444 HasDefaultArg =
true;
3491 unsigned ArgumentPackIndex,
3496 return CheckTemplateTypeArgument(TTP, Arg, Converted);
3503 QualType NTTPType = NTTP->getType();
3504 if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack())
3505 NTTPType = NTTP->getExpansionType(ArgumentPackIndex);
3508 !isa<TemplateTemplateParmDecl>(Template) &&
3509 !Template->getDeclContext()->isDependentContext()) {
3519 NTTPType = SubstType(NTTPType,
3521 NTTP->getLocation(),
3522 NTTP->getDeclName());
3526 NTTPType = CheckNonTypeTemplateParameterType(NTTPType,
3527 NTTP->getLocation());
3534 llvm_unreachable(
"Should never see a NULL template argument here");
3551 Converted.push_back(Result);
3585 Context, SS.getWithLocInContext(
Context), TemplateKWLoc, NameInfo,
3597 E = CheckTemplateArgument(NTTP, NTTPType, E.
get(), Result);
3601 Converted.push_back(Result);
3611 Diag(Param->getLocation(), diag::note_template_param_here);
3628 Diag(SR.
getBegin(), diag::err_template_arg_nontype_ambig) << SR << T;
3630 Diag(SR.
getBegin(), diag::err_template_arg_must_be_expr) << SR;
3631 Diag(Param->getLocation(), diag::note_template_param_here);
3636 llvm_unreachable(
"Caller must expand template argument packs");
3653 TempParm, Converted,
3659 TempParm = cast_or_null<TemplateTemplateParmDecl>(
3660 SubstDecl(TempParm, CurContext,
3668 llvm_unreachable(
"Should never see a NULL template argument here");
3672 if (CheckTemplateArgument(TempParm, Arg, ArgumentPackIndex))
3683 << getLangOpts().CPlusPlus11;
3687 llvm_unreachable(
"Declaration argument with template template parameter");
3689 llvm_unreachable(
"Integral argument with template template parameter");
3691 llvm_unreachable(
"Null pointer argument with template template parameter");
3694 llvm_unreachable(
"Caller must expand template argument packs");
3705 unsigned NumParams = Params->
size();
3709 if (NumArgs > NumParams)
3710 Range =
SourceRange(TemplateArgs[NumParams].getLocation(),
3712 S.
Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
3713 << (NumArgs > NumParams)
3714 << (isa<ClassTemplateDecl>(Template)? 0 :
3715 isa<FunctionTemplateDecl>(Template)? 1 :
3716 isa<TemplateTemplateParmDecl>(Template)? 2 : 3)
3717 << Template << Range;
3718 S.
Diag(Template->getLocation(), diag::note_template_decl_here)
3736 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
3737 if (NTTP->isExpandedParameterPack())
3738 return NTTP->getNumExpansionTypes();
3742 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
3743 if (TTP->isExpandedParameterPack())
3744 return TTP->getNumExpansionTemplateParameters();
3751 template<
typename TemplateParmDecl>
3754 const TemplateParmDecl *D,
3759 ->getTemplateParameters()
3760 ->getParam(D->getIndex()));
3767 D->getDefaultArgumentLoc(), Modules,
3784 bool PartialTemplateArgs,
3800 bool isTemplateTemplateParameter = isa<TemplateTemplateParmDecl>(Template);
3805 ParamEnd = Params->
end();
3806 Param != ParamEnd; ) {
3810 if (*Expansions == ArgumentPack.size()) {
3813 Converted.push_back(
3815 ArgumentPack.clear();
3820 }
else if (ArgIdx ==
NumArgs && !PartialTemplateArgs) {
3822 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
3824 << (isa<ClassTemplateDecl>(Template)? 0 :
3825 isa<FunctionTemplateDecl>(Template)? 1 :
3826 isa<TemplateTemplateParmDecl>(Template)? 2 : 3)
3828 Diag(Template->getLocation(), diag::note_template_decl_here)
3836 if (CheckTemplateArgument(*Param, NewArgs[ArgIdx], Template,
3837 TemplateLoc, RAngleLoc,
3838 ArgumentPack.size(), Converted))
3841 bool PackExpansionIntoNonPack =
3842 NewArgs[ArgIdx].getArgument().isPackExpansion() &&
3844 if (PackExpansionIntoNonPack && isa<TypeAliasTemplateDecl>(Template)) {
3848 Diag(NewArgs[ArgIdx].getLocation(),
3849 diag::err_alias_template_expansion_into_fixed_list)
3850 << NewArgs[ArgIdx].getSourceRange();
3851 Diag((*Param)->getLocation(), diag::note_template_param_here);
3858 if ((*Param)->isTemplateParameterPack()) {
3863 ArgumentPack.push_back(Converted.pop_back_val());
3872 if (PackExpansionIntoNonPack) {
3873 if (!ArgumentPack.empty()) {
3876 Converted.insert(Converted.end(),
3877 ArgumentPack.begin(), ArgumentPack.end());
3878 ArgumentPack.clear();
3882 Converted.push_back(NewArgs[ArgIdx].getArgument());
3893 if (PartialTemplateArgs) {
3894 if ((*Param)->isTemplateParameterPack() && !ArgumentPack.empty())
3895 Converted.push_back(
3903 if ((*Param)->isTemplateParameterPack()) {
3905 "Should have dealt with this already");
3910 if (Param + 1 != ParamEnd)
3913 Converted.push_back(
3915 ArgumentPack.clear();
3946 = dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
3963 = cast<TemplateTemplateParmDecl>(*Param);
3991 if (CheckTemplateArgument(*Param, Arg, Template, TemplateLoc,
3992 RAngleLoc, 0, Converted))
3998 if (isTemplateTemplateParameter)
4010 if (ArgIdx <
NumArgs && CurrentInstantiationScope &&
4011 CurrentInstantiationScope->getPartiallySubstitutedPack()) {
4012 while (ArgIdx <
NumArgs && NewArgs[ArgIdx].getArgument().isPackExpansion())
4013 Converted.push_back(NewArgs[ArgIdx++].getArgument());
4023 TemplateArgs = std::move(NewArgs);
4029 class UnnamedLocalNoLinkageFinder
4030 :
public TypeVisitor<UnnamedLocalNoLinkageFinder, bool>
4044 #define TYPE(Class, Parent) \
4045 bool Visit##Class##Type(const Class##Type *);
4046 #define ABSTRACT_TYPE(Class, Parent) \
4047 bool Visit##Class##Type(const Class##Type *) { return false; }
4048 #define NON_CANONICAL_TYPE(Class, Parent) \
4049 bool Visit##Class##Type(const Class##Type *) { return false; }
4050 #include "clang/AST/TypeNodes.def"
4052 bool VisitTagDecl(
const TagDecl *Tag);
4057 bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(
const BuiltinType*) {
4061 bool UnnamedLocalNoLinkageFinder::VisitComplexType(
const ComplexType* T) {
4065 bool UnnamedLocalNoLinkageFinder::VisitPointerType(
const PointerType* T) {
4069 bool UnnamedLocalNoLinkageFinder::VisitBlockPointerType(
4074 bool UnnamedLocalNoLinkageFinder::VisitLValueReferenceType(
4079 bool UnnamedLocalNoLinkageFinder::VisitRValueReferenceType(
4084 bool UnnamedLocalNoLinkageFinder::VisitMemberPointerType(
4089 bool UnnamedLocalNoLinkageFinder::VisitConstantArrayType(
4094 bool UnnamedLocalNoLinkageFinder::VisitIncompleteArrayType(
4099 bool UnnamedLocalNoLinkageFinder::VisitVariableArrayType(
4104 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedArrayType(
4109 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedExtVectorType(
4114 bool UnnamedLocalNoLinkageFinder::VisitVectorType(
const VectorType* T) {
4118 bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(
const ExtVectorType* T) {
4122 bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
4132 bool UnnamedLocalNoLinkageFinder::VisitFunctionNoProtoType(
4137 bool UnnamedLocalNoLinkageFinder::VisitUnresolvedUsingType(
4142 bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(
const TypeOfExprType*) {
4146 bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(
const TypeOfType* T) {
4150 bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(
const DecltypeType*) {
4154 bool UnnamedLocalNoLinkageFinder::VisitUnaryTransformType(
4159 bool UnnamedLocalNoLinkageFinder::VisitAutoType(
const AutoType *T) {
4163 bool UnnamedLocalNoLinkageFinder::VisitRecordType(
const RecordType* T) {
4164 return VisitTagDecl(T->
getDecl());
4167 bool UnnamedLocalNoLinkageFinder::VisitEnumType(
const EnumType* T) {
4168 return VisitTagDecl(T->
getDecl());
4171 bool UnnamedLocalNoLinkageFinder::VisitTemplateTypeParmType(
4176 bool UnnamedLocalNoLinkageFinder::VisitSubstTemplateTypeParmPackType(
4181 bool UnnamedLocalNoLinkageFinder::VisitTemplateSpecializationType(
4186 bool UnnamedLocalNoLinkageFinder::VisitInjectedClassNameType(
4188 return VisitTagDecl(T->
getDecl());
4191 bool UnnamedLocalNoLinkageFinder::VisitDependentNameType(
4196 bool UnnamedLocalNoLinkageFinder::VisitDependentTemplateSpecializationType(
4198 return VisitNestedNameSpecifier(T->getQualifier());
4201 bool UnnamedLocalNoLinkageFinder::VisitPackExpansionType(
4206 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectType(
const ObjCObjectType *) {
4210 bool UnnamedLocalNoLinkageFinder::VisitObjCInterfaceType(
4215 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectPointerType(
4220 bool UnnamedLocalNoLinkageFinder::VisitAtomicType(
const AtomicType* T) {
4224 bool UnnamedLocalNoLinkageFinder::VisitPipeType(
const PipeType* T) {
4228 bool UnnamedLocalNoLinkageFinder::VisitTagDecl(
const TagDecl *Tag) {
4230 S.
Diag(SR.getBegin(),
4232 diag::warn_cxx98_compat_template_arg_local_type :
4233 diag::ext_template_arg_local_type)
4239 S.
Diag(SR.getBegin(),
4241 diag::warn_cxx98_compat_template_arg_unnamed_type :
4242 diag::ext_template_arg_unnamed_type) << SR;
4243 S.
Diag(Tag->getLocation(), diag::note_template_unnamed_type_here);
4250 bool UnnamedLocalNoLinkageFinder::VisitNestedNameSpecifier(
4267 llvm_unreachable(
"Invalid NestedNameSpecifier::Kind!");
4277 assert(ArgInfo &&
"invalid TypeSourceInfo");
4282 return Diag(SR.
getBegin(), diag::err_variably_modified_template_arg) << Arg;
4284 return Diag(SR.
getBegin(), diag::err_template_arg_overload_type) << SR;
4295 if (LangOpts.CPlusPlus11)
4297 !Diags.isIgnored(diag::warn_cxx98_compat_template_arg_unnamed_type,
4299 !Diags.isIgnored(diag::warn_cxx98_compat_template_arg_local_type,
4305 UnnamedLocalNoLinkageFinder
Finder(*
this, SR);
4328 "Incomplete parameter type in isNullPointerValueTemplateArgument!");
4341 EvalResult.
Diag = &Notes;
4349 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
4350 diag::note_invalid_subexpr_in_const_expr) {
4351 DiagLoc = Notes[0].first;
4355 S.
Diag(DiagLoc, diag::err_template_arg_not_address_constant)
4356 << Arg->
getType() << Arg->getSourceRange();
4357 for (
unsigned I = 0, N = Notes.size();
I != N; ++
I)
4358 S.
Diag(Notes[
I].first, Notes[I].second);
4360 S.
Diag(Param->getLocation(), diag::note_template_param_here);
4376 bool ObjCLifetimeConversion;
4379 ObjCLifetimeConversion))
4384 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
4385 << Arg->
getType() << ParamType << Arg->getSourceRange();
4386 S.
Diag(Param->getLocation(), diag::note_template_param_here);
4393 std::string Code =
"static_cast<" + ParamType.
getAsString() +
">(";
4394 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_untyped_null_constant)
4398 S.
Diag(Param->getLocation(), diag::note_template_param_here);
4413 bool ObjCLifetimeConversion;
4417 ObjCLifetimeConversion)) {
4422 if (!ParamRef->getPointeeType()->isFunctionType()) {
4432 unsigned ParamQuals = ParamRef->getPointeeType().getCVRQualifiers();
4435 if ((ParamQuals | ArgQuals) != ParamQuals) {
4436 S.
Diag(Arg->getLocStart(),
4437 diag::err_template_arg_ref_bind_ignores_quals)
4438 << ParamType << Arg->
getType() << Arg->getSourceRange();
4439 S.
Diag(Param->getLocation(), diag::note_template_param_here);
4452 S.
Diag(Arg->getLocStart(), diag::err_template_arg_no_ref_bind)
4453 << ParamType << ArgIn->
getType() << Arg->getSourceRange();
4455 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_convertible)
4456 << ArgIn->
getType() << ParamType << Arg->getSourceRange();
4457 S.
Diag(Param->getLocation(), diag::note_template_param_here);
4473 bool Invalid =
false;
4477 bool AddressTaken =
false;
4484 bool ExtWarnMSTemplateArg =
false;
4487 while (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(Arg)) {
4489 if (UnOpKind == UO_Deref)
4490 ExtWarnMSTemplateArg =
true;
4491 if (UnOpKind == UO_AddrOf || UnOpKind == UO_Deref) {
4494 FirstOpKind = UnOpKind;
4495 FirstOpLoc = UnOp->getOperatorLoc();
4501 if (ExtWarnMSTemplateArg)
4502 S.
Diag(ArgIn->getLocStart(), diag::ext_ms_deref_template_argument)
4503 << ArgIn->getSourceRange();
4505 if (FirstOpKind == UO_AddrOf)
4506 AddressTaken =
true;
4510 assert(FirstOpKind == UO_Deref);
4511 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)
4512 << Arg->getSourceRange();
4533 bool ExtraParens =
false;
4534 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
4535 if (!Invalid && !ExtraParens) {
4536 S.
Diag(Arg->getLocStart(),
4538 ? diag::warn_cxx98_compat_template_arg_extra_parens
4539 : diag::ext_template_arg_extra_parens)
4540 << Arg->getSourceRange();
4544 Arg = Parens->getSubExpr();
4548 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
4552 if (UnOp->getOpcode() == UO_AddrOf) {
4553 Arg = UnOp->getSubExpr();
4554 AddressTaken =
true;
4555 AddrOpLoc = UnOp->getOperatorLoc();
4560 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
4572 if (Entity && Entity->hasAttr<DLLImportAttr>())
4578 S.
Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
4598 if (isa<CXXUuidofExpr>(Arg)) {
4600 ArgIn, Arg, ArgType))
4608 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)
4609 << Arg->getSourceRange();
4610 S.
Diag(Param->getLocation(), diag::note_template_param_here);
4615 if (isa<FieldDecl>(Entity) || isa<IndirectFieldDecl>(Entity)) {
4616 S.
Diag(Arg->getLocStart(), diag::err_template_arg_field)
4617 << Entity << Arg->getSourceRange();
4618 S.
Diag(Param->getLocation(), diag::note_template_param_here);
4623 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Entity)) {
4624 if (!Method->isStatic()) {
4625 S.
Diag(Arg->getLocStart(), diag::err_template_arg_method)
4626 << Method << Arg->getSourceRange();
4627 S.
Diag(Param->getLocation(), diag::note_template_param_here);
4636 if (!Func && !Var) {
4638 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_object_or_func)
4639 << Arg->getSourceRange();
4640 S.
Diag(DRE->
getDecl()->getLocation(), diag::note_template_arg_refers_here);
4647 diag::warn_cxx98_compat_template_arg_object_internal :
4648 diag::ext_template_arg_object_internal)
4649 << !Func << Entity << Arg->getSourceRange();
4650 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
4652 }
else if (!Entity->hasLinkage()) {
4653 S.
Diag(Arg->getLocStart(), diag::err_template_arg_object_no_linkage)
4654 << !Func << Entity << Arg->getSourceRange();
4655 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
4670 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
4672 S.
Diag(Param->getLocation(), diag::note_template_param_here);
4676 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
4679 S.
Diag(Param->getLocation(), diag::note_template_param_here);
4685 if (Var->getType()->isReferenceType()) {
4686 S.
Diag(Arg->getLocStart(),
4687 diag::err_template_arg_reference_var)
4688 << Var->getType() << Arg->getSourceRange();
4689 S.
Diag(Param->getLocation(), diag::note_template_param_here);
4694 if (Var->getTLSKind()) {
4695 S.
Diag(Arg->getLocStart(), diag::err_template_arg_thread_local)
4696 << Arg->getSourceRange();
4697 S.
Diag(Var->getLocation(), diag::note_template_arg_refers_here);
4710 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
4712 S.
Diag(Param->getLocation(), diag::note_template_param_here);
4716 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
4719 S.
Diag(Param->getLocation(), diag::note_template_param_here);
4721 ArgType = Var->getType();
4724 if (Var->getType()->isArrayType()) {
4733 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_address_of)
4735 S.
Diag(Param->getLocation(), diag::note_template_param_here);
4739 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_address_of)
4743 S.
Diag(Param->getLocation(), diag::note_template_param_here);
4766 bool Invalid =
false;
4769 Expr *Arg = ResultArg;
4774 S.
Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
4782 bool ObjCLifetimeConversion;
4785 false, ObjCLifetimeConversion)) {
4792 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_convertible)
4793 << Arg->
getType() << ParamType << Arg->getSourceRange();
4794 S.
Diag(Param->getLocation(), diag::note_template_param_here);
4800 Arg = Cast->getSubExpr();
4812 bool ExtraParens =
false;
4813 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
4814 if (!Invalid && !ExtraParens) {
4815 S.
Diag(Arg->getLocStart(),
4817 diag::warn_cxx98_compat_template_arg_extra_parens :
4818 diag::ext_template_arg_extra_parens)
4819 << Arg->getSourceRange();
4823 Arg = Parens->getSubExpr();
4827 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
4832 if (UnOp->getOpcode() == UO_AddrOf) {
4839 else if ((DRE = dyn_cast<DeclRefExpr>(Arg))) {
4841 if (VD->getType()->isMemberPointerType()) {
4842 if (isa<NonTypeTemplateParmDecl>(VD)) {
4846 VD = cast<ValueDecl>(VD->getCanonicalDecl());
4858 return S.
Diag(Arg->getLocStart(),
4859 diag::err_template_arg_not_pointer_to_member_form)
4860 << Arg->getSourceRange();
4862 if (isa<FieldDecl>(DRE->
getDecl()) ||
4863 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
4864 isa<CXXMethodDecl>(DRE->
getDecl())) {
4865 assert((isa<FieldDecl>(DRE->
getDecl()) ||
4866 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
4867 !cast<CXXMethodDecl>(DRE->
getDecl())->isStatic()) &&
4868 "Only non-static member pointers can make it here");
4882 S.
Diag(Arg->getLocStart(),
4883 diag::err_template_arg_not_pointer_to_member_form)
4884 << Arg->getSourceRange();
4885 S.
Diag(DRE->
getDecl()->getLocation(), diag::note_template_arg_refers_here);
4912 "non-type template parameter type cannot be qualified");
4914 if (CTAK == CTAK_Deduced &&
4924 Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
4927 Diag(Param->getLocation(), diag::note_template_param_here);
4944 Arg, ParamType, Value, CCEK_TemplateArg);
4965 Diag(Arg->getLocStart(),
4966 diag::err_template_arg_member_ptr_base_derived_not_supported)
4968 << Arg->getSourceRange();
4974 : TemplateArgument(CanonParamType,
true);
4987 if (isa<CXXUuidofExpr>(E)) {
4991 Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)
4992 << Arg->getSourceRange();
4999 VD && VD->getType()->isArrayType() &&
5007 Diag(StartLoc, diag::err_non_type_template_arg_subobject)
5012 "null reference should not be a constant expression");
5014 "non-null value of type nullptr_t?");
5016 : TemplateArgument(CanonParamType,
true);
5020 return Diag(StartLoc, diag::err_non_type_template_arg_addr_label_diff);
5028 llvm_unreachable(
"invalid kind for template argument");
5031 return ArgResult.
get();
5051 if (getLangOpts().CPlusPlus11) {
5079 IntegerType = Enum->getDecl()->getIntegerType();
5087 ExprResult ArgResult = DefaultLvalueConversion(Arg);
5090 Arg = ArgResult.
get();
5104 Diag(Arg->getLocStart(),
5105 diag::err_template_arg_not_integral_or_enumeral)
5106 << ArgType << Arg->getSourceRange();
5107 Diag(Param->getLocation(), diag::note_template_param_here);
5114 TmplArgICEDiagnoser(
QualType T) : T(T) { }
5118 S.
Diag(Loc, diag::err_template_arg_not_ice) << T << SR;
5120 } Diagnoser(ArgType);
5122 Arg = VerifyIntegerConstantExpression(Arg, &Value, Diagnoser,
5137 Arg = ImpCastExprToType(Arg, ParamType, CK_IntegralToBoolean).get();
5138 }
else if (IsIntegralPromotion(Arg, ArgType, ParamType) ||
5141 Arg = ImpCastExprToType(Arg, ParamType, CK_IntegralCast).get();
5144 Diag(Arg->getLocStart(),
5145 diag::err_template_arg_not_convertible)
5146 << Arg->
getType() << ParamType << Arg->getSourceRange();
5147 Diag(Param->getLocation(), diag::note_template_param_here);
5169 if (Value.getBitWidth() != AllowedBits)
5170 Value = Value.extOrTrunc(AllowedBits);
5173 llvm::APSInt OldValue =
Value;
5178 if (Value.getBitWidth() != AllowedBits)
5179 Value = Value.extOrTrunc(AllowedBits);
5184 && (OldValue.isSigned() && OldValue.isNegative())) {
5185 Diag(Arg->getLocStart(), diag::warn_template_arg_negative)
5186 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
5187 << Arg->getSourceRange();
5188 Diag(Param->getLocation(), diag::note_template_param_here);
5192 unsigned RequiredBits;
5194 RequiredBits = OldValue.getActiveBits();
5195 else if (OldValue.isUnsigned())
5196 RequiredBits = OldValue.getActiveBits() + 1;
5198 RequiredBits = OldValue.getMinSignedBits();
5199 if (RequiredBits > AllowedBits) {
5200 Diag(Arg->getLocStart(),
5201 diag::warn_template_arg_too_large)
5202 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
5203 << Arg->getSourceRange();
5204 Diag(Param->getLocation(), diag::note_template_param_here);
5243 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg, ParamType,
5246 if (DiagnoseUseOfDecl(Fn, Arg->getLocStart()))
5249 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
5275 "Only object pointers allowed here");
5291 assert(ParamRefType->getPointeeType()->isIncompleteOrObjectType() &&
5292 "Only object references allowed here");
5295 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg,
5296 ParamRefType->getPointeeType(),
5299 if (DiagnoseUseOfDecl(Fn, Arg->getLocStart()))
5302 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
5325 << Arg->
getType() << ParamType;
5326 Diag(Param->getLocation(), diag::note_template_param_here);
5333 Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
5357 unsigned ArgumentPackIndex) {
5362 assert(Name.
isDependent() &&
"Non-dependent template isn't a declaration?");
5378 if (!isa<ClassTemplateDecl>(Template) &&
5379 !isa<TemplateTemplateParmDecl>(Template) &&
5380 !isa<TypeAliasTemplateDecl>(Template) &&
5381 !isa<BuiltinTemplateDecl>(Template)) {
5382 assert(isa<FunctionTemplateDecl>(Template) &&
5383 "Only function templates are possible here");
5385 Diag(Template->getLocation(), diag::note_template_arg_refers_here_func)
5396 TPL_TemplateTemplateArgumentMatch,
5421 return ImpCastExprToType(
5425 ? CK_NullToMemberPointer
5426 : CK_NullToPointer);
5429 "Only declaration template arguments permitted here");
5433 if (VD->getDeclContext()->isRecord() &&
5434 (isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD) ||
5435 isa<IndirectFieldDecl>(VD))) {
5454 if (isa<CXXMethodDecl>(VD) && cast<CXXMethodDecl>(VD)->isInstance())
5458 VD->getType().getNonReferenceType(),
5465 RefExpr = CreateBuiltinUnaryOp(Loc, UO_AddrOf, RefExpr.
get());
5470 bool ObjCLifetimeConversion;
5471 if (IsQualificationConversion(((
Expr*) RefExpr.
get())->getType(),
5473 ObjCLifetimeConversion))
5483 QualType T = VD->getType().getNonReferenceType();
5494 RefExpr = DefaultFunctionArrayConversion(RefExpr.
get());
5502 return CreateBuiltinUnaryOp(Loc, UO_AddrOf, RefExpr.
get());
5514 }
else if (isa<FunctionDecl>(VD)) {
5519 return BuildDeclRefExpr(VD, T, VK, Loc);
5533 "Operation is only valid for integral template arguments");
5543 T = ET->getDecl()->getIntegerType();
5570 if (OrigT->isEnumeralType()) {
5588 if (Old->getKind() != New->getKind()) {
5590 unsigned NextDiag = diag::err_template_param_different_kind;
5591 if (TemplateArgLoc.
isValid()) {
5592 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
5593 NextDiag = diag::note_template_param_different_kind;
5595 S.
Diag(New->getLocation(), NextDiag)
5597 S.
Diag(Old->getLocation(), diag::note_template_prev_declaration)
5608 if (Old->isTemplateParameterPack() != New->isTemplateParameterPack() &&
5610 Old->isTemplateParameterPack())) {
5612 unsigned NextDiag = diag::err_template_parameter_pack_non_pack;
5613 if (TemplateArgLoc.
isValid()) {
5614 S.
Diag(TemplateArgLoc,
5615 diag::err_template_arg_template_params_mismatch);
5616 NextDiag = diag::note_template_parameter_pack_non_pack;
5619 unsigned ParamKind = isa<TemplateTypeParmDecl>(New)? 0
5620 : isa<NonTypeTemplateParmDecl>(New)? 1
5622 S.
Diag(New->getLocation(), NextDiag)
5623 << ParamKind << New->isParameterPack();
5624 S.
Diag(Old->getLocation(), diag::note_template_parameter_pack_here)
5625 << ParamKind << Old->isParameterPack();
5633 = dyn_cast<NonTypeTemplateParmDecl>(Old)) {
5641 (OldNTTP->getType()->isDependentType() ||
5647 unsigned NextDiag = diag::err_template_nontype_parm_different_type;
5648 if (TemplateArgLoc.
isValid()) {
5649 S.
Diag(TemplateArgLoc,
5650 diag::err_template_arg_template_params_mismatch);
5651 NextDiag = diag::note_template_nontype_parm_different_type;
5653 S.
Diag(NewNTTP->getLocation(), NextDiag)
5656 S.
Diag(OldNTTP->getLocation(),
5657 diag::note_template_nontype_parm_prev_declaration)
5658 << OldNTTP->getType();
5671 = dyn_cast<TemplateTemplateParmDecl>(Old)) {
5674 OldTTP->getTemplateParameters(),
5693 unsigned NextDiag = diag::err_template_param_list_different_arity;
5694 if (TemplateArgLoc.
isValid()) {
5695 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
5696 NextDiag = diag::note_template_param_list_different_arity;
5736 if (Old->
size() != New->
size() && Kind != TPL_TemplateTemplateArgumentMatch) {
5753 OldParmEnd = Old->
end();
5754 OldParm != OldParmEnd; ++OldParm) {
5755 if (Kind != TPL_TemplateTemplateArgumentMatch ||
5756 !(*OldParm)->isTemplateParameterPack()) {
5757 if (NewParm == NewParmEnd) {
5766 Kind, TemplateArgLoc))
5780 for (; NewParm != NewParmEnd; ++NewParm) {
5782 Kind, TemplateArgLoc))
5788 if (NewParm != NewParmEnd) {
5820 while (Ctx && isa<LinkageSpecDecl>(Ctx))
5832 if (RD->isLocalClass())
5834 diag::err_template_inside_local_class)
5842 diag::err_template_outside_namespace_or_class_scope)
5853 return Record->getTemplateSpecializationKind();
5854 if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(D))
5855 return Function->getTemplateSpecializationKind();
5856 if (
VarDecl *Var = dyn_cast<VarDecl>(D))
5857 return Var->getTemplateSpecializationKind();
5890 bool IsPartialSpecialization) {
5894 if (isa<ClassTemplateDecl>(Specialized))
5895 EntityKind = IsPartialSpecialization? 1 : 0;
5896 else if (isa<VarTemplateDecl>(Specialized))
5897 EntityKind = IsPartialSpecialization ? 3 : 2;
5898 else if (isa<FunctionTemplateDecl>(Specialized))
5900 else if (isa<CXXMethodDecl>(Specialized))
5902 else if (isa<VarDecl>(Specialized))
5904 else if (isa<RecordDecl>(Specialized))
5906 else if (isa<EnumDecl>(Specialized) && S.
getLangOpts().CPlusPlus11)
5909 S.
Diag(Loc, diag::err_template_spec_unknown_kind)
5911 S.
Diag(Specialized->getLocation(), diag::note_specialized_entity);
5929 S.
Diag(Loc, diag::err_template_spec_decl_function_scope)
5940 S.
Diag(Loc, diag::ext_function_specialization_in_class)
5943 S.
Diag(Loc, diag::err_template_spec_decl_class_scope)
5953 S.
Diag(Loc, diag::err_template_spec_decl_class_scope)
5963 = Specialized->getDeclContext()->getEnclosingNamespaceContext();
5973 if (!DC->
Encloses(SpecializedContext) &&
5974 !(isa<FunctionTemplateDecl>(Specialized) ||
5975 isa<FunctionDecl>(Specialized) ||
5976 isa<VarTemplateDecl>(Specialized) ||
5977 isa<VarDecl>(Specialized))) {
5978 if (isa<TranslationUnitDecl>(SpecializedContext))
5979 S.
Diag(Loc, diag::err_template_spec_redecl_global_scope)
5980 << EntityKind << Specialized;
5981 else if (isa<NamespaceDecl>(SpecializedContext)) {
5982 int Diag = diag::err_template_spec_redecl_out_of_scope;
5984 Diag = diag::ext_ms_template_spec_redecl_out_of_scope;
5985 S.
Diag(Loc, Diag) << EntityKind << Specialized
5986 << cast<NamedDecl>(SpecializedContext);
5988 llvm_unreachable(
"unexpected namespace context for specialization");
5990 S.
Diag(Specialized->getLocation(), diag::note_specialized_entity);
5991 }
else if ((!PrevDecl ||
6010 bool IsCPlusPlus11Extension = DC->
Encloses(SpecializedContext);
6011 if (isa<TranslationUnitDecl>(SpecializedContext)) {
6012 assert(!IsCPlusPlus11Extension &&
6013 "DC encloses TU but isn't in enclosing namespace set");
6014 S.
Diag(Loc, diag::err_template_spec_decl_out_of_scope_global)
6015 << EntityKind << Specialized;
6016 }
else if (isa<NamespaceDecl>(SpecializedContext)) {
6018 if (!IsCPlusPlus11Extension)
6019 Diag = diag::err_template_spec_decl_out_of_scope;
6021 Diag = diag::ext_template_spec_decl_out_of_scope;
6023 Diag = diag::warn_cxx98_compat_template_spec_decl_out_of_scope;
6025 << EntityKind << Specialized << cast<NamedDecl>(SpecializedContext);
6028 S.
Diag(Specialized->getLocation(), diag::note_specialized_entity);
6038 DependencyChecker Checker(Depth);
6039 Checker.TraverseStmt(E);
6040 if (Checker.Match && Checker.MatchLoc.isInvalid())
6041 return E->getSourceRange();
6042 return Checker.MatchLoc;
6048 DependencyChecker Checker(Depth);
6049 Checker.TraverseTypeLoc(TL);
6050 if (Checker.Match && Checker.MatchLoc.isInvalid())
6052 return Checker.MatchLoc;
6063 S, TemplateNameLoc, Param, Args[
I].pack_begin(),
6064 Args[
I].pack_size(), IsDefaultArgument))
6077 ArgExpr = Expansion->getPattern();
6081 ArgExpr = ICE->getSubExpr();
6091 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ArgExpr))
6092 if (isa<NonTypeTemplateParmDecl>(DRE->getDecl()))
6104 if (ParamUseRange.
isValid()) {
6105 if (IsDefaultArgument) {
6106 S.
Diag(TemplateNameLoc,
6107 diag::err_dependent_non_type_arg_in_partial_spec);
6109 diag::note_dependent_non_type_default_arg_in_partial_spec)
6113 diag::err_dependent_non_type_arg_in_partial_spec)
6133 if (ParamUseRange.
isValid()) {
6134 S.
Diag(IsDefaultArgument ? TemplateNameLoc : ArgExpr->getLocStart(),
6135 diag::err_dependent_typed_non_type_arg_in_partial_spec)
6136 << Param->
getType() << ParamUseRange;
6137 S.
Diag(Param->getLocation(), diag::note_template_param_here)
6138 << (IsDefaultArgument ? ParamUseRange :
SourceRange());
6160 SmallVectorImpl<TemplateArgument> &TemplateArgs) {
6163 for (
unsigned I = 0, N = TemplateParams->
size();
I != N; ++
I) {
6170 S, TemplateNameLoc, Param, &ArgList[
I], 1, I >= NumExplicit))
6185 TemplateParameterLists,
6187 assert(TUK != TUK_Reference &&
"References are not specializations");
6194 ? TemplateParameterLists[0]->getTemplateLoc() : KWLoc;
6204 if (!ClassTemplate) {
6205 Diag(TemplateNameLoc, diag::err_not_class_template_specialization)
6211 bool isExplicitSpecialization =
false;
6212 bool isPartialSpecialization =
false;
6218 bool Invalid =
false;
6220 MatchTemplateParametersToScopeSpecifier(
6221 KWLoc, TemplateNameLoc, SS, &TemplateId,
6222 TemplateParameterLists, TUK == TUK_Friend, isExplicitSpecialization,
6227 if (TemplateParams && TemplateParams->
size() > 0) {
6228 isPartialSpecialization =
true;
6230 if (TUK == TUK_Friend) {
6231 Diag(KWLoc, diag::err_partial_specialization_friend)
6239 for (
unsigned I = 0, N = TemplateParams->
size();
I != N; ++
I) {
6242 if (TTP->hasDefaultArgument()) {
6243 Diag(TTP->getDefaultArgumentLoc(),
6244 diag::err_default_arg_in_partial_spec);
6245 TTP->removeDefaultArgument();
6248 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
6249 if (
Expr *DefArg = NTTP->getDefaultArgument()) {
6250 Diag(NTTP->getDefaultArgumentLoc(),
6251 diag::err_default_arg_in_partial_spec)
6252 << DefArg->getSourceRange();
6253 NTTP->removeDefaultArgument();
6259 diag::err_default_arg_in_partial_spec)
6265 }
else if (TemplateParams) {
6266 if (TUK == TUK_Friend)
6267 Diag(KWLoc, diag::err_template_spec_friend)
6273 isExplicitSpecialization =
true;
6275 assert(TUK == TUK_Friend &&
"should have a 'template<>' for this decl");
6281 assert(Kind !=
TTK_Enum &&
"Invalid enum tag in class template spec!");
6283 Kind, TUK == TUK_Definition, KWLoc,
6285 Diag(KWLoc, diag::err_use_with_wrong_tag)
6290 diag::note_previous_use);
6299 for (
unsigned I = 0, N = TemplateArgs.
size();
I != N; ++
I)
6300 if (DiagnoseUnexpandedParameterPack(TemplateArgs[
I],
6301 UPPC_PartialSpecialization))
6307 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
6308 TemplateArgs,
false, Converted))
6313 if (isPartialSpecialization) {
6316 TemplateArgs.
size(), Converted))
6319 bool InstantiationDependent;
6322 TemplateArgs.
arguments(), InstantiationDependent)) {
6323 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
6325 isPartialSpecialization =
false;
6329 void *InsertPos =
nullptr;
6332 if (isPartialSpecialization)
6342 if (TUK != TUK_Friend &&
6345 isPartialSpecialization))
6350 if (isPartialSpecialization) {
6363 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
6364 << 0 << (TUK == TUK_Definition)
6366 return CheckClassTemplate(S, TagSpec, TUK, KWLoc, SS,
6373 TemplateParameterLists.size() - 1,
6374 TemplateParameterLists.data());
6379 = cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl);
6382 ClassTemplate->getDeclContext(),
6383 KWLoc, TemplateNameLoc,
6391 if (TemplateParameterLists.size() > 1 && SS.
isSet()) {
6392 Partial->setTemplateParameterListsInfo(
6393 Context, TemplateParameterLists.drop_back(1));
6397 ClassTemplate->AddPartialSpecialization(Partial, InsertPos);
6398 Specialization = Partial;
6409 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
6411 TemplateParams->getDepth(),
6414 if (!DeducibleParams.all()) {
6415 unsigned NumNonDeducible = DeducibleParams.size()-DeducibleParams.count();
6416 Diag(TemplateNameLoc, diag::warn_partial_specs_not_deducible)
6417 << 0 << (NumNonDeducible > 1)
6419 for (
unsigned I = 0, N = DeducibleParams.size(); I != N; ++
I) {
6420 if (!DeducibleParams[I]) {
6421 NamedDecl *Param = cast<NamedDecl>(TemplateParams->getParam(I));
6423 Diag(Param->getLocation(),
6424 diag::note_partial_spec_unused_parameter)
6427 Diag(Param->getLocation(),
6428 diag::note_partial_spec_unused_parameter)
6438 ClassTemplate->getDeclContext(),
6439 KWLoc, TemplateNameLoc,
6444 if (TemplateParameterLists.size() > 0) {
6446 TemplateParameterLists);
6450 ClassTemplate->AddSpecialization(Specialization, InsertPos);
6452 if (CurContext->isDependentContext()) {
6455 assert(getLangOpts().MicrosoftExt &&
6456 "Only possible with -fms-extensions!");
6459 CanonTemplate, Converted);
6483 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
6487 diag::note_instantiation_required_here)
6495 if (TUK != TUK_Friend)
6499 if (TUK == TUK_Definition) {
6502 if (Def && SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
6504 makeMergedDefinitionVisible(Hidden, KWLoc);
6506 TUK = TUK_Declaration;
6509 Diag(TemplateNameLoc, diag::err_redefinition)
6511 Diag(Def->getLocation(), diag::note_previous_definition);
6512 Specialization->setInvalidDecl();
6518 ProcessDeclAttributeList(S, Specialization, Attr);
6522 if (TUK == TUK_Definition) {
6523 AddAlignmentAttributesForRecord(Specialization);
6524 AddMsStructLayoutForRecord(Specialization);
6527 if (ModulePrivateLoc.
isValid())
6528 Diag(Specialization->getLocation(), diag::err_module_private_specialization)
6529 << (isPartialSpecialization? 1 : 0)
6541 TemplateArgs, CanonType);
6542 if (TUK != TUK_Friend) {
6555 Specialization->setLexicalDeclContext(CurContext);
6558 if (TUK == TUK_Definition)
6561 if (TUK == TUK_Friend) {
6567 CurContext->addDecl(Friend);
6572 CurContext->addDecl(Specialization);
6574 return Specialization;
6580 Decl *NewDecl = HandleDeclarator(S, D, TemplateParameterLists);
6581 ActOnDocumentableDecl(NewDecl);
6588 D->dropAttr<DLLImportAttr>();
6589 D->dropAttr<DLLExportAttr>();
6592 FD->setInlineSpecified(
false);
6603 for (
Decl *Prev = D; Prev && !PrevDiagLoc.
isValid();
6604 Prev = Prev->getPreviousDecl()) {
6605 PrevDiagLoc = Prev->getLocation();
6607 assert(PrevDiagLoc.
isValid() &&
6608 "Explicit instantiation without point of instantiation?");
6640 bool &HasNoEffect) {
6641 HasNoEffect =
false;
6648 "previous declaration must be implicit!");
6661 if (PrevPointOfInstantiation.
isInvalid()) {
6672 PrevPointOfInstantiation.
isValid()) &&
6673 "Explicit instantiation without point of instantiation?");
6681 for (
Decl *Prev = PrevDecl; Prev; Prev = Prev->getPreviousDecl()) {
6687 Diag(NewLoc, diag::err_specialization_after_instantiation)
6689 Diag(PrevPointOfInstantiation, diag::note_instantiation_required_here)
6723 diag::err_explicit_instantiation_declaration_after_definition);
6729 diag::note_explicit_instantiation_definition_here);
6753 diag::warn_cxx98_compat_explicit_instantiation_after_specialization :
6754 diag::ext_explicit_instantiation_after_specialization)
6756 Diag(PrevDecl->getLocation(),
6757 diag::note_previous_template_specialization);
6770 for (
Decl *Prev = PrevDecl; Prev; Prev = Prev->getPreviousDecl()) {
6787 Diag(NewLoc, (getLangOpts().MSVCCompat)
6788 ? diag::ext_explicit_instantiation_duplicate
6789 : diag::err_explicit_instantiation_duplicate)
6792 diag::note_previous_explicit_instantiation);
6798 llvm_unreachable(
"Missing specialization/instantiation case?");
6826 if (!isa<FunctionTemplateDecl>(D) ||
6828 D->getDeclContext()->getRedeclContext()))
6834 if (Previous.
empty())
return true;
6837 ExplicitTemplateArgs);
6868 llvm::SmallDenseMap<FunctionDecl *, TemplateArgumentListInfo, 8>
6869 ConvertedTemplateArgs;
6879 Ovl->getDeclContext()->getRedeclContext()))
6891 if (OldMD && OldMD->
isConst()) {
6901 if (ExplicitTemplateArgs)
6902 Args = *ExplicitTemplateArgs;
6914 cast<FunctionTemplateDecl>(FunTmpl->getFirstDecl()),
6915 ExplicitTemplateArgs ? &Args :
nullptr, FT, Specialization,
6919 FailedCandidates.addCandidate().set(
6920 I.getPair(), FunTmpl->getTemplatedDecl(),
6927 if (ExplicitTemplateArgs)
6928 ConvertedTemplateArgs[Specialization] = std::move(Args);
6929 Candidates.
addDecl(Specialization,
I.getAccess());
6935 Candidates.
begin(), Candidates.
end(), FailedCandidates,
6937 PDiag(diag::err_function_template_spec_no_match) << FD->
getDeclName(),
6938 PDiag(diag::err_function_template_spec_ambiguous)
6939 << FD->
getDeclName() << (ExplicitTemplateArgs !=
nullptr),
6940 PDiag(diag::note_function_template_spec_matched));
6942 if (Result == Candidates.
end())
6946 FunctionDecl *Specialization = cast<FunctionDecl>(*Result);
6951 Diag(FD->getLocation(), diag::err_concept_specialized)
6953 Diag(Specialization->getLocation(), diag::note_previous_declaration);
6959 assert(SpecInfo &&
"Function template specialization info missing?");
6965 Specialization->setLocation(FD->getLocation());
6977 bool isFriend = (FD->getFriendObjectKind() != Decl::FOK_None);
6983 Specialization, FD->getLocation(),
6993 bool HasNoEffect =
false;
6995 CheckSpecializationInstantiationRedecl(FD->getLocation(),
7015 !Specialization->getCanonicalDecl()->isReferenced()) {
7017 Specialization->getCanonicalDecl() == Specialization &&
7018 "This must be the only existing declaration of this specialization");
7019 Specialization->setDeletedAsWritten(
false);
7022 MarkUnusedFileScopedDecl(Specialization);
7031 FD->setFunctionTemplateSpecialization(
7032 Specialization->getPrimaryTemplate(), TemplArgs,
nullptr,
7034 ExplicitTemplateArgs ? &ConvertedTemplateArgs[Specialization] :
nullptr);
7039 Previous.
addDecl(Specialization);
7059 assert(!isa<TemplateDecl>(Member) &&
"Only for non-template members");
7062 NamedDecl *FoundInstantiation =
nullptr;
7067 if (Previous.
empty()) {
7069 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(Member)) {
7074 QualType Adjusted = Function->getType();
7075 if (!hasExplicitCallingConv(Adjusted))
7076 Adjusted = adjustCCAndNoReturn(Adjusted, Method->getType());
7078 FoundInstantiation = *
I;
7079 Instantiation = Method;
7080 InstantiatedFrom = Method->getInstantiatedFromMemberFunction();
7081 MSInfo = Method->getMemberSpecializationInfo();
7086 }
else if (isa<VarDecl>(Member)) {
7092 Instantiation = PrevVar;
7096 }
else if (isa<RecordDecl>(Member)) {
7101 Instantiation = PrevRecord;
7105 }
else if (isa<EnumDecl>(Member)) {
7110 Instantiation = PrevEnum;
7116 if (!Instantiation) {
7125 if (Member->getFriendObjectKind() != Decl::FOK_None) {
7127 if (InstantiatedFrom && isa<CXXMethodDecl>(Member)) {
7128 cast<CXXMethodDecl>(Member)->setInstantiationOfMemberFunction(
7129 cast<CXXMethodDecl>(InstantiatedFrom),
7131 }
else if (InstantiatedFrom && isa<CXXRecordDecl>(Member)) {
7132 cast<CXXRecordDecl>(Member)->setInstantiationOfMemberClass(
7133 cast<CXXRecordDecl>(InstantiatedFrom),
7138 Previous.
addDecl(FoundInstantiation);
7143 if (!InstantiatedFrom) {
7144 Diag(Member->getLocation(), diag::err_spec_member_not_instantiated)
7146 Diag(Instantiation->getLocation(), diag::note_specialized_decl);
7156 assert(MSInfo &&
"Member specialization info missing?");
7158 bool HasNoEffect =
false;
7159 if (CheckSpecializationInstantiationRedecl(Member->getLocation(),
7170 Instantiation, Member->getLocation(),
7178 if (isa<FunctionDecl>(Member)) {
7179 FunctionDecl *InstantiationFunction = cast<FunctionDecl>(Instantiation);
7184 InstantiationFunction->setLocation(Member->getLocation());
7187 if (InstantiationFunction->
isDeleted()) {
7189 InstantiationFunction);
7194 cast<FunctionDecl>(Member)->setInstantiationOfMemberFunction(
7195 cast<CXXMethodDecl>(InstantiatedFrom),
7197 MarkUnusedFileScopedDecl(InstantiationFunction);
7198 }
else if (isa<VarDecl>(Member)) {
7199 VarDecl *InstantiationVar = cast<VarDecl>(Instantiation);
7204 InstantiationVar->setLocation(Member->getLocation());
7207 cast<VarDecl>(Member)->setInstantiationOfStaticDataMember(
7209 MarkUnusedFileScopedDecl(InstantiationVar);
7210 }
else if (isa<CXXRecordDecl>(Member)) {
7211 CXXRecordDecl *InstantiationClass = cast<CXXRecordDecl>(Instantiation);
7216 InstantiationClass->setLocation(Member->getLocation());
7219 cast<CXXRecordDecl>(Member)->setInstantiationOfMemberClass(
7220 cast<CXXRecordDecl>(InstantiatedFrom),
7223 assert(isa<EnumDecl>(Member) &&
"Only member enums remain");
7224 EnumDecl *InstantiationEnum = cast<EnumDecl>(Instantiation);
7229 InstantiationEnum->setLocation(Member->getLocation());
7232 cast<EnumDecl>(Member)->setInstantiationOfMemberEnum(
7239 Previous.
addDecl(FoundInstantiation);
7248 bool WasQualifiedName) {
7249 DeclContext *OrigContext= D->getDeclContext()->getEnclosingNamespaceContext();
7253 S.
Diag(InstLoc, diag::err_explicit_instantiation_in_class)
7266 if (WasQualifiedName) {
7267 if (CurContext->
Encloses(OrigContext))
7274 if (
NamespaceDecl *NS = dyn_cast<NamespaceDecl>(OrigContext)) {
7275 if (WasQualifiedName)
7278 diag::err_explicit_instantiation_out_of_scope :
7279 diag::warn_explicit_instantiation_out_of_scope_0x)
7284 diag::err_explicit_instantiation_unqualified_wrong_namespace :
7285 diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x)
7290 diag::err_explicit_instantiation_must_be_global :
7291 diag::warn_explicit_instantiation_must_be_global_0x)
7293 S.
Diag(D->getLocation(), diag::note_explicit_instantiation_here);
7312 if (isa<TemplateSpecializationType>(T))
7339 "Invalid enum tag in class template explicit instantiation!");
7343 if (!ClassTemplate) {
7345 if (isa<TypeAliasTemplateDecl>(TD)) {
7347 }
else if (isa<TemplateTemplateParmDecl>(TD)) {
7351 Diag(TemplateNameLoc, diag::err_tag_reference_non_tag) <<
ErrorKind;
7352 Diag(TD->getLocation(), diag::note_previous_use);
7359 Diag(KWLoc, diag::err_use_with_wrong_tag)
7364 diag::note_previous_use);
7379 if (A->getKind() == AttributeList::AT_DLLExport) {
7381 diag::warn_attribute_dllexport_explicit_instantiation_decl);
7382 Diag(A->getLoc(), diag::note_attribute);
7387 if (
auto *A = ClassTemplate->
getTemplatedDecl()->getAttr<DLLExportAttr>()) {
7389 diag::warn_attribute_dllexport_explicit_instantiation_decl);
7390 Diag(A->getLocation(), diag::note_attribute);
7396 bool DLLImportExplicitInstantiationDef =
false;
7403 if (A->getKind() == AttributeList::AT_DLLImport)
7405 if (A->getKind() == AttributeList::AT_DLLExport) {
7413 DLLImportExplicitInstantiationDef =
true;
7419 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
7424 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
7425 TemplateArgs,
false, Converted))
7430 void *InsertPos =
nullptr;
7448 bool HasNoEffect =
false;
7450 if (CheckSpecializationInstantiationRedecl(TemplateNameLoc, TSK,
7451 PrevDecl, PrevDecl_TSK,
7466 Specialization = PrevDecl;
7467 Specialization->setLocation(TemplateNameLoc);
7472 DLLImportExplicitInstantiationDef) {
7474 HasNoEffect =
false;
7478 if (!Specialization) {
7483 ClassTemplate->getDeclContext(),
7484 KWLoc, TemplateNameLoc,
7490 if (!HasNoEffect && !PrevDecl) {
7492 ClassTemplate->AddSpecialization(Specialization, InsertPos);
7515 ProcessDeclAttributeList(S, Specialization, Attr);
7520 Specialization->setLexicalDeclContext(CurContext);
7521 CurContext->
addDecl(Specialization);
7527 return Specialization;
7538 = cast_or_null<ClassTemplateSpecializationDecl>(
7541 InstantiateClassTemplateSpecialization(TemplateNameLoc, Specialization, TSK);
7543 MarkVTableUsed(TemplateNameLoc, Specialization,
true);
7548 Def = cast_or_null<ClassTemplateSpecializationDecl>(
7556 DLLImportExplicitInstantiationDef)) {
7565 auto *A = cast<InheritableAttr>(
7567 A->setInherited(
true);
7572 assert(DelayedDllExportClasses.empty() &&
7573 "delayed exports present at explicit instantiation");
7574 checkClassLevelDLLAttribute(Def);
7575 referenceDLLExportedClassMethods();
7578 for (
auto &B : Def->
bases()) {
7579 if (
auto *BT = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
7580 B.getType()->getAsCXXRecordDecl()))
7581 propagateDLLAttrToBaseClassTemplate(Def, A, BT, B.
getLocStart());
7589 InstantiateClassTemplateSpecializationMembers(TemplateNameLoc, Def, TSK);
7596 return Specialization;
7612 bool IsDependent =
false;
7614 KWLoc, SS, Name, NameLoc, Attr,
AS_none,
7619 assert(!IsDependent &&
"explicit instantiation of dependent name not yet handled");
7624 TagDecl *Tag = cast<TagDecl>(TagD);
7625 assert(!Tag->
isEnum() &&
"shouldn't see enumerations here");
7627 if (Tag->isInvalidDecl())
7633 Diag(TemplateLoc, diag::err_explicit_instantiation_nontemplate_type)
7635 Diag(Record->getLocation(), diag::note_nontemplate_decl_here);
7646 Diag(TemplateLoc, diag::ext_explicit_instantiation_without_qualified_id)
7671 bool HasNoEffect =
false;
7672 assert(MSInfo &&
"No member specialization information?");
7673 if (CheckSpecializationInstantiationRedecl(TemplateLoc, TSK,
7690 = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
7692 Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member)
7693 << 0 << Record->
getDeclName() << Record->getDeclContext();
7694 Diag(Pattern->getLocation(), diag::note_forward_declaration)
7698 if (InstantiateClass(NameLoc, Record, Def,
7699 getTemplateInstantiationArgs(Record),
7703 RecordDef = cast_or_null<CXXRecordDecl>(Record->
getDefinition());
7710 InstantiateClassMembers(NameLoc, RecordDef,
7711 getTemplateInstantiationArgs(Record), TSK);
7714 MarkVTableUsed(NameLoc, RecordDef,
true);
7734 diag::err_explicit_instantiation_requires_name)
7776 getLangOpts().CPlusPlus11 ?
7777 diag::err_explicit_instantiation_inline :
7778 diag::warn_explicit_instantiation_inline_0x)
7784 diag::err_explicit_instantiation_constexpr);
7791 diag::err_concept_specified_specialization) << 0;
7820 if (!PrevTemplate) {
7827 Diag((*P)->getLocation(), diag::note_explicit_instantiation_here);
7834 diag::err_explicit_instantiation_data_member_not_instantiated)
7836 Diag(Prev->getLocation(), diag::note_explicit_instantiation_here);
7850 diag::err_auto_not_allowed_var_inst);
7859 diag::err_explicit_instantiation_without_template_id)
7861 Diag(PrevTemplate->getLocation(),
7862 diag::note_explicit_instantiation_here);
7868 if (PrevTemplate->isConcept()) {
7871 Diag(PrevTemplate->getLocation(), diag::note_previous_declaration);
7879 DeclResult Res = CheckVarTemplateId(PrevTemplate, TemplateLoc,
7881 if (Res.isInvalid())
7886 Prev = cast<VarDecl>(Res.get());
7901 diag::ext_explicit_instantiation_without_qualified_id)
7910 bool HasNoEffect =
false;
7911 if (CheckSpecializationInstantiationRedecl(D.
getIdentifierLoc(), TSK, Prev,
7912 PrevTSK, POI, HasNoEffect))
7922 ProcessDeclAttributeList(S, Prev,
Attr);
7931 diag::err_invalid_var_template_spec_type)
7932 << 0 << PrevTemplate << R << Prev->getType();
7933 Diag(PrevTemplate->getLocation(), diag::note_template_declared_here)
7934 << 2 << PrevTemplate->getDeclName();
7939 return (
Decl*)
nullptr;
7944 bool HasExplicitTemplateArgs =
false;
7948 HasExplicitTemplateArgs =
true;
7961 if (!HasExplicitTemplateArgs) {
7962 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Prev)) {
7963 QualType Adjusted = adjustCCAndNoReturn(R, Method->getType());
7967 Matches.
addDecl(Method,
P.getAccess());
7982 (HasExplicitTemplateArgs ? &TemplateArgs
7984 R, Specialization, Info)) {
7986 FailedCandidates.addCandidate()
7993 Matches.
addDecl(Specialization,
P.getAccess());
7998 Matches.
begin(), Matches.
end(), FailedCandidates,
8000 PDiag(diag::err_explicit_instantiation_not_known) <<
Name,
8001 PDiag(diag::err_explicit_instantiation_ambiguous) <<
Name,
8002 PDiag(diag::note_explicit_instantiation_candidate));
8004 if (Result == Matches.
end())
8008 FunctionDecl *Specialization = cast<FunctionDecl>(*Result);
8017 if (FPT->hasExceptionSpec()) {
8019 diag::err_mismatched_exception_spec_explicit_instantiation;
8020 if (getLangOpts().MicrosoftExt)
8021 DiagID = diag::ext_mismatched_exception_spec_explicit_instantiation;
8022 bool Result = CheckEquivalentExceptionSpec(
8023 PDiag(DiagID) << Specialization->
getType(),
8024 PDiag(diag::note_explicit_instantiation_here),
8026 Specialization->getLocation(), FPT, D.
getLocStart());
8029 if (!getLangOpts().MicrosoftExt && Result)
8035 diag::err_explicit_instantiation_member_function_not_instantiated)
8039 Diag(Specialization->getLocation(), diag::note_explicit_instantiation_here);
8045 PrevDecl = Specialization;
8048 bool HasNoEffect =
false;
8052 PrevDecl->getPointOfInstantiation(),
8059 return (
Decl*)
nullptr;
8065 ProcessDeclAttributeList(S, Specialization, Attr);
8070 Consumer.HandleTopLevelDecl(
DeclGroupRef(Specialization));
8086 diag::ext_explicit_instantiation_without_qualified_id)
8091 if (FunTmpl && FunTmpl->isConcept() &&
8095 Diag(FunTmpl->getLocation(), diag::note_previous_declaration);
8106 return (
Decl*)
nullptr;
8114 assert(Name &&
"Expected a name in a dependent tag");
8122 if (TUK == TUK_Declaration || TUK == TUK_Definition) {
8123 Diag(NameLoc, diag::err_dependent_tag_decl)
8124 << (TUK == TUK_Definition) << Kind << SS.
getRange();
8150 getLangOpts().CPlusPlus11 ?
8151 diag::warn_cxx98_compat_typename_outside_of_template :
8152 diag::ext_typename_outside_of_template)
8157 TypenameLoc, QualifierLoc, II, IdLoc);
8162 if (isa<DependentNameType>(T)) {
8174 return CreateParsedType(T, TSI);
8189 getLangOpts().CPlusPlus11 ?
8190 diag::warn_cxx98_compat_typename_outside_of_template :
8191 diag::ext_typename_outside_of_template)
8196 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
8201 assert(DTN &&
"dependent template has non-dependent name?");
8204 DTN->getQualifier(),
8205 DTN->getIdentifier(),
8218 for (
unsigned I = 0, N = TemplateArgs.
size();
I != N; ++
I)
8223 QualType T = CheckTemplateIdType(Template, TemplateNameLoc, TemplateArgs);
8235 for (
unsigned I = 0, N = TemplateArgs.
size();
I != N; ++
I)
8244 return CreateParsedType(T, TSI);
8253 if (!II.
isStr(
"type"))
8262 if (!EnableIfTSTLoc || EnableIfTSTLoc.
getNumArgs() == 0)
8265 cast<TemplateSpecializationType>(EnableIfTSTLoc.
getTypePtr());
8269 EnableIfTST->getTemplateName().getAsTemplateDecl();
8270 if (!EnableIfDecl || EnableIfTST->isIncompleteType())
8275 EnableIfDecl->getDeclName().getAsIdentifierInfo();
8276 if (!EnableIfII || !EnableIfII->
isStr(
"enable_if"))
8293 SS.
Adopt(QualifierLoc);
8311 if (RequireCompleteDeclContext(SS, Ctx))
8316 LookupQualifiedName(Result, Ctx, SS);
8317 unsigned DiagID = 0;
8318 Decl *Referenced =
nullptr;
8324 if (
isEnableIf(QualifierLoc, II, CondRange)) {
8325 Diag(CondRange.
getBegin(), diag::err_typename_nested_not_found_enable_if)
8326 << Ctx << CondRange;
8330 DiagID = diag::err_typename_nested_not_found;
8339 Diag(IILoc, diag::err_typename_refers_to_using_value_decl)
8340 << Name << Ctx << FullRange;
8344 Diag(Loc, diag::note_using_value_decl_missing_typename)
8361 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
8367 DiagID = diag::err_typename_nested_not_type;
8372 DiagID = diag::err_typename_nested_not_type;
8373 Referenced = *Result.
begin();
8384 Diag(IILoc, DiagID) << FullRange << Name << Ctx;
8386 Diag(Referenced->getLocation(), diag::note_typename_refers_here)
8393 class CurrentInstantiationRebuilder
8401 CurrentInstantiationRebuilder(
Sema &SemaRef,
8405 Loc(Loc), Entity(Entity) { }
8412 bool AlreadyTransformed(
QualType T) {
8427 this->Entity = Entity;
8469 CurrentInstantiationRebuilder Rebuilder(*
this, Loc, Name);
8470 return Rebuilder.TransformType(T);
8474 CurrentInstantiationRebuilder Rebuilder(*
this, E->
getExprLoc(),
8476 return Rebuilder.TransformExpr(E);
8487 = Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
8499 for (
unsigned I = 0, N = Params->
size();
I != N; ++
I) {
8503 if (isa<TemplateTypeParmDecl>(Param))
8508 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
8509 if (RebuildTemplateParamsInCurrentInstantiation(
8510 TTP->getTemplateParameters()))
8520 NTTP->getLocation(),
8527 NTTP->
setType(NewTSI->getType());
8539 return getTemplateArgumentBindingsText(Params, Args.
data(), Args.
size());
8547 llvm::raw_svector_ostream Out(Str);
8549 if (!Params || Params->
size() == 0 || NumArgs == 0)
8550 return std::string();
8552 for (
unsigned I = 0, N = Params->
size();
I != N; ++
I) {
8562 Out << Id->getName();
8568 Args[
I].
print(getPrintingPolicy(), Out);
8583 LPT->
Toks.swap(Toks);
8585 LateParsedTemplateMap.insert(std::make_pair(FD, LPT));
8600 if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(CurContext)) {
8638 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
8639 return checkImpl(FD);
8640 if (
auto *RD = dyn_cast<CXXRecordDecl>(ND))
8641 return checkImpl(RD);
8642 if (
auto *VD = dyn_cast<VarDecl>(ND))
8643 return checkImpl(VD);
8644 if (
auto *ED = dyn_cast<EnumDecl>(ND))
8645 return checkImpl(ED);
8649 void diagnose(
NamedDecl *D,
bool IsPartialSpec) {
8652 const bool Recover =
true;
8657 if (Modules.empty())
8675 template<
typename SpecDecl>
8676 void checkImpl(SpecDecl *Spec) {
8677 bool IsHiddenExplicitSpecialization =
false;
8679 IsHiddenExplicitSpecialization =
8680 Spec->getMemberSpecializationInfo()
8684 checkInstantiated(Spec);
8687 if (IsHiddenExplicitSpecialization)
8688 diagnose(Spec->getMostRecentDecl(),
false);
8712 void checkInstantiated(
VarDecl *RD) {
8728 void checkInstantiated(
EnumDecl *FD) {}
8730 template<
typename TemplDecl>
8731 void checkTemplate(TemplDecl *TD) {
8732 if (TD->isMemberSpecialization()) {
8734 diagnose(TD->getMostRecentDecl(),
false);
8740 if (!getLangOpts().Modules)
8751 if (!hasVisibleDeclaration(Spec, &Modules))
8752 diagnoseMissingImport(Loc, Spec, Spec->getLocation(), Modules,
8753 MissingImportKind::PartialSpecialization,
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
unsigned getFlags() const
getFlags - Return the flags for this scope.
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.
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
Name lookup found a set of overloaded functions that met the criteria.
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
BuiltinTemplateKind getBuiltinTemplateKind() const
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
DeclResult ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, TemplateIdAnnotation &TemplateId, AttributeList *Attr, MultiTemplateParamsArg TemplateParameterLists, SkipBodyInfo *SkipBody=nullptr)
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
static bool CheckTemplateArgumentIsCompatibleWithParameter(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *ArgIn, Expr *Arg, QualType ArgType)
Checks whether the given template argument is compatible with its template parameter.
bool 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.
PointerType - C99 6.7.5.1 - Pointer Declarators.
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization, retrieves the member specialization information.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
TemplateDeductionResult
Describes the result of template argument deduction.
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
bool isMemberPointerType() const
bool isSuppressingDiagnostics() const
Determines whether this lookup is suppressing diagnostics.
static bool isEnableIf(NestedNameSpecifierLoc NNS, const IdentifierInfo &II, SourceRange &CondRange)
Determine whether this failed name lookup should be treated as being disabled by a usage of std::enab...
static CXXDependentScopeMemberExpr * Create(const ASTContext &C, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
void addOuterTemplateArguments(const TemplateArgumentList *TemplateArgs)
Add a new outermost level to the multi-level template argument list.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
void setLookupName(DeclarationName Name)
Sets the name to look up.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
ParsedType getAsType() const
Retrieve the template type argument's type.
static UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
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 ...
The name refers to a function template or a set of overloaded functions that includes at least one fu...
const Scope * getParent() const
getParent - Return the scope that this is nested in.
The name refers to a dependent template name.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
Represents a qualified type name for which the type name is dependent.
void setObjCLifetime(ObjCLifetime type)
The template argument is an expression, and we've not resolved it to one of the other forms yet...
CXXRecordDecl * getDecl() const
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params)
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments...
void erase()
Erase the last element returned from this iterator.
static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D)
Determine what kind of template specialization the given declaration is.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
QualType getUnderlyingType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
bool isChar16Type() const
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Defines the C++ template declaration subclasses.
Represents a C++11 auto or C++14 decltype(auto) type.
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
bool isEnumeralType() const
static SourceRange getRangeOfTypeInNestedNameSpecifier(ASTContext &Context, QualType T, const CXXScopeSpec &SS)
ParenExpr - This represents a parethesized expression, e.g.
SCS getStorageClassSpec() const
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
std::string getAsString() const
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
QualType getPointeeType() const
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
bool isMemberPointer() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
void setTemplateKeywordLoc(SourceLocation Loc)
DependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, ArrayRef< TemplateArgument > Args, QualType Canon)
Declaration of a variable template.
TemplateParamListContext
The context in which we are checking a template parameter list.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
NamespaceDecl - Represent a C++ namespace.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
bool hasLValuePath() const
void setSpecializationKind(TemplateSpecializationKind TSK)
NamedDecl * getParam(unsigned Idx)
SourceLocation getInlineSpecLoc() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
bool isBooleanType() const
A container of type source information.
unsigned getIndex() const
void check(NamedDecl *ND)
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.
bool isConceptSpecified() const
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...
An identifier, stored as an IdentifierInfo*.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
RAII object that enters a new expression evaluation context.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
Information about one declarator, including the parsed type information and the identifier.
static SourceLocation DiagLocForExplicitInstantiation(NamedDecl *D, SourceLocation PointOfInstantiation)
Compute the diagnostic location for an explicit instantiation.
Represents an empty template argument, e.g., one that has not been deduced.
Extra information about a function prototype.
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*.
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
Stores a list of template parameters for a TemplateDecl and its derived classes.
TemplateArgumentLoc SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, Decl *Param, SmallVectorImpl< TemplateArgument > &Converted, bool &HasDefaultArg)
If the given template parameter has a default template argument, substitute into that default templat...
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
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Defines the clang::Expr interface and subclasses for C++ expressions.
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
bool isEmpty() const
No scope specifier.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier...
The collection of all-type qualifiers we support.
Information about a template-id annotation token.
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
static void DiagnoseTemplateParameterListArityMismatch(Sema &S, TemplateParameterList *New, TemplateParameterList *Old, Sema::TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc)
Diagnose a known arity mismatch when comparing template argument lists.
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
Base wrapper for a particular "section" of type source info.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
RecordDecl - Represents a struct/union/class.
static bool hasVisibleDefaultArgument(Sema &S, const ParmDecl *D, llvm::SmallVectorImpl< Module * > *Modules)
Scope * getTemplateParamParent()
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
QualType getElementType() const
DeclarationName getName() const
getName - Returns the embedded declaration name.
One of these records is kept for each identifier that is lexed.
Represents a class template specialization, which refers to a class template with a given set of temp...
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template.
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl)
DiagnoseTemplateParameterShadow - Produce a diagnostic complaining that the template parameter 'PrevD...
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
void replace(NamedDecl *D)
Replaces the current entry with the given one, preserving the access bits.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
Represents a class type in Objective C.
AttributeList * getList() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
CXXRecordDecl * getPreviousDecl()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
Represents a dependent template name that cannot be resolved prior to template instantiation.
NestedNameSpecifierLoc SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const MultiLevelTemplateArgumentList &TemplateArgs)
unsigned getNumArgs() const
ArrayRef< QualType > getParamTypes() const
static NamedDecl * isAcceptableTemplateName(ASTContext &Context, NamedDecl *Orig, bool AllowFunctionTemplates)
Determine whether the declaration found is acceptable as the name of a template and, if so, return that template declaration.
bool isIdentifier() const
Determine whether this template name refers to an identifier.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD, const TemplateArgumentListInfo &ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given dependent function template specialization.
Decl * ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, unsigned Depth, unsigned Position, SourceLocation EqualLoc, Expr *DefaultArg)
bool isReferenceType() const
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is visible.
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a templated declaration that would trigger an implicit instantiation.
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
The iterator over UnresolvedSets.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Represents the result of substituting a set of types for a template type parameter pack...
A non-type template parameter, stored as an expression.
bool hasAnyAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true)
SourceLocation getLocStart() const LLVM_READONLY
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
Perform semantic analysis for the given non-template member specialization.
static QualType checkBuiltinTemplateIdType(Sema &SemaRef, BuiltinTemplateDecl *BTD, const SmallVectorImpl< TemplateArgument > &Converted, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
void ClearStorageClassSpecs()
The type of a non-type template parameter.
TypeSourceInfo * getTypeSourceInfo() const
bool isExplicitSpecialization() const
SourceRange getSourceRange() const LLVM_READONLY
Fetches the full source range of the argument.
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
SourceLocation getTemplateEllipsisLoc() const
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
QualType getUnderlyingType() const
void setDefaultArgument(Expr *DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
Provides information about a function template specialization, which is a FunctionDecl that has been ...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, bool isAddressOfOperand, const TemplateArgumentListInfo *TemplateArgs)
ActOnDependentIdExpression - Handle a dependent id-expression that was just parsed.
static void maybeDiagnoseTemplateParameterShadow(Sema &SemaRef, Scope *S, SourceLocation Loc, IdentifierInfo *Name)
Represents a C++ unqualified-id that has been parsed.
TemplateArgument getArgumentPack() const
bool isCompleteType(SourceLocation Loc, QualType T)
An rvalue reference type, per C++11 [dcl.ref].
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
param_type_range param_types() const
SourceLocation getLAngleLoc() const
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
Represents the results of name lookup.
const TargetInfo & getTargetInfo() const
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
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)
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
APValue Val
Val - This is the value the expression can be folded to.
A convenient class for passing around template argument information.
QualType getReturnType() const
void FilterAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true)
const ValueDecl * getMemberPointerDecl() const
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
ParsedTemplateTy getAsTemplate() const
Retrieve the template template argument's template name.
KindType getKind() const
Determine what kind of template argument we have.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
Represents a typeof (or typeof) expression (a GCC extension).
NestedNameSpecifierLoc getTemplateQualifierLoc() const
char * location_data() const
Retrieve the data associated with the source-location information.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack)
SourceLocation getLocStart() const LLVM_READONLY
TypeDecl - Represents a declaration of a type.
void setRedeclaration(bool Val)
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
RecordDecl * getDecl() const
static bool MatchTemplateParameterKind(Sema &S, NamedDecl *New, NamedDecl *Old, bool Complain, Sema::TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc)
Match two template parameters within template parameter lists.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
void setSpecializationKind(TemplateSpecializationKind TSK)
Scope - A scope is a transient data structure that is used while parsing the program.
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
SourceLocation getRAngleLoc() const
Represents a C++ nested-name-specifier or a global scope specifier.
SourceLocation getConceptSpecLoc() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
SourceLocation getTemplateNameLoc() const
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Decl * ActOnTemplateDeclarator(Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
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 preordor or postorder depth-first traversal on the entire Clang AST and visits each...
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.
SourceLocation getLocStart() const LLVM_READONLY
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
We are matching the template parameter lists of a template template argument against the template par...
SourceRange getSourceRange() const LLVM_READONLY
detail::InMemoryDirectory::const_iterator I
Decl * ActOnTypeParameter(Scope *S, bool Typename, SourceLocation EllipsisLoc, SourceLocation KeyLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedType DefaultArg)
ActOnTypeParameter - Called when a C++ template type parameter (e.g., "typename T") has been parsed...
QualType getCanonicalTypeInternal() const
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const
getInjectedClassNameType - Return the unique reference to the injected class name type for the specif...
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.
Represents an extended vector type where either the type or size is dependent.
const UnresolvedSetImpl & asUnresolvedSet() const
SourceRange getRange() const
bool isDefined(const FunctionDecl *&Definition) const
isDefined - Returns true if the function is defined at all, including a deleted definition.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
EnumDecl * getDecl() const
We are matching the template parameter lists of two template template parameters as part of matching ...
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
TemplateName getUnderlying() const
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
Gets the type contained by this atomic type, i.e.
QualType getInjectedSpecializationType() const
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg, SmallVectorImpl< TemplateArgument > &Converted)
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
Sema - This implements semantic analysis and AST building for C.
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this...
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< Decl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, SmallVectorImpl< TemplateArgument > &Converted, CheckTemplateArgumentKind CTAK=CTAK_Specified)
Check that the given template argument corresponds to the given template parameter.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
Represents a prototype with parameter type info, e.g.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
SourceLocation getLocStart() const LLVM_READONLY
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
static TypeSourceInfo * SubstDefaultTemplateArgument(Sema &SemaRef, TemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, TemplateTypeParmDecl *Param, SmallVectorImpl< TemplateArgument > &Converted)
Substitute template arguments into the default template argument for the given template type paramete...
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...
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
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
void setTemplateNameLoc(SourceLocation Loc)
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, const TemplateArgumentListInfo &Args) const
Represents an array type in C++ whose size is a value-dependent expression.
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool isDeleted() const
Whether this function has been deleted.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
QualType getPointeeType() const
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
Expr - This represents one expression.
Defines the clang::LangOptions interface.
DeclResult CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation TemplateNameLoc, const TemplateArgumentListInfo &TemplateArgs)
DeclarationName getLookupName() const
Gets the name to look up.
StringRef getName() const
Return the actual identifier string.
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos, QualType CanonInjectedType, ClassTemplatePartialSpecializationDecl *PrevDecl)
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
Declaration of a template type parameter.
SourceLocation getNameLoc() const
Gets the location of the identifier.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
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...
TranslationUnitDecl * getTranslationUnitDecl() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
SourceLocation getLocation() const
ArgKind getKind() const
Return the kind of stored template argument.
ExtProtoInfo getExtProtoInfo() const
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
void setMemberSpecialization()
Note that this member template is a specialization.
void NoteAllFoundTemplates(TemplateName Name)
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
static DependentScopeDeclRefExpr * Create(const ASTContext &C, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Represents the type decltype(expr) (C++11).
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given function template specialization.
TypeSourceInfo * getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &Args, QualType Canon=QualType()) const
A namespace alias, stored as a NamespaceAliasDecl*.
void setLateTemplateParsed(bool ILT=true)
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
bool isConstexprSpecified() const
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.
QualType getType() const
Get the type for which this source info wrapper provides information.
StorageClass
Storage classes.
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isFunctionOrMethod() const
Declaration of an alias template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
Data structure that captures multiple levels of template argument lists for use in template instantia...
void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
Represents a GCC generic vector type.
An lvalue reference type, per C++11 [dcl.ref].
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization)
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
void setDescribedClassTemplate(ClassTemplateDecl *Template)
QualType getElementType() const
The result type of a method or function.
This template specialization was implicitly instantiated from a template.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type...
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
SourceLocation getStorageClassSpecLoc() const
RecordDecl * getDefinition() const
getDefinition - Returns the RecordDecl that actually defines this struct/union/class.
A type, stored as a Type*.
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
static TemplateArgumentLoc translateTemplateArgument(Sema &SemaRef, const ParsedTemplateArgument &Arg)
TypeSourceInfo * getTypeSourceInfo() const
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
const TypeClass * getTypePtr() const
bool isLValueOnePastTheEnd() const
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
bool hasUnnamedOrLocalType() const
Whether this type is or contains a local or unnamed type.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc)
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.
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...
Assigning into this object requires the old value to be released and the new value to be retained...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
void setLAngleLoc(SourceLocation Loc)
Represents the parsed form of a C++ template argument.
A stack object to be created when performing template instantiation.
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
static bool isSameAsPrimaryTemplate(TemplateParameterList *Params, ArrayRef< TemplateArgument > Args)
Encodes a location in the source.
Expr * getAsExpr() const
Retrieve the non-type template argument's expression.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
Walk the path from which a declaration was instantiated, and check that every explicit specialization...
QualType getElementType() const
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
void setBraceRange(SourceRange R)
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
An overloaded operator name, e.g., operator+.
static bool CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *ArgIn, TemplateArgument &Converted)
Checks whether the given template argument is the address of an object or function according to C++ [...
This names the __make_integer_seq BuiltinTemplateDecl.
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
bool isValid() const
Return true if this is a valid SourceLocation object.
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...
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
ASTContext & getASTContext() const
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
ValueKind getKind() const
Represents a dependent using declaration which was not marked with typename.
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
Represents a static or instance method of a struct/union/class.
unsigned getDepth() const
Retrieve the depth of the template parameter.
void print(const PrintingPolicy &Policy, raw_ostream &Out) const
Print this template argument to the given output stream.
SourceLocation getNameLoc() const
QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc)
Check that the type of a non-type template parameter is well-formed.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
Name lookup found an unresolvable value declaration and cannot yet complete.
static bool CheckTemplateSpecializationScope(Sema &S, NamedDecl *Specialized, NamedDecl *PrevDecl, SourceLocation Loc, bool IsPartialSpecialization)
Check whether a specialization is well-formed in the current context.
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template...
SourceLocation getConstexprSpecLoc() const
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
void addDecl(NamedDecl *D)
void setPointOfInstantiation(SourceLocation Loc)
A class for iterating through a result set and possibly filtering out results.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setElaboratedKeywordLoc(SourceLocation Loc)
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
SourceLocation getBegin() const
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
const T * castAs() const
Member-template castAs<specific type>.
SourceLocation getBeginLoc() const
No entity found met the criteria.
This template specialization was instantiated from a template due to an explicit instantiation defini...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
bool isFileContext() const
A template type parameter, stored as a type.
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization, returns the templated static data member from which it was instantiated.
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, Sema::TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
Attr * clone(ASTContext &C) const
void checkPartialSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a template specialization that would select a partial specialization.
QualType getType() const
Return the type wrapped by this type source info.
void addArgument(const TemplateArgumentLoc &Loc)
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
The injected class name of a C++ class template or class template partial specialization.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
QualType getPointeeType() const
A qualified reference to a name whose declaration cannot yet be resolved.
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
A POD class for pairing a NamedDecl* with an access specifier.
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>...
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template...
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Decl * ActOnTemplateTemplateParameter(Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params, SourceLocation EllipsisLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg)
ActOnTemplateTemplateParameter - Called when a C++ template template parameter (e.g.
Represents a template argument.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
QualType getAsType() const
Retrieve the type for a type template argument.
TagTypeKind
The kind of a tag type.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
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.
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
EvalResult is a struct with detailed info about an evaluated expression.
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
bool isDependent() const
Determines whether this is a dependent template name.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
SourceLocation getLocStart() const LLVM_READONLY
The template argument is a pack expansion of a template name that was provided for a template templat...
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.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
TemplateName getCanonicalTemplateName(TemplateName Name) const
Retrieves the "canonical" template name that refers to a given template.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
This is a scope that corresponds to the template parameters of a C++ template.
This template specialization was instantiated from a template due to an explicit instantiation declar...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
DeclarationName - The name of a declaration.
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo &TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization...
Represents a C++11 pack expansion that produces a sequence of expressions.
std::string getAsString(ASTContext &Ctx, QualType Ty) const
bool isThisDeclarationADefinition() const
isThisDeclarationADefinition - Returns whether this specific declaration of the function is also a de...
EnumDecl - Represents an enum.
detail::InMemoryDirectory::const_iterator E
A pointer to member type per C++ 8.3.3 - Pointers to members.
This names the __type_pack_element BuiltinTemplateDecl.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set...
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS, const IdentifierInfo &II, SourceLocation IdLoc)
Called when the parser has parsed a C++ typename specifier, e.g., "typename T::type".
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
A type that was preceded by the 'template' keyword, stored as a Type*.
The name refers to a template whose specialization produces a type.
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
bool isWideCharType() const
unsigned getDepth() const
Get the nesting depth of the template parameter.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
void setNameLoc(SourceLocation Loc)
Represents a pointer to an Objective C object.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
Name lookup found a single declaration that met the criteria.
bool empty() const
Return true if no decls were found.
ArrayRef< LValuePathEntry > getLValuePath() const
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool HasSideEffects
Whether the evaluated expression has side effects.
bool hasVisibleMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a visible declaration of D that is a member specialization declaration (as oppo...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
const T * getAs() const
Member-template getAs<specific type>'.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Determine what kind of template instantiation this function represents.
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
This template specialization was declared or defined by an explicit specialization (C++ [temp...
static SourceRange findTemplateParameter(unsigned Depth, Expr *E)
static VarTemplatePartialSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
unsigned getNumArgs() const
QualType getIntegralType() const
Retrieve the type of the integral value.
bool isNull() const
Determine whether this template name is NULL.
void setTypeSourceInfo(TypeSourceInfo *TI)
void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK)
Specify that this variable is an instantiation of the static data member VD.
ExplicitSpecializationVisibilityChecker(Sema &S, SourceLocation Loc)
bool isFunctionType() const
ExtVectorType - Extended vector type.
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...
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isInvalid() const
Determine whether the given template argument is invalid.
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.
void addDecl(Decl *D)
Add the declaration D into this context.
const TypeClass * getTypePtr() const
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
bool isInlineSpecified() const
The template argument is actually a parameter pack.
A template-id, e.g., f<int>.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
bool isStaticDataMember() const
Determines whether this is a static data member.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
static bool ScopeSpecifierHasTemplateId(const CXXScopeSpec &SS)
Determine whether the given scope specifier has a template-id in it.
bool isConcept() const
Whether this is a (C++ Concepts TS) function or variable concept.
void setInstantiationOf(VarTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this variable template specialization is actually an instantiation of the given variable te...
QualType getPointeeType() const
This is a scope that can contain a declaration.
IdentifierInfo * getIdentifier() const
A template argument list.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
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.
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
SourceLocation getIdentifierLoc() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
const LValueBase getLValueBase() const
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
A user-defined literal name, e.g., operator "" _i.
Decl * D
The template function declaration to be late parsed.
The template argument is a template name that was provided for a template template parameter...
Represents a C array with an unspecified size.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member...
void setConstexpr(bool IC)
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
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)
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...
This class is used for builtin types like 'int'.
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)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
void LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType, bool EnteringContext, bool &MemberOfUnknownSpecialization)
The name refers to a variable template whose specialization produces a variable.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
A reference to a declared variable, function, enum, etc.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isSet() const
Deprecated.
NamedDecl * getMostRecentDecl()
SourceLocation getRAngleLoc() const
QualType getElementType() const
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
void setMemberSpecialization()
Note that this member template is a specialization.
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.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
AttributeList * getNext() const
An l-value expression is a reference to an object with independent storage.
static bool DependsOnTemplateParameters(QualType T, TemplateParameterList *Params)
Determines whether a given type depends on the given parameter list.
StringRef getKindName() const
Wrapper for template type parameters.
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
A trivial tuple used to represent a source range.
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
FunctionDecl * getCanonicalDecl() override
NamedDecl - This represents a decl with a name.
bool isInvalidType() const
A boolean literal, per ([C++ lex.bool] Boolean literals).
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization, retrieves the function from which it was instantiated.
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
A template template argument, stored as a template name.
Represents a C array with a specified size that is not an integer-constant-expression.
void setTemplateNameLoc(SourceLocation Loc)
No keyword precedes the qualified type name.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
unsigned NumArgs
NumArgs - The number of template arguments.
The global specifier '::'. There is no stored value.
void setType(QualType newType)
const TemplateArgument & getArgument() const
SourceRange getSourceRange() const LLVM_READONLY
void setDeletedAsWritten(bool D=true)
TemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon, QualType Aliased)
Represents the canonical version of C arrays with a specified constant size.
Defines enum values for all the target-independent builtin functions.
Declaration of a template function.
void clear()
Clears out any current state.
bool IsInsideALocalClassWithinATemplateFunction()
void setElaboratedKeywordLoc(SourceLocation Loc)
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc, TemplateDecl *TD, const TemplateParmDecl *D, TemplateArgumentListInfo &Args)
Diagnose a missing template argument.
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
NamedDecl *const * iterator
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
AttributeList - Represents a syntactic attribute.
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
Return true if this is an incomplete or object type, in other words, not a function type...
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 ...