32 #include "llvm/ADT/SmallBitVector.h"
33 #include "llvm/ADT/SmallString.h"
34 #include "llvm/ADT/StringExtras.h"
35 using namespace clang;
43 return SourceRange(Ps[0]->getTemplateLoc(), Ps[N-1]->getRAngleLoc());
51 bool AllowFunctionTemplates) {
54 if (isa<TemplateDecl>(D)) {
55 if (!AllowFunctionTemplates && isa<FunctionTemplateDecl>(D))
73 if (Record->isInjectedClassName()) {
74 Record = cast<CXXRecordDecl>(Record->getDeclContext());
75 if (Record->getDescribedClassTemplate())
76 return Record->getDescribedClassTemplate();
79 = dyn_cast<ClassTemplateSpecializationDecl>(Record))
80 return Spec->getSpecializedTemplate();
90 bool AllowFunctionTemplates) {
92 llvm::SmallPtrSet<ClassTemplateDecl *, 8> ClassTemplates;
97 AllowFunctionTemplates);
100 else if (Repl != Orig) {
111 if (!ClassTemplates.insert(ClassTmpl).second) {
128 bool AllowFunctionTemplates) {
138 bool hasTemplateKeyword,
141 bool EnteringContext,
143 bool &MemberOfUnknownSpecialization) {
144 assert(getLangOpts().
CPlusPlus &&
"No template names in C!");
147 MemberOfUnknownSpecialization =
false;
170 LookupTemplateName(R, S, SS, ObjectType, EnteringContext,
171 MemberOfUnknownSpecialization);
173 if (R.isAmbiguous()) {
175 R.suppressDiagnostics();
185 unsigned ResultCount = R.end() - R.begin();
186 if (ResultCount > 1) {
193 R.suppressDiagnostics();
195 TemplateDecl *TD = cast<TemplateDecl>((*R.begin())->getUnderlyingDecl());
200 hasTemplateKeyword, TD);
205 if (isa<FunctionTemplateDecl>(TD)) {
209 R.suppressDiagnostics();
211 assert(isa<ClassTemplateDecl>(TD) || isa<TemplateTemplateParmDecl>(TD) ||
212 isa<TypeAliasTemplateDecl>(TD) || isa<VarTemplateDecl>(TD) ||
213 isa<BuiltinTemplateDecl>(TD));
219 TemplateResult = TemplateTy::make(Template);
232 if (!SS || !SS->
isSet() || !isDependentScopeSpecifier(*SS) ||
233 computeDeclContext(*SS))
239 Diag(IILoc, diag::err_template_kw_missing)
251 bool EnteringContext,
252 bool &MemberOfUnknownSpecialization) {
254 MemberOfUnknownSpecialization =
false;
256 bool isDependent =
false;
257 if (!ObjectType.
isNull()) {
260 assert(!SS.
isSet() &&
"ObjectType and scope specifier cannot coexist");
261 LookupCtx = computeDeclContext(ObjectType);
265 "Caller should have completed object type");
272 }
else if (SS.
isSet()) {
275 LookupCtx = computeDeclContext(SS, EnteringContext);
276 isDependent = isDependentScopeSpecifier(SS);
279 if (LookupCtx && RequireCompleteDeclContext(SS, LookupCtx))
283 bool ObjectTypeSearchedInScope =
false;
284 bool AllowFunctionTemplatesInLookup =
true;
290 LookupQualifiedName(Found, LookupCtx);
301 if (S) LookupName(Found, S);
302 ObjectTypeSearchedInScope =
true;
303 AllowFunctionTemplatesInLookup =
false;
305 }
else if (isDependent && (!S || ObjectType.
isNull())) {
308 MemberOfUnknownSpecialization =
true;
312 LookupName(Found, S);
315 AllowFunctionTemplatesInLookup =
false;
318 if (Found.
empty() && !isDependent) {
323 auto FilterCCC = llvm::make_unique<CorrectionCandidateCallback>();
324 FilterCCC->WantTypeSpecifiers =
false;
325 FilterCCC->WantExpressionKeywords =
false;
326 FilterCCC->WantRemainingKeywords =
false;
327 FilterCCC->WantCXXNamedCasts =
true;
330 std::move(FilterCCC), CTK_ErrorRecovery, LookupCtx)) {
332 if (
auto *ND = Corrected.getFoundDecl())
334 FilterAcceptableTemplateNames(Found);
335 if (!Found.
empty()) {
337 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
338 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
340 diagnoseTypo(Corrected, PDiag(diag::err_no_member_template_suggest)
341 << Name << LookupCtx << DroppedSpecifier
344 diagnoseTypo(Corrected, PDiag(diag::err_no_template_suggest) << Name);
352 FilterAcceptableTemplateNames(Found, AllowFunctionTemplatesInLookup);
355 MemberOfUnknownSpecialization =
true;
359 if (S && !ObjectType.
isNull() && !ObjectTypeSearchedInScope &&
360 !getLangOpts().CPlusPlus11) {
369 LookupName(FoundOuter, S);
370 FilterAcceptableTemplateNames(FoundOuter,
false);
372 if (FoundOuter.empty()) {
376 FoundOuter.isAmbiguous()) {
389 diag::ext_nested_name_member_ref_lookup_ambiguous)
393 diag::note_ambig_member_ref_object_type)
395 Diag(FoundOuter.getFoundDecl()->getLocation(),
396 diag::note_ambig_member_ref_scope);
412 bool isAddressOfOperand,
416 if (!isAddressOfOperand &&
417 isa<CXXMethodDecl>(DC) &&
418 cast<CXXMethodDecl>(DC)->isInstance()) {
423 NamedDecl *FirstQualifierInScope =
nullptr;
426 Context,
nullptr, ThisType,
true,
428 FirstQualifierInScope, NameInfo, TemplateArgs);
431 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
452 if (getLangOpts().MicrosoftExt)
458 Diag(Loc, diag::err_template_param_shadow)
459 << cast<NamedDecl>(PrevDecl)->getDeclName();
468 if (
TemplateDecl *Temp = dyn_cast_or_null<TemplateDecl>(D)) {
469 D = Temp->getTemplatedDecl();
477 assert(
Kind == Template &&
478 "Only template template arguments can be pack expansions here");
479 assert(getAsTemplate().
get().containsUnexpandedParameterPack() &&
480 "Template template argument pack expansion without packs");
482 Result.EllipsisLoc = EllipsisLoc;
518 llvm_unreachable(
"Unhandled parsed template argument");
525 for (
unsigned I = 0,
Last = TemplateArgsIn.size();
I !=
Last; ++
I)
557 "Template type parameter not in template parameter scope!");
558 bool Invalid =
false;
564 bool IsParameterPack = EllipsisLoc.
isValid();
568 Typename, IsParameterPack);
578 IdResolver.AddDecl(Param);
584 if (DefaultArg && IsParameterPack) {
585 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
592 GetTypeFromParser(DefaultArg, &DefaultTInfo);
594 assert(DefaultTInfo &&
"expected source information for type");
597 if (DiagnoseUnexpandedParameterPack(Loc, DefaultTInfo,
598 UPPC_DefaultArgument))
602 if (CheckTemplateArgument(Param, DefaultTInfo)) {
623 Diag(Loc, diag::err_variably_modified_nontype_template_param)
659 Diag(Loc, diag::err_template_nontype_parm_bad_type)
674 "Non-type template parameter not in template parameter scope!");
675 bool Invalid =
false;
690 IsParameterPack, TInfo);
702 IdResolver.AddDecl(Param);
708 if (Default && IsParameterPack) {
709 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
716 if (DiagnoseUnexpandedParameterPack(Default, UPPC_DefaultArgument))
721 CheckTemplateArgument(Param, Param->
getType(), Default, Converted);
726 Default = DefaultRes.
get();
748 "Template template parameter not in template parameter scope!");
751 bool IsParameterPack = EllipsisLoc.
isValid();
765 IdResolver.AddDecl(Param);
768 if (Params->
size() == 0) {
777 if (IsParameterPack && !Default.
isInvalid()) {
778 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
793 Diag(DefaultArg.
getLocation(), diag::err_template_arg_not_class_template)
799 if (DiagnoseUnexpandedParameterPack(DefaultArg.
getLocation(),
801 UPPC_DefaultArgument))
820 Diag(ExportLoc, diag::warn_template_export_unsupported);
823 Context, TemplateLoc, LAngleLoc,
824 llvm::makeArrayRef((
NamedDecl *
const *)Params.data(), Params.size()),
841 unsigned NumOuterTemplateParamLists,
844 assert(TemplateParams && TemplateParams->
size() > 0 &&
845 "No template parameters");
846 assert(TUK != TUK_Reference &&
"Can only declare or define class templates");
847 bool Invalid =
false;
850 if (CheckTemplateDeclScope(S, TemplateParams))
854 assert(Kind !=
TTK_Enum &&
"can't build template of enumerated type");
858 Diag(KWLoc, diag::err_template_unnamed_class);
867 (SS.
isEmpty() && TUK == TUK_Friend)
868 ? LookupTagName : LookupOrdinaryName,
871 SemanticContext = computeDeclContext(SS,
true);
872 if (!SemanticContext) {
876 Diag(NameLoc, TUK == TUK_Friend
877 ? diag::warn_template_qualified_friend_ignored
878 : diag::err_template_qualified_declarator_no_match)
880 return TUK != TUK_Friend;
883 if (RequireCompleteDeclContext(SS, SemanticContext))
891 if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams))
893 }
else if (TUK != TUK_Friend && TUK != TUK_Reference)
894 diagnoseQualifiedDeclaration(SS, SemanticContext, Name, NameLoc);
896 LookupQualifiedName(Previous, SemanticContext);
898 SemanticContext = CurContext;
904 if (TUK != TUK_Friend &&
905 DiagnoseClassNameShadow(SemanticContext,
909 LookupName(Previous, S);
916 if (Previous.
begin() != Previous.
end())
917 PrevDecl = (*Previous.
begin())->getUnderlyingDecl();
922 = dyn_cast_or_null<ClassTemplateDecl>(PrevDecl);
927 if (!PrevClassTemplate && PrevDecl && isa<CXXRecordDecl>(PrevDecl) &&
928 cast<CXXRecordDecl>(PrevDecl)->isInjectedClassName()) {
931 = cast<CXXRecordDecl>(PrevDecl)->getDescribedClassTemplate();
932 if (!PrevClassTemplate && isa<ClassTemplateSpecializationDecl>(PrevDecl)) {
934 = cast<ClassTemplateSpecializationDecl>(PrevDecl)
935 ->getSpecializedTemplate();
939 if (TUK == TUK_Friend) {
958 PrevDecl = PrevClassTemplate =
nullptr;
959 SemanticContext = OutermostContext;
963 Previous.
clear(LookupOrdinaryName);
967 LookupQualifiedName(Previous, LookupContext);
972 if (Previous.
begin() != Previous.
end())
973 PrevDecl = (*Previous.
begin())->getUnderlyingDecl();
976 }
else if (PrevDecl &&
979 PrevDecl = PrevClassTemplate =
nullptr;
981 if (
auto *Shadow = dyn_cast_or_null<UsingShadowDecl>(
984 !(PrevClassTemplate &&
987 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
988 Diag(Shadow->getTargetDecl()->getLocation(),
989 diag::note_using_decl_target);
990 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl) << 0;
992 PrevDecl = PrevClassTemplate =
nullptr;
996 if (PrevClassTemplate) {
1000 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
1001 !TemplateParameterListsAreEqual(TemplateParams,
1013 if (!isAcceptableTagRedeclaration(PrevRecordDecl, Kind,
1014 TUK == TUK_Definition, KWLoc, Name)) {
1015 Diag(KWLoc, diag::err_use_with_wrong_tag)
1023 if (TUK == TUK_Definition) {
1028 if (SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
1030 auto *Tmpl = cast<CXXRecordDecl>(Hidden)->getDescribedClassTemplate();
1031 assert(Tmpl &&
"original definition of a class template is not a "
1033 makeMergedDefinitionVisible(Hidden, KWLoc);
1034 makeMergedDefinitionVisible(Tmpl, KWLoc);
1038 Diag(NameLoc, diag::err_redefinition) <<
Name;
1039 Diag(Def->getLocation(), diag::note_previous_definition);
1047 DiagnoseTemplateParameterShadow(NameLoc, PrevDecl);
1050 }
else if (PrevDecl) {
1056 Diag(NameLoc, diag::err_redefinition_different_kind) <<
Name;
1065 if (!(TUK == TUK_Friend && CurContext->isDependentContext()) &&
1066 CheckTemplateParameterList(
1070 (SS.
isSet() && SemanticContext && SemanticContext->
isRecord() &&
1072 ? TPC_ClassTemplateMember
1073 : TUK == TUK_Friend ? TPC_FriendClassTemplate
1074 : TPC_ClassTemplate))
1080 if (!SS.
isInvalid() && !Invalid && !PrevClassTemplate) {
1081 Diag(NameLoc, TUK == TUK_Friend ? diag::err_friend_decl_does_not_match
1082 : diag::err_member_decl_does_not_match)
1083 << Name << SemanticContext <<
true << SS.
getRange();
1094 if (NumOuterTemplateParamLists > 0)
1096 Context, llvm::makeArrayRef(OuterTemplateParamLists,
1097 NumOuterTemplateParamLists));
1101 if (TUK == TUK_Definition) {
1102 AddAlignmentAttributesForRecord(NewClass);
1103 AddMsStructLayoutForRecord(NewClass);
1109 NewClass, PrevClassTemplate);
1112 if (ModulePrivateLoc.
isValid())
1118 assert(T->
isDependentType() &&
"Class template type is not dependent?");
1123 if (PrevClassTemplate &&
1129 SetMemberAccessSpecifier(NewTemplate, PrevClassTemplate, AS);
1135 if (TUK == TUK_Definition)
1139 ProcessDeclAttributeList(S, NewClass, Attr);
1141 if (PrevClassTemplate)
1144 AddPushedVisibilityAttribute(NewClass);
1146 if (TUK != TUK_Friend) {
1151 PushOnScopeChains(NewTemplate, Outer);
1161 if (!CurContext->isDependentContext()) {
1164 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
1165 PushOnScopeChains(NewTemplate, EnclosingScope,
1172 CurContext->addDecl(Friend);
1180 ActOnDocumentableDecl(NewTemplate);
1210 diag::warn_cxx98_compat_template_parameter_default_in_function_template
1211 : diag::ext_template_parameter_default_in_function_template)
1220 S.
Diag(ParamLoc, diag::err_template_parameter_default_template_member)
1229 S.
Diag(ParamLoc, diag::err_template_parameter_default_friend_template)
1238 llvm_unreachable(
"Invalid TemplateParamListContext!");
1251 for (
unsigned I = 0, N = Params->
size();
I != N; ++
I) {
1254 if (!NTTP->isParameterPack() &&
1256 NTTP->getTypeSourceInfo(),
1264 = dyn_cast<TemplateTemplateParmDecl>(P))
1297 bool Invalid =
false;
1305 bool SawDefaultArgument =
false;
1311 OldParam = OldParams->
begin();
1313 bool RemoveDefaultArguments =
false;
1315 NewParamEnd = NewParams->
end();
1316 NewParam != NewParamEnd; ++NewParam) {
1318 bool RedundantDefaultArg =
false;
1323 bool MissingDefaultArg =
false;
1326 bool SawParameterPack =
false;
1329 = dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
1331 if (NewTypeParm->hasDefaultArgument() &&
1333 NewTypeParm->getLocation(),
1334 NewTypeParm->getDefaultArgumentInfo()->getTypeLoc()
1336 NewTypeParm->removeDefaultArgument();
1340 = OldParams? cast<TemplateTypeParmDecl>(*OldParam) :
nullptr;
1341 if (NewTypeParm->isParameterPack()) {
1342 assert(!NewTypeParm->hasDefaultArgument() &&
1343 "Parameter packs can't have a default argument!");
1344 SawParameterPack =
true;
1346 NewTypeParm->hasDefaultArgument()) {
1348 NewDefaultLoc = NewTypeParm->getDefaultArgumentLoc();
1349 SawDefaultArgument =
true;
1350 RedundantDefaultArg =
true;
1351 PreviousDefaultArgLoc = NewDefaultLoc;
1355 NewTypeParm->setInheritedDefaultArgument(
Context, OldTypeParm);
1357 }
else if (NewTypeParm->hasDefaultArgument()) {
1358 SawDefaultArgument =
true;
1359 PreviousDefaultArgLoc = NewTypeParm->getDefaultArgumentLoc();
1360 }
else if (SawDefaultArgument)
1361 MissingDefaultArg =
true;
1363 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
1365 if (!NewNonTypeParm->isParameterPack() &&
1366 DiagnoseUnexpandedParameterPack(NewNonTypeParm->getLocation(),
1367 NewNonTypeParm->getTypeSourceInfo(),
1368 UPPC_NonTypeTemplateParameterType)) {
1374 if (NewNonTypeParm->hasDefaultArgument() &&
1376 NewNonTypeParm->getLocation(),
1377 NewNonTypeParm->getDefaultArgument()->getSourceRange())) {
1378 NewNonTypeParm->removeDefaultArgument();
1383 = OldParams? cast<NonTypeTemplateParmDecl>(*OldParam) :
nullptr;
1384 if (NewNonTypeParm->isParameterPack()) {
1385 assert(!NewNonTypeParm->hasDefaultArgument() &&
1386 "Parameter packs can't have a default argument!");
1387 if (!NewNonTypeParm->isPackExpansion())
1388 SawParameterPack =
true;
1390 NewNonTypeParm->hasDefaultArgument()) {
1392 NewDefaultLoc = NewNonTypeParm->getDefaultArgumentLoc();
1393 SawDefaultArgument =
true;
1394 RedundantDefaultArg =
true;
1395 PreviousDefaultArgLoc = NewDefaultLoc;
1399 NewNonTypeParm->setInheritedDefaultArgument(
Context, OldNonTypeParm);
1401 }
else if (NewNonTypeParm->hasDefaultArgument()) {
1402 SawDefaultArgument =
true;
1403 PreviousDefaultArgLoc = NewNonTypeParm->getDefaultArgumentLoc();
1404 }
else if (SawDefaultArgument)
1405 MissingDefaultArg =
true;
1408 = cast<TemplateTemplateParmDecl>(*NewParam);
1425 = OldParams? cast<TemplateTemplateParmDecl>(*OldParam) :
nullptr;
1428 "Parameter packs can't have a default argument!");
1430 SawParameterPack =
true;
1431 }
else if (OldTemplateParm &&
1436 SawDefaultArgument =
true;
1437 RedundantDefaultArg =
true;
1438 PreviousDefaultArgLoc = NewDefaultLoc;
1443 PreviousDefaultArgLoc
1446 SawDefaultArgument =
true;
1447 PreviousDefaultArgLoc
1449 }
else if (SawDefaultArgument)
1450 MissingDefaultArg =
true;
1456 if (SawParameterPack && (NewParam + 1) != NewParamEnd &&
1457 (TPC == TPC_ClassTemplate || TPC == TPC_VarTemplate ||
1458 TPC == TPC_TypeAliasTemplate)) {
1459 Diag((*NewParam)->getLocation(),
1460 diag::err_template_param_pack_must_be_last_template_parameter);
1464 if (RedundantDefaultArg) {
1468 Diag(NewDefaultLoc, diag::err_template_param_default_arg_redefinition);
1469 Diag(OldDefaultLoc, diag::note_template_param_prev_default_arg);
1471 }
else if (MissingDefaultArg && TPC != TPC_FunctionTemplate) {
1477 Diag((*NewParam)->getLocation(),
1478 diag::err_template_param_default_arg_missing);
1479 Diag(PreviousDefaultArgLoc, diag::note_template_param_prev_default_arg);
1481 RemoveDefaultArguments =
true;
1492 if (RemoveDefaultArguments) {
1494 NewParamEnd = NewParams->
end();
1495 NewParam != NewParamEnd; ++NewParam) {
1497 TTP->removeDefaultArgument();
1499 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
1500 NTTP->removeDefaultArgument();
1502 cast<TemplateTemplateParmDecl>(*NewParam)->removeDefaultArgument();
1520 DependencyChecker(
unsigned Depth) : Depth(Depth), Match(
false) {}
1525 Depth = PD->getDepth();
1527 dyn_cast<NonTypeTemplateParmDecl>(ND)) {
1528 Depth = PD->getDepth();
1530 Depth = cast<TemplateTemplateParmDecl>(ND)->getDepth();
1535 if (ParmDepth >=
Depth) {
1556 return super::TraverseTemplateName(N);
1561 dyn_cast<NonTypeTemplateParmDecl>(E->
getDecl()))
1564 return super::VisitDeclRefExpr(E);
1586 DependencyChecker Checker(Params);
1587 Checker.TraverseType(T);
1588 return Checker.Match;
1598 if (
const Type *CurType = NNS->getAsType()) {
1604 NNSLoc = NNSLoc.getPrefix();
1646 bool &IsExplicitSpecialization,
bool &Invalid) {
1647 IsExplicitSpecialization =
false;
1657 = dyn_cast_or_null<CXXRecordDecl>(computeDeclContext(SS,
true)))
1669 NestedTypes.push_back(T);
1675 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
1676 if (!isa<ClassTemplatePartialSpecializationDecl>(Spec) &&
1678 ExplicitSpecLoc = Spec->getLocation();
1681 }
else if (Record->getTemplateSpecializationKind()
1683 ExplicitSpecLoc = Record->getLocation();
1687 if (
TypeDecl *Parent = dyn_cast<TypeDecl>(Record->getParent()))
1696 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
1697 if (
TypeDecl *Parent = dyn_cast<TypeDecl>(Template->getDeclContext()))
1742 std::reverse(NestedTypes.begin(), NestedTypes.end());
1750 bool SawNonEmptyTemplateParameterList =
false;
1752 auto CheckExplicitSpecialization = [&](
SourceRange Range,
bool Recovery) {
1753 if (SawNonEmptyTemplateParameterList) {
1754 Diag(DeclLoc, diag::err_specialize_member_of_template)
1755 << !Recovery << Range;
1757 IsExplicitSpecialization =
false;
1764 auto DiagnoseMissingExplicitSpecialization = [&] (
SourceRange Range) {
1766 if (CheckExplicitSpecialization(Range,
true))
1771 if (!ParamLists.empty())
1772 ExpectedTemplateLoc = ParamLists[0]->getTemplateLoc();
1774 ExpectedTemplateLoc = DeclStartLoc;
1776 Diag(DeclLoc, diag::err_template_spec_needs_header)
1782 unsigned ParamIdx = 0;
1783 for (
unsigned TypeIdx = 0, NumTypes = NestedTypes.size(); TypeIdx != NumTypes;
1785 T = NestedTypes[TypeIdx];
1788 bool NeedEmptyTemplateHeader =
false;
1791 bool NeedNonemptyTemplateHeader =
false;
1804 = dyn_cast<ClassTemplatePartialSpecializationDecl>(Record)) {
1805 ExpectedTemplateParams = Partial->getTemplateParameters();
1806 NeedNonemptyTemplateHeader =
true;
1807 }
else if (Record->isDependentType()) {
1808 if (Record->getDescribedClassTemplate()) {
1809 ExpectedTemplateParams = Record->getDescribedClassTemplate()
1810 ->getTemplateParameters();
1811 NeedNonemptyTemplateHeader =
true;
1814 = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
1820 NeedEmptyTemplateHeader =
true;
1823 }
else if (Record->getTemplateSpecializationKind()) {
1824 if (Record->getTemplateSpecializationKind()
1826 TypeIdx == NumTypes - 1)
1827 IsExplicitSpecialization =
true;
1833 if (
TemplateDecl *Template = TST->getTemplateName().getAsTemplateDecl()) {
1834 ExpectedTemplateParams = Template->getTemplateParameters();
1835 NeedNonemptyTemplateHeader =
true;
1840 NeedNonemptyTemplateHeader =
false;
1850 if (ParamIdx < ParamLists.size()) {
1851 if (ParamLists[ParamIdx]->size() == 0) {
1852 if (CheckExplicitSpecialization(ParamLists[ParamIdx]->getSourceRange(),
1856 SawNonEmptyTemplateParameterList =
true;
1859 if (NeedEmptyTemplateHeader) {
1862 if (TypeIdx == NumTypes - 1)
1863 IsExplicitSpecialization =
true;
1865 if (ParamIdx < ParamLists.size()) {
1866 if (ParamLists[ParamIdx]->size() > 0) {
1868 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
1869 diag::err_template_param_list_matches_nontemplate)
1871 <<
SourceRange(ParamLists[ParamIdx]->getLAngleLoc(),
1872 ParamLists[ParamIdx]->getRAngleLoc())
1884 if (DiagnoseMissingExplicitSpecialization(
1891 if (NeedNonemptyTemplateHeader) {
1897 if (ParamIdx < ParamLists.size() &&
1899 ExpectedTemplateParams =
nullptr;
1904 if (ParamIdx < ParamLists.size()) {
1906 if (ExpectedTemplateParams &&
1907 !TemplateParameterListsAreEqual(ParamLists[ParamIdx],
1908 ExpectedTemplateParams,
1909 true, TPL_TemplateMatch))
1913 CheckTemplateParameterList(ParamLists[ParamIdx],
nullptr,
1914 TPC_ClassTemplateMember))
1921 Diag(DeclLoc, diag::err_template_spec_needs_template_parameters)
1932 if (ParamIdx >= ParamLists.size()) {
1933 if (TemplateId && !IsFriend) {
1936 IsExplicitSpecialization =
true;
1950 if (ParamIdx < ParamLists.size() - 1) {
1951 bool HasAnyExplicitSpecHeader =
false;
1952 bool AllExplicitSpecHeaders =
true;
1953 for (
unsigned I = ParamIdx, E = ParamLists.size() - 1;
I !=
E; ++
I) {
1954 if (ParamLists[
I]->size() == 0)
1955 HasAnyExplicitSpecHeader =
true;
1957 AllExplicitSpecHeaders =
false;
1960 Diag(ParamLists[ParamIdx]->getTemplateLoc(),
1961 AllExplicitSpecHeaders ? diag::warn_template_spec_extra_headers
1962 : diag::err_template_spec_extra_headers)
1963 <<
SourceRange(ParamLists[ParamIdx]->getTemplateLoc(),
1964 ParamLists[ParamLists.size() - 2]->getRAngleLoc());
1969 if (ExplicitSpecLoc.
isValid() && HasAnyExplicitSpecHeader)
1970 Diag(ExplicitSpecLoc,
1971 diag::note_explicit_template_spec_does_not_need_header)
1972 << NestedTypes.back();
1977 if (!AllExplicitSpecHeaders)
1988 if (ParamLists.back()->size() == 0 &&
1989 CheckExplicitSpecialization(ParamLists[ParamIdx]->getSourceRange(),
1995 return ParamLists.back();
2000 Diag(Template->getLocation(), diag::note_template_declared_here)
2001 << (isa<FunctionTemplateDecl>(Template)
2003 : isa<ClassTemplateDecl>(Template)
2005 : isa<VarTemplateDecl>(Template)
2007 : isa<TypeAliasTemplateDecl>(Template) ? 3 : 4)
2008 << Template->getDeclName();
2016 Diag((*I)->getLocation(), diag::note_template_declared_here)
2017 << 0 << (*I)->getDeclName();
2025 const SmallVectorImpl<TemplateArgument> &Converted,
2036 if (!Converted[1].getAsType()->isIntegralType(Context)) {
2037 SemaRef.
Diag(TemplateArgs[1].getLocation(),
2038 diag::err_integer_sequence_integral_element_type);
2047 SemaRef.
Diag(TemplateArgs[2].getLocation(),
2048 diag::err_integer_sequence_negative_length);
2056 SyntheticTemplateArgs.
addArgument(TemplateArgs[1]);
2058 for (llvm::APSInt
I(NumArgs.getBitWidth(), NumArgs.isUnsigned());
2062 TA, TemplateArgs[2].getLocation())
2070 TemplateLoc, SyntheticTemplateArgs);
2072 llvm_unreachable(
"unexpected BuiltinTemplateDecl!");
2091 if (!Template || isa<FunctionTemplateDecl>(Template) ||
2092 isa<VarTemplateDecl>(Template)) {
2098 Diag(TemplateLoc, diag::err_template_id_not_a_type)
2100 NoteAllFoundTemplates(Name);
2107 if (CheckTemplateArgumentList(Template, TemplateLoc, TemplateArgs,
2113 bool InstantiationDependent =
false;
2115 dyn_cast<TypeAliasTemplateDecl>(Template)) {
2122 Converted.data(), Converted.size());
2127 unsigned Depth = AliasTemplate->getTemplateParameters()->getDepth();
2128 for (
unsigned I = 0;
I <
Depth; ++
I)
2129 TemplateArgLists.addOuterTemplateArguments(
None);
2137 TemplateArgLists, AliasTemplate->getLocation(),
2138 AliasTemplate->getDeclName());
2143 TemplateArgs, InstantiationDependent)) {
2168 if (isa<ClassTemplateDecl>(Template)) {
2171 if (Ctx->isFileContext())
break;
2175 if (!Record)
continue;
2179 if (!isa<ClassTemplatePartialSpecializationDecl>(Record) &&
2186 QualType Injected = cast<InjectedClassNameType>(ICNT)
2187 ->getInjectedSpecializationType();
2200 = dyn_cast<ClassTemplateDecl>(Template)) {
2203 void *InsertPos =
nullptr;
2205 = ClassTemplate->findSpecialization(Converted, InsertPos);
2211 ClassTemplate->getTemplatedDecl()->getTagKind(),
2212 ClassTemplate->getDeclContext(),
2213 ClassTemplate->getTemplatedDecl()->getLocStart(),
2214 ClassTemplate->getLocation(),
2217 Converted.size(),
nullptr);
2218 ClassTemplate->AddSpecialization(Decl, InsertPos);
2219 if (ClassTemplate->isOutOfLine())
2224 (void)DiagnoseUseOfDecl(Decl, TemplateLoc);
2227 assert(isa<RecordType>(CanonType) &&
2228 "type of non-dependent specialization is not a RecordType");
2229 }
else if (
auto *BTD = dyn_cast<BuiltinTemplateDecl>(Template)) {
2246 bool IsCtorOrDtorName) {
2254 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
2259 DTN->getQualifier(),
2260 DTN->getIdentifier(),
2277 QualType Result = CheckTemplateIdType(Template, TemplateLoc, TemplateArgs);
2290 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
2321 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
2330 DTN->getQualifier(),
2331 DTN->getIdentifier(),
2355 Diag(TemplateLoc, diag::err_tag_reference_non_tag) << 4;
2356 Diag(TAT->getLocation(), diag::note_declared_at);
2359 QualType Result = CheckTemplateIdType(Template, TemplateLoc, TemplateArgs);
2368 assert(Id &&
"templated class must have an identifier");
2370 if (!isAcceptableTagRedeclaration(D, TagKind, TUK == TUK_Definition,
2372 Diag(TagLoc, diag::err_use_with_wrong_tag)
2387 for (
unsigned i = 0, e = SpecTL.
getNumArgs(); i != e; ++i)
2406 bool IsPartialSpecialization);
2440 dyn_cast_or_null<TemplateTemplateParmDecl>(
2444 llvm_unreachable(
"unexpected kind of template argument");
2449 if (Params->
size() != Args.size())
2454 for (
unsigned I = 0, N = Args.size();
I != N; ++
I) {
2481 return TemplateArgs;
2487 bool IsPartialSpecialization) {
2490 "Variable template specialization is declared with a template it.");
2507 FnTemplate = *OTS->begin();
2514 << IsPartialSpecialization;
2518 for (
unsigned I = 0, N = TemplateArgs.
size();
I != N; ++
I)
2519 if (DiagnoseUnexpandedParameterPack(TemplateArgs[
I],
2520 UPPC_PartialSpecialization))
2526 if (CheckTemplateArgumentList(VarTemplate, TemplateNameLoc, TemplateArgs,
2532 if (IsPartialSpecialization) {
2535 TemplateArgs.
size(), Converted))
2538 bool InstantiationDependent;
2542 InstantiationDependent)) {
2543 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
2545 IsPartialSpecialization =
false;
2554 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
2556 << (SC !=
SC_Extern && !CurContext->isRecord())
2564 void *InsertPos =
nullptr;
2567 if (IsPartialSpecialization)
2579 IsPartialSpecialization))
2587 Specialization = PrevDecl;
2590 }
else if (IsPartialSpecialization) {
2593 cast_or_null<VarTemplatePartialSpecializationDecl>(PrevDecl);
2597 TemplateNameLoc, TemplateParams, VarTemplate, DI->
getType(), DI, SC,
2598 Converted.data(), Converted.size(), TemplateArgs);
2601 VarTemplate->AddPartialSpecialization(Partial, InsertPos);
2602 Specialization = Partial;
2613 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
2615 TemplateParams->getDepth(), DeducibleParams);
2617 if (!DeducibleParams.all()) {
2618 unsigned NumNonDeducible =
2619 DeducibleParams.size() - DeducibleParams.count();
2620 Diag(TemplateNameLoc, diag::warn_partial_specs_not_deducible)
2621 << 1 << (NumNonDeducible > 1)
2623 for (
unsigned I = 0, N = DeducibleParams.size(); I != N; ++
I) {
2624 if (!DeducibleParams[I]) {
2625 NamedDecl *Param = cast<NamedDecl>(TemplateParams->getParam(I));
2640 VarTemplate, DI->
getType(), DI, SC, Converted.data(), Converted.size());
2644 VarTemplate->AddSpecialization(Specialization, InsertPos);
2665 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
2669 diag::note_instantiation_required_here)
2682 CurContext->addDecl(Specialization);
2690 LookupResult PrevSpec(*
this, GetNameForDeclarator(D), LookupOrdinaryName,
2706 return Specialization;
2712 struct PartialSpecMatchResult {
2722 assert(Template &&
"A variable template id without template?");
2726 if (CheckTemplateArgumentList(
2727 Template, TemplateNameLoc,
2728 const_cast<TemplateArgumentListInfo &>(TemplateArgs),
false,
2734 void *InsertPos =
nullptr;
2736 Converted, InsertPos))
2746 Converted.data(), Converted.size());
2748 bool AmbiguousPartialSpec =
false;
2749 typedef PartialSpecMatchResult MatchResult;
2764 bool InstantiationDependent =
false;
2766 TemplateArgs, InstantiationDependent)) {
2771 for (
unsigned I = 0, N = PartialSpecs.size();
I != N; ++
I) {
2783 Matched.push_back(PartialSpecMatchResult());
2784 Matched.back().Partial = Partial;
2785 Matched.back().Args = Info.take();
2789 if (Matched.size() >= 1) {
2791 if (Matched.size() == 1) {
2804 PEnd = Matched.end();
2806 if (getMoreSpecializedPartialSpecialization(
P->Partial, Best->Partial,
2807 PointOfInstantiation) ==
2815 PEnd = Matched.end();
2817 if (
P != Best && getMoreSpecializedPartialSpecialization(
2818 P->Partial, Best->Partial,
2819 PointOfInstantiation) != Best->Partial) {
2820 AmbiguousPartialSpec =
true;
2827 InstantiationPattern = Best->Partial;
2828 InstantiationArgs = Best->Args;
2841 Template, InstantiationPattern, *InstantiationArgs, TemplateArgs,
2842 Converted, TemplateNameLoc, InsertPos );
2846 if (AmbiguousPartialSpec) {
2849 Diag(PointOfInstantiation, diag::err_partial_spec_ordering_ambiguous)
2854 PEnd = Matched.end();
2856 Diag(
P->Partial->getLocation(), diag::note_partial_spec_match)
2857 << getTemplateArgumentBindingsText(
2858 P->Partial->getTemplateParameters(), *
P->Args);
2863 dyn_cast<VarTemplatePartialSpecializationDecl>(InstantiationPattern))
2866 assert(Decl &&
"No variable template specialization?");
2887 return BuildDeclarationNameExpr(SS, NameInfo, Var,
2888 nullptr, TemplateArgs);
2907 assert(!R.
empty() &&
"empty lookup results when building templateid");
2908 assert(!R.
isAmbiguous() &&
"ambiguous lookup when building templateid");
2911 bool InstantiationDependent;
2914 *TemplateArgs, InstantiationDependent)) {
2917 TemplateKWLoc, TemplateArgs);
2928 RequiresADL, TemplateArgs,
2941 assert(TemplateArgs || TemplateKWLoc.
isValid());
2943 if (!(DC = computeDeclContext(SS,
false)) ||
2944 DC->isDependentContext() ||
2945 RequireCompleteDeclContext(SS, DC))
2946 return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
2948 bool MemberOfUnknownSpecialization;
2950 LookupTemplateName(R, (
Scope*)
nullptr, SS,
QualType(),
false,
2951 MemberOfUnknownSpecialization);
2957 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_non_template)
2963 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_class_template)
2966 Diag(Temp->getLocation(), diag::note_referenced_class_template);
2970 return BuildTemplateIdExpr(SS, TemplateKWLoc, R,
false, TemplateArgs);
2985 bool EnteringContext,
2989 getLangOpts().CPlusPlus11 ?
2990 diag::warn_cxx98_compat_template_outside_of_template :
2991 diag::ext_template_outside_of_template)
2996 LookupCtx = computeDeclContext(SS, EnteringContext);
2997 if (!LookupCtx && ObjectType)
2998 LookupCtx = computeDeclContext(ObjectType.
get());
3016 bool MemberOfUnknownSpecialization;
3018 ObjectType, EnteringContext, Result,
3019 MemberOfUnknownSpecialization);
3021 isa<CXXRecordDecl>(LookupCtx) &&
3022 (!cast<CXXRecordDecl>(LookupCtx)->hasDefinition() ||
3023 cast<CXXRecordDecl>(LookupCtx)->hasAnyDependentBases())) {
3027 diag::err_template_kw_refers_to_non_template)
3028 << GetNameFromUnqualifiedId(Name).getName()
3052 llvm_unreachable(
"literal operator id cannot have a dependent scope");
3059 diag::err_template_kw_refers_to_non_template)
3060 << GetNameFromUnqualifiedId(Name).getName()
3101 SS.
Adopt(ArgExpr->getQualifierLoc());
3102 NameInfo = ArgExpr->getNameInfo();
3104 dyn_cast<DependentScopeDeclRefExpr>(Arg.
getAsExpr())) {
3105 SS.
Adopt(ArgExpr->getQualifierLoc());
3106 NameInfo = ArgExpr->getNameInfo();
3108 dyn_cast<CXXDependentScopeMemberExpr>(Arg.
getAsExpr())) {
3109 if (ArgExpr->isImplicitAccess()) {
3110 SS.
Adopt(ArgExpr->getQualifierLoc());
3111 NameInfo = ArgExpr->getMemberNameInfo();
3117 LookupParsedName(Result, CurScope, &SS);
3124 Diag(Loc, getLangOpts().MSVCCompat
3125 ? diag::ext_ms_template_type_arg_missing_typename
3126 : diag::err_template_arg_must_be_type_suggest)
3155 Diag(SR.
getBegin(), diag::err_template_arg_must_be_type) << SR;
3162 if (CheckTemplateArgument(Param, TSI))
3171 if (getLangOpts().ObjCAutoRefCount &&
3210 SmallVectorImpl<TemplateArgument> &Converted) {
3217 Template, Converted,
3223 Converted.data(), Converted.size());
3228 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
3229 TemplateArgLists.addOuterTemplateArguments(
None);
3233 SemaRef.
SubstType(ArgType, TemplateArgLists,
3268 SmallVectorImpl<TemplateArgument> &Converted) {
3270 Template, Converted,
3276 Converted.data(), Converted.size());
3281 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
3282 TemplateArgLists.addOuterTemplateArguments(
None);
3320 SmallVectorImpl<TemplateArgument> &Converted,
3328 Converted.data(), Converted.size());
3333 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
3334 TemplateArgLists.addOuterTemplateArguments(
None);
3363 bool &HasDefaultArg) {
3364 HasDefaultArg =
false;
3370 HasDefaultArg =
true;
3383 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
3387 HasDefaultArg =
true;
3401 = cast<TemplateTemplateParmDecl>(Param);
3405 HasDefaultArg =
true;
3452 unsigned ArgumentPackIndex,
3457 return CheckTemplateTypeArgument(TTP, Arg, Converted);
3464 QualType NTTPType = NTTP->getType();
3465 if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack())
3466 NTTPType = NTTP->getExpansionType(ArgumentPackIndex);
3469 !isa<TemplateTemplateParmDecl>(Template) &&
3479 Converted.data(), Converted.size());
3480 NTTPType = SubstType(NTTPType,
3482 NTTP->getLocation(),
3483 NTTP->getDeclName());
3486 if (!NTTPType.isNull())
3487 NTTPType = CheckNonTypeTemplateParameterType(NTTPType,
3488 NTTP->getLocation());
3489 if (NTTPType.isNull())
3495 llvm_unreachable(
"Should never see a NULL template argument here");
3512 Converted.push_back(Result);
3546 Context, SS.getWithLocInContext(
Context), TemplateKWLoc, NameInfo,
3558 E = CheckTemplateArgument(NTTP, NTTPType, E.
get(), Result);
3562 Converted.push_back(Result);
3589 Diag(SR.
getBegin(), diag::err_template_arg_nontype_ambig) << SR << T;
3591 Diag(SR.
getBegin(), diag::err_template_arg_must_be_expr) << SR;
3597 llvm_unreachable(
"Caller must expand template argument packs");
3614 TempParm, Converted,
3620 Converted.data(), Converted.size());
3621 TempParm = cast_or_null<TemplateTemplateParmDecl>(
3622 SubstDecl(TempParm, CurContext,
3630 llvm_unreachable(
"Should never see a NULL template argument here");
3634 if (CheckTemplateArgument(TempParm, Arg, ArgumentPackIndex))
3645 << getLangOpts().CPlusPlus11;
3649 llvm_unreachable(
"Declaration argument with template template parameter");
3651 llvm_unreachable(
"Integral argument with template template parameter");
3653 llvm_unreachable(
"Null pointer argument with template template parameter");
3656 llvm_unreachable(
"Caller must expand template argument packs");
3667 unsigned NumParams = Params->
size();
3671 if (NumArgs > NumParams)
3672 Range =
SourceRange(TemplateArgs[NumParams].getLocation(),
3674 S.
Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
3675 << (NumArgs > NumParams)
3676 << (isa<ClassTemplateDecl>(Template)? 0 :
3677 isa<FunctionTemplateDecl>(Template)? 1 :
3678 isa<TemplateTemplateParmDecl>(Template)? 2 : 3)
3679 << Template << Range;
3698 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
3699 if (NTTP->isExpandedParameterPack())
3700 return NTTP->getNumExpansionTypes();
3704 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
3705 if (TTP->isExpandedParameterPack())
3706 return TTP->getNumExpansionTemplateParameters();
3713 template<
typename TemplateParmDecl>
3716 const TemplateParmDecl *D,
3721 ->getTemplateParameters()
3722 ->getParam(D->getIndex()));
3729 D->getDefaultArgumentLoc(), Modules,
3746 bool PartialTemplateArgs,
3762 bool isTemplateTemplateParameter = isa<TemplateTemplateParmDecl>(Template);
3767 ParamEnd = Params->
end();
3768 Param != ParamEnd; ) {
3772 if (*Expansions == ArgumentPack.size()) {
3775 Converted.push_back(
3777 ArgumentPack.clear();
3782 }
else if (ArgIdx ==
NumArgs && !PartialTemplateArgs) {
3784 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
3786 << (isa<ClassTemplateDecl>(Template)? 0 :
3787 isa<FunctionTemplateDecl>(Template)? 1 :
3788 isa<TemplateTemplateParmDecl>(Template)? 2 : 3)
3798 if (CheckTemplateArgument(*Param, NewArgs[ArgIdx], Template,
3799 TemplateLoc, RAngleLoc,
3800 ArgumentPack.size(), Converted))
3803 bool PackExpansionIntoNonPack =
3804 NewArgs[ArgIdx].getArgument().isPackExpansion() &&
3806 if (PackExpansionIntoNonPack && isa<TypeAliasTemplateDecl>(Template)) {
3810 Diag(NewArgs[ArgIdx].getLocation(),
3811 diag::err_alias_template_expansion_into_fixed_list)
3812 << NewArgs[ArgIdx].getSourceRange();
3813 Diag((*Param)->getLocation(), diag::note_template_param_here);
3820 if ((*Param)->isTemplateParameterPack()) {
3825 ArgumentPack.push_back(Converted.pop_back_val());
3834 if (PackExpansionIntoNonPack) {
3835 if (!ArgumentPack.empty()) {
3838 Converted.insert(Converted.end(),
3839 ArgumentPack.begin(), ArgumentPack.end());
3840 ArgumentPack.clear();
3844 Converted.push_back(NewArgs[ArgIdx].getArgument());
3855 if (PartialTemplateArgs) {
3856 if ((*Param)->isTemplateParameterPack() && !ArgumentPack.empty())
3857 Converted.push_back(
3865 if ((*Param)->isTemplateParameterPack()) {
3867 "Should have dealt with this already");
3872 if (Param + 1 != ParamEnd)
3875 Converted.push_back(
3877 ArgumentPack.clear();
3908 = dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
3925 = cast<TemplateTemplateParmDecl>(*Param);
3953 if (CheckTemplateArgument(*Param, Arg, Template, TemplateLoc,
3954 RAngleLoc, 0, Converted))
3960 if (isTemplateTemplateParameter)
3972 if (ArgIdx <
NumArgs && CurrentInstantiationScope &&
3973 CurrentInstantiationScope->getPartiallySubstitutedPack()) {
3974 while (ArgIdx <
NumArgs && NewArgs[ArgIdx].getArgument().isPackExpansion())
3975 Converted.push_back(NewArgs[ArgIdx++].getArgument());
3985 TemplateArgs = std::move(NewArgs);
3991 class UnnamedLocalNoLinkageFinder
3992 :
public TypeVisitor<UnnamedLocalNoLinkageFinder, bool>
4006 #define TYPE(Class, Parent) \
4007 bool Visit##Class##Type(const Class##Type *);
4008 #define ABSTRACT_TYPE(Class, Parent) \
4009 bool Visit##Class##Type(const Class##Type *) { return false; }
4010 #define NON_CANONICAL_TYPE(Class, Parent) \
4011 bool Visit##Class##Type(const Class##Type *) { return false; }
4012 #include "clang/AST/TypeNodes.def"
4014 bool VisitTagDecl(
const TagDecl *Tag);
4019 bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(
const BuiltinType*) {
4023 bool UnnamedLocalNoLinkageFinder::VisitComplexType(
const ComplexType* T) {
4027 bool UnnamedLocalNoLinkageFinder::VisitPointerType(
const PointerType* T) {
4031 bool UnnamedLocalNoLinkageFinder::VisitBlockPointerType(
4036 bool UnnamedLocalNoLinkageFinder::VisitLValueReferenceType(
4041 bool UnnamedLocalNoLinkageFinder::VisitRValueReferenceType(
4046 bool UnnamedLocalNoLinkageFinder::VisitMemberPointerType(
4051 bool UnnamedLocalNoLinkageFinder::VisitConstantArrayType(
4056 bool UnnamedLocalNoLinkageFinder::VisitIncompleteArrayType(
4061 bool UnnamedLocalNoLinkageFinder::VisitVariableArrayType(
4066 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedArrayType(
4071 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedExtVectorType(
4076 bool UnnamedLocalNoLinkageFinder::VisitVectorType(
const VectorType* T) {
4080 bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(
const ExtVectorType* T) {
4084 bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
4094 bool UnnamedLocalNoLinkageFinder::VisitFunctionNoProtoType(
4099 bool UnnamedLocalNoLinkageFinder::VisitUnresolvedUsingType(
4104 bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(
const TypeOfExprType*) {
4108 bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(
const TypeOfType* T) {
4112 bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(
const DecltypeType*) {
4116 bool UnnamedLocalNoLinkageFinder::VisitUnaryTransformType(
4121 bool UnnamedLocalNoLinkageFinder::VisitAutoType(
const AutoType *T) {
4125 bool UnnamedLocalNoLinkageFinder::VisitRecordType(
const RecordType* T) {
4126 return VisitTagDecl(T->
getDecl());
4129 bool UnnamedLocalNoLinkageFinder::VisitEnumType(
const EnumType* T) {
4130 return VisitTagDecl(T->
getDecl());
4133 bool UnnamedLocalNoLinkageFinder::VisitTemplateTypeParmType(
4138 bool UnnamedLocalNoLinkageFinder::VisitSubstTemplateTypeParmPackType(
4143 bool UnnamedLocalNoLinkageFinder::VisitTemplateSpecializationType(
4148 bool UnnamedLocalNoLinkageFinder::VisitInjectedClassNameType(
4150 return VisitTagDecl(T->
getDecl());
4153 bool UnnamedLocalNoLinkageFinder::VisitDependentNameType(
4158 bool UnnamedLocalNoLinkageFinder::VisitDependentTemplateSpecializationType(
4160 return VisitNestedNameSpecifier(T->getQualifier());
4163 bool UnnamedLocalNoLinkageFinder::VisitPackExpansionType(
4168 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectType(
const ObjCObjectType *) {
4172 bool UnnamedLocalNoLinkageFinder::VisitObjCInterfaceType(
4177 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectPointerType(
4182 bool UnnamedLocalNoLinkageFinder::VisitAtomicType(
const AtomicType* T) {
4186 bool UnnamedLocalNoLinkageFinder::VisitPipeType(
const PipeType* T) {
4190 bool UnnamedLocalNoLinkageFinder::VisitTagDecl(
const TagDecl *Tag) {
4192 S.
Diag(SR.getBegin(),
4194 diag::warn_cxx98_compat_template_arg_local_type :
4195 diag::ext_template_arg_local_type)
4201 S.
Diag(SR.getBegin(),
4203 diag::warn_cxx98_compat_template_arg_unnamed_type :
4204 diag::ext_template_arg_unnamed_type) << SR;
4212 bool UnnamedLocalNoLinkageFinder::VisitNestedNameSpecifier(
4229 llvm_unreachable(
"Invalid NestedNameSpecifier::Kind!");
4240 assert(ArgInfo &&
"invalid TypeSourceInfo");
4245 return Diag(SR.
getBegin(), diag::err_variably_modified_template_arg) << Arg;
4247 return Diag(SR.
getBegin(), diag::err_template_arg_overload_type) << SR;
4258 if (LangOpts.CPlusPlus11)
4260 !Diags.isIgnored(diag::warn_cxx98_compat_template_arg_unnamed_type,
4262 !Diags.isIgnored(diag::warn_cxx98_compat_template_arg_local_type,
4268 UnnamedLocalNoLinkageFinder
Finder(*
this, SR);
4291 "Incomplete parameter type in isNullPointerValueTemplateArgument!");
4304 EvalResult.
Diag = &Notes;
4312 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
4313 diag::note_invalid_subexpr_in_const_expr) {
4314 DiagLoc = Notes[0].first;
4318 S.
Diag(DiagLoc, diag::err_template_arg_not_address_constant)
4319 << Arg->
getType() << Arg->getSourceRange();
4320 for (
unsigned I = 0, N = Notes.size();
I != N; ++
I)
4321 S.
Diag(Notes[
I].first, Notes[I].second);
4339 bool ObjCLifetimeConversion;
4342 ObjCLifetimeConversion))
4347 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
4348 << Arg->
getType() << ParamType << Arg->getSourceRange();
4356 std::string Code =
"static_cast<" + ParamType.
getAsString() +
">(";
4357 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_untyped_null_constant)
4376 bool ObjCLifetimeConversion;
4380 ObjCLifetimeConversion)) {
4385 if (!ParamRef->getPointeeType()->isFunctionType()) {
4395 unsigned ParamQuals = ParamRef->getPointeeType().getCVRQualifiers();
4398 if ((ParamQuals | ArgQuals) != ParamQuals) {
4399 S.
Diag(Arg->getLocStart(),
4400 diag::err_template_arg_ref_bind_ignores_quals)
4401 << ParamType << Arg->
getType() << Arg->getSourceRange();
4415 S.
Diag(Arg->getLocStart(), diag::err_template_arg_no_ref_bind)
4416 << ParamType << ArgIn->
getType() << Arg->getSourceRange();
4418 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_convertible)
4419 << ArgIn->
getType() << ParamType << Arg->getSourceRange();
4436 bool Invalid =
false;
4440 bool AddressTaken =
false;
4447 bool ExtWarnMSTemplateArg =
false;
4450 while (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(Arg)) {
4453 ExtWarnMSTemplateArg =
true;
4457 FirstOpKind = UnOpKind;
4458 FirstOpLoc = UnOp->getOperatorLoc();
4464 if (ExtWarnMSTemplateArg)
4465 S.
Diag(ArgIn->getLocStart(), diag::ext_ms_deref_template_argument)
4466 << ArgIn->getSourceRange();
4469 AddressTaken =
true;
4474 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)
4475 << Arg->getSourceRange();
4496 bool ExtraParens =
false;
4497 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
4498 if (!Invalid && !ExtraParens) {
4499 S.
Diag(Arg->getLocStart(),
4501 ? diag::warn_cxx98_compat_template_arg_extra_parens
4502 : diag::ext_template_arg_extra_parens)
4503 << Arg->getSourceRange();
4507 Arg = Parens->getSubExpr();
4511 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
4516 Arg = UnOp->getSubExpr();
4517 AddressTaken =
true;
4518 AddrOpLoc = UnOp->getOperatorLoc();
4523 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
4535 if (Entity && Entity->hasAttr<DLLImportAttr>())
4541 S.
Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
4561 if (isa<CXXUuidofExpr>(Arg)) {
4563 ArgIn, Arg, ArgType))
4571 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)
4572 << Arg->getSourceRange();
4578 if (isa<FieldDecl>(Entity) || isa<IndirectFieldDecl>(Entity)) {
4579 S.
Diag(Arg->getLocStart(), diag::err_template_arg_field)
4580 << Entity << Arg->getSourceRange();
4586 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Entity)) {
4587 if (!Method->isStatic()) {
4588 S.
Diag(Arg->getLocStart(), diag::err_template_arg_method)
4589 << Method << Arg->getSourceRange();
4599 if (!Func && !Var) {
4601 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_object_or_func)
4602 << Arg->getSourceRange();
4610 diag::warn_cxx98_compat_template_arg_object_internal :
4611 diag::ext_template_arg_object_internal)
4612 << !Func << Entity << Arg->getSourceRange();
4613 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
4615 }
else if (!Entity->hasLinkage()) {
4616 S.
Diag(Arg->getLocStart(), diag::err_template_arg_object_no_linkage)
4617 << !Func << Entity << Arg->getSourceRange();
4618 S.
Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
4633 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
4639 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
4648 if (Var->getType()->isReferenceType()) {
4649 S.
Diag(Arg->getLocStart(),
4650 diag::err_template_arg_reference_var)
4651 << Var->getType() << Arg->getSourceRange();
4657 if (Var->getTLSKind()) {
4658 S.
Diag(Arg->getLocStart(), diag::err_template_arg_thread_local)
4659 << Arg->getSourceRange();
4660 S.
Diag(Var->getLocation(), diag::note_template_arg_refers_here);
4673 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
4679 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
4684 ArgType = Var->getType();
4687 if (Var->getType()->isArrayType()) {
4696 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_address_of)
4702 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_address_of)
4729 bool Invalid =
false;
4732 Expr *Arg = ResultArg;
4737 S.
Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
4745 bool ObjCLifetimeConversion;
4748 false, ObjCLifetimeConversion)) {
4755 S.
Diag(Arg->getLocStart(), diag::err_template_arg_not_convertible)
4756 << Arg->
getType() << ParamType << Arg->getSourceRange();
4763 Arg = Cast->getSubExpr();
4775 bool ExtraParens =
false;
4776 while (
ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
4777 if (!Invalid && !ExtraParens) {
4778 S.
Diag(Arg->getLocStart(),
4780 diag::warn_cxx98_compat_template_arg_extra_parens :
4781 diag::ext_template_arg_extra_parens)
4782 << Arg->getSourceRange();
4786 Arg = Parens->getSubExpr();
4790 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
4802 else if ((DRE = dyn_cast<DeclRefExpr>(Arg))) {
4804 if (VD->getType()->isMemberPointerType()) {
4805 if (isa<NonTypeTemplateParmDecl>(VD)) {
4809 VD = cast<ValueDecl>(VD->getCanonicalDecl());
4821 return S.
Diag(Arg->getLocStart(),
4822 diag::err_template_arg_not_pointer_to_member_form)
4823 << Arg->getSourceRange();
4825 if (isa<FieldDecl>(DRE->
getDecl()) ||
4826 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
4827 isa<CXXMethodDecl>(DRE->
getDecl())) {
4828 assert((isa<FieldDecl>(DRE->
getDecl()) ||
4829 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
4830 !cast<CXXMethodDecl>(DRE->
getDecl())->isStatic()) &&
4831 "Only non-static member pointers can make it here");
4845 S.
Diag(Arg->getLocStart(),
4846 diag::err_template_arg_not_pointer_to_member_form)
4847 << Arg->getSourceRange();
4875 "non-type template parameter type cannot be qualified");
4877 if (CTAK == CTAK_Deduced &&
4887 Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
4907 Arg, ParamType, Value, CCEK_TemplateArg);
4928 Diag(Arg->getLocStart(),
4929 diag::err_template_arg_member_ptr_base_derived_not_supported)
4931 << Arg->getSourceRange();
4937 : TemplateArgument(CanonParamType,
true);
4950 if (isa<CXXUuidofExpr>(E)) {
4954 Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)
4955 << Arg->getSourceRange();
4962 VD && VD->getType()->isArrayType() &&
4970 Diag(StartLoc, diag::err_non_type_template_arg_subobject)
4975 "null reference should not be a constant expression");
4977 "non-null value of type nullptr_t?");
4979 : TemplateArgument(CanonParamType,
true);
4983 return Diag(StartLoc, diag::err_non_type_template_arg_addr_label_diff);
4991 llvm_unreachable(
"invalid kind for template argument");
4994 return ArgResult.
get();
5014 if (getLangOpts().CPlusPlus11) {
5042 IntegerType = Enum->getDecl()->getIntegerType();
5050 ExprResult ArgResult = DefaultLvalueConversion(Arg);
5053 Arg = ArgResult.
get();
5067 Diag(Arg->getLocStart(),
5068 diag::err_template_arg_not_integral_or_enumeral)
5069 << ArgType << Arg->getSourceRange();
5077 TmplArgICEDiagnoser(
QualType T) : T(T) { }
5081 S.
Diag(Loc, diag::err_template_arg_not_ice) << T << SR;
5083 } Diagnoser(ArgType);
5085 Arg = VerifyIntegerConstantExpression(Arg, &Value, Diagnoser,
5101 }
else if (IsIntegralPromotion(Arg, ArgType, ParamType) ||
5107 Diag(Arg->getLocStart(),
5108 diag::err_template_arg_not_convertible)
5109 << Arg->
getType() << ParamType << Arg->getSourceRange();
5132 if (Value.getBitWidth() != AllowedBits)
5133 Value = Value.extOrTrunc(AllowedBits);
5136 llvm::APSInt OldValue =
Value;
5141 if (Value.getBitWidth() != AllowedBits)
5142 Value = Value.extOrTrunc(AllowedBits);
5147 && (OldValue.isSigned() && OldValue.isNegative())) {
5148 Diag(Arg->getLocStart(), diag::warn_template_arg_negative)
5149 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
5150 << Arg->getSourceRange();
5155 unsigned RequiredBits;
5157 RequiredBits = OldValue.getActiveBits();
5158 else if (OldValue.isUnsigned())
5159 RequiredBits = OldValue.getActiveBits() + 1;
5161 RequiredBits = OldValue.getMinSignedBits();
5162 if (RequiredBits > AllowedBits) {
5163 Diag(Arg->getLocStart(),
5164 diag::warn_template_arg_too_large)
5165 << OldValue.toString(10) << Value.toString(10) << Param->
getType()
5166 << Arg->getSourceRange();
5206 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg, ParamType,
5209 if (DiagnoseUseOfDecl(Fn, Arg->getLocStart()))
5212 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
5238 "Only object pointers allowed here");
5254 assert(ParamRefType->getPointeeType()->isIncompleteOrObjectType() &&
5255 "Only object references allowed here");
5258 if (
FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg,
5259 ParamRefType->getPointeeType(),
5262 if (DiagnoseUseOfDecl(Fn, Arg->getLocStart()))
5265 Arg = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
5288 << Arg->
getType() << ParamType;
5296 Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
5320 unsigned ArgumentPackIndex) {
5325 assert(Name.
isDependent() &&
"Non-dependent template isn't a declaration?");
5341 if (!isa<ClassTemplateDecl>(Template) &&
5342 !isa<TemplateTemplateParmDecl>(Template) &&
5343 !isa<TypeAliasTemplateDecl>(Template)) {
5344 assert(isa<FunctionTemplateDecl>(Template) &&
5345 "Only function templates are possible here");
5347 Diag(Template->
getLocation(), diag::note_template_arg_refers_here_func)
5358 TPL_TemplateTemplateArgumentMatch,
5383 return ImpCastExprToType(
5391 "Only declaration template arguments permitted here");
5395 if (VD->getDeclContext()->isRecord() &&
5396 (isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD) ||
5397 isa<IndirectFieldDecl>(VD))) {
5416 if (isa<CXXMethodDecl>(VD) && cast<CXXMethodDecl>(VD)->isInstance())
5420 VD->getType().getNonReferenceType(),
5427 RefExpr = CreateBuiltinUnaryOp(Loc,
UO_AddrOf, RefExpr.
get());
5432 bool ObjCLifetimeConversion;
5433 if (IsQualificationConversion(((
Expr*) RefExpr.
get())->getType(),
5435 ObjCLifetimeConversion))
5445 QualType T = VD->getType().getNonReferenceType();
5456 RefExpr = DefaultFunctionArrayConversion(RefExpr.
get());
5464 return CreateBuiltinUnaryOp(Loc,
UO_AddrOf, RefExpr.
get());
5476 }
else if (isa<FunctionDecl>(VD)) {
5481 return BuildDeclRefExpr(VD, T, VK, Loc);
5495 "Operation is only valid for integral template arguments");
5505 T = ET->getDecl()->getIntegerType();
5532 if (OrigT->isEnumeralType()) {
5552 unsigned NextDiag = diag::err_template_param_different_kind;
5553 if (TemplateArgLoc.
isValid()) {
5554 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
5555 NextDiag = diag::note_template_param_different_kind;
5574 unsigned NextDiag = diag::err_template_parameter_pack_non_pack;
5575 if (TemplateArgLoc.
isValid()) {
5576 S.
Diag(TemplateArgLoc,
5577 diag::err_template_arg_template_params_mismatch);
5578 NextDiag = diag::note_template_parameter_pack_non_pack;
5581 unsigned ParamKind = isa<TemplateTypeParmDecl>(New)? 0
5582 : isa<NonTypeTemplateParmDecl>(New)? 1
5595 = dyn_cast<NonTypeTemplateParmDecl>(Old)) {
5603 (OldNTTP->getType()->isDependentType() ||
5609 unsigned NextDiag = diag::err_template_nontype_parm_different_type;
5610 if (TemplateArgLoc.
isValid()) {
5611 S.
Diag(TemplateArgLoc,
5612 diag::err_template_arg_template_params_mismatch);
5613 NextDiag = diag::note_template_nontype_parm_different_type;
5618 S.
Diag(OldNTTP->getLocation(),
5619 diag::note_template_nontype_parm_prev_declaration)
5620 << OldNTTP->getType();
5633 = dyn_cast<TemplateTemplateParmDecl>(Old)) {
5636 OldTTP->getTemplateParameters(),
5655 unsigned NextDiag = diag::err_template_param_list_different_arity;
5656 if (TemplateArgLoc.
isValid()) {
5657 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
5658 NextDiag = diag::note_template_param_list_different_arity;
5698 if (Old->
size() != New->
size() && Kind != TPL_TemplateTemplateArgumentMatch) {
5715 OldParmEnd = Old->
end();
5716 OldParm != OldParmEnd; ++OldParm) {
5717 if (Kind != TPL_TemplateTemplateArgumentMatch ||
5718 !(*OldParm)->isTemplateParameterPack()) {
5719 if (NewParm == NewParmEnd) {
5728 Kind, TemplateArgLoc))
5742 for (; NewParm != NewParmEnd; ++NewParm) {
5744 Kind, TemplateArgLoc))
5750 if (NewParm != NewParmEnd) {
5782 while (Ctx && isa<LinkageSpecDecl>(Ctx))
5794 if (RD->isLocalClass())
5796 diag::err_template_inside_local_class)
5804 diag::err_template_outside_namespace_or_class_scope)
5815 return Record->getTemplateSpecializationKind();
5816 if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(D))
5817 return Function->getTemplateSpecializationKind();
5818 if (
VarDecl *Var = dyn_cast<VarDecl>(D))
5819 return Var->getTemplateSpecializationKind();
5852 bool IsPartialSpecialization) {
5856 if (isa<ClassTemplateDecl>(Specialized))
5857 EntityKind = IsPartialSpecialization? 1 : 0;
5858 else if (isa<VarTemplateDecl>(Specialized))
5859 EntityKind = IsPartialSpecialization ? 3 : 2;
5860 else if (isa<FunctionTemplateDecl>(Specialized))
5862 else if (isa<CXXMethodDecl>(Specialized))
5864 else if (isa<VarDecl>(Specialized))
5866 else if (isa<RecordDecl>(Specialized))
5868 else if (isa<EnumDecl>(Specialized) && S.
getLangOpts().CPlusPlus11)
5871 S.
Diag(Loc, diag::err_template_spec_unknown_kind)
5891 S.
Diag(Loc, diag::err_template_spec_decl_function_scope)
5902 S.
Diag(Loc, diag::ext_function_specialization_in_class)
5905 S.
Diag(Loc, diag::err_template_spec_decl_class_scope)
5915 S.
Diag(Loc, diag::err_template_spec_decl_class_scope)
5935 if (!DC->
Encloses(SpecializedContext) &&
5936 !(isa<FunctionTemplateDecl>(Specialized) ||
5937 isa<FunctionDecl>(Specialized) ||
5938 isa<VarTemplateDecl>(Specialized) ||
5939 isa<VarDecl>(Specialized))) {
5940 if (isa<TranslationUnitDecl>(SpecializedContext))
5941 S.
Diag(Loc, diag::err_template_spec_redecl_global_scope)
5942 << EntityKind << Specialized;
5943 else if (isa<NamespaceDecl>(SpecializedContext)) {
5944 int Diag = diag::err_template_spec_redecl_out_of_scope;
5946 Diag = diag::ext_ms_template_spec_redecl_out_of_scope;
5947 S.
Diag(Loc, Diag) << EntityKind << Specialized
5948 << cast<NamedDecl>(SpecializedContext);
5950 llvm_unreachable(
"unexpected namespace context for specialization");
5952 S.
Diag(Specialized->getLocation(), diag::note_specialized_entity);
5953 }
else if ((!PrevDecl ||
5972 bool IsCPlusPlus11Extension = DC->
Encloses(SpecializedContext);
5973 if (isa<TranslationUnitDecl>(SpecializedContext)) {
5974 assert(!IsCPlusPlus11Extension &&
5975 "DC encloses TU but isn't in enclosing namespace set");
5976 S.
Diag(Loc, diag::err_template_spec_decl_out_of_scope_global)
5977 << EntityKind << Specialized;
5978 }
else if (isa<NamespaceDecl>(SpecializedContext)) {
5980 if (!IsCPlusPlus11Extension)
5981 Diag = diag::err_template_spec_decl_out_of_scope;
5983 Diag = diag::ext_template_spec_decl_out_of_scope;
5985 Diag = diag::warn_cxx98_compat_template_spec_decl_out_of_scope;
5987 << EntityKind << Specialized << cast<NamedDecl>(SpecializedContext);
6000 DependencyChecker Checker(Depth);
6001 Checker.TraverseStmt(E);
6002 if (Checker.Match && Checker.MatchLoc.isInvalid())
6003 return E->getSourceRange();
6004 return Checker.MatchLoc;
6010 DependencyChecker Checker(Depth);
6011 Checker.TraverseTypeLoc(TL);
6012 if (Checker.Match && Checker.MatchLoc.isInvalid())
6014 return Checker.MatchLoc;
6025 S, TemplateNameLoc, Param, Args[
I].pack_begin(),
6026 Args[
I].pack_size(), IsDefaultArgument))
6039 ArgExpr = Expansion->getPattern();
6043 ArgExpr = ICE->getSubExpr();
6053 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ArgExpr))
6054 if (isa<NonTypeTemplateParmDecl>(DRE->getDecl()))
6066 if (ParamUseRange.
isValid()) {
6067 if (IsDefaultArgument) {
6068 S.
Diag(TemplateNameLoc,
6069 diag::err_dependent_non_type_arg_in_partial_spec);
6071 diag::note_dependent_non_type_default_arg_in_partial_spec)
6075 diag::err_dependent_non_type_arg_in_partial_spec)
6095 if (ParamUseRange.
isValid()) {
6096 S.
Diag(IsDefaultArgument ? TemplateNameLoc : ArgExpr->getLocStart(),
6097 diag::err_dependent_typed_non_type_arg_in_partial_spec)
6098 << Param->
getType() << ParamUseRange;
6100 << (IsDefaultArgument ? ParamUseRange :
SourceRange());
6122 SmallVectorImpl<TemplateArgument> &TemplateArgs) {
6125 for (
unsigned I = 0, N = TemplateParams->
size();
I != N; ++
I) {
6132 S, TemplateNameLoc, Param, &ArgList[
I], 1, I >= NumExplicit))
6147 TemplateParameterLists,
6149 assert(TUK != TUK_Reference &&
"References are not specializations");
6156 ? TemplateParameterLists[0]->getTemplateLoc() : KWLoc;
6166 if (!ClassTemplate) {
6167 Diag(TemplateNameLoc, diag::err_not_class_template_specialization)
6173 bool isExplicitSpecialization =
false;
6174 bool isPartialSpecialization =
false;
6180 bool Invalid =
false;
6182 MatchTemplateParametersToScopeSpecifier(
6183 KWLoc, TemplateNameLoc, SS, &TemplateId,
6184 TemplateParameterLists, TUK == TUK_Friend, isExplicitSpecialization,
6189 if (TemplateParams && TemplateParams->
size() > 0) {
6190 isPartialSpecialization =
true;
6192 if (TUK == TUK_Friend) {
6193 Diag(KWLoc, diag::err_partial_specialization_friend)
6201 for (
unsigned I = 0, N = TemplateParams->
size();
I != N; ++
I) {
6204 if (TTP->hasDefaultArgument()) {
6205 Diag(TTP->getDefaultArgumentLoc(),
6206 diag::err_default_arg_in_partial_spec);
6207 TTP->removeDefaultArgument();
6210 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
6211 if (
Expr *DefArg = NTTP->getDefaultArgument()) {
6212 Diag(NTTP->getDefaultArgumentLoc(),
6213 diag::err_default_arg_in_partial_spec)
6214 << DefArg->getSourceRange();
6215 NTTP->removeDefaultArgument();
6221 diag::err_default_arg_in_partial_spec)
6227 }
else if (TemplateParams) {
6228 if (TUK == TUK_Friend)
6229 Diag(KWLoc, diag::err_template_spec_friend)
6235 isExplicitSpecialization =
true;
6237 assert(TUK == TUK_Friend &&
"should have a 'template<>' for this decl");
6243 assert(Kind !=
TTK_Enum &&
"Invalid enum tag in class template spec!");
6245 Kind, TUK == TUK_Definition, KWLoc,
6247 Diag(KWLoc, diag::err_use_with_wrong_tag)
6252 diag::note_previous_use);
6261 for (
unsigned I = 0, N = TemplateArgs.
size();
I != N; ++
I)
6262 if (DiagnoseUnexpandedParameterPack(TemplateArgs[
I],
6263 UPPC_PartialSpecialization))
6269 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
6270 TemplateArgs,
false, Converted))
6275 if (isPartialSpecialization) {
6278 TemplateArgs.
size(), Converted))
6281 bool InstantiationDependent;
6285 TemplateArgs.
size(),
6286 InstantiationDependent)) {
6287 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
6289 isPartialSpecialization =
false;
6293 void *InsertPos =
nullptr;
6296 if (isPartialSpecialization)
6306 if (TUK != TUK_Friend &&
6309 isPartialSpecialization))
6314 if (isPartialSpecialization) {
6328 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
6329 << 0 << (TUK == TUK_Definition)
6331 return CheckClassTemplate(S, TagSpec, TUK, KWLoc, SS,
6338 TemplateParameterLists.size() - 1,
6339 TemplateParameterLists.data());
6344 = cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl);
6348 KWLoc, TemplateNameLoc,
6357 if (TemplateParameterLists.size() > 1 && SS.
isSet()) {
6358 Partial->setTemplateParameterListsInfo(
6359 Context, TemplateParameterLists.drop_back(1));
6363 ClassTemplate->AddPartialSpecialization(Partial, InsertPos);
6364 Specialization = Partial;
6375 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
6377 TemplateParams->getDepth(),
6380 if (!DeducibleParams.all()) {
6381 unsigned NumNonDeducible = DeducibleParams.size()-DeducibleParams.count();
6382 Diag(TemplateNameLoc, diag::warn_partial_specs_not_deducible)
6383 << 0 << (NumNonDeducible > 1)
6385 for (
unsigned I = 0, N = DeducibleParams.size(); I != N; ++
I) {
6386 if (!DeducibleParams[I]) {
6387 NamedDecl *Param = cast<NamedDecl>(TemplateParams->getParam(I));
6390 diag::note_partial_spec_unused_parameter)
6394 diag::note_partial_spec_unused_parameter)
6405 KWLoc, TemplateNameLoc,
6411 if (TemplateParameterLists.size() > 0) {
6413 TemplateParameterLists);
6417 ClassTemplate->AddSpecialization(Specialization, InsertPos);
6419 if (CurContext->isDependentContext()) {
6422 assert(getLangOpts().MicrosoftExt &&
6423 "Only possible with -fms-extensions!");
6426 CanonTemplate, Converted.data(), Converted.size());
6450 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
6454 diag::note_instantiation_required_here)
6462 if (TUK != TUK_Friend)
6466 if (TUK == TUK_Definition) {
6469 if (Def && SkipBody && !hasVisibleDefinition(Def, &Hidden)) {
6471 makeMergedDefinitionVisible(Hidden, KWLoc);
6473 TUK = TUK_Declaration;
6476 Diag(TemplateNameLoc, diag::err_redefinition)
6485 ProcessDeclAttributeList(S, Specialization, Attr);
6489 if (TUK == TUK_Definition) {
6490 AddAlignmentAttributesForRecord(Specialization);
6491 AddMsStructLayoutForRecord(Specialization);
6494 if (ModulePrivateLoc.
isValid())
6495 Diag(Specialization->
getLocation(), diag::err_module_private_specialization)
6496 << (isPartialSpecialization? 1 : 0)
6508 TemplateArgs, CanonType);
6509 if (TUK != TUK_Friend) {
6525 if (TUK == TUK_Definition)
6528 if (TUK == TUK_Friend) {
6534 CurContext->addDecl(Friend);
6539 CurContext->addDecl(Specialization);
6541 return Specialization;
6547 Decl *NewDecl = HandleDeclarator(S, D, TemplateParameterLists);
6548 ActOnDocumentableDecl(NewDecl);
6559 FD->setInlineSpecified(
false);
6570 for (
Decl *Prev = D; Prev && !PrevDiagLoc.
isValid();
6571 Prev = Prev->getPreviousDecl()) {
6572 PrevDiagLoc = Prev->getLocation();
6574 assert(PrevDiagLoc.
isValid() &&
6575 "Explicit instantiation without point of instantiation?");
6607 bool &HasNoEffect) {
6608 HasNoEffect =
false;
6615 "previous declaration must be implicit!");
6628 if (PrevPointOfInstantiation.
isInvalid()) {
6639 PrevPointOfInstantiation.
isValid()) &&
6640 "Explicit instantiation without point of instantiation?");
6654 Diag(NewLoc, diag::err_specialization_after_instantiation)
6656 Diag(PrevPointOfInstantiation, diag::note_instantiation_required_here)
6690 diag::err_explicit_instantiation_declaration_after_definition);
6696 diag::note_explicit_instantiation_definition_here);
6720 diag::warn_cxx98_compat_explicit_instantiation_after_specialization :
6721 diag::ext_explicit_instantiation_after_specialization)
6724 diag::note_previous_template_specialization);
6754 Diag(NewLoc, (getLangOpts().MSVCCompat)
6755 ? diag::ext_explicit_instantiation_duplicate
6756 : diag::err_explicit_instantiation_duplicate)
6759 diag::note_previous_explicit_instantiation);
6765 llvm_unreachable(
"Missing specialization/instantiation case?");
6793 if (!isa<FunctionTemplateDecl>(D) ||
6801 if (Previous.
empty())
return true;
6804 ExplicitTemplateArgs);
6835 llvm::SmallDenseMap<FunctionDecl *, TemplateArgumentListInfo, 8>
6836 ConvertedTemplateArgs;
6858 if (OldMD && OldMD->
isConst()) {
6868 if (ExplicitTemplateArgs)
6869 Args = *ExplicitTemplateArgs;
6881 cast<FunctionTemplateDecl>(FunTmpl->getFirstDecl()),
6882 ExplicitTemplateArgs ? &Args :
nullptr, FT, Specialization, Info)) {
6885 FailedCandidates.addCandidate()
6886 .set(FunTmpl->getTemplatedDecl(),
6893 if (ExplicitTemplateArgs)
6894 ConvertedTemplateArgs[Specialization] = std::move(Args);
6895 Candidates.
addDecl(Specialization,
I.getAccess());
6901 Candidates.
begin(), Candidates.
end(), FailedCandidates,
6903 PDiag(diag::err_function_template_spec_no_match) << FD->
getDeclName(),
6904 PDiag(diag::err_function_template_spec_ambiguous)
6905 << FD->
getDeclName() << (ExplicitTemplateArgs !=
nullptr),
6906 PDiag(diag::note_function_template_spec_matched));
6908 if (Result == Candidates.
end())
6912 FunctionDecl *Specialization = cast<FunctionDecl>(*Result);
6916 assert(SpecInfo &&
"Function template specialization info missing?");
6950 bool HasNoEffect =
false;
6952 CheckSpecializationInstantiationRedecl(FD->
getLocation(),
6964 MarkUnusedFileScopedDecl(Specialization);
6973 FD->setFunctionTemplateSpecialization(
6974 Specialization->getPrimaryTemplate(), TemplArgs,
nullptr,
6976 ExplicitTemplateArgs ? &ConvertedTemplateArgs[Specialization] :
nullptr);
6981 Previous.
addDecl(Specialization);
7001 assert(!isa<TemplateDecl>(Member) &&
"Only for non-template members");
7008 if (Previous.
empty()) {
7010 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(Member)) {
7015 QualType Adjusted = Function->getType();
7016 if (!hasExplicitCallingConv(Adjusted))
7017 Adjusted = adjustCCAndNoReturn(Adjusted, Method->getType());
7019 Instantiation = Method;
7020 InstantiatedFrom = Method->getInstantiatedFromMemberFunction();
7021 MSInfo = Method->getMemberSpecializationInfo();
7026 }
else if (isa<VarDecl>(Member)) {
7031 Instantiation = PrevVar;
7035 }
else if (isa<RecordDecl>(Member)) {
7039 Instantiation = PrevRecord;
7043 }
else if (isa<EnumDecl>(Member)) {
7047 Instantiation = PrevEnum;
7053 if (!Instantiation) {
7064 if (InstantiatedFrom && isa<CXXMethodDecl>(Member)) {
7065 cast<CXXMethodDecl>(Member)->setInstantiationOfMemberFunction(
7066 cast<CXXMethodDecl>(InstantiatedFrom),
7068 }
else if (InstantiatedFrom && isa<CXXRecordDecl>(Member)) {
7069 cast<CXXRecordDecl>(Member)->setInstantiationOfMemberClass(
7070 cast<CXXRecordDecl>(InstantiatedFrom),
7075 Previous.
addDecl(Instantiation);
7080 if (!InstantiatedFrom) {
7093 assert(MSInfo &&
"Member specialization info missing?");
7095 bool HasNoEffect =
false;
7096 if (CheckSpecializationInstantiationRedecl(Member->
getLocation(),
7115 if (isa<FunctionDecl>(Member)) {
7116 FunctionDecl *InstantiationFunction = cast<FunctionDecl>(Instantiation);
7124 cast<FunctionDecl>(Member)->setInstantiationOfMemberFunction(
7125 cast<CXXMethodDecl>(InstantiatedFrom),
7127 MarkUnusedFileScopedDecl(InstantiationFunction);
7128 }
else if (isa<VarDecl>(Member)) {
7129 VarDecl *InstantiationVar = cast<VarDecl>(Instantiation);
7137 cast<VarDecl>(Member)->setInstantiationOfStaticDataMember(
7139 MarkUnusedFileScopedDecl(InstantiationVar);
7140 }
else if (isa<CXXRecordDecl>(Member)) {
7141 CXXRecordDecl *InstantiationClass = cast<CXXRecordDecl>(Instantiation);
7149 cast<CXXRecordDecl>(Member)->setInstantiationOfMemberClass(
7150 cast<CXXRecordDecl>(InstantiatedFrom),
7153 assert(isa<EnumDecl>(Member) &&
"Only member enums remain");
7154 EnumDecl *InstantiationEnum = cast<EnumDecl>(Instantiation);
7162 cast<EnumDecl>(Member)->setInstantiationOfMemberEnum(
7169 Previous.
addDecl(Instantiation);
7178 bool WasQualifiedName) {
7183 S.
Diag(InstLoc, diag::err_explicit_instantiation_in_class)
7196 if (WasQualifiedName) {
7197 if (CurContext->
Encloses(OrigContext))
7204 if (
NamespaceDecl *NS = dyn_cast<NamespaceDecl>(OrigContext)) {
7205 if (WasQualifiedName)
7208 diag::err_explicit_instantiation_out_of_scope :
7209 diag::warn_explicit_instantiation_out_of_scope_0x)
7214 diag::err_explicit_instantiation_unqualified_wrong_namespace :
7215 diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x)
7220 diag::err_explicit_instantiation_must_be_global :
7221 diag::warn_explicit_instantiation_must_be_global_0x)
7242 if (isa<TemplateSpecializationType>(T))
7269 "Invalid enum tag in class template explicit instantiation!");
7271 if (isa<TypeAliasTemplateDecl>(TD)) {
7272 Diag(KWLoc, diag::err_tag_reference_non_tag) <<
Kind;
7274 diag::note_previous_use);
7283 Diag(KWLoc, diag::err_use_with_wrong_tag)
7288 diag::note_previous_use);
7303 if (A->getKind() == AttributeList::AT_DLLExport) {
7305 diag::warn_attribute_dllexport_explicit_instantiation_decl);
7306 Diag(A->getLoc(), diag::note_attribute);
7313 diag::warn_attribute_dllexport_explicit_instantiation_decl);
7314 Diag(A->getLocation(), diag::note_attribute);
7320 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
7325 if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc,
7326 TemplateArgs,
false, Converted))
7331 void *InsertPos =
nullptr;
7349 bool HasNoEffect =
false;
7351 if (CheckSpecializationInstantiationRedecl(TemplateNameLoc, TSK,
7352 PrevDecl, PrevDecl_TSK,
7367 Specialization = PrevDecl;
7373 if (!Specialization) {
7379 KWLoc, TemplateNameLoc,
7386 if (!HasNoEffect && !PrevDecl) {
7388 ClassTemplate->AddSpecialization(Specialization, InsertPos);
7411 ProcessDeclAttributeList(S, Specialization, Attr);
7417 CurContext->addDecl(Specialization);
7423 return Specialization;
7434 = cast_or_null<ClassTemplateSpecializationDecl>(
7437 InstantiateClassTemplateSpecialization(TemplateNameLoc, Specialization, TSK);
7439 MarkVTableUsed(TemplateNameLoc, Specialization,
true);
7444 Def = cast_or_null<ClassTemplateSpecializationDecl>(
7461 auto *A = cast<InheritableAttr>(
7463 A->setInherited(
true);
7465 checkClassLevelDLLAttribute(Def);
7468 for (
auto &B : Def->
bases()) {
7469 if (
auto *BT = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
7470 B.getType()->getAsCXXRecordDecl()))
7471 propagateDLLAttrToBaseClassTemplate(Def, A, BT, B.
getLocStart());
7479 InstantiateClassTemplateSpecializationMembers(TemplateNameLoc, Def, TSK);
7486 return Specialization;
7502 bool IsDependent =
false;
7504 KWLoc, SS, Name, NameLoc, Attr,
AS_none,
7509 assert(!IsDependent &&
"explicit instantiation of dependent name not yet handled");
7514 TagDecl *Tag = cast<TagDecl>(TagD);
7515 assert(!Tag->
isEnum() &&
"shouldn't see enumerations here");
7523 Diag(TemplateLoc, diag::err_explicit_instantiation_nontemplate_type)
7536 Diag(TemplateLoc, diag::ext_explicit_instantiation_without_qualified_id)
7561 bool HasNoEffect =
false;
7562 assert(MSInfo &&
"No member specialization information?");
7563 if (CheckSpecializationInstantiationRedecl(TemplateLoc, TSK,
7580 = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
7582 Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member)
7584 Diag(Pattern->getLocation(), diag::note_forward_declaration)
7588 if (InstantiateClass(NameLoc, Record, Def,
7589 getTemplateInstantiationArgs(Record),
7593 RecordDef = cast_or_null<CXXRecordDecl>(Record->
getDefinition());
7600 InstantiateClassMembers(NameLoc, RecordDef,
7601 getTemplateInstantiationArgs(Record), TSK);
7604 MarkVTableUsed(NameLoc, RecordDef,
true);
7624 diag::err_explicit_instantiation_requires_name)
7666 getLangOpts().CPlusPlus11 ?
7667 diag::err_explicit_instantiation_inline :
7668 diag::warn_explicit_instantiation_inline_0x)
7674 diag::err_explicit_instantiation_constexpr);
7701 if (!PrevTemplate) {
7708 Diag((*P)->getLocation(), diag::note_explicit_instantiation_here);
7715 diag::err_explicit_instantiation_data_member_not_instantiated)
7731 diag::err_auto_not_allowed_var_inst);
7740 diag::err_explicit_instantiation_without_template_id)
7742 Diag(PrevTemplate->getLocation(),
7743 diag::note_explicit_instantiation_here);
7751 DeclResult Res = CheckVarTemplateId(PrevTemplate, TemplateLoc,
7753 if (Res.isInvalid())
7758 Prev = cast<VarDecl>(Res.get());
7773 diag::ext_explicit_instantiation_without_qualified_id)
7782 bool HasNoEffect =
false;
7783 if (CheckSpecializationInstantiationRedecl(D.
getIdentifierLoc(), TSK, Prev,
7784 PrevTSK, POI, HasNoEffect))
7794 ProcessDeclAttributeList(S, Prev,
Attr);
7803 diag::err_invalid_var_template_spec_type)
7804 << 0 << PrevTemplate << R << Prev->getType();
7805 Diag(PrevTemplate->getLocation(), diag::note_template_declared_here)
7806 << 2 << PrevTemplate->getDeclName();
7811 return (
Decl*)
nullptr;
7816 bool HasExplicitTemplateArgs =
false;
7820 HasExplicitTemplateArgs =
true;
7833 if (!HasExplicitTemplateArgs) {
7834 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Prev)) {
7835 QualType Adjusted = adjustCCAndNoReturn(R, Method->getType());
7839 Matches.
addDecl(Method,
P.getAccess());
7854 (HasExplicitTemplateArgs ? &TemplateArgs
7856 R, Specialization, Info)) {
7858 FailedCandidates.addCandidate()
7865 Matches.
addDecl(Specialization,
P.getAccess());
7870 Matches.
begin(), Matches.
end(), FailedCandidates,
7872 PDiag(diag::err_explicit_instantiation_not_known) <<
Name,
7873 PDiag(diag::err_explicit_instantiation_ambiguous) <<
Name,
7874 PDiag(diag::note_explicit_instantiation_candidate));
7876 if (Result == Matches.
end())
7880 FunctionDecl *Specialization = cast<FunctionDecl>(*Result);
7889 if (FPT->hasExceptionSpec()) {
7891 diag::err_mismatched_exception_spec_explicit_instantiation;
7892 if (getLangOpts().MicrosoftExt)
7893 DiagID = diag::ext_mismatched_exception_spec_explicit_instantiation;
7894 bool Result = CheckEquivalentExceptionSpec(
7895 PDiag(DiagID) << Specialization->
getType(),
7896 PDiag(diag::note_explicit_instantiation_here),
7901 if (!getLangOpts().MicrosoftExt && Result)
7907 diag::err_explicit_instantiation_member_function_not_instantiated)
7911 Diag(Specialization->
getLocation(), diag::note_explicit_instantiation_here);
7917 PrevDecl = Specialization;
7920 bool HasNoEffect =
false;
7924 PrevDecl->getPointOfInstantiation(),
7931 return (
Decl*)
nullptr;
7937 ProcessDeclAttributeList(S, Specialization, Attr);
7942 Consumer.HandleTopLevelDecl(
DeclGroupRef(Specialization));
7958 diag::ext_explicit_instantiation_without_qualified_id)
7968 return (
Decl*)
nullptr;
7976 assert(Name &&
"Expected a name in a dependent tag");
7984 if (TUK == TUK_Declaration || TUK == TUK_Definition) {
7985 Diag(NameLoc, diag::err_dependent_tag_decl)
7986 << (TUK == TUK_Definition) << Kind << SS.
getRange();
8012 getLangOpts().CPlusPlus11 ?
8013 diag::warn_cxx98_compat_typename_outside_of_template :
8014 diag::ext_typename_outside_of_template)
8019 TypenameLoc, QualifierLoc, II, IdLoc);
8024 if (isa<DependentNameType>(T)) {
8036 return CreateParsedType(T, TSI);
8051 getLangOpts().CPlusPlus11 ?
8052 diag::warn_cxx98_compat_typename_outside_of_template :
8053 diag::ext_typename_outside_of_template)
8058 translateTemplateArguments(TemplateArgsIn, TemplateArgs);
8063 assert(DTN &&
"dependent template has non-dependent name?");
8066 DTN->getQualifier(),
8067 DTN->getIdentifier(),
8080 for (
unsigned I = 0, N = TemplateArgs.
size();
I != N; ++
I)
8085 QualType T = CheckTemplateIdType(Template, TemplateNameLoc, TemplateArgs);
8097 for (
unsigned I = 0, N = TemplateArgs.
size();
I != N; ++
I)
8106 return CreateParsedType(T, TSI);
8115 if (!II.
isStr(
"type"))
8124 if (!EnableIfTSTLoc || EnableIfTSTLoc.
getNumArgs() == 0)
8127 cast<TemplateSpecializationType>(EnableIfTSTLoc.
getTypePtr());
8131 EnableIfTST->getTemplateName().getAsTemplateDecl();
8132 if (!EnableIfDecl || EnableIfTST->isIncompleteType())
8137 EnableIfDecl->getDeclName().getAsIdentifierInfo();
8138 if (!EnableIfII || !EnableIfII->
isStr(
"enable_if"))
8155 SS.
Adopt(QualifierLoc);
8173 if (RequireCompleteDeclContext(SS, Ctx))
8178 LookupQualifiedName(Result, Ctx, SS);
8179 unsigned DiagID = 0;
8180 Decl *Referenced =
nullptr;
8186 if (
isEnableIf(QualifierLoc, II, CondRange)) {
8187 Diag(CondRange.
getBegin(), diag::err_typename_nested_not_found_enable_if)
8188 << Ctx << CondRange;
8192 DiagID = diag::err_typename_nested_not_found;
8201 Diag(IILoc, diag::err_typename_refers_to_using_value_decl)
8202 << Name << Ctx << FullRange;
8206 Diag(Loc, diag::note_using_value_decl_missing_typename)
8223 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
8229 DiagID = diag::err_typename_nested_not_type;
8234 DiagID = diag::err_typename_nested_not_type;
8235 Referenced = *Result.
begin();
8246 Diag(IILoc, DiagID) << FullRange << Name << Ctx;
8255 class CurrentInstantiationRebuilder
8263 CurrentInstantiationRebuilder(
Sema &SemaRef,
8267 Loc(Loc), Entity(Entity) { }
8274 bool AlreadyTransformed(
QualType T) {
8289 this->Entity = Entity;
8331 CurrentInstantiationRebuilder Rebuilder(*
this, Loc, Name);
8332 return Rebuilder.TransformType(T);
8336 CurrentInstantiationRebuilder Rebuilder(*
this, E->
getExprLoc(),
8338 return Rebuilder.TransformExpr(E);
8349 = Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
8361 for (
unsigned I = 0, N = Params->
size();
I != N; ++
I) {
8365 if (isa<TemplateTypeParmDecl>(Param))
8370 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
8371 if (RebuildTemplateParamsInCurrentInstantiation(
8372 TTP->getTemplateParameters()))
8389 NTTP->
setType(NewTSI->getType());
8401 return getTemplateArgumentBindingsText(Params, Args.
data(), Args.
size());
8409 llvm::raw_svector_ostream Out(Str);
8411 if (!Params || Params->
size() == 0 || NumArgs == 0)
8412 return std::string();
8414 for (
unsigned I = 0, N = Params->
size();
I != N; ++
I) {
8424 Out << Id->getName();
8430 Args[
I].
print(getPrintingPolicy(), Out);
8445 LPT->
Toks.swap(Toks);
8447 LateParsedTemplateMap.insert(std::make_pair(FD, LPT));
8462 if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(CurContext)) {
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 isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a 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.
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< Decl * > Params, SourceLocation RAngleLoc)
ActOnTemplateParameterList - Builds a TemplateParameterList that contains the template parameters in ...
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.
Decl - This represents one declaration (or definition), e.g.
bool isChar16Type() const
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Defines the C++ template declaration subclasses.
void setModulePrivate(bool MP=true)
Specify whether this declaration was marked as being private to the module in which it was defined...
Represents a C++11 auto or C++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.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
SCS getStorageClassSpec() const
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
std::string getAsString() const
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
TemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs, QualType Canon, QualType Aliased)
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.
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, const TemplateArgument *Args, unsigned NumArgs, ClassTemplateSpecializationDecl *PrevDecl)
bool isMemberPointer() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
DependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, unsigned NumArgs, const TemplateArgument *Args, QualType Canon)
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
void setTemplateKeywordLoc(SourceLocation Loc)
Declaration of a variable template.
TemplateParamListContext
The context in which we are checking a template parameter list.
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
Expr * getAsExpr() const
Retrieve the template argument as an expression.
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
static void StripImplicitInstantiation(NamedDecl *D)
Strips various properties off an implicit instantiation that has just been explicitly specialized...
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList * > FriendTypeTPLists=None)
Abstract base class used for diagnosing integer constant expression violations.
TemplateName SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs)
static bool CheckTemplatePartialSpecializationArgs(Sema &S, SourceLocation NameLoc, TemplateParameterList *TemplateParams, unsigned ExplicitArgs, SmallVectorImpl< TemplateArgument > &TemplateArgs)
Check the non-type template arguments of a class template partial specialization according to C++ [te...
const TemplateArgumentLoc * getArgumentArray() const
An identifier, stored as an IdentifierInfo*.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
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...
CK_IntegralCast - A cast between integral types (other than to boolean).
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.
AccessSpecifier getAccess() const
SourceLocation getLocation() const
Retrieve the location of the template argument.
TypeSpecifierType
Specifies the kind of type.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Represents a variable template specialization, which refers to a variable template with a given set o...
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
static bool isTemplateArgumentTemplateParameter(const TemplateArgument &Arg, unsigned Depth, unsigned Index)
A namespace, stored as a NamespaceDecl*.
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.
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.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool OdrUse)
Perform marking for a reference to an arbitrary declaration.
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
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
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.
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
SourceLocation getLocation() const
Fetches the primary location of the argument.
OverloadedOperatorKind Operator
The kind of overloaded operator.
TypeResult ActOnTemplateIdType(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false)
void startDefinition()
Starts the definition of this tag declaration.
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
bool isChar32Type() const
CXXRecordDecl * getDefinition() const
bool isTranslationUnit() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
void setElaboratedKeywordLoc(SourceLocation Loc)
TagKind getTagKind() const
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
SourceRange getSourceRange() const LLVM_READONLY
Fetches the full source range of the argument.
CK_NullToPointer - Null pointer constant to pointer, ObjC pointer, or block pointer.
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.
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)
CK_IntegralToBoolean - Integral to boolean.
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
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.
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 preorder depth-first traversal on the entire Clang AST and visits each node...
static bool CheckTemplateArgumentPointerToMember(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *&ResultArg, TemplateArgument &Converted)
Checks whether the given template argument is a pointer to member constant according to C++ [temp...
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
ParsedTemplateArgument getTemplatePackExpansion(SourceLocation EllipsisLoc) const
Retrieve a pack expansion of the given template template argument.
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...
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
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 ...
QualType getTemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs, QualType Canon=QualType()) const
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
TemplateName getUnderlying() const
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack...
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.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, SmallVectorImpl< TemplateArgument > &Converted, CheckTemplateArgumentKind CTAK=CTAK_Specified)
Check that the given template argument corresponds to the given template parameter.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
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...
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 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.
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...
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
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
DeclContext * getDeclContext()
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.
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, const TemplateArgument *Args, unsigned NumArgs, const TemplateArgumentListInfo &ArgInfos, QualType CanonInjectedType, ClassTemplatePartialSpecializationDecl *PrevDecl)
Data structure that captures multiple levels of template argument lists for use in template instantia...
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.
void setLocation(SourceLocation L)
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.
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.
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.
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...
ASTContext & getASTContext() const LLVM_READONLY
CK_NullToMemberPointer - Null pointer constant to member pointer.
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.
Represents a static or instance method of a struct/union/class.
unsigned getDepth() const
Retrieve the depth of the template parameter.
void print(const PrintingPolicy &Policy, raw_ostream &Out) const
Print this template argument to the given output stream.
SourceLocation getNameLoc() const
QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc)
Check that the type of a non-type template parameter is well-formed.
void set(Decl *Spec, DeductionFailureInfo Info)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
Name lookup found an unresolvable value declaration and cannot yet complete.
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
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.
bool isInvalidDecl() const
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
This is a scope that corresponds to the template parameters of a C++ template.
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.
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...
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration...
bool isWideCharType() const
unsigned getDepth() const
Get the nesting depth of the template parameter.
QualType getNonReferenceType() const
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.
static VarTemplatePartialSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, const TemplateArgument *Args, unsigned NumArgs, const TemplateArgumentListInfo &ArgInfos)
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
Name lookup found a single declaration that met the criteria.
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.
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)
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, const TemplateArgument *Args, unsigned NumArgs)
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)
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.
void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl, bool NeedDefinition, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
bool isFunctionType() const
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.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
SourceRange getTemplateParamsRange(TemplateParameterList const *const *Params, unsigned NumParams)
Retrieves the range of the given template parameter lists.
DeclResult ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS, TemplateTy Template, SourceLocation TemplateNameLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, AttributeList *Attr)
The template argument is a type.
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
ActionResult< ParsedType > TypeResult
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
const TypeClass * getTypePtr() const
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
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.
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.
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
SourceLocation getIdentifierLoc() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
const LValueBase getLValueBase() const
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
A user-defined literal name, e.g., operator "" _i.
Decl * D
The template function declaration to be late parsed.
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...
static bool anyDependentTemplateArguments(const TemplateArgumentLoc *Args, unsigned NumArgs, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
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.
CK_NoOp - A conversion which does not affect the type other than (possibly) adding qualifiers...
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.
bool isParameterPack() const
Whether this declaration is a parameter pack.
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
void setLexicalDeclContext(DeclContext *DC)
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.
void setAccess(AccessSpecifier AS)
A template template argument, stored as a template name.
Represents a C array with a specified size that is not an integer-constant-expression.
void 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
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.
void setRBraceLoc(SourceLocation L)
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 ...