41#include "llvm/ADT/SmallBitVector.h"
42#include "llvm/ADT/StringExtras.h"
43#include "llvm/Support/Casting.h"
44#include "llvm/Support/SaveAndRestore.h"
55 return SourceRange(Ps[0]->getTemplateLoc(), Ps[N-1]->getRAngleLoc());
63 for (
Scope *TempParamScope = S->getTemplateParamParent(); TempParamScope;
64 TempParamScope = TempParamScope->getParent()->getTemplateParamParent()) {
69 auto ParamsAtDepth = [&](
unsigned D) { Depth = std::max(Depth,
D + 1); };
74 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(FSI)) {
75 if (!LSI->TemplateParams.empty()) {
76 ParamsAtDepth(LSI->AutoTemplateParameterDepth);
79 if (LSI->GLTemplateParameterList) {
80 ParamsAtDepth(LSI->GLTemplateParameterList->getDepth());
90 if (!Info.TemplateParams.empty()) {
91 ParamsAtDepth(Info.AutoTemplateParameterDepth);
106 bool AllowFunctionTemplates,
107 bool AllowDependent) {
108 D =
D->getUnderlyingDecl();
110 if (isa<TemplateDecl>(
D)) {
111 if (!AllowFunctionTemplates && isa<FunctionTemplateDecl>(
D))
117 if (
const auto *
Record = dyn_cast<CXXRecordDecl>(
D)) {
129 if (
Record->isInjectedClassName()) {
131 if (
Record->getDescribedClassTemplate())
132 return Record->getDescribedClassTemplate();
134 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(
Record))
135 return Spec->getSpecializedTemplate();
144 if (AllowDependent && isa<UnresolvedUsingValueDecl>(
D))
151 bool AllowFunctionTemplates,
152 bool AllowDependent) {
163 bool AllowFunctionTemplates,
165 bool AllowNonTemplateFunctions) {
169 if (AllowNonTemplateFunctions &&
170 isa<FunctionDecl>((*I)->getUnderlyingDecl()))
179 bool hasTemplateKeyword,
182 bool EnteringContext,
184 bool &MemberOfUnknownSpecialization,
185 bool Disambiguation) {
189 MemberOfUnknownSpecialization =
false;
191 switch (Name.getKind()) {
198 Name.OperatorFunctionId.Operator);
238 bool AnyFunctionTemplates =
false;
241 if (isa<FunctionTemplateDecl>(FoundTemplate))
242 AnyFunctionTemplates =
true;
245 FoundUsingShadow = dyn_cast<UsingShadowDecl>(FoundD);
253 if (!
D && !AnyFunctionTemplates) {
254 R.suppressDiagnostics();
271 unsigned ResultCount = R.
end() - R.
begin();
272 if (!
D && ResultCount > 1) {
283 assert(
D &&
"unambiguous result is not a template name");
286 if (isa<UnresolvedUsingValueDecl>(
D)) {
288 MemberOfUnknownSpecialization =
true;
295 assert(!FoundUsingShadow || FoundUsingShadow->
getTargetDecl() == TD);
302 if (isa<FunctionTemplateDecl>(TD)) {
308 assert(isa<ClassTemplateDecl>(TD) || isa<TemplateTemplateParmDecl>(TD) ||
309 isa<TypeAliasTemplateDecl>(TD) || isa<VarTemplateDecl>(TD) ||
310 isa<BuiltinTemplateDecl>(TD) || isa<ConceptDecl>(TD));
312 isa<TemplateTemplateParmDecl>(TD)
313 ? dyn_cast<TemplateTemplateParmDecl>(TD)->templateParameterKind()
321 S->getTemplateParamParent() ==
nullptr)
322 Diag(Name.getBeginLoc(), diag::err_builtin_pack_outside_template) << TName;
341 if (R.
empty())
return false;
378 {SS->getScopeRep(), &II, false}));
379 Diag(IILoc, diag::err_template_kw_missing)
380 << SuggestedTemplate.
get()
387 QualType ObjectType,
bool EnteringContext,
390 bool AllowTypoCorrection) {
397 Found.setTemplateNameLookup(
true);
401 bool IsDependent =
false;
402 if (!ObjectType.
isNull()) {
405 assert(SS.
isEmpty() &&
"ObjectType and scope specifier cannot coexist");
413 "Caller should have completed object type");
445 bool ObjectTypeSearchedInScope =
false;
446 bool AllowFunctionTemplatesInLookup =
true;
462 IsDependent |=
Found.wasNotFoundInCurrentInstantiation();
478 if (!ObjectType.
isNull()) {
482 AllowFunctionTemplatesInLookup =
false;
483 ObjectTypeSearchedInScope =
true;
486 IsDependent |=
Found.wasNotFoundInCurrentInstantiation();
489 if (
Found.isAmbiguous())
506 if (AllFunctions || (
Found.empty() && !IsDependent)) {
510 *ATK = (
Found.empty() &&
Found.getLookupName().isIdentifier())
518 if (
Found.empty() && !IsDependent && AllowTypoCorrection) {
526 FilterCCC.WantExpressionKeywords =
false;
527 FilterCCC.WantRemainingKeywords =
false;
528 FilterCCC.WantCXXNamedCasts =
true;
530 Found.getLookupNameInfo(),
Found.getLookupKind(), S, &SS, FilterCCC,
532 if (
auto *ND = Corrected.getFoundDecl())
535 if (
Found.isAmbiguous()) {
537 }
else if (!
Found.empty()) {
540 AllowFunctionTemplatesInLookup =
true;
541 Found.setLookupName(Corrected.getCorrection());
543 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
544 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
545 Name.getAsString() == CorrectedStr;
547 << Name << LookupCtx << DroppedSpecifier
557 Found.empty() ? nullptr :
Found.getRepresentativeDecl();
561 Found.setNotFoundInCurrentInstantiation();
567 if (ExampleLookupResult && RequiredTemplate) {
568 Diag(
Found.getNameLoc(), diag::err_template_kw_refers_to_non_template)
573 diag::note_template_kw_refers_to_non_template)
574 <<
Found.getLookupName();
581 if (S && !ObjectType.
isNull() && !ObjectTypeSearchedInScope &&
598 if (FoundOuter.
empty()) {
608 }
else if (!
Found.isSuppressingAmbiguousDiagnostics()) {
612 if (!
Found.isSingleResult() ||
616 diag::ext_nested_name_member_ref_lookup_ambiguous)
617 <<
Found.getLookupName()
619 Diag(
Found.getRepresentativeDecl()->getLocation(),
620 diag::note_ambig_member_ref_object_type)
623 diag::note_ambig_member_ref_scope);
646 bool MissingTemplateKeyword =
false;
649 if (
auto *DRE = dyn_cast<DeclRefExpr>(
TemplateName.get())) {
650 NameInfo = DRE->getNameInfo();
651 SS.
Adopt(DRE->getQualifierLoc());
653 Found = DRE->getFoundDecl();
654 }
else if (
auto *ME = dyn_cast<MemberExpr>(
TemplateName.get())) {
655 NameInfo = ME->getMemberNameInfo();
656 SS.
Adopt(ME->getQualifierLoc());
658 LookupCtx = ME->getBase()->getType()->getAsCXXRecordDecl();
659 Found = ME->getMemberDecl();
660 }
else if (
auto *DSDRE =
661 dyn_cast<DependentScopeDeclRefExpr>(
TemplateName.get())) {
662 NameInfo = DSDRE->getNameInfo();
663 SS.
Adopt(DSDRE->getQualifierLoc());
664 MissingTemplateKeyword =
true;
665 }
else if (
auto *DSME =
666 dyn_cast<CXXDependentScopeMemberExpr>(
TemplateName.get())) {
667 NameInfo = DSME->getMemberNameInfo();
668 SS.
Adopt(DSME->getQualifierLoc());
669 MissingTemplateKeyword =
true;
671 llvm_unreachable(
"unexpected kind of potential template name");
676 if (MissingTemplateKeyword) {
685 TemplateCandidateFilter(
Sema &S) : S(S) {
686 WantTypeSpecifiers =
false;
687 WantExpressionKeywords =
false;
688 WantRemainingKeywords =
false;
689 WantCXXNamedCasts =
true;
691 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
697 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
698 return std::make_unique<TemplateCandidateFilter>(*
this);
703 TemplateCandidateFilter CCC(*
this);
707 auto *ND = Corrected.getFoundDecl();
710 if (ND || Corrected.isKeyword()) {
712 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
713 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
714 Name.getAsString() == CorrectedStr;
716 PDiag(diag::err_non_template_in_member_template_id_suggest)
717 << Name << LookupCtx << DroppedSpecifier
721 PDiag(diag::err_non_template_in_template_id_suggest)
726 diag::note_non_template_in_template_id_found);
731 Diag(NameInfo.
getLoc(), diag::err_non_template_in_template_id)
734 Diag(
Found->getLocation(), diag::note_non_template_in_template_id_found);
741 bool isAddressOfOperand,
757 nullptr, NameInfo, TemplateArgs);
780 bool InstantiatedFromMember,
784 bool Complain,
bool *Unreachable) {
785 assert(isa<TagDecl>(Instantiation) || isa<FunctionDecl>(Instantiation) ||
786 isa<VarDecl>(Instantiation));
788 bool IsEntityBeingDefined =
false;
789 if (
const TagDecl *TD = dyn_cast_or_null<TagDecl>(PatternDef))
790 IsEntityBeingDefined = TD->isBeingDefined();
792 if (PatternDef && !IsEntityBeingDefined) {
809 if (!Complain || (PatternDef && PatternDef->
isInvalidDecl()))
813 if (
TagDecl *TD = dyn_cast<TagDecl>(Instantiation))
816 Diag(PointOfInstantiation,
817 diag::err_template_instantiate_within_definition)
823 }
else if (InstantiatedFromMember) {
824 if (isa<FunctionDecl>(Instantiation)) {
825 Diag(PointOfInstantiation,
826 diag::err_explicit_instantiation_undefined_member)
831 assert(isa<TagDecl>(Instantiation) &&
"Must be a TagDecl!");
832 Diag(PointOfInstantiation,
833 diag::err_implicit_instantiate_member_undefined)
838 if (isa<FunctionDecl>(Instantiation)) {
839 Diag(PointOfInstantiation,
840 diag::err_explicit_instantiation_undefined_func_template)
843 }
else if (isa<TagDecl>(Instantiation)) {
844 Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
849 assert(isa<VarDecl>(Instantiation) &&
"Must be a VarDecl!");
850 if (isa<VarTemplateSpecializationDecl>(Instantiation)) {
851 Diag(PointOfInstantiation,
852 diag::err_explicit_instantiation_undefined_var_template)
856 Diag(PointOfInstantiation,
857 diag::err_explicit_instantiation_undefined_member)
874 bool SupportedForCompatibility) {
887 ? diag::ext_template_param_shadow
888 : (SupportedForCompatibility ? diag::ext_compat_template_param_shadow
889 : diag::err_template_param_shadow);
890 const auto *ND = cast<NamedDecl>(PrevDecl);
891 Diag(
Loc, DiagId) << ND->getDeclName();
896 if (
TemplateDecl *Temp = dyn_cast_or_null<TemplateDecl>(
D)) {
897 D = Temp->getTemplatedDecl();
906 "Only template template arguments can be pack expansions here");
907 assert(
getAsTemplate().get().containsUnexpandedParameterPack() &&
908 "Template template argument pack expansion without packs");
910 Result.EllipsisLoc = EllipsisLoc;
945 llvm_unreachable(
"Unhandled parsed template argument");
950 for (
unsigned I = 0,
Last = TemplateArgsIn.size(); I !=
Last; ++I)
960 RedeclarationKind::ForVisibleRedeclaration);
970 assert(TInfo &&
"template argument with no location");
978 EllipsisLoc = PET.getEllipsisLoc();
979 TL = PET.getPatternLoc();
983 TemplateName Name = DTST.getTypePtr()->getTemplateName();
985 SS.
Adopt(DTST.getQualifierLoc());
988 DTST.getTemplateNameLoc());
1009 unsigned Depth,
unsigned Position,
1012 bool HasTypeConstraint) {
1013 assert(S->isTemplateParamScope() &&
1014 "Template type parameter not in template parameter scope!");
1016 bool IsParameterPack = EllipsisLoc.
isValid();
1019 KeyLoc, ParamNameLoc, Depth, Position,
1020 ParamName,
Typename, IsParameterPack,
1026 CSI->LocalPacks.push_back(Param);
1039 if (DefaultArg && IsParameterPack) {
1040 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1041 DefaultArg =
nullptr;
1049 assert(DefaultTInfo &&
"expected source information for type");
1077 return TemplateArgs;
1084 bool IsTypeConcept =
false;
1085 bool RequiresArguments =
false;
1087 IsTypeConcept = TTP->isTypeConceptTemplateParam();
1089 TTP->getTemplateParameters()->getMinRequiredArguments() > 1;
1093 IsTypeConcept = cast<ConceptDecl>(CD)->isTypeConcept();
1094 RequiresArguments = cast<ConceptDecl>(CD)
1102 if (!IsTypeConcept) {
1104 diag::err_type_constraint_non_type_concept);
1113 if (!WereArgsSpecified && RequiresArguments) {
1115 diag::err_type_constraint_missing_arguments)
1134 bool AllowUnexpandedPack) {
1151 if (EllipsisLoc.
isInvalid() && !AllowUnexpandedPack) {
1160 ConceptName, CD, USD ? cast<NamedDecl>(USD) : CD,
1162 ConstrainedParameter, EllipsisLoc);
1165template <
typename ArgumentLocAppender>
1180 Appender(ConstraintArgs);
1188 if (
auto *CD = dyn_cast<ConceptDecl>(NamedConcept)) {
1191 FoundDecl ? FoundDecl : NamedConcept, CD,
1196 auto *CDT = dyn_cast<TemplateTemplateParmDecl>(NamedConcept);
1201 return ImmediatelyDeclaredConstraint;
1217 ImmediatelyDeclaredConstraint.
get(), BO_LAnd,
1218 EllipsisLoc,
nullptr,
1235 *TemplateArgs) :
nullptr;
1240 *
this,
NS, NameInfo, NamedConcept, FoundDecl,
1243 ParamAsArgument, ConstrainedParameter->
getLocation(),
1246 for (const auto &ArgLoc : TemplateArgs->arguments())
1247 ConstraintArgs.addArgument(ArgLoc);
1250 if (ImmediatelyDeclaredConstraint.
isInvalid())
1260 CL, ImmediatelyDeclaredConstraint.
get(), std::nullopt);
1271 diag::err_unsupported_placeholder_constraint)
1290 for (unsigned I = 0, C = TL.getNumArgs(); I != C; ++I)
1291 ConstraintArgs.addArgument(TL.getArgLoc(I));
1294 if (ImmediatelyDeclaredConstraint.
isInvalid() ||
1295 !ImmediatelyDeclaredConstraint.
isUsable())
1299 ImmediatelyDeclaredConstraint.
get());
1329 Diag(
Loc, diag::err_template_nontype_parm_rvalue_ref) <<
T;
1339 Diag(
Loc, diag::err_template_nontype_parm_bad_type) <<
T;
1347 Diag(
Loc, diag::err_template_nontype_parm_not_structural) <<
T;
1354 for (
const FieldDecl *FD : RD->fields()) {
1356 Diag(FD->getLocation(), diag::note_not_structural_non_public) <<
T << 0;
1359 if (FD->isMutable()) {
1360 Diag(FD->getLocation(), diag::note_not_structural_mutable_field) <<
T;
1363 if (FD->getType()->isRValueReferenceType()) {
1364 Diag(FD->getLocation(), diag::note_not_structural_rvalue_ref_field)
1371 for (
const auto &BaseSpec : RD->bases()) {
1372 if (BaseSpec.getAccessSpecifier() !=
AS_public) {
1373 Diag(BaseSpec.getBaseTypeLoc(), diag::note_not_structural_non_public)
1384 for (
const FieldDecl *FD : RD->fields()) {
1387 SubLoc = FD->getLocation();
1395 for (
const auto &BaseSpec : RD->bases()) {
1398 SubLoc = BaseSpec.getBaseTypeLoc();
1406 assert(Kind != -1 &&
"couldn't find reason why type is not structural");
1407 Diag(SubLoc, diag::note_not_structural_subobject)
1408 <<
T << Kind << SubType;
1421 Diag(
Loc, diag::err_variably_modified_nontype_template_param)
1445 return T.getUnqualifiedType();
1463 return T.getUnqualifiedType();
1474 Diag(
Loc, diag::err_template_nontype_parm_bad_structural_type) <<
T;
1478 Diag(
Loc, diag::warn_cxx17_compat_template_nontype_parm_type) <<
T;
1479 return T.getUnqualifiedType();
1490 auto CheckValidDeclSpecifiers = [
this, &
D] {
1504 Diag(
Loc, diag::err_invalid_decl_specifier_in_nontype_parm)
1541 CheckValidDeclSpecifiers();
1544 if (isa<AutoType>(
T))
1545 Diag(
D.getIdentifierLoc(),
1546 diag::warn_cxx14_compat_template_nontype_parm_auto_type)
1549 assert(S->isTemplateParamScope() &&
1550 "Non-type template parameter not in template parameter scope!");
1562 bool IsParameterPack =
D.hasEllipsis();
1565 D.getIdentifierLoc(), Depth, Position, ParamName,
T, IsParameterPack,
1570 if (TL.isConstrained()) {
1571 if (
D.getEllipsisLoc().isInvalid() &&
1573 assert(TL.getConceptReference()->getTemplateArgsAsWritten());
1575 TL.getConceptReference()->getTemplateArgsAsWritten()->arguments())
1589 CSI->LocalPacks.push_back(Param);
1603 if (
Default && IsParameterPack) {
1604 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1632 assert(S->isTemplateParamScope() &&
1633 "Template template parameter not in template parameter scope!");
1635 bool IsParameterPack = EllipsisLoc.
isValid();
1647 NameLoc.
isInvalid() ? TmpLoc : NameLoc, Depth, Position, IsParameterPack,
1653 LSI->LocalPacks.push_back(Param);
1664 if (Params->
size() == 0) {
1676 if (IsParameterPack && !
Default.isInvalid()) {
1677 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1692 Diag(DefaultArg.
getLocation(), diag::err_template_arg_not_valid_template)
1718class ConstraintRefersToContainingTemplateChecker
1719 :
public TreeTransform<ConstraintRefersToContainingTemplateChecker> {
1720 bool Result =
false;
1722 unsigned TemplateDepth = 0;
1726 void CheckIfContainingRecord(
const CXXRecordDecl *CheckingRD) {
1732 DC && !DC->isFileContext(); DC = DC->getParent())
1733 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
1734 if (CheckingRD == RD->getMostRecentDecl())
1739 if (
D->getDepth() < TemplateDepth)
1744 TransformType(
D->getType());
1750 ConstraintRefersToContainingTemplateChecker(
Sema &SemaRef,
1752 unsigned TemplateDepth)
1753 : inherited(SemaRef),
Friend(
Friend), TemplateDepth(TemplateDepth) {}
1754 bool getResult()
const {
return Result; }
1760 using inherited::TransformTemplateTypeParmType;
1765 return inherited::TransformTemplateTypeParmType(
1777 if (
auto *TD = dyn_cast<TypedefNameDecl>(
D))
1778 TransformType(TD->getUnderlyingType());
1779 else if (
auto *NTTPD = dyn_cast<NonTypeTemplateParmDecl>(
D))
1780 CheckNonTypeTemplateParmDecl(NTTPD);
1781 else if (
auto *VD = dyn_cast<ValueDecl>(
D))
1782 TransformType(VD->getType());
1783 else if (
auto *TD = dyn_cast<TemplateDecl>(
D))
1784 TransformTemplateParameterList(TD->getTemplateParameters());
1785 else if (
auto *RD = dyn_cast<CXXRecordDecl>(
D))
1786 CheckIfContainingRecord(RD);
1787 else if (isa<NamedDecl>(
D)) {
1790 llvm_unreachable(
"Don't know how to handle this declaration type yet");
1798 const Expr *Constraint) {
1799 assert(
Friend->getFriendObjectKind() &&
"Only works on a friend");
1800 ConstraintRefersToContainingTemplateChecker Checker(*
this,
Friend,
1802 Checker.TransformExpr(
const_cast<Expr *
>(Constraint));
1803 return Checker.getResult();
1813 Expr *RequiresClause) {
1815 Diag(ExportLoc, diag::warn_template_export_unsupported);
1857 return cast<TemplateDecl>(
D)->getTemplateParameters();
1867 assert(TemplateParams && TemplateParams->
size() > 0 &&
1868 "No template parameters");
1870 "Can only declare or define class templates");
1879 "can't build template of enumerated type");
1883 Diag(KWLoc, diag::err_template_unnamed_class);
1898 if (!SemanticContext) {
1903 ? diag::warn_template_qualified_friend_ignored
1904 : diag::err_template_qualified_declarator_no_match)
1963 if (S->isTemplateParamScope())
1968 PrevDecl = (*
Previous.begin())->getUnderlyingDecl();
1980 dyn_cast_or_null<ClassTemplateDecl>(PrevDecl);
1985 if (!PrevClassTemplate && isa_and_nonnull<CXXRecordDecl>(PrevDecl) &&
1986 cast<CXXRecordDecl>(PrevDecl)->isInjectedClassName()) {
1989 = cast<CXXRecordDecl>(PrevDecl)->getDescribedClassTemplate();
1990 if (!PrevClassTemplate && isa<ClassTemplateSpecializationDecl>(PrevDecl)) {
1992 = cast<ClassTemplateSpecializationDecl>(PrevDecl)
1993 ->getSpecializedTemplate();
2016 PrevDecl = PrevClassTemplate =
nullptr;
2017 SemanticContext = OutermostContext;
2031 PrevDecl = (*
Previous.begin())->getUnderlyingDecl();
2035 SemanticContext, S, SS.
isValid()))
2036 PrevDecl = PrevClassTemplate =
nullptr;
2038 if (
auto *Shadow = dyn_cast_or_null<UsingShadowDecl>(
2039 PrevDecl ?
Previous.getRepresentativeDecl() :
nullptr)) {
2041 !(PrevClassTemplate &&
2044 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
2045 Diag(Shadow->getTargetDecl()->getLocation(),
2046 diag::note_using_decl_target);
2047 Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl) << 0;
2049 PrevDecl = PrevClassTemplate =
nullptr;
2053 if (PrevClassTemplate) {
2062 TemplateParams, PrevClassTemplate,
2075 Diag(KWLoc, diag::err_use_with_wrong_tag)
2088 bool HiddenDefVisible =
false;
2093 if (!HiddenDefVisible && Hidden) {
2095 cast<CXXRecordDecl>(Hidden)->getDescribedClassTemplate();
2096 assert(Tmpl &&
"original definition of a class template is not a "
2102 Diag(NameLoc, diag::err_redefinition) << Name;
2103 Diag(Def->getLocation(), diag::note_previous_definition);
2110 }
else if (PrevDecl) {
2116 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
2130 (SS.
isSet() && SemanticContext && SemanticContext->
isRecord() &&
2143 ? diag::err_friend_decl_does_not_match
2144 : diag::err_member_decl_does_not_match)
2145 << Name << SemanticContext <<
true << SS.
getRange();
2155 bool ShouldAddRedecl =
2159 Context, Kind, SemanticContext, KWLoc, NameLoc, Name,
2160 PrevClassTemplate && ShouldAddRedecl
2164 if (NumOuterTemplateParamLists > 0)
2167 llvm::ArrayRef(OuterTemplateParamLists, NumOuterTemplateParamLists));
2183 if (ShouldAddRedecl)
2188 if (ModulePrivateLoc.
isValid())
2193 if (PrevClassTemplate &&
2211 if (PrevClassTemplate)
2247 if (PrevClassTemplate)
2286 S.
DiagCompat(ParamLoc, diag_compat::templ_default_in_function_templ)
2295 S.
Diag(ParamLoc, diag::err_template_parameter_default_template_member)
2304 S.
Diag(ParamLoc, diag::err_template_parameter_default_friend_template)
2313 llvm_unreachable(
"Invalid TemplateParamListContext!");
2326 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
2331 if (TC->hasExplicitTemplateArgs())
2332 for (
auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
2340 if (!NTTP->isParameterPack() &&
2342 NTTP->getTypeSourceInfo(),
2350 = dyn_cast<TemplateTemplateParmDecl>(
P))
2370 bool SawDefaultArgument =
false;
2376 OldParam = OldParams->
begin();
2378 bool RemoveDefaultArguments =
false;
2380 NewParamEnd = NewParams->
end();
2381 NewParam != NewParamEnd; ++NewParam) {
2384 bool RedundantDefaultArg =
false;
2387 bool InconsistentDefaultArg =
false;
2389 std::string PrevModuleName;
2395 bool MissingDefaultArg =
false;
2398 bool SawParameterPack =
false;
2401 = dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
2403 if (NewTypeParm->hasDefaultArgument() &&
2405 *
this, TPC, NewTypeParm->getLocation(),
2406 NewTypeParm->getDefaultArgument().getSourceRange()))
2407 NewTypeParm->removeDefaultArgument();
2411 = OldParams? cast<TemplateTypeParmDecl>(*OldParam) :
nullptr;
2412 if (NewTypeParm->isParameterPack()) {
2413 assert(!NewTypeParm->hasDefaultArgument() &&
2414 "Parameter packs can't have a default argument!");
2415 SawParameterPack =
true;
2417 NewTypeParm->hasDefaultArgument() &&
2420 NewDefaultLoc = NewTypeParm->getDefaultArgumentLoc();
2421 SawDefaultArgument =
true;
2424 RedundantDefaultArg =
true;
2425 else if (!
getASTContext().isSameDefaultTemplateArgument(OldTypeParm,
2427 InconsistentDefaultArg =
true;
2431 PreviousDefaultArgLoc = NewDefaultLoc;
2435 NewTypeParm->setInheritedDefaultArgument(
Context, OldTypeParm);
2437 }
else if (NewTypeParm->hasDefaultArgument()) {
2438 SawDefaultArgument =
true;
2439 PreviousDefaultArgLoc = NewTypeParm->getDefaultArgumentLoc();
2440 }
else if (SawDefaultArgument)
2441 MissingDefaultArg =
true;
2443 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
2448 !NewNonTypeParm->isParameterPack() &&
2450 NewNonTypeParm->getTypeSourceInfo(),
2457 if (NewNonTypeParm->hasDefaultArgument() &&
2459 *
this, TPC, NewNonTypeParm->getLocation(),
2460 NewNonTypeParm->getDefaultArgument().getSourceRange())) {
2461 NewNonTypeParm->removeDefaultArgument();
2466 = OldParams? cast<NonTypeTemplateParmDecl>(*OldParam) :
nullptr;
2467 if (NewNonTypeParm->isParameterPack()) {
2468 assert(!NewNonTypeParm->hasDefaultArgument() &&
2469 "Parameter packs can't have a default argument!");
2470 if (!NewNonTypeParm->isPackExpansion())
2471 SawParameterPack =
true;
2473 NewNonTypeParm->hasDefaultArgument() &&
2476 NewDefaultLoc = NewNonTypeParm->getDefaultArgumentLoc();
2477 SawDefaultArgument =
true;
2479 RedundantDefaultArg =
true;
2481 OldNonTypeParm, NewNonTypeParm)) {
2482 InconsistentDefaultArg =
true;
2486 PreviousDefaultArgLoc = NewDefaultLoc;
2490 NewNonTypeParm->setInheritedDefaultArgument(
Context, OldNonTypeParm);
2492 }
else if (NewNonTypeParm->hasDefaultArgument()) {
2493 SawDefaultArgument =
true;
2494 PreviousDefaultArgLoc = NewNonTypeParm->getDefaultArgumentLoc();
2495 }
else if (SawDefaultArgument)
2496 MissingDefaultArg =
true;
2499 = cast<TemplateTemplateParmDecl>(*NewParam);
2516 = OldParams? cast<TemplateTemplateParmDecl>(*OldParam) :
nullptr;
2519 "Parameter packs can't have a default argument!");
2521 SawParameterPack =
true;
2522 }
else if (OldTemplateParm &&
2528 SawDefaultArgument =
true;
2530 RedundantDefaultArg =
true;
2532 OldTemplateParm, NewTemplateParm)) {
2533 InconsistentDefaultArg =
true;
2537 PreviousDefaultArgLoc = NewDefaultLoc;
2542 PreviousDefaultArgLoc
2545 SawDefaultArgument =
true;
2546 PreviousDefaultArgLoc
2548 }
else if (SawDefaultArgument)
2549 MissingDefaultArg =
true;
2555 if (SawParameterPack && (NewParam + 1) != NewParamEnd &&
2557 Diag((*NewParam)->getLocation(),
2558 diag::err_template_param_pack_must_be_last_template_parameter);
2575 if (RedundantDefaultArg) {
2576 Diag(NewDefaultLoc, diag::err_template_param_default_arg_redefinition);
2577 Diag(OldDefaultLoc, diag::note_template_param_prev_default_arg);
2579 }
else if (InconsistentDefaultArg) {
2583 diag::err_template_param_default_arg_inconsistent_redefinition);
2585 diag::note_template_param_prev_default_arg_in_other_module)
2588 }
else if (MissingDefaultArg &&
2596 Diag((*NewParam)->getLocation(),
2597 diag::err_template_param_default_arg_missing);
2598 Diag(PreviousDefaultArgLoc, diag::note_template_param_prev_default_arg);
2600 RemoveDefaultArguments =
true;
2611 if (RemoveDefaultArguments) {
2613 NewParamEnd = NewParams->
end();
2614 NewParam != NewParamEnd; ++NewParam) {
2616 TTP->removeDefaultArgument();
2618 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
2619 NTTP->removeDefaultArgument();
2621 cast<TemplateTemplateParmDecl>(*NewParam)->removeDefaultArgument();
2639 bool IgnoreNonTypeDependent;
2644 DependencyChecker(
unsigned Depth,
bool IgnoreNonTypeDependent)
2645 : Depth(Depth), IgnoreNonTypeDependent(IgnoreNonTypeDependent),
2649 : IgnoreNonTypeDependent(IgnoreNonTypeDependent),
Match(
false) {
2652 Depth = PD->getDepth();
2654 dyn_cast<NonTypeTemplateParmDecl>(ND)) {
2655 Depth = PD->getDepth();
2657 Depth = cast<TemplateTemplateParmDecl>(ND)->getDepth();
2662 if (ParmDepth >= Depth) {
2670 bool TraverseStmt(
Stmt *S)
override {
2675 if (
auto *
E = dyn_cast_or_null<Expr>(S))
2681 bool TraverseTypeLoc(
TypeLoc TL,
bool TraverseQualifier =
true)
override {
2682 if (IgnoreNonTypeDependent && !TL.
isNull() &&
2694 return IgnoreNonTypeDependent || !Matches(
T->getDepth());
2700 if (Matches(PD->getDepth()))
2707 dyn_cast<NonTypeTemplateParmDecl>(
E->getDecl()))
2710 return DynamicRecursiveASTVisitor::VisitDeclRefExpr(
E);
2716 if (Matches(TTP->getDepth(), ULE->
getExprLoc()))
2722 return DynamicRecursiveASTVisitor::VisitUnresolvedLookupExpr(ULE);
2726 return TraverseType(
T->getReplacementType());
2729 bool VisitSubstTemplateTypeParmPackType(
2731 return TraverseTemplateArgument(
T->getArgumentPack());
2735 bool TraverseQualifier)
override {
2738 return TraverseTemplateArguments(
2739 T->getTemplateArgs(
T->getOriginalDecl()->getASTContext()));
2748 if (!Params->
size())
2751 DependencyChecker Checker(Params,
false);
2752 Checker.TraverseType(
T);
2753 return Checker.Match;
2779 bool &IsMemberSpecialization,
bool &
Invalid,
bool SuppressDiagnostic) {
2780 IsMemberSpecialization =
false;
2802 while (!
T.isNull()) {
2803 NestedTypes.push_back(
T);
2809 = dyn_cast<ClassTemplateSpecializationDecl>(
Record)) {
2810 if (!isa<ClassTemplatePartialSpecializationDecl>(Spec) &&
2812 ExplicitSpecLoc = Spec->getLocation();
2815 }
else if (
Record->getTemplateSpecializationKind()
2817 ExplicitSpecLoc =
Record->getLocation();
2843 DependentTST->getDependentTemplateName().getQualifier();
2879 std::reverse(NestedTypes.begin(), NestedTypes.end());
2887 bool SawNonEmptyTemplateParameterList =
false;
2890 if (SawNonEmptyTemplateParameterList) {
2891 if (!SuppressDiagnostic)
2892 Diag(DeclLoc, diag::err_specialize_member_of_template)
2893 << !Recovery <<
Range;
2895 IsMemberSpecialization =
false;
2904 if (CheckExplicitSpecialization(
Range,
true))
2909 if (!ParamLists.empty())
2910 ExpectedTemplateLoc = ParamLists[0]->getTemplateLoc();
2912 ExpectedTemplateLoc = DeclStartLoc;
2914 if (!SuppressDiagnostic)
2915 Diag(DeclLoc, diag::err_template_spec_needs_header)
2922 for (
unsigned TypeIdx = 0, NumTypes = NestedTypes.size(); TypeIdx != NumTypes;
2924 T = NestedTypes[TypeIdx];
2927 bool NeedEmptyTemplateHeader =
false;
2930 bool NeedNonemptyTemplateHeader =
false;
2943 = dyn_cast<ClassTemplatePartialSpecializationDecl>(
Record)) {
2944 ExpectedTemplateParams = Partial->getTemplateParameters();
2945 NeedNonemptyTemplateHeader =
true;
2946 }
else if (
Record->isDependentType()) {
2947 if (
Record->getDescribedClassTemplate()) {
2948 ExpectedTemplateParams =
Record->getDescribedClassTemplate()
2949 ->getTemplateParameters();
2950 NeedNonemptyTemplateHeader =
true;
2953 = dyn_cast<ClassTemplateSpecializationDecl>(
Record)) {
2959 NeedEmptyTemplateHeader =
true;
2962 }
else if (
Record->getTemplateSpecializationKind()) {
2963 if (
Record->getTemplateSpecializationKind()
2965 TypeIdx == NumTypes - 1)
2966 IsMemberSpecialization =
true;
2973 ExpectedTemplateParams =
Template->getTemplateParameters();
2974 NeedNonemptyTemplateHeader =
true;
2979 NeedNonemptyTemplateHeader =
false;
2989 if (
ParamIdx < ParamLists.size()) {
2990 if (ParamLists[
ParamIdx]->size() == 0) {
2991 if (CheckExplicitSpecialization(ParamLists[
ParamIdx]->getSourceRange(),
2995 SawNonEmptyTemplateParameterList =
true;
2998 if (NeedEmptyTemplateHeader) {
3001 if (TypeIdx == NumTypes - 1)
3002 IsMemberSpecialization =
true;
3004 if (
ParamIdx < ParamLists.size()) {
3005 if (ParamLists[
ParamIdx]->size() > 0) {
3007 if (!SuppressDiagnostic)
3009 diag::err_template_param_list_matches_nontemplate)
3012 ParamLists[
ParamIdx]->getRAngleLoc())
3024 if (DiagnoseMissingExplicitSpecialization(
3031 if (NeedNonemptyTemplateHeader) {
3037 if (
ParamIdx < ParamLists.size() &&
3039 ExpectedTemplateParams =
nullptr;
3044 if (
ParamIdx < ParamLists.size()) {
3046 if (ExpectedTemplateParams &&
3048 ExpectedTemplateParams,
3061 if (!SuppressDiagnostic)
3062 Diag(DeclLoc, diag::err_template_spec_needs_template_parameters)
3073 if (
ParamIdx >= ParamLists.size()) {
3074 if (TemplateId && !IsFriend) {
3090 if (
ParamIdx < ParamLists.size() - 1) {
3091 bool HasAnyExplicitSpecHeader =
false;
3092 bool AllExplicitSpecHeaders =
true;
3093 for (
unsigned I =
ParamIdx,
E = ParamLists.size() - 1; I !=
E; ++I) {
3094 if (ParamLists[I]->size() == 0)
3095 HasAnyExplicitSpecHeader =
true;
3097 AllExplicitSpecHeaders =
false;
3100 if (!SuppressDiagnostic)
3102 AllExplicitSpecHeaders ? diag::ext_template_spec_extra_headers
3103 : diag::err_template_spec_extra_headers)
3105 ParamLists[ParamLists.size() - 2]->getRAngleLoc());
3110 if (ExplicitSpecLoc.
isValid() && HasAnyExplicitSpecHeader &&
3111 !SuppressDiagnostic)
3112 Diag(ExplicitSpecLoc,
3113 diag::note_explicit_template_spec_does_not_need_header)
3114 << NestedTypes.back();
3119 if (!AllExplicitSpecHeaders)
3130 if (ParamLists.back()->size() == 0 &&
3131 CheckExplicitSpecialization(ParamLists[
ParamIdx]->getSourceRange(),
3137 return ParamLists.back();
3142 Diag(
Template->getLocation(), diag::note_template_declared_here)
3143 << (isa<FunctionTemplateDecl>(
Template)
3149 : isa<TypeAliasTemplateDecl>(
Template) ? 3 : 4)
3158 Diag((*I)->getLocation(), diag::note_template_declared_here)
3159 << 0 << (*I)->getDeclName();
3194 return BaseTemplateInst;
3199 switch (Ts.size()) {
3209 return lookUpCommonType(Ts[0], Ts[0]);
3223 return lookUpCommonType(D1, D2);
3228 auto CheckConditionalOperands = [&](
bool ConstRefQual) ->
QualType {
3267 if (
auto Res = CheckConditionalOperands(
false); !Res.isNull())
3280 return CheckConditionalOperands(
true);
3291 for (
auto T : llvm::drop_begin(Ts)) {
3317 bool Literal =
false;
3319 if (
isInVkNamespace(RT) && RT->getOriginalDecl()->getName() ==
"Literal") {
3321 dyn_cast<ClassTemplateSpecializationDecl>(RT->getOriginalDecl());
3325 QualType ConstantType = LiteralArgs[0].getAsType();
3328 LiteralLoc = SpecDecl->getSourceRange().getBegin();
3332 RT->getOriginalDecl()->getName() ==
"integral_constant") {
3334 dyn_cast<ClassTemplateSpecializationDecl>(RT->getOriginalDecl());
3339 QualType ConstantType = ConstantArgs[0].getAsType();
3340 llvm::APInt
Value = ConstantArgs[1].getAsIntegral();
3345 }
else if (Literal) {
3346 SemaRef.
Diag(LiteralLoc, diag::err_hlsl_vk_literal_must_contain_constant);
3351 diag::err_call_incomplete_argument))
3363 case BTK__make_integer_seq: {
3367 QualType OrigType = Converted[1].getAsType();
3371 SemaRef.
Diag(TemplateArgs[1].getLocation(),
3372 diag::err_integer_sequence_integral_element_type);
3386 OrigType, TemplateArgs[1].getLocation())));
3388 if (llvm::APSInt NumArgs = NumArgsArg.
getAsIntegral(); NumArgs >= 0) {
3390 for (llvm::APSInt I(NumArgs.getBitWidth(), NumArgs.isUnsigned());
3394 TA, OrigType, TemplateArgs[2].getLocation()));
3399 SemaRef.
Diag(TemplateArgs[2].getLocation(),
3400 diag::err_integer_sequence_negative_length);
3407 TemplateLoc, SyntheticTemplateArgs);
3410 case BTK__type_pack_element: {
3414 assert(Converted.size() == 2 &&
3415 "__type_pack_element should be given an index and a parameter pack");
3422 assert(Index >= 0 &&
"the index used with __type_pack_element should be of "
3423 "type std::size_t, and hence be non-negative");
3425 if (Index >= Ts.pack_size()) {
3426 SemaRef.
Diag(TemplateArgs[0].getLocation(),
3427 diag::err_type_pack_element_out_of_bounds);
3432 int64_t N = Index.getExtValue();
3433 return Ts.getPackAsArray()[N].getAsType();
3436 case BTK__builtin_common_type: {
3437 assert(Converted.size() == 4);
3438 if (llvm::any_of(Converted, [](
auto &
C) {
return C.isDependent(); }))
3441 TemplateName BaseTemplate = Converted[0].getAsTemplate();
3449 CT, TemplateArgs[1].getLocation())));
3450 TemplateName HasTypeMember = Converted[1].getAsTemplate();
3454 QualType HasNoTypeMember = Converted[2].getAsType();
3455 return HasNoTypeMember;
3458 case BTK__hlsl_spirv_type: {
3459 assert(Converted.size() == 4);
3462 SemaRef.
Diag(TemplateLoc, diag::err_hlsl_spirv_only) << BTD;
3465 if (llvm::any_of(Converted, [](
auto &
C) {
return C.isDependent(); }))
3468 uint64_t Opcode = Converted[0].getAsIntegral().getZExtValue();
3469 uint64_t Size = Converted[1].getAsIntegral().getZExtValue();
3470 uint64_t Alignment = Converted[2].getAsIntegral().getZExtValue();
3476 for (
auto &OperandTA : OperandArgs) {
3477 QualType OperandArg = OperandTA.getAsType();
3479 TemplateArgs[3].getLocation());
3480 if (!Operand.isValid())
3482 Operands.push_back(Operand);
3487 case BTK__builtin_dedup_pack: {
3488 assert(Converted.size() == 1 &&
"__builtin_dedup_pack should be given "
3489 "a parameter pack");
3498 llvm::SmallDenseSet<QualType> Seen;
3502 if (!Seen.insert(
T.getAsType().getCanonicalType()).second)
3504 OutArgs.push_back(
T);
3510 llvm_unreachable(
"unexpected BuiltinTemplateDecl!");
3529 if (BinOp->getOpcode() == BO_LAnd) {
3536 Terms.push_back(Clause);
3545 if (!BinOp)
return Cond;
3547 if (BinOp->getOpcode() != BO_LOr)
return Cond;
3550 Expr *LHS = BinOp->getLHS();
3552 if (!InnerBinOp)
return Cond;
3554 if (InnerBinOp->getOpcode() != BO_EQ ||
3555 !isa<IntegerLiteral>(InnerBinOp->getRHS()))
3565 if (MacroName ==
"CONCEPT_REQUIRES" || MacroName ==
"CONCEPT_REQUIRES_")
3566 return BinOp->getRHS();
3576class FailedBooleanConditionPrinterHelper :
public PrinterHelper {
3581 bool handledStmt(
Stmt *
E, raw_ostream &OS)
override {
3582 const auto *DR = dyn_cast<DeclRefExpr>(
E);
3583 if (DR && DR->getQualifier()) {
3586 DR->getQualifier().print(OS, Policy,
true);
3590 if (
const auto *IV = dyn_cast<VarTemplateSpecializationDecl>(VD)) {
3593 OS, IV->getTemplateArgs().asArray(), Policy,
3594 IV->getSpecializedTemplate()->getTemplateParameters());
3607std::pair<Expr *, std::string>
3616 Expr *FailedCond =
nullptr;
3617 for (
Expr *Term : Terms) {
3621 if (isa<CXXBoolLiteralExpr>(TermAsWritten) ||
3622 isa<IntegerLiteral>(TermAsWritten))
3631 if (Term->EvaluateAsBooleanCondition(Succeeded,
Context) &&
3633 FailedCond = TermAsWritten;
3640 std::string Description;
3642 llvm::raw_string_ostream Out(Description);
3645 FailedBooleanConditionPrinterHelper Helper(Policy);
3646 FailedCond->
printPretty(Out, &Helper, Policy, 0,
"\n",
nullptr);
3648 return { FailedCond, Description };
3658 Name.getUnderlying().getAsDependentTemplateName();
3659 DTN && DTN->getName().getIdentifier())
3667 if (Name.getAsAssumedTemplateName() &&
3674 Name.getAsSubstTemplateTemplateParmPack()) {
3677 std::tie(
Template, DefaultArgs) = Name.getTemplateDeclAndDefaultArgs();
3680 Diag(TemplateLoc, diag::err_template_id_not_a_type) << Name;
3697 if (isa<TemplateTemplateParmDecl>(
Template)) {
3701 dyn_cast<TypeAliasTemplateDecl>(
Template)) {
3709 SemaRef.
Diag(TemplateLoc, diag::err_tag_reference_non_tag)
3739 std::optional<ContextRAII> SavedContext;
3741 SavedContext.emplace(*
this,
AliasTemplate->getDeclContext());
3746 if (CanonType.
isNull()) {
3752 if (*DeductionInfo &&
3753 (*DeductionInfo)->hasSFINAEDiagnostic() &&
3754 (*DeductionInfo)->peekSFINAEDiagnostic().second.getDiagID() ==
3755 diag::err_typename_nested_not_found_enable_if &&
3756 TemplateArgs[0].getArgument().getKind()
3759 std::string FailedDescription;
3760 std::tie(FailedCond, FailedDescription) =
3766 (*DeductionInfo)->takeSFINAEDiagnostic(OldDiag);
3770 (*DeductionInfo)->addSFINAEDiagnostic(
3772 PDiag(diag::err_typename_nested_not_found_requirement)
3773 << FailedDescription
3781 }
else if (
auto *BTD = dyn_cast<BuiltinTemplateDecl>(
Template)) {
3784 }
else if (Name.isDependent() ||
3805 if (isa<ClassTemplateDecl>(
Template)) {
3808 if (Ctx->isFileContext())
break;
3816 if (!isa<ClassTemplatePartialSpecializationDecl>(
Record) &&
3817 !
Record->getDescribedClassTemplate())
3826 if (CanonType != Injected)
3836 dyn_cast<ClassTemplateDecl>(
Template)) {
3839 void *InsertPos =
nullptr;
3873 assert(isa<RecordType>(CanonType) &&
3874 "type of non-dependent specialization is not a RecordType");
3876 llvm_unreachable(
"Unhandled template kind");
3894 auto *ATN = Name.getAsAssumedTemplateName();
3895 assert(ATN &&
"not an assumed template name");
3896 II = ATN->getDeclName().getAsIdentifierInfo();
3912 assert(ATN &&
"not an assumed template name");
3920 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
3921 return std::make_unique<CandidateCallback>(*
this);
3932 std::nullopt,
false,
3948 SourceLocation RAngleLoc,
bool IsCtorOrDtorName,
bool IsClassName,
3953 if (!IsCtorOrDtorName && !IsClassName && SS.
isSet()) {
3979 TemplateD, TemplateII, TemplateIILoc, LAngleLoc,
3980 TemplateArgsIn, RAngleLoc);
3987 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
3988 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
3991 ? diag::err_out_of_line_qualified_id_type_names_constructor
3992 : diag::ext_out_of_line_qualified_id_type_names_constructor)
3999 if (
Template.getAsAssumedTemplateName() &&
4010 ElaboratedKeyword, *DTN, TemplateArgs.
arguments());
4021 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
4027 TemplateIILoc, TemplateArgs);
4035 TemplateIILoc, TemplateArgs);
4078 for (
unsigned I = 0, N = SpecTL.
getNumArgs(); I != N; ++I)
4093 assert(
Id &&
"templated class must have an identifier");
4097 Diag(TagLoc, diag::err_use_with_wrong_tag)
4136 return TPT && !
Type.hasQualifiers() &&
4145 dyn_cast<NonTypeTemplateParmDecl>(DRE->
getDecl());
4151 dyn_cast_or_null<TemplateTemplateParmDecl>(
4155 llvm_unreachable(
"unexpected kind of template argument");
4161 if (Params->
size() != Args.size() || Params->
size() != SpecParams->
size())
4164 unsigned Depth = Params->
getDepth();
4166 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
4184 if (
auto *SpecNTTP =
4185 dyn_cast<NonTypeTemplateParmDecl>(SpecParams->
getParam(I))) {
4186 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(I));
4187 if (!NTTP || NTTP->getType().getCanonicalType() !=
4188 SpecNTTP->getType().getCanonicalType())
4196template<
typename PartialSpecDecl>
4198 if (Partial->getDeclContext()->isDependentContext())
4207 auto *
Template = Partial->getSpecializedTemplate();
4208 S.
Diag(Partial->getLocation(),
4209 diag::ext_partial_spec_not_more_specialized_than_primary)
4219 diag::note_partial_spec_not_more_specialized_than_primary)
4225 Template->getAssociatedConstraints(TemplateAC);
4226 Partial->getAssociatedConstraints(PartialAC);
4233 const llvm::SmallBitVector &DeducibleParams) {
4234 for (
unsigned I = 0, N = DeducibleParams.size(); I != N; ++I) {
4235 if (!DeducibleParams[I]) {
4248template<
typename PartialSpecDecl>
4250 PartialSpecDecl *Partial) {
4263 auto *TemplateParams = Partial->getTemplateParameters();
4264 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
4266 TemplateParams->getDepth(), DeducibleParams);
4268 if (!DeducibleParams.all()) {
4269 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
4270 S.
Diag(Partial->getLocation(), diag::ext_partial_specs_not_deducible)
4271 << isa<VarTemplatePartialSpecializationDecl>(Partial)
4272 << (NumNonDeducible > 1)
4274 Partial->getTemplateArgsAsWritten()->RAngleLoc);
4295 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
4297 for (
unsigned I = 0; I != TemplateParams->size(); ++I) {
4299 auto *Param = TemplateParams->getParam(I);
4301 DeducibleParams[I] =
true;
4304 if (!DeducibleParams.all()) {
4305 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
4306 Diag(TD->
getLocation(), diag::err_deduction_guide_template_not_deducible)
4307 << (NumNonDeducible > 1);
4318 "Variable template specialization is declared with a template id.");
4331 dyn_cast_or_null<VarTemplateDecl>(Name.getAsTemplateDecl());
4334 if (
auto *OTS = Name.getAsOverloadedTemplate())
4335 FnTemplate = *OTS->begin();
4337 FnTemplate = dyn_cast_or_null<FunctionTemplateDecl>(Name.getAsTemplateDecl());
4339 return Diag(
D.getIdentifierLoc(), diag::err_var_spec_no_template_but_method)
4341 return Diag(
D.getIdentifierLoc(), diag::err_var_spec_no_template)
4345 if (
const auto *DSA =
VarTemplate->getAttr<NoSpecializationsAttr>()) {
4346 auto Message = DSA->getMessage();
4347 Diag(TemplateNameLoc, diag::warn_invalid_specialization)
4349 Diag(DSA->getLoc(), diag::note_marked_here) << DSA;
4353 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
4373 TemplateArgs.
size(),
4379 if (!Name.isDependent() &&
4382 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
4395 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
4405 void *InsertPos =
nullptr;
4409 PrevDecl =
VarTemplate->findPartialSpecialization(
4435 cast_or_null<VarTemplatePartialSpecializationDecl>(PrevDecl);
4444 VarTemplate->AddPartialSpecialization(Partial, InsertPos);
4483 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
4487 diag::note_instantiation_required_here)
4517struct PartialSpecMatchResult {
4525 if (Var->
getName() !=
"format_kind" ||
4546 assert(
Template &&
"A variable template id without template?");
4558 if (
Template->getDeclContext()->isDependentContext() ||
4572 !IsLibstdcxxStdFormatKind(
PP, Var) &&
4576 IsSameTemplateArg)) {
4577 Diag(TemplateNameLoc,
4578 diag::err_auto_variable_cannot_appear_in_own_initializer)
4579 << diag::ParsingInitFor::VarTemplate << Var << Var->
getType();
4584 Template->getPartialSpecializations(PartialSpecs);
4588 Partial->getTemplateArgs().asArray(),
4589 IsSameTemplateArg)) {
4590 Diag(TemplateNameLoc,
4591 diag::err_auto_variable_cannot_appear_in_own_initializer)
4592 << diag::ParsingInitFor::VarTemplatePartialSpec << Partial
4593 << Partial->getType();
4602 void *InsertPos =
nullptr;
4606 if (Spec->getType()->isUndeducedType()) {
4608 Diag(TemplateNameLoc,
4609 diag::err_auto_variable_cannot_appear_in_own_initializer)
4610 << diag::ParsingInitFor::VarTemplateExplicitSpec << Spec
4615 Diag(TemplateNameLoc, diag::err_var_template_spec_type_depends_on_self)
4616 << Spec << Spec->getType();
4630 bool AmbiguousPartialSpec =
false;
4643 Template->getPartialSpecializations(PartialSpecs);
4655 if (
Template->getMostRecentDecl()->isMemberSpecialization() &&
4656 !Partial->getMostRecentDecl()->isMemberSpecialization())
4671 Matched.push_back(PartialSpecMatchResult());
4672 Matched.back().Partial = Partial;
4677 if (Matched.size() >= 1) {
4679 if (Matched.size() == 1) {
4692 PEnd = Matched.end();
4695 PointOfInstantiation) ==
4703 PEnd = Matched.end();
4706 P->Partial, Best->Partial,
4707 PointOfInstantiation) != Best->Partial) {
4708 AmbiguousPartialSpec =
true;
4715 InstantiationPattern = Best->Partial;
4716 PartialSpecArgs = Best->Args;
4728 Template, InstantiationPattern, PartialSpecArgs, TemplateArgs,
4733 if (AmbiguousPartialSpec) {
4736 Diag(PointOfInstantiation, diag::err_partial_spec_ordering_ambiguous)
4741 Diag(
P.Partial->getLocation(), diag::note_partial_spec_match)
4748 dyn_cast<VarTemplatePartialSpecializationDecl>(InstantiationPattern))
4749 Decl->setInstantiationOf(
D, PartialSpecArgs);
4753 assert(
Decl &&
"No variable template specialization?");
4764 if (
Decl.isInvalid())
4783 assert(
Template &&
"A variable template id without template?");
4786 Template->templateParameterKind() !=
4818 Diag(
Loc, diag::err_template_missing_args)
4826 bool TemplateKeyword,
4841 assert(NamedConcept &&
"A concept template id without a template?");
4848 NamedConcept, ConceptNameInfo.
getLoc(),
4861 bool AreArgsDependent =
4871 if (!AreArgsDependent &&
4882 TemplateKWLoc, ConceptNameInfo, FoundDecl, NamedConcept,
4885 Context,
CL, CSD, AreArgsDependent ?
nullptr : &Satisfaction);
4904 assert(!R.
isAmbiguous() &&
"ambiguous lookup when building templateid");
4908 if (!TemplateArgs && !isa<FunctionTemplateDecl>(TD)) {
4914 bool KnownDependent =
false;
4923 KnownDependent =
true;
4941 TemplateKWLoc, TemplateArgs);
4947 R.
begin(), R.
end(), KnownDependent,
4963 assert(TemplateArgs || TemplateKWLoc.
isValid());
4967 false, TemplateKWLoc))
4996 bool EnteringContext,
4998 bool AllowInjectedClassName) {
4999 if (TemplateKWLoc.
isValid() && S && !S->getTemplateParamParent())
5002 diag::warn_cxx98_compat_template_outside_of_template :
5003 diag::ext_template_outside_of_template)
5013 else if (ObjectType)
5032 bool MemberOfUnknownSpecialization;
5034 ObjectType, EnteringContext,
Result,
5035 MemberOfUnknownSpecialization);
5038 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
5039 if (!AllowInjectedClassName && SS.
isNotEmpty() && LookupRD &&
5041 Name.Identifier && LookupRD->getIdentifier() == Name.Identifier) {
5051 Diag(Name.getBeginLoc(),
5052 diag::ext_out_of_line_qualified_id_type_names_constructor)
5060 if (!MemberOfUnknownSpecialization) {
5077 Diag(Name.getBeginLoc(), diag::err_no_member)
5080 Diag(Name.getBeginLoc(), diag::err_undeclared_use)
5088 switch (Name.getKind()) {
5091 {Qualifier, Name.Identifier, TemplateKWLoc.isValid()}));
5096 {Qualifier, Name.OperatorFunctionId.Operator,
5097 TemplateKWLoc.isValid()}));
5111 Diag(Name.getBeginLoc(),
5112 diag::err_template_kw_refers_to_dependent_non_template)
5114 << TemplateKWLoc.
isValid() << TemplateKWLoc;
5151 dyn_cast<DependentScopeDeclRefExpr>(Arg.
getAsExpr())) {
5152 SS.
Adopt(ArgExpr->getQualifierLoc());
5153 NameInfo = ArgExpr->getNameInfo();
5155 dyn_cast<CXXDependentScopeMemberExpr>(Arg.
getAsExpr())) {
5156 if (ArgExpr->isImplicitAccess()) {
5157 SS.
Adopt(ArgExpr->getQualifierLoc());
5158 NameInfo = ArgExpr->getMemberNameInfo();
5167 Result.wasNotFoundInCurrentInstantiation()) {
5168 assert(SS.
getScopeRep() &&
"dependent scope expr must has a scope!");
5172 ? diag::ext_ms_template_type_arg_missing_typename
5173 : diag::err_template_arg_must_be_type_suggest)
5205 SugaredConverted.push_back(Arg);
5206 CanonicalConverted.push_back(Arg);
5212 Diag(SR.
getBegin(), diag::err_template_arg_must_be_type) << SR;
5234 CanonicalConverted.push_back(
5283 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
5286 bool ForLambdaCallOperator =
false;
5287 if (
const auto *Rec = dyn_cast<CXXRecordDecl>(
Template->getDeclContext()))
5288 ForLambdaCallOperator = Rec->isLambda();
5290 !ForLambdaCallOperator);
5338 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
5345 TemplateArgLists, Output);
5382 SugaredConverted,
SourceRange(TemplateLoc, RAngleLoc));
5389 for (
unsigned i = 0, e = Param->
getDepth(); i != e; ++i)
5406 HasDefaultArg =
false;
5412 HasDefaultArg =
true;
5415 RAngleLoc, TypeParm, SugaredConverted,
5416 CanonicalConverted, Output))
5422 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
5426 HasDefaultArg =
true;
5429 RAngleLoc, NonTypeParm, SugaredConverted,
5430 CanonicalConverted, Output))
5436 = cast<TemplateTemplateParmDecl>(Param);
5440 HasDefaultArg =
true;
5444 *
this,
Template, TemplateKWLoc, TemplateNameLoc, RAngleLoc, TempTempParm,
5445 SugaredConverted, CanonicalConverted, QualifierLoc);
5469 TemplateName Name = TagLoc.getTypePtr()->getTemplateName(Context);
5475 TagLoc.getQualifierLoc(), TagLoc.getNameLoc());
5482 unsigned ArgumentPackIndex,
5496 QualType NTTPType = NTTP->getType();
5497 if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack())
5498 NTTPType = NTTP->getExpansionType(ArgumentPackIndex);
5501 !isa<TemplateTemplateParmDecl>(
Template) &&
5502 !
Template->getDeclContext()->isDependentContext()) {
5515 NTTPType =
SubstType(PET->getPattern(), MLTAL, NTTP->getLocation(),
5516 NTTP->getDeclName());
5518 NTTPType =
SubstType(NTTPType, MLTAL, NTTP->getLocation(),
5519 NTTP->getDeclName());
5526 NTTP->getLocation());
5531 auto checkExpr = [&](
Expr *
E) ->
Expr * {
5535 NTTP, NTTPType,
E, SugaredResult, CanonicalResult,
5547 llvm_unreachable(
"Should never see a NULL template argument here");
5551 Expr *R = checkExpr(
E);
5577 if (!checkExpr(R.
get()))
5616 NTTP, NTTPType,
E.get(), SugaredResult, CanonicalResult,
5649 Diag(SR.
getBegin(), diag::err_template_arg_nontype_ambig) << SR <<
T;
5651 Diag(SR.
getBegin(), diag::err_template_arg_must_be_expr) << SR;
5657 llvm_unreachable(
"Caller must expand template argument packs");
5702 ArgLoc = ConvertedArg;
5707 llvm_unreachable(
"Should never see a NULL template argument here");
5746 llvm_unreachable(
"non-type argument with template template parameter");
5749 llvm_unreachable(
"Caller must expand template argument packs");
5756template<
typename TemplateParmDecl>
5759 const TemplateParmDecl *
D,
5764 ->getTemplateParameters()
5765 ->getParam(
D->getIndex()));
5772 D->getDefaultArgumentLoc(), Modules,
5783 S.
Diag(
Loc, diag::err_template_arg_list_different_arity)
5816 bool isTemplateTemplateParameter = isa<TemplateTemplateParmDecl>(
Template);
5819 unsigned ArgIdx = 0, NumArgs = NewArgs.
size();
5822 ParamEnd = Params->
end(),
5826 if (
size_t ParamIdx = Param - ParamBegin;
5829 assert(ArgIdx == NumArgs &&
"bad default argument deduction");
5831 assert(Param + DefaultArgs.
Args.size() <= ParamEnd);
5846 if (*Expansions == SugaredArgumentPack.size()) {
5851 SugaredArgumentPack.clear();
5855 CanonicalArgumentPack.clear();
5860 }
else if (ArgIdx == NumArgs && !PartialTemplateArgs) {
5862 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
5874 dyn_cast<NonTypeTemplateParmDecl>(*Param);
5876 auto TL = NTTP->getTypeSourceInfo()
5881 for (
const auto &UPP : Unexpanded) {
5887 Diag(TL.getEllipsisLoc(),
5888 diag::err_unsupported_builtin_template_pack_expansion)
5889 << TST->getTemplateName();
5894 if (ArgIdx < NumArgs) {
5896 bool NonPackParameter =
5906 if (!(*Param)->isTemplateParameterPack() ||
5913 RAngleLoc, SugaredArgumentPack.size(), CTAI,
5928 RAngleLoc, SugaredArgumentPack.size(), CTAI,
5935 if (ArgIsExpansion && NonPackParameter) {
5939 if (isa<TypeAliasTemplateDecl, ConceptDecl>(
Template)) {
5941 diag::err_template_expansion_into_fixed_list)
5942 << (isa<ConceptDecl>(
Template) ? 1 : 0)
5953 if (ArgIsExpansion && (CTAI.
MatchingTTP || NonPackParameter)) {
5957 if (!SugaredArgumentPack.empty()) {
5961 SugaredArgumentPack.begin(),
5962 SugaredArgumentPack.end());
5963 SugaredArgumentPack.clear();
5966 CanonicalArgumentPack.begin(),
5967 CanonicalArgumentPack.end());
5968 CanonicalArgumentPack.clear();
5971 while (ArgIdx < NumArgs) {
5982 if ((*Param)->isTemplateParameterPack()) {
5997 if (PartialTemplateArgs) {
5998 if ((*Param)->isTemplateParameterPack() && !SugaredArgumentPack.empty()) {
6009 if ((*Param)->isTemplateParameterPack()) {
6011 "Should have dealt with this already");
6016 if (Param + 1 != ParamEnd) {
6018 (
Template->getMostRecentDecl()->getKind() != Decl::Kind::Concept) &&
6019 "Concept templates must have parameter packs at the end.");
6025 SugaredArgumentPack.clear();
6029 CanonicalArgumentPack.clear();
6048 if (!HasDefaultArg) {
6053 dyn_cast<NonTypeTemplateParmDecl>(*Param))
6057 cast<TemplateTemplateParmDecl>(*Param),
6087 if (isTemplateTemplateParameter)
6102 while (ArgIdx < NumArgs &&
6103 NewArgs[ArgIdx].
getArgument().isPackExpansion()) {
6113 if (ArgIdx < NumArgs) {
6114 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
6125 if (UpdateArgsWithConversions)
6126 TemplateArgs = std::move(NewArgs);
6128 if (!PartialTemplateArgs) {
6135 if (
auto *TD = dyn_cast<TemplateDecl>(NewContext))
6137 auto *RD = dyn_cast<CXXRecordDecl>(NewContext);
6141 dyn_cast_or_null<CXXMethodDecl>(
Template->getTemplatedDecl()))
6142 ThisQuals =
Method->getMethodQualifiers();
6165 class UnnamedLocalNoLinkageFinder
6166 :
public TypeVisitor<UnnamedLocalNoLinkageFinder, bool>
6174 UnnamedLocalNoLinkageFinder(
Sema &S,
SourceRange SR) : S(S), SR(SR) { }
6177 return T.isNull() ?
false : inherited::Visit(
T.getTypePtr());
6180#define TYPE(Class, Parent) \
6181 bool Visit##Class##Type(const Class##Type *);
6182#define ABSTRACT_TYPE(Class, Parent) \
6183 bool Visit##Class##Type(const Class##Type *) { return false; }
6184#define NON_CANONICAL_TYPE(Class, Parent) \
6185 bool Visit##Class##Type(const Class##Type *) { return false; }
6186#include "clang/AST/TypeNodes.inc"
6188 bool VisitTagDecl(
const TagDecl *Tag);
6193bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(
const BuiltinType*) {
6197bool UnnamedLocalNoLinkageFinder::VisitComplexType(
const ComplexType*
T) {
6198 return Visit(
T->getElementType());
6201bool UnnamedLocalNoLinkageFinder::VisitPointerType(
const PointerType*
T) {
6205bool UnnamedLocalNoLinkageFinder::VisitBlockPointerType(
6210bool UnnamedLocalNoLinkageFinder::VisitLValueReferenceType(
6215bool UnnamedLocalNoLinkageFinder::VisitRValueReferenceType(
6220bool UnnamedLocalNoLinkageFinder::VisitMemberPointerType(
6224 if (
auto *RD =
T->getMostRecentCXXRecordDecl())
6225 return VisitTagDecl(RD);
6226 return VisitNestedNameSpecifier(
T->getQualifier());
6229bool UnnamedLocalNoLinkageFinder::VisitConstantArrayType(
6231 return Visit(
T->getElementType());
6234bool UnnamedLocalNoLinkageFinder::VisitIncompleteArrayType(
6236 return Visit(
T->getElementType());
6239bool UnnamedLocalNoLinkageFinder::VisitVariableArrayType(
6241 return Visit(
T->getElementType());
6244bool UnnamedLocalNoLinkageFinder::VisitDependentSizedArrayType(
6246 return Visit(
T->getElementType());
6249bool UnnamedLocalNoLinkageFinder::VisitDependentSizedExtVectorType(
6251 return Visit(
T->getElementType());
6254bool UnnamedLocalNoLinkageFinder::VisitDependentSizedMatrixType(
6256 return Visit(
T->getElementType());
6259bool UnnamedLocalNoLinkageFinder::VisitDependentAddressSpaceType(
6264bool UnnamedLocalNoLinkageFinder::VisitVectorType(
const VectorType*
T) {
6265 return Visit(
T->getElementType());
6268bool UnnamedLocalNoLinkageFinder::VisitDependentVectorType(
6270 return Visit(
T->getElementType());
6273bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(
const ExtVectorType*
T) {
6274 return Visit(
T->getElementType());
6277bool UnnamedLocalNoLinkageFinder::VisitConstantMatrixType(
6279 return Visit(
T->getElementType());
6282bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
6292bool UnnamedLocalNoLinkageFinder::VisitFunctionNoProtoType(
6297bool UnnamedLocalNoLinkageFinder::VisitUnresolvedUsingType(
6302bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(
const TypeOfExprType*) {
6306bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(
const TypeOfType*
T) {
6307 return Visit(
T->getUnmodifiedType());
6310bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(
const DecltypeType*) {
6314bool UnnamedLocalNoLinkageFinder::VisitPackIndexingType(
6319bool UnnamedLocalNoLinkageFinder::VisitUnaryTransformType(
6324bool UnnamedLocalNoLinkageFinder::VisitAutoType(
const AutoType *
T) {
6325 return Visit(
T->getDeducedType());
6328bool UnnamedLocalNoLinkageFinder::VisitDeducedTemplateSpecializationType(
6330 return Visit(
T->getDeducedType());
6333bool UnnamedLocalNoLinkageFinder::VisitRecordType(
const RecordType*
T) {
6334 return VisitTagDecl(
T->getOriginalDecl()->getDefinitionOrSelf());
6337bool UnnamedLocalNoLinkageFinder::VisitEnumType(
const EnumType*
T) {
6338 return VisitTagDecl(
T->getOriginalDecl()->getDefinitionOrSelf());
6341bool UnnamedLocalNoLinkageFinder::VisitTemplateTypeParmType(
6346bool UnnamedLocalNoLinkageFinder::VisitSubstTemplateTypeParmPackType(
6351bool UnnamedLocalNoLinkageFinder::VisitSubstBuiltinTemplatePackType(
6356bool UnnamedLocalNoLinkageFinder::VisitTemplateSpecializationType(
6361bool UnnamedLocalNoLinkageFinder::VisitInjectedClassNameType(
6363 return VisitTagDecl(
T->getOriginalDecl()->getDefinitionOrSelf());
6366bool UnnamedLocalNoLinkageFinder::VisitDependentNameType(
6368 return VisitNestedNameSpecifier(
T->getQualifier());
6371bool UnnamedLocalNoLinkageFinder::VisitDependentTemplateSpecializationType(
6373 return VisitNestedNameSpecifier(
T->getDependentTemplateName().getQualifier());
6376bool UnnamedLocalNoLinkageFinder::VisitPackExpansionType(
6378 return Visit(
T->getPattern());
6381bool UnnamedLocalNoLinkageFinder::VisitObjCObjectType(
const ObjCObjectType *) {
6385bool UnnamedLocalNoLinkageFinder::VisitObjCInterfaceType(
6390bool UnnamedLocalNoLinkageFinder::VisitObjCObjectPointerType(
6395bool UnnamedLocalNoLinkageFinder::VisitAtomicType(
const AtomicType*
T) {
6396 return Visit(
T->getValueType());
6399bool UnnamedLocalNoLinkageFinder::VisitPipeType(
const PipeType*
T) {
6403bool UnnamedLocalNoLinkageFinder::VisitBitIntType(
const BitIntType *
T) {
6407bool UnnamedLocalNoLinkageFinder::VisitArrayParameterType(
6409 return VisitConstantArrayType(
T);
6412bool UnnamedLocalNoLinkageFinder::VisitDependentBitIntType(
6417bool UnnamedLocalNoLinkageFinder::VisitTagDecl(
const TagDecl *Tag) {
6418 if (
Tag->getDeclContext()->isFunctionOrMethod()) {
6420 ? diag::warn_cxx98_compat_template_arg_local_type
6421 : diag::ext_template_arg_local_type)
6426 if (!
Tag->hasNameForLinkage()) {
6427 S.
Diag(SR.getBegin(),
6429 diag::warn_cxx98_compat_template_arg_unnamed_type :
6430 diag::ext_template_arg_unnamed_type) << SR;
6431 S.
Diag(
Tag->getLocation(), diag::note_template_unnamed_type_here);
6438bool UnnamedLocalNoLinkageFinder::VisitNestedNameSpecifier(
6449 llvm_unreachable(
"Invalid NestedNameSpecifier::Kind!");
6452bool UnnamedLocalNoLinkageFinder::VisitHLSLAttributedResourceType(
6454 if (
T->hasContainedType() && Visit(
T->getContainedType()))
6456 return Visit(
T->getWrappedType());
6459bool UnnamedLocalNoLinkageFinder::VisitHLSLInlineSpirvType(
6461 for (
auto &Operand :
T->getOperands())
6463 if (Visit(
Operand.getResultType()))
6469 assert(ArgInfo &&
"invalid TypeSourceInfo");
6475 return Diag(SR.
getBegin(), diag::err_variably_modified_template_arg) << Arg;
6477 return Diag(SR.
getBegin(), diag::err_template_arg_overload_type) << SR;
6488 UnnamedLocalNoLinkageFinder Finder(*
this, SR);
6489 (void)Finder.Visit(CanonArg);
6506 Decl *Entity =
nullptr) {
6512 if (Entity && Entity->hasAttr<DLLImportAttr>())
6517 "Incomplete parameter type in isNullPointerValueTemplateArgument!");
6530 EvalResult.
Diag = &Notes;
6538 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
6539 diag::note_invalid_subexpr_in_const_expr) {
6540 DiagLoc = Notes[0].first;
6544 S.
Diag(DiagLoc, diag::err_template_arg_not_address_constant)
6546 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
6547 S.
Diag(Notes[I].first, Notes[I].second);
6565 bool ObjCLifetimeConversion;
6568 ObjCLifetimeConversion))
6573 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
6592 std::string Code =
"static_cast<" + ParamType.
getAsString() +
">(";
6593 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_untyped_null_constant)
6613 bool ObjCLifetimeConversion;
6617 ObjCLifetimeConversion)) {
6622 if (!ParamRef->getPointeeType()->isFunctionType()) {
6632 unsigned ParamQuals = ParamRef->getPointeeType().getCVRQualifiers();
6635 if ((ParamQuals | ArgQuals) != ParamQuals) {
6637 diag::err_template_arg_ref_bind_ignores_quals)
6674 bool AddressTaken =
false;
6681 bool ExtWarnMSTemplateArg =
false;
6684 while (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(Arg)) {
6686 if (UnOpKind == UO_Deref)
6687 ExtWarnMSTemplateArg =
true;
6688 if (UnOpKind == UO_AddrOf || UnOpKind == UO_Deref) {
6691 FirstOpKind = UnOpKind;
6692 FirstOpLoc = UnOp->getOperatorLoc();
6698 if (ExtWarnMSTemplateArg)
6702 if (FirstOpKind == UO_AddrOf)
6703 AddressTaken =
true;
6707 assert(FirstOpKind == UO_Deref);
6730 bool ExtraParens =
false;
6732 if (!
Invalid && !ExtraParens) {
6738 Arg =
Parens->getSubExpr();
6742 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6746 if (UnOp->getOpcode() == UO_AddrOf) {
6747 Arg = UnOp->getSubExpr();
6748 AddressTaken =
true;
6749 AddrOpLoc = UnOp->getOperatorLoc();
6754 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6759 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Arg))
6760 Entity = DRE->getDecl();
6762 Entity = CUE->getGuidDecl();
6769 S.
Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
6772 CanonicalConverted =
6789 CanonicalConverted =
6802 if (isa<FieldDecl>(Entity) || isa<IndirectFieldDecl>(Entity)) {
6811 if (!
Method->isStatic()) {
6820 VarDecl *Var = dyn_cast<VarDecl>(Entity);
6821 MSGuidDecl *Guid = dyn_cast<MSGuidDecl>(Entity);
6824 if (!
Func && !Var && !Guid) {
6836 ? diag::warn_cxx98_compat_template_arg_object_internal
6837 : diag::ext_template_arg_object_internal)
6839 S.
Diag(Entity->
getLocation(), diag::note_template_arg_internal_object)
6844 S.
Diag(Entity->
getLocation(), diag::note_template_arg_internal_object)
6873 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
6879 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
6921 CanonicalConverted =
6935 Expr *Arg = ResultArg;
6936 bool ObjCLifetimeConversion;
6948 bool ExtraParens =
false;
6950 if (!
Invalid && !ExtraParens) {
6956 Arg =
Parens->getSubExpr();
6960 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6965 if (UnOp->getOpcode() == UO_AddrOf) {
6966 DRE = dyn_cast<DeclRefExpr>(UnOp->getSubExpr());
6972 else if ((DRE = dyn_cast<DeclRefExpr>(Arg))) {
6975 if (isa<NonTypeTemplateParmDecl>(VD)) {
6978 CanonicalConverted =
6982 CanonicalConverted =
7001 S.
Diag(ResultArg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
7013 ObjCLifetimeConversion)) {
7020 S.
Diag(ResultArg->
getBeginLoc(), diag::err_template_arg_not_convertible)
7028 diag::err_template_arg_not_pointer_to_member_form)
7031 if (isa<FieldDecl>(DRE->
getDecl()) ||
7032 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
7033 isa<CXXMethodDecl>(DRE->
getDecl())) {
7034 assert((isa<FieldDecl>(DRE->
getDecl()) ||
7035 isa<IndirectFieldDecl>(DRE->
getDecl()) ||
7036 cast<CXXMethodDecl>(DRE->
getDecl())
7037 ->isImplicitObjectMemberFunction()) &&
7038 "Only non-static member pointers can make it here");
7044 CanonicalConverted =
7049 CanonicalConverted =
7057 S.
Diag(Arg->
getBeginLoc(), diag::err_template_arg_not_pointer_to_member_form)
7077 auto *ArgPE = dyn_cast<PackExpansionExpr>(Arg);
7078 Expr *DeductionArg = ArgPE ? ArgPE->getPattern() : Arg;
7079 auto setDeductionArg = [&](
Expr *NewDeductionArg) {
7080 DeductionArg = NewDeductionArg;
7084 DeductionArg, ArgPE->getEllipsisLoc(), ArgPE->getNumExpansions());
7099 auto *AT = dyn_cast<AutoType>(DeducedT);
7100 if (AT && AT->isDecltypeAuto()) {
7113 if (isa<DeducedTemplateSpecializationType>(DeducedT)) {
7117 DeductionArg->
getBeginLoc(),
false, DeductionArg);
7118 Expr *Inits[1] = {DeductionArg};
7139 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
7141 diag::err_non_type_template_parm_type_deduction_failure)
7154 if (ParamType.
isNull()) {
7162 "non-type template parameter type cannot be qualified");
7175 setDeductionArg(
E.get());
7193 Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
7206 if (ArgPE && !StrictCheck) {
7222 if (ParamType->
isRecordType() && isa<DeclRefExpr>(InnerArg) &&
7224 NamedDecl *ND = cast<DeclRefExpr>(InnerArg)->getDecl();
7225 if (
auto *TPO = dyn_cast<TemplateParamObjectDecl>(ND)) {
7232 if (isa<NonTypeTemplateParmDecl>(ND)) {
7234 CanonicalConverted =
7245 bool IsConvertedConstantExpression =
true;
7246 if (isa<InitListExpr>(DeductionArg) || ParamType->
isRecordType()) {
7248 StartLoc,
false, DeductionArg);
7249 Expr *Inits[1] = {DeductionArg};
7264 IsConvertedConstantExpression =
false;
7273 if (IsConvertedConstantExpression) {
7275 DeductionArg, ParamType,
7283 ArgResult = DeductionArg;
7289 setDeductionArg(ArgResult.
get());
7291 CanonicalConverted =
7299 false, PreNarrowingValue);
7302 setDeductionArg(ArgResult.
get());
7304 if (
Value.isLValue()) {
7317 isa<LifetimeExtendedTemporaryDecl, UnnamedGlobalConstantDecl>(VD))) {
7323 if (
Value.hasLValuePath() &&
Value.getLValuePath().size() == 1 && VD &&
7325 Value.getLValuePath()[0].getAsArrayIndex() == 0 &&
7329 CanonicalConverted =
7333 CanonicalConverted =
7342 if (!
Value.hasLValuePath() ||
Value.getLValuePath().size() ||
7343 Value.isLValueOnePastTheEnd()) {
7344 Diag(StartLoc, diag::err_non_type_template_arg_subobject)
7349 "null reference should not be a constant expression");
7351 "non-null value of type nullptr_t?");
7355 if (
Value.isAddrLabelDiff())
7356 return Diag(StartLoc, diag::err_non_type_template_arg_addr_label_diff);
7360 CanonicalConverted =
7364 CanonicalConverted =
7400 setDeductionArg(ArgResult.
get());
7405 CanonicalConverted =
7415 IntegerType = ED->getIntegerType();
7422 CanonicalConverted =
7435 DeductionArg = ArgResult.
get();
7448 Diag(StartLoc, diag::err_template_arg_not_integral_or_enumeral)
7461 return S.
Diag(
Loc, diag::err_template_arg_not_ice) <<
T;
7463 } Diagnoser(ArgType);
7491 Diag(StartLoc, diag::err_template_arg_not_convertible)
7492 << DeductionArg->
getType() << ParamType
7497 setDeductionArg(DeductionArg);
7506 CanonicalConverted =
7513 IntegerType = ED->getIntegerType();
7520 if (
Value.getBitWidth() != AllowedBits)
7524 llvm::APSInt OldValue =
Value;
7531 if (
Value.getBitWidth() != AllowedBits)
7537 (OldValue.isSigned() && OldValue.isNegative())) {
7545 unsigned RequiredBits;
7547 RequiredBits = OldValue.getActiveBits();
7548 else if (OldValue.isUnsigned())
7549 RequiredBits = OldValue.getActiveBits() + 1;
7551 RequiredBits = OldValue.getSignificantBits();
7552 if (RequiredBits > AllowedBits) {
7562 CanonicalConverted =
7567 CanonicalConverted =
7610 DeductionArg = Res.
get();
7615 setDeductionArg(DeductionArg);
7619 *
this, Param, ParamType, Arg, SugaredConverted,
7620 CanonicalConverted))
7626 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
7631 setDeductionArg(DeductionArg);
7639 "Only object pointers allowed here");
7643 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
7655 assert(ParamRefType->getPointeeType()->isIncompleteOrObjectType() &&
7656 "Only object references allowed here");
7661 ParamRefType->getPointeeType(),
7676 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
7685 CanonicalConverted =
7694 << DeductionArg->
getType() << ParamType;
7702 Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
7705 CanonicalConverted =
7710 CanonicalConverted =
7724 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
7747 unsigned DiagFoundKind = 0;
7749 if (
auto *TTP = llvm::dyn_cast<TemplateTemplateParmDecl>(
Template)) {
7750 switch (TTP->templateParameterKind()) {
7761 Kind = TTP->templateParameterKind();
7762 }
else if (isa<ConceptDecl>(
Template)) {
7765 }
else if (isa<FunctionTemplateDecl>(
Template)) {
7768 }
else if (isa<VarTemplateDecl>(
Template)) {
7771 }
else if (isa<ClassTemplateDecl>(
Template) ||
7772 isa<TypeAliasTemplateDecl>(
Template) ||
7773 isa<BuiltinTemplateDecl>(
Template)) {
7777 assert(
false &&
"Unexpected Decl");
7784 unsigned DiagKind = 0;
7798 Diag(
Template->getLocation(), diag::note_template_arg_refers_to_template_here)
7812 bool *StrictPackMatch) {
7814 auto [
Template, DefaultArgs] = Name.getTemplateDeclAndDefaultArgs();
7817 assert(Name.isDependent() &&
"Non-dependent template isn't a declaration?");
7844 if (ParamsAC.empty())
7847 Template->getAssociatedConstraints(TemplateAC);
7849 bool IsParamAtLeastAsConstrained;
7851 IsParamAtLeastAsConstrained))
7853 if (!IsParamAtLeastAsConstrained) {
7855 diag::err_template_template_parameter_not_at_least_as_constrained)
7867 unsigned HereDiagID,
7868 unsigned ExternalDiagID) {
7873 llvm::raw_svector_ostream Out(Str);
7881 std::optional<SourceRange> ParamRange) {
7884 diag::note_template_decl_external);
7885 if (ParamRange && ParamRange->isValid()) {
7887 "Parameter range has location when Decl does not");
7894 diag::note_template_param_external);
7921 ? CK_NullToMemberPointer
7922 : CK_NullToPointer);
7925 "Only declaration template arguments permitted here");
7934 (isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD) ||
7935 isa<IndirectFieldDecl>(VD)));
7961 assert(isa<TemplateParamObjectDecl>(VD) &&
7962 "arg for class template param not a template parameter object");
7967 "unexpected type for decl template argument");
7969 dyn_cast_if_present<NonTypeTemplateParmDecl>(
TemplateParam)) {
7970 QualType TemplateParamType = NTTP->getType();
7984 "value kind mismatch for non-type template argument");
8003 "unexpected conversion required for non-type template argument");
8030 T = ED->getIntegerType();
8081 llvm_unreachable(
"unexpected template argument value");
8106 return MakeInitList(
8119 return MakeInitList(Elts);
8124 llvm_unreachable(
"Unexpected APValue kind.");
8140 llvm_unreachable(
"Unhandled APValue::ValueKind enum");
8152 llvm_unreachable(
"not a non-type template argument");
8170 llvm_unreachable(
"Unhandled TemplateArgument::ArgKind enum");
8177 const NamedDecl *OldInstFrom,
bool Complain,
8182 unsigned NextDiag = diag::err_template_param_different_kind;
8183 if (TemplateArgLoc.
isValid()) {
8184 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
8185 NextDiag = diag::note_template_param_different_kind;
8187 S.
Diag(
New->getLocation(), NextDiag)
8202 unsigned NextDiag = diag::err_template_parameter_pack_non_pack;
8203 if (TemplateArgLoc.
isValid()) {
8204 S.
Diag(TemplateArgLoc,
8205 diag::err_template_arg_template_params_mismatch);
8206 NextDiag = diag::note_template_parameter_pack_non_pack;
8209 unsigned ParamKind = isa<TemplateTypeParmDecl>(
New)? 0
8210 : isa<NonTypeTemplateParmDecl>(
New)? 1
8212 S.
Diag(
New->getLocation(), NextDiag)
8213 << ParamKind <<
New->isParameterPack();
8222 dyn_cast<NonTypeTemplateParmDecl>(Old)) {
8230 (!OldNTTP->getType()->isDependentType() &&
8240 unsigned NextDiag = diag::err_template_nontype_parm_different_type;
8241 if (TemplateArgLoc.
isValid()) {
8242 S.
Diag(TemplateArgLoc,
8243 diag::err_template_arg_template_params_mismatch);
8244 NextDiag = diag::note_template_nontype_parm_different_type;
8248 S.
Diag(OldNTTP->getLocation(),
8249 diag::note_template_nontype_parm_prev_declaration)
8250 << OldNTTP->getType();
8260 dyn_cast<TemplateTemplateParmDecl>(Old)) {
8266 OldTTP->getTemplateParameters(), Complain,
8276 !isa<TemplateTemplateParmDecl>(Old)) {
8277 const Expr *NewC =
nullptr, *OldC =
nullptr;
8279 if (isa<TemplateTypeParmDecl>(
New)) {
8280 if (
const auto *TC = cast<TemplateTypeParmDecl>(
New)->getTypeConstraint())
8281 NewC = TC->getImmediatelyDeclaredConstraint();
8282 if (
const auto *TC = cast<TemplateTypeParmDecl>(Old)->getTypeConstraint())
8283 OldC = TC->getImmediatelyDeclaredConstraint();
8284 }
else if (isa<NonTypeTemplateParmDecl>(
New)) {
8285 if (
const Expr *
E = cast<NonTypeTemplateParmDecl>(
New)
8286 ->getPlaceholderTypeConstraint())
8288 if (
const Expr *
E = cast<NonTypeTemplateParmDecl>(Old)
8289 ->getPlaceholderTypeConstraint())
8292 llvm_unreachable(
"unexpected template parameter type");
8294 auto Diagnose = [&] {
8296 diag::err_template_different_type_constraint);
8298 diag::note_template_prev_declaration) << 0;
8301 if (!NewC != !OldC) {
8328 unsigned NextDiag = diag::err_template_param_list_different_arity;
8329 if (TemplateArgLoc.
isValid()) {
8330 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
8331 NextDiag = diag::note_template_param_list_different_arity;
8333 S.
Diag(
New->getTemplateLoc(), NextDiag)
8334 << (
New->size() > Old->
size())
8346 if (Old->
size() !=
New->size()) {
8363 OldParmEnd = Old->
end();
8364 OldParm != OldParmEnd; ++OldParm, ++NewParm) {
8365 if (NewParm == NewParmEnd) {
8372 OldInstFrom, Complain, Kind,
8378 if (NewParm != NewParmEnd) {
8387 const Expr *NewRC =
New->getRequiresClause();
8392 diag::err_template_different_requires_clause);
8394 diag::note_template_prev_declaration) << 0;
8397 if (!NewRC != !OldRC) {
8422 S = S->getDeclParent();
8428 if (Ctx && Ctx->isExternCContext()) {
8435 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
8438 Ctx = Ctx ? Ctx->getRedeclContext() :
nullptr;
8450 if (Ctx->isFileContext())
8455 if (RD->isLocalClass())
8457 diag::err_template_inside_local_class)
8465 diag::err_template_outside_namespace_or_class_scope)
8476 return Record->getTemplateSpecializationKind();
8478 return Function->getTemplateSpecializationKind();
8479 if (
VarDecl *Var = dyn_cast<VarDecl>(
D))
8517 if (isa<ClassTemplateDecl>(Specialized))
8519 else if (isa<VarTemplateDecl>(Specialized))
8521 else if (isa<FunctionTemplateDecl>(Specialized))
8523 else if (isa<CXXMethodDecl>(Specialized))
8525 else if (isa<VarDecl>(Specialized))
8527 else if (isa<RecordDecl>(Specialized))
8529 else if (isa<EnumDecl>(Specialized) && S.
getLangOpts().CPlusPlus11)
8532 S.
Diag(
Loc, diag::err_template_spec_unknown_kind)
8542 S.
Diag(
Loc, diag::err_template_spec_decl_function_scope)
8557 : DC->
Equals(SpecializedContext))) {
8558 if (isa<TranslationUnitDecl>(SpecializedContext))
8559 S.
Diag(
Loc, diag::err_template_spec_redecl_global_scope)
8560 << EntityKind << Specialized;
8562 auto *ND = cast<NamedDecl>(SpecializedContext);
8563 int Diag = diag::err_template_spec_redecl_out_of_scope;
8565 Diag = diag::ext_ms_template_spec_redecl_out_of_scope;
8567 << ND << isa<CXXRecordDecl>(ND);
8570 S.
Diag(Specialized->getLocation(), diag::note_specialized_entity);
8584 DependencyChecker Checker(Depth,
true);
8585 Checker.TraverseStmt(
E);
8586 if (Checker.MatchLoc.isInvalid())
8588 return Checker.MatchLoc;
8594 DependencyChecker Checker(Depth,
true);
8595 Checker.TraverseTypeLoc(TL);
8596 if (Checker.MatchLoc.isInvalid())
8598 return Checker.MatchLoc;
8606 for (
unsigned I = 0; I != NumArgs; ++I) {
8609 S, TemplateNameLoc, Param, Args[I].pack_begin(),
8610 Args[I].pack_size(), IsDefaultArgument))
8623 ArgExpr = Expansion->getPattern();
8627 ArgExpr = ICE->getSubExpr();
8637 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ArgExpr))
8638 if (isa<NonTypeTemplateParmDecl>(DRE->getDecl()))
8641 if (
auto *ULE = dyn_cast<UnresolvedLookupExpr>(ArgExpr);
8663 if (ParamUseRange.
isValid()) {
8664 if (IsDefaultArgument) {
8665 S.
Diag(TemplateNameLoc,
8666 diag::err_dependent_non_type_arg_in_partial_spec);
8668 diag::note_dependent_non_type_default_arg_in_partial_spec)
8672 diag::err_dependent_non_type_arg_in_partial_spec)
8680 if (ParamUseRange.
isValid()) {
8682 diag::err_dependent_typed_non_type_arg_in_partial_spec)
8702 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
8704 = dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->
getParam(I));
8709 Param, &TemplateArgs[I],
8710 1, I >= NumExplicit))
8731 = dyn_cast_or_null<ClassTemplateDecl>(Name.getAsTemplateDecl());
8734 Diag(TemplateNameLoc, diag::err_not_class_template_specialization)
8735 << (Name.getAsTemplateDecl() &&
8736 isa<TemplateTemplateParmDecl>(Name.getAsTemplateDecl()));
8740 if (
const auto *DSA =
ClassTemplate->getAttr<NoSpecializationsAttr>()) {
8741 auto Message = DSA->getMessage();
8742 Diag(TemplateNameLoc, diag::warn_invalid_specialization)
8744 Diag(DSA->getLoc(), diag::note_marked_here) << DSA;
8747 if (S->isTemplateParamScope())
8752 bool isMemberSpecialization =
false;
8753 bool isPartialSpecialization =
false;
8758 TemplateNameLoc, &TemplateId,
8770 KWLoc, TemplateNameLoc, SS, &TemplateId, TemplateParameterLists,
8785 if (TemplateParams && TemplateParams->
size() > 0) {
8786 isPartialSpecialization =
true;
8789 Diag(KWLoc, diag::err_partial_specialization_friend)
8797 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
8800 if (TTP->hasDefaultArgument()) {
8801 Diag(TTP->getDefaultArgumentLoc(),
8802 diag::err_default_arg_in_partial_spec);
8803 TTP->removeDefaultArgument();
8806 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
8807 if (NTTP->hasDefaultArgument()) {
8808 Diag(NTTP->getDefaultArgumentLoc(),
8809 diag::err_default_arg_in_partial_spec)
8810 << NTTP->getDefaultArgument().getSourceRange();
8811 NTTP->removeDefaultArgument();
8817 diag::err_default_arg_in_partial_spec)
8823 }
else if (TemplateParams) {
8825 Diag(KWLoc, diag::err_template_spec_friend)
8832 "should have a 'template<>' for this decl");
8839 "Invalid enum tag in class template spec!");
8843 Diag(KWLoc, diag::err_use_with_wrong_tag)
8848 diag::note_previous_use);
8857 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
8859 isPartialSpecialization
8875 if (isPartialSpecialization) {
8877 TemplateArgs.
size(),
8883 if (!Name.isDependent() &&
8886 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
8888 isPartialSpecialization =
false;
8893 void *InsertPos =
nullptr;
8896 if (isPartialSpecialization)
8910 isPartialSpecialization))
8913 if (!isPartialSpecialization) {
8921 if (TemplateParameterLists.size() > 0) {
8923 TemplateParameterLists);
8945 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
8953 TemplateParameterLists.data());
8958 cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl);
8961 Context, Kind, DC, KWLoc, TemplateNameLoc, TemplateParams,
8965 if (TemplateParameterLists.size() > 1 && SS.
isSet()) {
8967 Context, TemplateParameterLists.drop_back(1));
8971 ClassTemplate->AddPartialSpecialization(Partial, InsertPos);
9000 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
9004 diag::note_instantiation_required_here)
9019 bool HiddenDefVisible =
false;
9020 if (Def && SkipBody &&
9024 if (!HiddenDefVisible && Hidden)
9047 if (ModulePrivateLoc.
isValid())
9049 << (isPartialSpecialization? 1 : 0)
9117 diag::err_concept_decls_may_only_appear_in_global_namespace_scope);
9121 if (TemplateParameterLists.size() > 1) {
9122 Diag(NameLoc, diag::err_concept_extra_headers);
9128 if (Params->
size() == 0) {
9129 Diag(NameLoc, diag::err_concept_no_parameters);
9136 ParamEnd = Params->
end();
9137 ParamIt != ParamEnd; ++ParamIt) {
9138 Decl const *Param = *ParamIt;
9140 if (++ParamIt == ParamEnd)
9143 diag::err_template_param_pack_must_be_last_template_parameter);
9154 Diag(NameLoc, diag::err_concept_no_associated_constraints);
9191 Expr *ConstraintExpr,
9193 assert(!
C->hasDefinition() &&
"Concept already defined");
9195 C->setInvalidDecl();
9198 C->setDefinition(ConstraintExpr);
9209 bool AddToScope =
true;
9213 if (!WasAlreadyAdded && AddToScope)
9226 auto *OldConcept = dyn_cast<ConceptDecl>(
Previous.getRepresentativeDecl()->getUnderlyingDecl());
9228 auto *Old =
Previous.getRepresentativeDecl();
9238 Diag(NewDecl->
getLocation(), diag::err_redefinition_different_concept)
9262 if (
auto *CE = llvm::dyn_cast<ConceptDecl>(
Concept);
9263 CE && !CE->isInvalidDecl() && !CE->hasDefinition()) {
9264 Diag(
Loc, diag::err_recursive_concept) << CE;
9265 Diag(CE->getLocation(), diag::note_declared_at);
9276 if (MinGW || (isa<FunctionDecl>(
D) &&
9277 cast<FunctionDecl>(
D)->isFunctionTemplateSpecialization()))
9278 D->
dropAttrs<DLLImportAttr, DLLExportAttr>();
9281 FD->setInlineSpecified(
false);
9293 Prev = Prev->getPreviousDecl()) {
9294 PrevDiagLoc = Prev->getLocation();
9296 assert(PrevDiagLoc.
isValid() &&
9297 "Explicit instantiation without point of instantiation?");
9307 bool &HasNoEffect) {
9308 HasNoEffect =
false;
9315 "previous declaration must be implicit!");
9328 if (PrevPointOfInstantiation.
isInvalid()) {
9341 PrevPointOfInstantiation.
isValid()) &&
9342 "Explicit instantiation without point of instantiation?");
9356 Diag(NewLoc, diag::err_specialization_after_instantiation)
9358 Diag(PrevPointOfInstantiation, diag::note_instantiation_required_here)
9363 llvm_unreachable(
"The switch over PrevTSK must be exhaustive.");
9393 diag::err_explicit_instantiation_declaration_after_definition);
9399 diag::note_explicit_instantiation_definition_here);
9403 llvm_unreachable(
"Unexpected TemplateSpecializationKind!");
9419 Diag(NewLoc, diag::warn_explicit_instantiation_after_specialization)
9422 diag::note_previous_template_specialization);
9453 ? diag::ext_explicit_instantiation_duplicate
9454 : diag::err_explicit_instantiation_duplicate)
9457 diag::note_previous_explicit_instantiation);
9463 llvm_unreachable(
"Missing specialization/instantiation case?");
9473 enum DiscardReason { NotAFunctionTemplate, NotAMemberOfEnclosing };
9477 if (!isa<FunctionTemplateDecl>(
D)) {
9479 DiscardedCandidates.push_back(std::make_pair(NotAFunctionTemplate,
D));
9486 DiscardedCandidates.push_back(std::make_pair(NotAMemberOfEnclosing,
D));
9494 Diag(FD->
getLocation(), diag::err_dependent_function_template_spec_no_match)
9496 for (
auto &
P : DiscardedCandidates)
9497 Diag(
P.second->getLocation(),
9498 diag::note_dependent_function_template_spec_discard_reason)
9499 <<
P.first << IsFriend;
9504 ExplicitTemplateArgs);
9517 llvm::SmallDenseMap<FunctionDecl *, TemplateArgumentListInfo, 8>
9518 ConvertedTemplateArgs;
9541 if (
auto *NewMD = dyn_cast<CXXMethodDecl>(FD);
9542 !
getLangOpts().CPlusPlus14 && NewMD && NewMD->isConstexpr() &&
9543 !isa<CXXConstructorDecl, CXXDestructorDecl>(NewMD)) {
9544 auto *OldMD = dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl());
9545 if (OldMD && OldMD->isConst()) {
9555 if (ExplicitTemplateArgs)
9556 Args = *ExplicitTemplateArgs;
9568 cast<FunctionTemplateDecl>(FunTmpl->getFirstDecl()),
9569 ExplicitTemplateArgs ? &Args :
nullptr, FT,
Specialization, Info);
9574 I.getPair(), FunTmpl->getTemplatedDecl(),
9590 I.getPair(), FunTmpl->getTemplatedDecl(),
9597 if (ExplicitTemplateArgs)
9606 if (QualifiedFriend && Candidates.
empty()) {
9612 if (
auto *OldFD = dyn_cast<FunctionDecl>(OldND->getUnderlyingDecl()))
9623 PDiag(diag::err_function_template_spec_ambiguous)
9624 << FD->
getDeclName() << (ExplicitTemplateArgs !=
nullptr),
9625 PDiag(diag::note_function_template_spec_matched));
9634 const auto *DSA = PT->getAttr<NoSpecializationsAttr>()) {
9635 auto Message = DSA->getMessage();
9637 << PT << !Message.empty() << Message;
9638 Diag(DSA->getLoc(), diag::note_marked_here) << DSA;
9666 auto *SpecializationFPT =
9677 assert(SpecInfo &&
"Function template specialization info missing?");
9715 bool HasNoEffect =
false;
9730 !isFriend || (InstFrom && InstFrom->getDependentSpecializationInfo())) {
9744 "This must be the only existing declaration of this specialization");
9759 FD->setFunctionTemplateSpecialization(
9762 ExplicitTemplateArgs ? &ConvertedTemplateArgs[
Specialization] :
nullptr);
9781 assert(!
Member->isTemplateDecl() && !
Member->getDescribedTemplate() &&
9782 "Only for non-template members");
9785 NamedDecl *FoundInstantiation =
nullptr;
9795 auto *
Method = dyn_cast<CXXMethodDecl>(Candidate->getUnderlyingDecl());
9813 Method->getTrailingRequiresClause() &&
9817 !Satisfaction.IsSatisfied))
9820 Candidates.
addDecl(Candidate);
9824 if (Candidates.
empty())
9833 auto *
Method = cast<CXXMethodDecl>(I->getUnderlyingDecl());
9841 FoundInstantiation = *Best;
9842 Instantiation = BestMethod;
9850 auto *
Method = cast<CXXMethodDecl>(I->getUnderlyingDecl());
9859 Diag(
Member->getLocation(), diag::err_function_member_spec_ambiguous)
9860 <<
Member << (InstantiatedFrom ? InstantiatedFrom : Instantiation);
9861 for (
NamedDecl *Candidate : Candidates) {
9862 Candidate = Candidate->getUnderlyingDecl();
9863 Diag(Candidate->getLocation(), diag::note_function_member_spec_matched)
9868 }
else if (isa<VarDecl>(
Member)) {
9871 (PrevVar = dyn_cast<VarDecl>(
Previous.getFoundDecl())))
9873 FoundInstantiation =
Previous.getRepresentativeDecl();
9874 Instantiation = PrevVar;
9878 }
else if (isa<RecordDecl>(
Member)) {
9881 (PrevRecord = dyn_cast<CXXRecordDecl>(
Previous.getFoundDecl()))) {
9882 FoundInstantiation =
Previous.getRepresentativeDecl();
9883 Instantiation = PrevRecord;
9887 }
else if (isa<EnumDecl>(
Member)) {
9890 (PrevEnum = dyn_cast<EnumDecl>(
Previous.getFoundDecl()))) {
9891 FoundInstantiation =
Previous.getRepresentativeDecl();
9892 Instantiation = PrevEnum;
9898 if (!Instantiation) {
9912 if (InstantiatedFrom && isa<CXXMethodDecl>(
Member)) {
9913 cast<CXXMethodDecl>(
Member)->setInstantiationOfMemberFunction(
9914 cast<CXXMethodDecl>(InstantiatedFrom),
9916 }
else if (InstantiatedFrom && isa<CXXRecordDecl>(
Member)) {
9917 cast<CXXRecordDecl>(
Member)->setInstantiationOfMemberClass(
9918 cast<CXXRecordDecl>(InstantiatedFrom),
9923 Previous.addDecl(FoundInstantiation);
9928 if (!InstantiatedFrom) {
9929 Diag(
Member->getLocation(), diag::err_spec_member_not_instantiated)
9941 assert(MSInfo &&
"Member specialization info missing?");
9943 bool HasNoEffect =
false;
9955 Instantiation,
Member->getLocation(),
9961 if (
auto *MemberFunction = dyn_cast<FunctionDecl>(
Member)) {
9962 FunctionDecl *InstantiationFunction = cast<FunctionDecl>(Instantiation);
9967 if (InstantiationFunction->
isDeleted()) {
9970 InstantiationFunction);
9976 MemberFunction->setInstantiationOfMemberFunction(
9978 }
else if (
auto *MemberVar = dyn_cast<VarDecl>(
Member)) {
9979 MemberVar->setInstantiationOfStaticDataMember(
9981 }
else if (
auto *MemberClass = dyn_cast<CXXRecordDecl>(
Member)) {
9982 MemberClass->setInstantiationOfMemberClass(
9984 }
else if (
auto *MemberEnum = dyn_cast<EnumDecl>(
Member)) {
9985 MemberEnum->setInstantiationOfMemberEnum(
9988 llvm_unreachable(
"unknown member specialization kind");
9994 Previous.addDecl(FoundInstantiation);
10003template<
typename DeclT>
10014 OrigD->setLocation(
Loc);
10019 NamedDecl *Instantiation = cast<NamedDecl>(
Member->getCanonicalDecl());
10020 if (Instantiation ==
Member)
10023 if (
auto *
Function = dyn_cast<CXXMethodDecl>(Instantiation))
10025 else if (
auto *Var = dyn_cast<VarDecl>(Instantiation))
10027 else if (
auto *
Record = dyn_cast<CXXRecordDecl>(Instantiation))
10029 else if (
auto *
Enum = dyn_cast<EnumDecl>(Instantiation))
10032 llvm_unreachable(
"unknown member specialization kind");
10040 bool WasQualifiedName) {
10045 S.
Diag(InstLoc, diag::err_explicit_instantiation_in_class)
10058 if (WasQualifiedName) {
10059 if (CurContext->
Encloses(OrigContext))
10066 if (
NamespaceDecl *NS = dyn_cast<NamespaceDecl>(OrigContext)) {
10067 if (WasQualifiedName)
10070 diag::err_explicit_instantiation_out_of_scope :
10071 diag::warn_explicit_instantiation_out_of_scope_0x)
10076 diag::err_explicit_instantiation_unqualified_wrong_namespace :
10077 diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x)
10082 diag::err_explicit_instantiation_must_be_global :
10083 diag::warn_explicit_instantiation_must_be_global_0x)
10092 bool WasQualifiedName,
10099 S.
Diag(InstLoc, diag::err_explicit_instantiation_internal_linkage) <<
D;
10125 if (isa<TemplateSpecializationType>(
T))
10136 auto *A = cast_or_null<InheritableAttr>(
getDLLAttr(Def));
10137 assert(A &&
"dllExportImportClassTemplateSpecialization called "
10138 "on Def without dllexport or dllimport");
10143 "delayed exports present at explicit instantiation");
10147 for (
auto &B : Def->
bases()) {
10148 if (
auto *BT = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
10149 B.getType()->getAsCXXRecordDecl()))
10169 "Invalid enum tag in class template explicit instantiation!");
10175 Diag(TemplateNameLoc, diag::err_tag_reference_non_tag) << TD << NTK << Kind;
10181 Kind,
false, KWLoc,
10183 Diag(KWLoc, diag::err_use_with_wrong_tag)
10188 diag::note_previous_use);
10205 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
10207 diag::warn_attribute_dllexport_explicit_instantiation_decl);
10208 Diag(AL.getLoc(), diag::note_attribute);
10213 if (
auto *A =
ClassTemplate->getTemplatedDecl()->getAttr<DLLExportAttr>()) {
10215 diag::warn_attribute_dllexport_explicit_instantiation_decl);
10216 Diag(A->getLocation(), diag::note_attribute);
10222 bool DLLImportExplicitInstantiationDef =
false;
10227 ClassTemplate->getTemplatedDecl()->getAttr<DLLImportAttr>();
10229 if (AL.getKind() == ParsedAttr::AT_DLLImport)
10231 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
10239 DLLImportExplicitInstantiationDef =
true;
10258 void *InsertPos =
nullptr;
10270 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
10272 diag::warn_attribute_dllexport_explicit_instantiation_def);
10284 bool HasNoEffect =
false;
10287 PrevDecl, PrevDecl_TSK,
10304 PrevDecl =
nullptr;
10308 DLLImportExplicitInstantiationDef) {
10310 HasNoEffect =
false;
10325 if (
const auto *A = PrevDecl->
getAttr<MSInheritanceAttr>()) {
10327 Clone->setInherited(
true);
10333 if (!HasNoEffect && !PrevDecl) {
10346 bool PreviouslyDLLExported =
Specialization->hasAttr<DLLExportAttr>();
10371 = cast_or_null<ClassTemplateSpecializationDecl>(
10383 Def = cast_or_null<ClassTemplateSpecializationDecl>(
10391 DLLImportExplicitInstantiationDef)) {
10400 auto *A = cast<InheritableAttr>(
10402 A->setInherited(
true);
10410 bool NewlyDLLExported =
10411 !PreviouslyDLLExported &&
Specialization->hasAttr<DLLExportAttr>();
10427 "Def and Specialization should match for implicit instantiation");
10435 PrevDecl->
hasAttr<DLLExportAttr>()) {
10459 bool Owned =
false;
10460 bool IsDependent =
false;
10468 assert(!IsDependent &&
"explicit instantiation of dependent name not yet handled");
10473 TagDecl *Tag = cast<TagDecl>(TagD);
10474 assert(!Tag->isEnum() &&
"shouldn't see enumerations here");
10476 if (Tag->isInvalidDecl())
10482 Diag(TemplateLoc, diag::err_explicit_instantiation_nontemplate_type)
10484 Diag(
Record->getLocation(), diag::note_nontemplate_decl_here);
10495 Diag(TemplateLoc, diag::ext_explicit_instantiation_without_qualified_id)
10510 = cast_or_null<CXXRecordDecl>(
Record->getPreviousDecl());
10515 bool HasNoEffect =
false;
10516 assert(MSInfo &&
"No member specialization information?");
10528 = cast_or_null<CXXRecordDecl>(
Record->getDefinition());
10536 Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member)
10537 << 0 <<
Record->getDeclName() <<
Record->getDeclContext();
10547 RecordDef = cast_or_null<CXXRecordDecl>(
Record->getDefinition());
10576 if (!
D.isInvalidType())
10578 diag::err_explicit_instantiation_requires_name)
10585 S = S->getDeclParent();
10597 Diag(
D.getIdentifierLoc(), diag::err_explicit_instantiation_of_typedef)
10600 }
else if (
D.getDeclSpec().getStorageClassSpec()
10603 Diag(
D.getIdentifierLoc(), diag::err_explicit_instantiation_storage_class)
10606 D.getMutableDeclSpec().ClearStorageClassSpecs();
10614 if (
D.getDeclSpec().isInlineSpecified())
10615 Diag(
D.getDeclSpec().getInlineSpecLoc(),
10617 diag::err_explicit_instantiation_inline :
10618 diag::warn_explicit_instantiation_inline_0x)
10623 Diag(
D.getDeclSpec().getConstexprSpecLoc(),
10624 diag::err_explicit_instantiation_constexpr);
10629 Diag(
D.getDeclSpec().
getBeginLoc(), diag::err_deduction_guide_specialized)
10660 if (!PrevTemplate) {
10663 Diag(
D.getIdentifierLoc(), diag::err_explicit_instantiation_not_known)
10667 Diag((*P)->getLocation(), diag::note_explicit_instantiation_here);
10673 Diag(
D.getIdentifierLoc(),
10674 diag::err_explicit_instantiation_data_member_not_instantiated)
10689 Diag(
T->getTypeLoc().getBeginLoc(),
10690 diag::err_auto_not_allowed_var_inst);
10698 Diag(
D.getIdentifierLoc(),
10699 diag::err_explicit_instantiation_without_template_id)
10701 Diag(PrevTemplate->getLocation(),
10702 diag::note_explicit_instantiation_here);
10711 D.getIdentifierLoc(), TemplateArgs);
10719 Diag(
D.getIdentifierLoc(), diag::err_explicit_instantiation_dependent);
10725 Prev = cast<VarDecl>(Res.
get());
10739 Diag(
D.getIdentifierLoc(),
10740 diag::ext_explicit_instantiation_without_qualified_id)
10741 << Prev <<
D.getCXXScopeSpec().getRange();
10748 bool HasNoEffect =
false;
10750 PrevTSK, POI, HasNoEffect))
10753 if (!HasNoEffect) {
10756 if (
auto *VTSD = dyn_cast<VarTemplatePartialSpecializationDecl>(Prev)) {
10757 VTSD->setExternKeywordLoc(ExternLoc);
10758 VTSD->setTemplateKeywordLoc(TemplateLoc);
10772 Diag(
T->getTypeLoc().getBeginLoc(),
10773 diag::err_invalid_var_template_spec_type)
10774 << 0 << PrevTemplate << R << Prev->
getType();
10775 Diag(PrevTemplate->getLocation(), diag::note_template_declared_here)
10776 << 2 << PrevTemplate->getDeclName();
10781 return (
Decl*)
nullptr;
10786 bool HasExplicitTemplateArgs =
false;
10790 HasExplicitTemplateArgs =
true;
10805 if (!HasExplicitTemplateArgs) {
10810 if (
Method->getPrimaryTemplate()) {
10814 C.FoundDecl =
P.getPair();
10818 if (
Method->getTrailingRequiresClause() &&
10837 FunTmpl, (HasExplicitTemplateArgs ? &TemplateArgs :
nullptr), R,
10868 if (!NonTemplateMatches.
empty()) {
10879 Msg = diag::err_explicit_instantiation_ambiguous;
10883 Msg = diag::err_explicit_instantiation_no_candidate;
10899 TemplateMatches.
begin(), TemplateMatches.
end(),
10900 FailedTemplateCandidates,
D.getIdentifierLoc(),
10901 PDiag(diag::err_explicit_instantiation_not_known) << Name,
10902 PDiag(diag::err_explicit_instantiation_ambiguous) << Name,
10903 PDiag(diag::note_explicit_instantiation_candidate));
10919 if (FPT->hasExceptionSpec()) {
10921 diag::err_mismatched_exception_spec_explicit_instantiation;
10923 DiagID = diag::ext_mismatched_exception_spec_explicit_instantiation;
10926 PDiag(diag::note_explicit_instantiation_here),
10936 Diag(
D.getIdentifierLoc(),
10937 diag::err_explicit_instantiation_member_function_not_instantiated)
10946 if (!PrevDecl &&
Specialization->isThisDeclarationADefinition())
10950 bool HasNoEffect =
false;
10961 return (
Decl*)
nullptr;
10972 if (
auto *RD = dyn_cast<CXXRecordDecl>(
Specialization->getDeclContext()))
10973 if (RD->getIdentifier() && RD->getIdentifier()->isStr(
"valarray") &&
10974 RD->isInStdNamespace())
10975 return (
Decl*)
nullptr;
10988 Specialization->setTemplateSpecializationKind(TSK,
D.getIdentifierLoc());
11006 D.getCXXScopeSpec().isSet() &&
11008 Diag(
D.getIdentifierLoc(),
11009 diag::ext_explicit_instantiation_without_qualified_id)
11016 D.getIdentifierLoc(),
D.getCXXScopeSpec().isSet(), TSK);
11019 return (
Decl*)
nullptr;
11028 assert(Name &&
"Expected a name in a dependent tag");
11037 Diag(NameLoc, diag::err_dependent_tag_decl)
11063 if (TypenameLoc.
isValid() && S && !S->getTemplateParamParent())
11064 DiagCompat(TypenameLoc, diag_compat::typename_outside_of_template)
11072 TypenameLoc, QualifierLoc, II, IdLoc, &TSI,
11086 if (TypenameLoc.
isValid() && S && !S->getTemplateParamParent())
11088 ? diag::compat_cxx11_typename_outside_of_template
11089 : diag::compat_pre_cxx11_typename_outside_of_template)
11097 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
11098 Diag(TemplateIILoc,
11099 diag::ext_out_of_line_qualified_id_type_names_constructor)
11101 << (TemplateKWLoc.
isValid() ? 1 : 0 );
11115 assert(DTN &&
"dependent template has non-dependent name?");
11118 if (!DTN->getName().getIdentifier()) {
11119 Diag(TemplateIILoc, diag::err_template_id_not_a_type) <<
Template;
11137 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
11145 Template, TemplateIILoc, TemplateArgs);
11154 TemplateIILoc, TemplateArgs);
11164 if (!II.
isStr(
"type"))
11172 auto EnableIfTSTLoc =
11174 if (!EnableIfTSTLoc || EnableIfTSTLoc.getNumArgs() == 0)
11187 if (!EnableIfII || !EnableIfII->
isStr(
"enable_if"))
11191 CondRange = EnableIfTSTLoc.getArgLoc(0).getSourceRange();
11195 if (EnableIfTSTLoc.getArgLoc(0).getArgument().getKind()
11199 Cond = EnableIfTSTLoc.getArgLoc(0).getSourceExpression();
11215 bool DeducedTSTContext) {
11217 DeducedTSTContext);
11222 if (isa<DependentNameType>(
T)) {
11224 TL.setElaboratedKeywordLoc(KeywordLoc);
11225 TL.setQualifierLoc(QualifierLoc);
11226 TL.setNameLoc(IILoc);
11227 }
else if (isa<DeducedTemplateSpecializationType>(
T)) {
11229 TL.setElaboratedKeywordLoc(KeywordLoc);
11230 TL.setQualifierLoc(QualifierLoc);
11231 TL.setNameLoc(IILoc);
11232 }
else if (isa<TemplateTypeParmType>(
T)) {
11235 assert(!QualifierLoc);
11237 }
else if (isa<TagType>(
T)) {
11239 TL.setElaboratedKeywordLoc(KeywordLoc);
11240 TL.setQualifierLoc(QualifierLoc);
11241 TL.setNameLoc(IILoc);
11242 }
else if (isa<TypedefType>(
T)) {
11262 SS.
Adopt(QualifierLoc);
11265 if (QualifierLoc) {
11292 unsigned DiagID = 0;
11293 Decl *Referenced =
nullptr;
11294 switch (
Result.getResultKind()) {
11299 Expr *Cond =
nullptr;
11300 if (Ctx &&
isEnableIf(QualifierLoc, II, CondRange, Cond)) {
11305 std::string FailedDescription;
11306 std::tie(FailedCond, FailedDescription) =
11310 diag::err_typename_nested_not_found_requirement)
11311 << FailedDescription
11317 diag::err_typename_nested_not_found_enable_if)
11318 << Ctx << CondRange;
11322 DiagID = Ctx ? diag::err_typename_nested_not_found
11323 : diag::err_unknown_typename;
11332 Diag(IILoc, diag::err_typename_refers_to_using_value_decl)
11333 << Name << Ctx << FullRange;
11335 = dyn_cast<UnresolvedUsingValueDecl>(
Result.getRepresentativeDecl())){
11337 Diag(
Loc, diag::note_using_value_decl_missing_typename)
11375 if (isa<TemplateTypeParmDecl>(
Type)) {
11377 assert(!QualifierLoc);
11390 if (!DeducedTSTContext) {
11393 Diag(IILoc, diag::err_dependent_deduced_tst)
11395 <<
QualType(Qualifier.getAsType(), 0);
11397 Diag(IILoc, diag::err_deduced_tst)
11410 DiagID = Ctx ? diag::err_typename_nested_not_type
11411 : diag::err_typename_not_type;
11412 Referenced =
Result.getFoundDecl();
11416 DiagID = Ctx ? diag::err_typename_nested_not_type
11417 : diag::err_typename_not_type;
11418 Referenced = *
Result.begin();
11430 Diag(IILoc, DiagID) << FullRange << Name << Ctx;
11432 Diag(IILoc, DiagID) << FullRange << Name;
11435 Ctx ? diag::note_typename_member_refers_here
11436 : diag::note_typename_refers_here)
11443 class CurrentInstantiationRebuilder
11451 CurrentInstantiationRebuilder(
Sema &SemaRef,
11455 Loc(
Loc), Entity(Entity) { }
11477 this->Entity = Entity;
11493 CurrentInstantiationRebuilder Rebuilder(*
this,
Loc, Name);
11494 return Rebuilder.TransformType(
T);
11498 CurrentInstantiationRebuilder Rebuilder(*
this,
E->
getExprLoc(),
11500 return Rebuilder.TransformExpr(
E);
11511 = Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
11521 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
11525 if (isa<TemplateTypeParmDecl>(Param))
11530 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
11532 TTP->getTemplateParameters()))
11574 unsigned NumArgs) {
11576 llvm::raw_svector_ostream Out(Str);
11578 if (!Params || Params->
size() == 0 || NumArgs == 0)
11579 return std::string();
11581 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
11591 Out <<
Id->getName();
11603 return std::string(Out.str());
11611 auto LPT = std::make_unique<LateParsedTemplate>();
11614 LPT->Toks.swap(Toks);
11661class ExplicitSpecializationVisibilityChecker {
11673 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
11674 return checkImpl(FD);
11675 if (
auto *RD = dyn_cast<CXXRecordDecl>(ND))
11676 return checkImpl(RD);
11677 if (
auto *VD = dyn_cast<VarDecl>(ND))
11678 return checkImpl(VD);
11679 if (
auto *ED = dyn_cast<EnumDecl>(ND))
11680 return checkImpl(ED);
11684 void diagnose(
NamedDecl *
D,
bool IsPartialSpec) {
11685 auto Kind = IsPartialSpec ? Sema::MissingImportKind::PartialSpecialization
11686 : Sema::MissingImportKind::ExplicitSpecialization;
11687 const bool Recover =
true;
11692 if (Modules.empty())
11698 bool CheckMemberSpecialization(
const NamedDecl *
D) {
11699 return Kind == Sema::AcceptableKind::Visible
11704 bool CheckExplicitSpecialization(
const NamedDecl *
D) {
11705 return Kind == Sema::AcceptableKind::Visible
11727 template<
typename SpecDecl>
11728 void checkImpl(SpecDecl *Spec) {
11729 bool IsHiddenExplicitSpecialization =
false;
11733 if constexpr (std::is_same_v<SpecDecl, FunctionDecl>)
11734 SpecKind = Spec->getTemplateSpecializationKindForInstantiation();
11736 IsHiddenExplicitSpecialization = Spec->getMemberSpecializationInfo()
11737 ? !CheckMemberSpecialization(Spec)
11738 : !CheckExplicitSpecialization(Spec);
11740 checkInstantiated(Spec);
11743 if (IsHiddenExplicitSpecialization)
11744 diagnose(Spec->getMostRecentDecl(),
false);
11753 auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(RD);
11757 auto From = SD->getSpecializedTemplateOrPartial();
11760 else if (
auto *TD =
11762 if (!CheckDeclaration(TD))
11763 diagnose(TD,
true);
11768 void checkInstantiated(
VarDecl *RD) {
11769 auto *SD = dyn_cast<VarTemplateSpecializationDecl>(RD);
11773 auto From = SD->getSpecializedTemplateOrPartial();
11776 else if (
auto *TD =
11778 if (!CheckDeclaration(TD))
11779 diagnose(TD,
true);
11784 void checkInstantiated(
EnumDecl *FD) {}
11786 template<
typename TemplDecl>
11787 void checkTemplate(TemplDecl *TD) {
11788 if (TD->isMemberSpecialization()) {
11789 if (!CheckMemberSpecialization(TD))
11790 diagnose(TD->getMostRecentDecl(),
false);
11800 ExplicitSpecializationVisibilityChecker(*
this,
Loc,
11810 ExplicitSpecializationVisibilityChecker(*
this,
Loc,
11818 if (
const auto *FD = dyn_cast<FunctionDecl>(N)) {
11826 if (!CSC.isInstantiationRecord() || CSC.PointOfInstantiation.isInvalid())
11828 return CSC.PointOfInstantiation;
Defines the clang::ASTContext interface.
Defines enum values for all the target-independent builtin functions.
enum clang::sema::@1840::IndirectLocalPathEntry::EntryKind Kind
static Decl::Kind getKind(const Decl *D)
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines the clang::LangOptions interface.
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.
llvm::MachO::Record Record
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
MatchFinder::MatchResult MatchResult
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
This file declares semantic analysis for CUDA constructs.
static void SetNestedNameSpecifier(Sema &S, DeclaratorDecl *DD, Declarator &D)
static bool DependsOnTemplateParameters(QualType T, TemplateParameterList *Params)
Determines whether a given type depends on the given parameter list.
static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D)
Determine what kind of template specialization the given declaration is.
static Expr * BuildExpressionFromNonTypeTemplateArgumentValue(Sema &S, QualType T, const APValue &Val, SourceLocation Loc)
static void maybeDiagnoseTemplateParameterShadow(Sema &SemaRef, Scope *S, SourceLocation Loc, const IdentifierInfo *Name)
static TemplateArgumentLoc convertTypeTemplateArgumentToTemplate(ASTContext &Context, TypeLoc TLoc)
Convert a template-argument that we parsed as a type into a template, if possible.
static bool CheckTemplateSpecializationScope(Sema &S, NamedDecl *Specialized, NamedDecl *PrevDecl, SourceLocation Loc, bool IsPartialSpecialization)
Check whether a specialization is well-formed in the current context.
static bool ScopeSpecifierHasTemplateId(const CXXScopeSpec &SS)
Determine whether the given scope specifier has a template-id in it.
static SourceRange findTemplateParameterInType(unsigned Depth, Expr *E)
static Sema::SemaDiagnosticBuilder noteLocation(Sema &S, const NamedDecl &Decl, unsigned HereDiagID, unsigned ExternalDiagID)
static SourceRange getRangeOfTypeInNestedNameSpecifier(ASTContext &Context, QualType T, const CXXScopeSpec &SS)
static Expr * BuildExpressionFromIntegralTemplateArgumentValue(Sema &S, QualType OrigT, const llvm::APSInt &Int, SourceLocation Loc)
Construct a new expression that refers to the given integral template argument with the given source-...
static SourceRange findTemplateParameter(unsigned Depth, TypeLoc TL)
static QualType builtinCommonTypeImpl(Sema &S, ElaboratedTypeKeyword Keyword, TemplateName BaseTemplate, SourceLocation TemplateLoc, ArrayRef< TemplateArgument > Ts)
static bool isSameAsPrimaryTemplate(TemplateParameterList *Params, TemplateParameterList *SpecParams, ArrayRef< TemplateArgument > Args)
static bool SubstDefaultTemplateArgument(Sema &SemaRef, TemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, TemplateTypeParmDecl *Param, ArrayRef< TemplateArgument > SugaredConverted, ArrayRef< TemplateArgument > CanonicalConverted, TemplateArgumentLoc &Output)
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...
static QualType checkBuiltinTemplateIdType(Sema &SemaRef, ElaboratedTypeKeyword Keyword, BuiltinTemplateDecl *BTD, ArrayRef< TemplateArgument > Converted, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
static void StripImplicitInstantiation(NamedDecl *D, bool MinGW)
Strips various properties off an implicit instantiation that has just been explicitly specialized.
static bool isEnableIf(NestedNameSpecifierLoc NNS, const IdentifierInfo &II, SourceRange &CondRange, Expr *&Cond)
Determine whether this failed name lookup should be treated as being disabled by a usage of std::enab...
static void DiagnoseTemplateParameterListArityMismatch(Sema &S, TemplateParameterList *New, TemplateParameterList *Old, Sema::TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc)
Diagnose a known arity mismatch when comparing template argument lists.
static bool isTemplateArgumentTemplateParameter(const TemplateArgument &Arg, unsigned Depth, unsigned Index)
static bool CheckTemplateArgumentIsCompatibleWithParameter(Sema &S, NamedDecl *Param, QualType ParamType, Expr *ArgIn, Expr *Arg, QualType ArgType)
Checks whether the given template argument is compatible with its template parameter.
static bool isInVkNamespace(const RecordType *RT)
static ExprResult formImmediatelyDeclaredConstraint(Sema &S, NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, NamedDecl *NamedConcept, NamedDecl *FoundDecl, SourceLocation LAngleLoc, SourceLocation RAngleLoc, QualType ConstrainedType, SourceLocation ParamNameLoc, ArgumentLocAppender Appender, SourceLocation EllipsisLoc)
static TemplateArgumentListInfo makeTemplateArgumentListInfo(Sema &S, TemplateIdAnnotation &TemplateId)
Convert the parser's template argument list representation into our form.
static void collectConjunctionTerms(Expr *Clause, SmallVectorImpl< Expr * > &Terms)
Collect all of the separable terms in the given condition, which might be a conjunction.
static void checkMoreSpecializedThanPrimary(Sema &S, PartialSpecDecl *Partial)
static SpirvOperand checkHLSLSpirvTypeOperand(Sema &SemaRef, QualType OperandArg, SourceLocation Loc)
static SourceLocation DiagLocForExplicitInstantiation(NamedDecl *D, SourceLocation PointOfInstantiation)
Compute the diagnostic location for an explicit instantiation.
static bool RemoveLookupResult(LookupResult &R, NamedDecl *C)
static bool CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, NamedDecl *Param, QualType ParamType, Expr *ArgIn, TemplateArgument &SugaredConverted, TemplateArgument &CanonicalConverted)
Checks whether the given template argument is the address of an object or function according to C++ [...
static bool isEnableIfAliasTemplate(TypeAliasTemplateDecl *AliasTemplate)
Determine whether this alias template is "enable_if_t".
static bool DiagnoseUnexpandedParameterPacks(Sema &S, TemplateTemplateParmDecl *TTP)
Check for unexpanded parameter packs within the template parameters of a template template parameter,...
static bool CheckExplicitInstantiationScope(Sema &S, NamedDecl *D, SourceLocation InstLoc, bool WasQualifiedName)
Check the scope of an explicit instantiation.
static TemplateArgumentLoc translateTemplateArgument(Sema &SemaRef, const ParsedTemplateArgument &Arg)
static NullPointerValueKind isNullPointerValueTemplateArgument(Sema &S, NamedDecl *Param, QualType ParamType, Expr *Arg, Decl *Entity=nullptr)
Determine whether the given template argument is a null pointer value of the appropriate type.
static void checkTemplatePartialSpecialization(Sema &S, PartialSpecDecl *Partial)
static bool CheckExplicitInstantiation(Sema &S, NamedDecl *D, SourceLocation InstLoc, bool WasQualifiedName, TemplateSpecializationKind TSK)
Common checks for whether an explicit instantiation of D is valid.
static Expr * lookThroughRangesV3Condition(Preprocessor &PP, Expr *Cond)
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 ...
static void noteNonDeducibleParameters(Sema &S, TemplateParameterList *TemplateParams, const llvm::SmallBitVector &DeducibleParams)
static void completeMemberSpecializationImpl(Sema &S, DeclT *OrigD, SourceLocation Loc)
Complete the explicit specialization of a member of a class template by updating the instantiated mem...
static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc, TemplateDecl *TD, const TemplateParmDecl *D, TemplateArgumentListInfo &Args)
Diagnose a missing template argument.
static bool CheckTemplateArgumentPointerToMember(Sema &S, NamedDecl *Param, QualType ParamType, Expr *&ResultArg, TemplateArgument &SugaredConverted, TemplateArgument &CanonicalConverted)
Checks whether the given template argument is a pointer to member constant according to C++ [temp....
static bool MatchTemplateParameterKind(Sema &S, NamedDecl *New, const Sema::TemplateCompareNewDeclInfo &NewInstFrom, NamedDecl *Old, const NamedDecl *OldInstFrom, bool Complain, Sema::TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc)
Match two template parameters within template parameter lists.
static void dllExportImportClassTemplateSpecialization(Sema &S, ClassTemplateSpecializationDecl *Def)
Make a dllexport or dllimport attr on a class template specialization take effect.
Defines the clang::SourceLocation class and associated facilities.
Allows QualTypes to be sorted and hence used in maps and sets.
static const TemplateArgument & getArgument(const TemplateArgument &A)
C Language Family Type Representation.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
const LValueBase getLValueBase() const
APSInt & getComplexIntImag()
ValueKind getKind() const
APFixedPoint & getFixedPoint()
const ValueDecl * getMemberPointerDecl() const
APValue & getVectorElt(unsigned I)
unsigned getVectorLength() const
bool isMemberPointer() const
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
@ Indeterminate
This object has an indeterminate value (C++ [basic.indet]).
@ None
There is no such object (it's outside its lifetime).
bool isNullPointer() const
APSInt & getComplexIntReal()
APFloat & getComplexFloatImag()
APFloat & getComplexFloatReal()
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
virtual void AssignInheritanceModel(CXXRecordDecl *RD)
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TranslationUnitDecl * getTranslationUnitDecl() const
unsigned getIntWidth(QualType T) const
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
DeclarationNameTable DeclarationNames
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, const DependentTemplateStorage &Name, ArrayRef< TemplateArgumentLoc > Args) const
QualType getSubstBuiltinTemplatePack(const TemplateArgument &ArgPack)
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getCanonicalTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > CanonicalArgs) const
TemplateName getDependentTemplateName(const DependentTemplateStorage &Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template operat...
TemplateName getCanonicalTemplateName(TemplateName Name, bool IgnoreDeduced=false) const
Retrieves the "canonical" template name that refers to a given template.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const LangOptions & getLangOpts() const
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier NNS, const IdentifierInfo *Name) const
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
TypeSourceInfo * getTemplateSpecializationTypeInfo(ElaboratedTypeKeyword Keyword, SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKeywordLoc, TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Canon=QualType()) const
CanQualType UnresolvedTemplateTy
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
bool isSameEntity(const NamedDecl *X, const NamedDecl *Y) const
Determine whether the two declarations refer to the same entity.
QualType getHLSLInlineSpirvType(uint32_t Opcode, uint32_t Size, uint32_t Alignment, ArrayRef< SpirvOperand > Operands)
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
QualType getTypeDeclType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypeDecl *Decl) const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType getCanonicalTypeDeclType(const TypeDecl *TD) const
QualType getTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Underlying=QualType()) const
TemplateName getQualifiedTemplateName(NestedNameSpecifier Qualifier, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
bool hasSimilarType(QualType T1, QualType T2) const
Determine if two types are similar, according to the C++ rules.
const TargetInfo & getTargetInfo() const
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
QualType getDeducedTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
QualType getUnconstrainedType(QualType T) const
Remove any type constraints from a template parameter type, for equivalence comparison of template pa...
CanQualType getCanonicalTagType(const TagDecl *TD) const
bool isSameTemplateArgument(const TemplateArgument &Arg1, const TemplateArgument &Arg2) const
Determine whether the given template arguments Arg1 and Arg2 are equivalent.
void setPrimaryMergedDecl(Decl *D, Decl *Primary)
TemplateName getAssumedTemplateName(DeclarationName Name) const
Retrieve a template name representing an unqualified-id that has been assumed to name a template for ...
Represents a constant array type that does not decay to a pointer when used as a function parameter.
A structure for storing the information associated with a name that has been assumed to be a template...
DeclarationName getDeclName() const
Get the name of the template.
Attr - This represents one attribute.
AutoTypeKeyword getAutoKeyword() const
const NestedNameSpecifierLoc getNestedNameSpecifierLoc() const
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
NamedDecl * getFoundDecl() const
TemplateDecl * getNamedConcept() const
DeclarationNameInfo getConceptNameInfo() const
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
bool isDecltypeAuto() const
A fixed int type of a specified bitwidth.
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
BuiltinTemplateKind getBuiltinTemplateKind() const
This class is used for builtin types like 'int'.
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, FPOptionsOverride FPO, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
static CXXBoolLiteralExpr * Create(const ASTContext &C, bool Val, QualType Ty, SourceLocation Loc)
Represents a C++ member access expression where the actual member referenced could not be resolved be...
static CXXDependentScopeMemberExpr * Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Represents a static or instance method of a struct/union/class.
The null pointer literal (C++11 [lex.nullptr])
Represents a C++ struct/union/class.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr)
CXXRecordDecl * getMostRecentDecl()
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
CXXRecordDecl * getDefinition() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
void setDescribedClassTemplate(ClassTemplateDecl *Template)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization,...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
CXXRecordDecl * getPreviousDecl()
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
char * location_data() const
Retrieve the data associated with the source-location information.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
SourceRange getRange() const
SourceLocation getBeginLoc() const
bool isSet() const
Deprecated.
NestedNameSpecifier getScopeRep() const
Retrieve the representation of the nested-name-specifier.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isEmpty() const
No scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
static CanQual< Type > CreateUnsafe(QualType Other)
Builds a canonical type from a QualType.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
Declaration of a class template.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a class template node.
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, CanQualType CanonInjectedTST, ClassTemplatePartialSpecializationDecl *PrevDecl)
void setMemberSpecialization()
Note that this member template is a specialization.
Represents a class template specialization, which refers to a class template with a given set of temp...
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, bool StrictPackMatch, ClassTemplateSpecializationDecl *PrevDecl)
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
Complex values, per C99 6.2.5p11.
Declaration of a C++20 concept.
Expr * getConstraintExpr() const
ConceptDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
static ConceptDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, Expr *ConstraintExpr=nullptr)
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
static ConceptSpecializationExpr * Create(const ASTContext &C, ConceptReference *ConceptRef, ImplicitConceptSpecializationDecl *SpecDecl, const ConstraintSatisfaction *Satisfaction)
Represents the canonical version of C arrays with a specified constant size.
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
Represents a concrete matrix type with constant number of rows and columns.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isFileContext() const
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context,...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDecl(Decl *D)
Add the declaration D into this context.
bool isStdNamespace() const
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
bool isFunctionOrMethod() const
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context semantically encloses the declaration context DC.
A reference to a declared variable, function, enum, etc.
NestedNameSpecifier getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
Captures information about "declaration specifiers".
bool isVirtualSpecified() const
bool isNoreturnSpecified() const
SourceLocation getStorageClassSpecLoc() const
SCS getStorageClassSpec() const
SourceLocation getNoreturnSpecLoc() const
SourceLocation getExplicitSpecLoc() const
TSCS getThreadStorageClassSpec() const
bool isInlineSpecified() const
SourceLocation getThreadStorageClassSpecLoc() const
SourceLocation getVirtualSpecLoc() const
SourceLocation getConstexprSpecLoc() const
SourceLocation getInlineSpecLoc() const
bool hasExplicitSpecifier() const
bool hasConstexprSpecifier() const
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
bool isParameterPack() const
Whether this declaration is a parameter pack.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
@ FOK_None
Not a friend object.
bool isTemplated() const
Determine whether this declaration is a templated entity (whether it is.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
unsigned getTemplateDepth() const
Determine the number of levels of template parameter surrounding this declaration.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
static DeclContext * castToDeclContext(const Decl *)
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
bool isInvalidDecl() const
void setAccess(AccessSpecifier AS)
SourceLocation getLocation() const
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
SourceLocation getBeginLoc() const LLVM_READONLY
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
void setLexicalDeclContext(DeclContext *DC)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
void setTypeSourceInfo(TypeSourceInfo *TI)
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
Represents the type decltype(expr) (C++11).
Represents a C++17 deduced template specialization type.
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
Represents an extended address space qualifier where the input address space value is dependent.
void setNameLoc(SourceLocation Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Represents a qualified type name for which the type name is dependent.
A qualified reference to a name whose declaration cannot yet be resolved.
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Represents an array type in C++ whose size is a value-dependent expression.
Represents an extended vector type where either the type or size is dependent.
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
unsigned getNumArgs() const
void setTemplateKeywordLoc(SourceLocation Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void setLAngleLoc(SourceLocation Loc)
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
void setTemplateNameLoc(SourceLocation Loc)
Represents a template specialization type whose template cannot be resolved, e.g.
Represents a vector type where either the type or size is dependent.
Recursive AST visitor that supports extension via dynamic dispatch.
virtual bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc)
Recursively visit a template argument location and dispatch to the appropriate method for the argumen...
virtual bool TraverseTypeLoc(TypeLoc TL, bool TraverseQualifier=true)
Recursively visit a type with location, by dispatching to Traverse*TypeLoc() based on the argument ty...
virtual bool TraverseStmt(MaybeConst< Stmt > *S)
Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument's dy...
virtual bool TraverseTemplateName(TemplateName Template)
Recursively visit a template name and dispatch to the appropriate method.
RAII object that enters a new expression evaluation context.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
This represents one expression.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
@ NPC_NeverValueDependent
Specifies that the expression should never be value-dependent.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
ExtVectorType - Extended vector type.
Represents a member of a struct/union/class.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
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.
static FixedPointLiteral * CreateFromRawInt(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l, unsigned Scale)
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, SourceLocation EllipsisLoc={}, ArrayRef< TemplateParameterList * > FriendTypeTPLists={})
Represents a function declaration or definition.
ConstexprSpecKind getConstexprKind() const
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
SourceLocation getPointOfInstantiation() const
Retrieve the (first) point of instantiation of a function template specialization or a member of a cl...
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization,...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isDeleted() const
Whether this function has been deleted.
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo *TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization.
void setLateTemplateParsed(bool ILT=true)
State that this templated function will be late parsed.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
void setDeletedAsWritten(bool D=true, StringLiteral *Message=nullptr)
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization,...
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Represents a prototype with parameter type info, e.g.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > getParamTypes() const
ArrayRef< QualType > param_types() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
bool isExplicitSpecialization() const
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
QualType getReturnType() const
Represents an arbitrary, user-specified SPIR-V type instruction.
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
void AddDecl(NamedDecl *D)
AddDecl - Link the decl to its shadowed decl chain.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitConceptSpecializationDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation SL, ArrayRef< TemplateArgument > ConvertedArgs)
Represents a C array with an unspecified size.
const TypeClass * getTypePtr() const
Describes an C or C++ initializer list.
Describes the kind of initialization being performed, along with location information for tokens rela...
static InitializationKind CreateForInit(SourceLocation Loc, bool DirectInit, Expr *Init)
Create an initialization from an initializer (which, for direct initialization from a parenthesized l...
Describes the sequence of initializations required to initialize a given object or reference with a s...
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence.
Describes an entity that is being initialized.
static InitializedEntity InitializeTemplateParameter(QualType T, NamedDecl *Param)
Create the initialization entity for a template parameter.
The injected class name of a C++ class template or class template partial specialization.
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'.
An lvalue reference type, per C++11 [dcl.ref].
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Represents a linkage specification.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
NamedDecl * getPartiallySubstitutedPack(const TemplateArgument **ExplicitArgs=nullptr, unsigned *NumExplicitArgs=nullptr) const
Retrieve the partially-substitued template parameter pack.
A class for iterating through a result set and possibly filtering out results.
void erase()
Erase the last element returned from this iterator.
Represents the results of name lookup.
bool wasNotFoundInCurrentInstantiation() const
Determine whether no result was found because we could not search into dependent base classes of the ...
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
void setTemplateNameLookup(bool TemplateName)
Sets whether this is a template-name lookup.
DeclClass * getAsSingle() const
bool empty() const
Return true if no decls were found.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Filter makeFilter()
Create a filter for this result set.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
DeclarationName getLookupName() const
Gets the name to look up.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
A pointer to member type per C++ 8.3.3 - Pointers to members.
QualType getPointeeType() const
Provides information a specialization of a member of a class template, which may be a member function...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
Data structure that captures multiple levels of template argument lists for use in template instantia...
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
void addOuterTemplateArguments(Decl *AssociatedDecl, ArgList Args, bool Final)
Add a new outmost level to the multi-level template argument list.
void addOuterRetainedLevels(unsigned Num)
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
std::string getQualifiedNameAsString() const
NamedDecl * getMostRecentDecl()
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined.
bool hasLinkage() const
Determine whether this declaration has linkage.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
NamespaceAndPrefixLoc getAsNamespaceAndPrefix() const
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
TypeLoc castAsTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
const Type * getAsType() const
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, const IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
unsigned getDepth() const
Get the nesting depth of the template parameter.
void setPlaceholderTypeConstraint(Expr *E)
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Interfaces are the core concept in Objective-C for object oriented design.
Represents a pointer to an Objective C object.
Represents a class type in Objective C.
static OpaquePtr make(TemplateName P)
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
@ CSK_Normal
Normal lookup.
SmallVectorImpl< OverloadCandidate >::iterator iterator
void NoteCandidates(PartialDiagnosticAt PA, Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
OverloadCandidate & addCandidate(unsigned NumConversions=0, ConversionSequenceList Conversions={})
Add a new candidate with NumConversions conversion sequence slots to the overload set.
bool isVarDeclReference() const
TemplateTemplateParmDecl * getTemplateTemplateDecl() const
bool isConceptReference() const
ArrayRef< TemplateArgumentLoc > template_arguments() const
A structure for storing the information associated with an overloaded template name.
NamedDecl *const * iterator
Represents a C++11 pack expansion that produces a sequence of expressions.
Represents a pack expansion of types.
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
ParenExpr - This represents a parenthesized expression, e.g.
ParsedAttr - Represents a syntactic attribute.
Represents the parsed form of a C++ template argument.
KindType getKind() const
Determine what kind of template argument we have.
ParsedTemplateTy getAsTemplate() const
Retrieve the template template argument's template name.
ParsedTemplateArgument getTemplatePackExpansion(SourceLocation EllipsisLoc) const
Retrieve a pack expansion of the given template template argument.
ParsedType getAsType() const
Retrieve the template type argument's type.
@ Type
A template type parameter, stored as a type.
@ Template
A template template argument, stored as a template name.
@ NonType
A non-type template parameter, stored as an expression.
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that makes a template template argument into a pack expansion.
SourceLocation getTemplateKwLoc() const
Retrieve the location of the template argument.
Expr * getAsExpr() const
Retrieve the non-type template argument's expression.
SourceLocation getNameLoc() const
Retrieve the location of the template argument.
const CXXScopeSpec & getScopeSpec() const
Retrieve the nested-name-specifier that precedes the template name in a template template argument.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
StringRef getImmediateMacroName(SourceLocation Loc)
Retrieve the name of the immediate macro expansion.
bool NeedsStdLibCxxWorkaroundBefore(std::uint64_t FixedVersion)
A (possibly-)qualified type.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
void addConst()
Add the const type qualifier to this QualType.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
void * getAsOpaquePtr() const
QualType getNonPackExpansionType() const
Remove an outer pack expansion type (if any) from this type.
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
The collection of all-type qualifiers we support.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
void setObjCLifetime(ObjCLifetime type)
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getOriginalDecl() const
void setMemberSpecialization()
Note that this member template is a specialization.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
Scope - A scope is a transient data structure that is used while parsing the program.
unsigned getFlags() const
getFlags - Return the flags for this scope.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
@ TemplateParamScope
This is a scope that corresponds to the template parameters of a C++ template.
A generic diagnostic builder for errors which may or may not be deferred.
SemaDiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId, bool DeferHint=false)
Emit a compatibility diagnostic.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
CUDAFunctionTarget IdentifyTarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
void inheritTargetAttrs(FunctionDecl *FD, const FunctionTemplateDecl &TD)
Copies target attributes from the template TD to the function FD.
RAII object used to change the argument pack substitution index within a Sema object.
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Whether and why a template name is required in this lookup.
SourceLocation getTemplateKeywordLoc() const
bool hasTemplateKeyword() const
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Abstract base class used for diagnosing integer constant expression violations.
Sema - This implements semantic analysis and AST building for C.
bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a reachable definition.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
VarTemplateSpecializationDecl * BuildVarTemplateInstantiation(VarTemplateDecl *VarTemplate, VarDecl *FromVar, const TemplateArgumentList *PartialSpecArgs, const TemplateArgumentListInfo &TemplateArgsInfo, SmallVectorImpl< TemplateArgument > &Converted, SourceLocation PointOfInstantiation, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *StartingScope=nullptr)
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
DeclResult ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, CXXScopeSpec &SS, TemplateIdAnnotation &TemplateId, const ParsedAttributesView &Attr, MultiTemplateParamsArg TemplateParameterLists, SkipBodyInfo *SkipBody=nullptr)
ConceptDecl * ActOnStartConceptDefinition(Scope *S, MultiTemplateParamsArg TemplateParameterLists, const IdentifierInfo *Name, SourceLocation NameLoc)
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
sema::CapturingScopeInfo * getEnclosingLambdaOrBlock() const
Get the innermost lambda or block enclosing the current location, if any.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false) const
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S',...
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
LookupNameKind
Describes the kind of name lookup to perform.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
ExprResult ActOnConstantExpression(ExprResult Res)
bool LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType, bool EnteringContext, RequiredTemplateKind RequiredTemplate=SourceLocation(), AssumedTemplateKind *ATK=nullptr, bool AllowTypoCorrection=true)
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, NamedDecl *PrevMemberDecl, AccessSpecifier LexicalAS)
SetMemberAccessSpecifier - Set the access specifier of a member.
bool BuildTypeConstraint(const CXXScopeSpec &SS, TemplateIdAnnotation *TypeConstraint, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc, bool AllowUnexpandedPack)
NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK)
Given a non-tag type declaration, returns an enum useful for indicating what kind of non-tag type thi...
bool diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC, DeclarationName Name, SourceLocation Loc, TemplateIdAnnotation *TemplateId, bool IsMemberSpecialization)
Diagnose a declaration whose declarator-id has the given nested-name-specifier.
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
bool ActOnTypeConstraint(const CXXScopeSpec &SS, TemplateIdAnnotation *TypeConstraint, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is visible.
bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info)
DiagnoseClassNameShadow - Implement C++ [class.mem]p13: If T is the name of a class,...
void NoteAllFoundTemplates(TemplateName Name)
TemplateName SubstTemplateName(SourceLocation TemplateKWLoc, NestedNameSpecifierLoc &QualifierLoc, TemplateName Name, SourceLocation NameLoc, const MultiLevelTemplateArgumentList &TemplateArgs)
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, const IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
void InstantiateClassTemplateSpecializationMembers(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK)
Instantiate the definitions of all of the members of the given class template specialization,...
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
bool TemplateParameterListsAreEqual(const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New, const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
DeclResult ActOnVarTemplateSpecialization(Scope *S, Declarator &D, TypeSourceInfo *DI, LookupResult &Previous, SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, StorageClass SC, bool IsPartialSpecialization)
ClassTemplatePartialSpecializationDecl * getMoreSpecializedPartialSpecialization(ClassTemplatePartialSpecializationDecl *PS1, ClassTemplatePartialSpecializationDecl *PS2, SourceLocation Loc)
Returns the more specialized class template partial specialization according to the rules of partial ...
FunctionDecl * getMoreConstrainedFunction(FunctionDecl *FD1, FunctionDecl *FD2)
Returns the more constrained function according to the rules of partial ordering by constraints (C++ ...
void referenceDLLExportedClassMethods()
static NamedDecl * getAsTemplateNameDecl(NamedDecl *D, bool AllowFunctionTemplates=true, bool AllowDependent=true)
Try to interpret the lookup result D as a template-name.
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
TemplateParameterList * MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, ArrayRef< TemplateParameterList * > ParamLists, bool IsFriend, bool &IsMemberSpecialization, bool &Invalid, bool SuppressDiagnostic=false)
Match the given template parameter lists to the given scope specifier, returning the template paramet...
void AddAlignmentAttributesForRecord(RecordDecl *RD)
AddAlignmentAttributesForRecord - Adds any needed alignment attributes to a the record decl,...
bool RequireStructuralType(QualType T, SourceLocation Loc)
Require the given type to be a structural type, and diagnose if it is not.
ExprResult EvaluateConvertedConstantExpression(Expr *E, QualType T, APValue &Value, CCEKind CCE, bool RequireInt, const APValue &PreNarrowingValue)
EvaluateConvertedConstantExpression - Evaluate an Expression That is a converted constant expression ...
ConceptDecl * ActOnFinishConceptDefinition(Scope *S, ConceptDecl *C, Expr *ConstraintExpr, const ParsedAttributesView &Attrs)
FPOptionsOverride CurFPFeatureOverrides()
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.
bool hasVisibleExplicitSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a visible declaration of D that is an explicit specialization declaration for a...
bool IsInsideALocalClassWithinATemplateFunction()
Decl * ActOnTemplateDeclarator(Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
bool CheckConceptUseInDefinition(NamedDecl *Concept, SourceLocation Loc)
LateParsedTemplateMapT LateParsedTemplateMap
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
@ CTAK_Deduced
The template argument was deduced via template argument deduction.
void CheckTemplatePartialSpecialization(ClassTemplatePartialSpecializationDecl *Partial)
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization, bool Disambiguation=false)
QualType CheckTemplateIdType(ElaboratedTypeKeyword Keyword, TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
ParsedTemplateArgument ActOnTemplateTypeArgument(TypeResult ParsedType)
Convert a parsed type into a parsed template argument.
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain, bool PrimaryStrictPackMatch)
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
bool ConstraintExpressionDependsOnEnclosingTemplate(const FunctionDecl *Friend, unsigned TemplateDepth, const Expr *Constraint)
bool CheckTemplatePartialSpecializationArgs(SourceLocation Loc, TemplateDecl *PrimaryTemplate, unsigned NumExplicitArgs, ArrayRef< TemplateArgument > Args)
Check the non-type template arguments of a class template partial specialization according to C++ [te...
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
DiagnosticsEngine & getDiagnostics() const
ExprResult BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
void propagateDLLAttrToBaseClassTemplate(CXXRecordDecl *Class, Attr *ClassAttr, ClassTemplateSpecializationDecl *BaseTemplateSpec, SourceLocation BaseLoc)
Perform propagation of DLL attributes from a derived class to a templated base class for MS compatibi...
bool isRedefinitionAllowedFor(NamedDecl *D, NamedDecl **Suggested, bool &Visible)
Determine if D has a definition which allows we redefine it in current TU.
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over....
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
void checkSpecializationReachability(SourceLocation Loc, NamedDecl *Spec)
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
ASTContext & getASTContext() const
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd, TemplateSpecCandidateSet &FailedCandidates, SourceLocation Loc, const PartialDiagnostic &NoneDiag, const PartialDiagnostic &AmbigDiag, const PartialDiagnostic &CandidateDiag, bool Complain=true, QualType TargetType=QualType())
Retrieve the most specialized of the given function template specializations.
bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
IsIntegralPromotion - Determines whether the conversion from the expression From (whose potentially-a...
TypeSourceInfo * SubstType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, bool AllowDeducedTST=false)
Perform substitution on the type T with a given set of template arguments.
bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const
Check the redefinition in C++20 Modules.
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
TemplateParameterList * GetTemplateParameterList(TemplateDecl *TD)
Returns the template parameter list with all default template argument information.
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given variable from its template.
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
bool isTemplateTemplateParameterAtLeastAsSpecializedAs(TemplateParameterList *PParam, TemplateDecl *PArg, TemplateDecl *AArg, const DefaultArguments &DefaultArgs, SourceLocation ArgLoc, bool PartialOrdering, bool *StrictPackMatch)
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
bool CheckDeclCompatibleWithTemplateTemplate(TemplateDecl *Template, TemplateTemplateParmDecl *Param, const TemplateArgumentLoc &Arg)
bool isAcceptableTagRedeclaration(const TagDecl *Previous, TagTypeKind NewTag, bool isDefinition, SourceLocation NewTagLoc, const IdentifierInfo *Name)
Determine whether a tag with a given kind is acceptable as a redeclaration of the given tag declarati...
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, UnsignedOrNone NumExpansions)
unsigned NumSFINAEErrors
The number of SFINAE diagnostics that have been trapped.
TemplateParameterListEqualKind
Enumeration describing how template parameter lists are compared for equality.
@ TPL_TemplateTemplateParmMatch
We are matching the template parameter lists of two template template parameters as part of matching ...
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
@ TPL_TemplateParamsEquivalent
We are determining whether the template-parameters are equivalent according to C++ [temp....
NamedDecl * ActOnTypeParameter(Scope *S, bool Typename, SourceLocation EllipsisLoc, SourceLocation KeyLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedType DefaultArg, bool HasTypeConstraint)
ActOnTypeParameter - Called when a C++ template type parameter (e.g., "typename T") has been parsed.
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
@ FoundFunctions
This is assumed to be a template name because lookup found one or more functions (but no function tem...
@ None
This is not assumed to be a template name.
@ FoundNothing
This is assumed to be a template name because lookup found nothing.
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, CheckTemplateArgumentInfo &CTAI, CheckTemplateArgumentKind CTAK)
Check that the given template argument corresponds to the given template parameter.
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
ArrayRef< InventedTemplateParameterInfo > getInventedParameterInfos() const
void inferGslOwnerPointerAttribute(CXXRecordDecl *Record)
Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
NamedDecl * ActOnTemplateTemplateParameter(Scope *S, SourceLocation TmpLoc, TemplateNameKind Kind, bool TypenameKeyword, 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....
FPOptions & getCurFPFeatures()
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
bool EnsureTemplateArgumentListConstraints(TemplateDecl *Template, const MultiLevelTemplateArgumentList &TemplateArgs, SourceRange TemplateIDRange)
Ensure that the given template arguments satisfy the constraints associated with the given template,...
@ UPPC_PartialSpecialization
Partial specialization.
@ UPPC_DefaultArgument
A default argument.
@ UPPC_ExplicitSpecialization
Explicit specialization.
@ UPPC_NonTypeTemplateParameterType
The type of a non-type template parameter.
@ UPPC_TypeConstraint
A type constraint.
const LangOptions & getLangOpts() const
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl, bool SupportedForCompatibility=false)
DiagnoseTemplateParameterShadow - Produce a diagnostic complaining that the template parameter 'PrevD...
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
bool RebuildTemplateParamsInCurrentInstantiation(TemplateParameterList *Params)
Rebuild the template parameters now that we know we're in a current instantiation.
bool CheckConstraintSatisfaction(const NamedDecl *Template, ArrayRef< AssociatedConstraint > AssociatedConstraints, const MultiLevelTemplateArgumentList &TemplateArgLists, SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction)
Check whether the given list of constraint expressions are satisfied (as if in a 'conjunction') given...
void EnterTemplatedContext(Scope *S, DeclContext *DC)
Enter a template parameter scope, after it's been associated with a particular DeclContext.
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
void NoteTemplateLocation(const NamedDecl &Decl, std::optional< SourceRange > ParamRange={})
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, QualType ObjectType, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
bool isPotentialImplicitMemberAccess(const CXXScopeSpec &SS, LookupResult &R, bool IsAddressOfOperand)
Check whether an expression might be an implicit class member access.
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool hasVisibleMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a visible declaration of D that is a member specialization declaration (as oppo...
void checkClassLevelDLLAttribute(CXXRecordDecl *Class)
Check class-level dllimport/dllexport attribute.
const LangOptions & LangOpts
void InstantiateClassMembers(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK)
Instantiates the definitions of all of the member of the given class, which is an instantiation of a ...
std::pair< Expr *, std::string > findFailedBooleanCondition(Expr *Cond)
Find the failed Boolean condition within a given Boolean constant expression, and describe it with a ...
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc, TypeSourceInfo **TSI, bool DeducedTSTContext)
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
bool hasAnyAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true, bool AllowNonTemplateFunctions=false)
ExprResult BuildConvertedConstantExpression(Expr *From, QualType T, CCEKind CCE, NamedDecl *Dest=nullptr)
bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD, const TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given dependent function template specialization.
bool hasExplicitCallingConv(QualType T)
bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg, SmallVectorImpl< TemplateArgument > &SugaredConverted, SmallVectorImpl< TemplateArgument > &CanonicalConverted)
bool AreConstraintExpressionsEqual(const NamedDecl *Old, const Expr *OldConstr, const TemplateCompareNewDeclInfo &New, const Expr *NewConstr)
void AddPushedVisibilityAttribute(Decl *RD)
AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, add an appropriate visibility at...
std::optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
ExprResult DefaultLvalueConversion(Expr *E)
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
void NoteOverloadCandidate(const NamedDecl *Found, const FunctionDecl *Fn, OverloadCandidateRewriteKind RewriteKind=OverloadCandidateRewriteKind(), QualType DestType=QualType(), bool TakingAddress=false)
bool hasReachableDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a reachable default argument.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(const NamedDecl *D, const DeclContext *DC=nullptr, bool Final=false, std::optional< ArrayRef< TemplateArgument > > Innermost=std::nullopt, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr, bool ForConstraintInstantiation=false, bool SkipForSpecialization=false, bool ForDefaultArgumentSubstitution=false)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
QualType BuiltinDecay(QualType BaseType, SourceLocation Loc)
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool CheckFunctionConstraints(const FunctionDecl *FD, ConstraintSatisfaction &Satisfaction, SourceLocation UsageLoc=SourceLocation(), bool ForOverloadResolution=false)
Check whether the given function decl's trailing requires clause is satisfied, if any.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
bool CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, TemplateSpecializationKind ActOnExplicitInstantiationNewTSK, NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK, SourceLocation PrevPtOfInstantiation, bool &SuppressNew)
Diagnose cases where we have an explicit template specialization before/after an explicit template in...
bool CheckTypeConstraint(TemplateIdAnnotation *TypeConstraint)
TemplateNameKind ActOnTemplateName(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool AllowInjectedClassName=false)
Form a template name from a name that is syntactically required to name a template,...
void diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName, SourceLocation Less, SourceLocation Greater)
ExprResult FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
bool IsFunctionConversion(QualType FromType, QualType ToType, bool *DiscardingCFIUncheckedCallee=nullptr, bool *AddingCFIUncheckedCallee=nullptr) const
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
DeclResult CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation TemplateNameLoc, const TemplateArgumentListInfo &TemplateArgs)
Get the specialization of the given variable template corresponding to the specified argument list,...
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
QualType CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI, SourceLocation Loc)
Check that the type of a non-type template parameter is well-formed.
void diagnoseMissingImport(SourceLocation Loc, const NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, TemplateDecl *NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
TemplateArgumentLoc SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, SourceLocation TemplateKWLoc, SourceLocation TemplateNameLoc, SourceLocation RAngleLoc, Decl *Param, ArrayRef< TemplateArgument > SugaredConverted, ArrayRef< TemplateArgument > CanonicalConverted, bool &HasDefaultArg)
If the given template parameter has a default template argument, substitute into that default templat...
void FilterAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true)
TypeSourceInfo * SubstAutoTypeSourceInfoDependent(TypeSourceInfo *TypeWithAuto)
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams)
Check whether a template can be declared within this scope.
void AddMsStructLayoutForRecord(RecordDecl *RD)
AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
TemplateParameterList * SubstTemplateParams(TemplateParameterList *Params, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs, bool EvaluateConstraints=true)
SourceLocation getTopMostPointOfInstantiation(const NamedDecl *) const
Returns the top most location responsible for the definition of N.
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion.
void ActOnUndeclaredTypeTemplateName(Scope *S, TemplateTy &Name, TemplateNameKind &TNK, SourceLocation NameLoc, IdentifierInfo *&II)
Try to resolve an undeclared template name as a type template.
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
Perform semantic analysis for the given non-template member specialization.
TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS, const IdentifierInfo &II, SourceLocation IdLoc, ImplicitTypenameContext IsImplicitTypename=ImplicitTypenameContext::No)
Called when the parser has parsed a C++ typename specifier, e.g., "typename T::type".
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
bool InstantiateClass(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK, bool Complain=true)
Instantiate the definition of a class from a given pattern.
bool hasReachableMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a reachable declaration of D that is a member specialization declaration (as op...
RedeclarationKind forRedeclarationInCurContext() const
bool SubstTemplateArgument(const TemplateArgumentLoc &Input, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentLoc &Output, SourceLocation Loc={}, const DeclarationName &Entity={})
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, FunctionDecl *Function, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given function from its template.
void InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
void MarkUnusedFileScopedDecl(const DeclaratorDecl *D)
If it's a file scoped decl that must warn if not used, keep track of it.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=AllowFoldKind::No)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, bool IsAddressOfOperand)
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
bool CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param, TemplateParameterList *Params, TemplateArgumentLoc &Arg, bool PartialOrdering, bool *StrictPackMatch)
Check a template argument against its corresponding template template parameter.
void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
Mark which template parameters are used in a given expression.
DeclResult ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS, TemplateTy Template, SourceLocation TemplateNameLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, const ParsedAttributesView &Attr)
QualType CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation QuestionLoc)
Note that LHS is not null here, even if this is the gnu "x ?: y" extension.
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
QualType BuildDecltypeType(Expr *E, bool AsUnevaluated=true)
If AsUnevaluated is false, E is treated as though it were an evaluated context, such as when building...
ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, bool IsTemplateParamOrArg, OffsetOfKind OOK, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
void makeMergedDefinitionVisible(NamedDecl *ND)
Make a merged definition of an existing hidden definition ND visible at the specified location.
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AvailabilityMergeKind::Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation, NamedDecl *Instantiation, bool InstantiatedFromMember, const NamedDecl *Pattern, const NamedDecl *PatternDef, TemplateSpecializationKind TSK, bool Complain=true, bool *Unreachable=nullptr)
Determine whether we would be unable to instantiate this template (because it either has no definitio...
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
bool hasReachableExplicitSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a reachable declaration of D that is an explicit specialization declaration for...
bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name, SourceLocation NameLoc, CXXScopeSpec &SS, ParsedTemplateTy *Template=nullptr)
Determine whether a particular identifier might be the name in a C++1z deduction-guide declaration.
bool IsAtLeastAsConstrained(const NamedDecl *D1, MutableArrayRef< AssociatedConstraint > AC1, const NamedDecl *D2, MutableArrayRef< AssociatedConstraint > AC2, bool &Result)
Check whether the given declaration's associated constraints are at least as constrained than another...
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
NamedDecl * ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, unsigned Depth, unsigned Position, SourceLocation EqualLoc, Expr *DefaultArg)
void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc)
void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D)
Common checks for a parameter-declaration that should apply to both function parameters and non-type ...
TemplateParamListContext
The context in which we are checking a template parameter list.
@ TPC_TemplateTemplateParameterPack
@ TPC_FriendFunctionTemplate
@ TPC_ClassTemplateMember
@ TPC_FriendClassTemplate
@ TPC_FriendFunctionTemplateDefinition
void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a templated declaration that would trigger an implicit instantiation.
void FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S, bool ConsiderLinkage, bool AllowInlineNamespace)
Filters out lookup results that don't fall within the given scope as determined by isDeclInScope.
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, ArrayRef< TemplateArgument > TemplateArgs, sema::TemplateDeductionInfo &Info)
bool resolveAssumedTemplateNameAsType(Scope *S, TemplateName &Name, SourceLocation NameLoc, bool Diagnose=true)
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
Finds the scope corresponding to the given decl context, if it happens to be an enclosing scope.
ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs)
void CheckConceptRedefinition(ConceptDecl *NewDecl, LookupResult &Previous, bool &AddToScope)
TypeResult ActOnTemplateIdType(Scope *S, ElaboratedTypeKeyword ElaboratedKeyword, SourceLocation ElaboratedKeywordLoc, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, const IdentifierInfo *TemplateII, SourceLocation TemplateIILoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false, bool IsClassName=false, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No)
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC, SkipBodyInfo *SkipBody=nullptr)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
bool isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl *T, sema::TemplateDeductionInfo &Info)
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
ExprResult CheckVarOrConceptTemplateTemplateId(const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, TemplateTemplateParmDecl *Template, SourceLocation TemplateLoc, const TemplateArgumentListInfo *TemplateArgs)
void ProcessAPINotes(Decl *D)
Map any API notes provided for this declaration to attributes on the declaration.
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments.
bool CheckRedeclarationInModule(NamedDecl *New, NamedDecl *Old)
A wrapper function for checking the semantic restrictions of a redeclaration within a module.
bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic(const NamedDecl *D1, ArrayRef< AssociatedConstraint > AC1, const NamedDecl *D2, ArrayRef< AssociatedConstraint > AC2)
If D1 was not at least as constrained as D2, but would've been if a pair of atomic constraints involv...
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, const DefaultArguments &DefaultArgs, bool PartialTemplateArgs, CheckTemplateArgumentInfo &CTAI, bool UpdateArgsWithConversions=true, bool *ConstraintsNotSatisfied=nullptr)
Check that the given template arguments can be provided to the given template, converting the argumen...
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
unsigned getTemplateDepth(Scope *S) const
Determine the number of levels of enclosing template parameters.
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
TemplateDeductionResult DeduceAutoType(TypeLoc AutoTypeLoc, Expr *Initializer, QualType &Result, sema::TemplateDeductionInfo &Info, bool DependentDeduction=false, bool IgnoreConstraints=false, TemplateSpecCandidateSet *FailedTSC=nullptr)
Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
QualType adjustCCAndNoReturn(QualType ArgFunctionType, QualType FunctionType, bool AdjustExceptionSpec=false)
Adjust the type ArgFunctionType to match the calling convention, noreturn, and optionally the excepti...
void NoteTemplateParameterLocation(const NamedDecl &Decl)
IdentifierResolver IdResolver
ArrayRef< sema::FunctionScopeInfo * > getFunctionScopes() const
void checkTypeDeclType(DeclContext *LookupCtx, DiagCtorKind DCK, TypeDecl *TD, SourceLocation NameLoc)
Returns the TypeDeclType for the given type declaration, as ASTContext::getTypeDeclType would,...
void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD)
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.
bool hasReachableDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is reachable.
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
bool DiagnoseUnexpandedParameterPacks(SourceLocation Loc, UnexpandedParameterPackContext UPPC, ArrayRef< UnexpandedParameterPack > Unexpanded)
Diagnose unexpanded parameter packs.
void warnOnReservedIdentifier(const NamedDecl *D)
void inferNullableClassAttribute(CXXRecordDecl *CRD)
Add _Nullable attributes for std:: types.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Instances of this class represent operands to a SPIR-V type instruction.
static SpirvOperand createConstant(QualType ResultType, llvm::APInt Val)
static SpirvOperand createType(QualType T)
static SpirvOperand createLiteral(llvm::APInt Val)
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
Represents the result of substituting a builtin template as a pack.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
A structure for storing an already-substituted template template parameter pack.
Represents the result of substituting a set of types for a template type parameter pack.
Represents the result of substituting a type for a template type parameter.
Represents the declaration of a struct/union/class/enum.
StringRef getKindName() const
void startDefinition()
Starts the definition of this tag declaration.
bool isEntityBeingDefined() const
Determines whether this entity is in the process of being defined.
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
TagKind getTagKind() const
TagDecl * getOriginalDecl() const
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
virtual bool shouldDLLImportComdatSymbols() const
Does this target aim for semantic compatibility with Microsoft C++ code using dllimport/export attrib...
A convenient class for passing around template argument information.
SourceLocation getRAngleLoc() const
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
ArrayRef< TemplateArgumentLoc > arguments() const
SourceLocation getLAngleLoc() const
A template argument list.
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Location wrapper for a TemplateArgument.
SourceLocation getLocation() const
SourceLocation getTemplateEllipsisLoc() const
TemplateArgumentLocInfo getLocInfo() const
const TemplateArgument & getArgument() const
SourceLocation getTemplateNameLoc() const
TypeSourceInfo * getTypeSourceInfo() const
SourceRange getSourceRange() const LLVM_READONLY
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Represents a template argument.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
QualType getStructuralValueType() const
Get the type of a StructuralValue.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
bool isNull() const
Determine whether this template argument has no value.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
void print(const PrintingPolicy &Policy, raw_ostream &Out, bool IncludeType) const
Print this template argument to the given output stream.
QualType getIntegralType() const
Retrieve the type of the integral value.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
The base class of all kinds of template declarations (e.g., class, function, etc.).
bool hasAssociatedConstraints() const
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
bool isNull() const
Determine whether this template name is NULL.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
UsingShadowDecl * getAsUsingShadowDecl() const
Retrieve the using shadow declaration through which the underlying template declaration is introduced...
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
SourceRange getSourceRange() const LLVM_READONLY
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
bool hasAssociatedConstraints() const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
NamedDecl *const * const_iterator
Iterates through the template parameters in this list.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
void getAssociatedConstraints(llvm::SmallVectorImpl< AssociatedConstraint > &AC) const
All associated constraints derived from this template parameter list, including the requires clause a...
static bool shouldIncludeTypeForArgument(const PrintingPolicy &Policy, const TemplateParameterList *TPL, unsigned Idx)
SourceLocation getTemplateLoc() const
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
void NoteCandidates(Sema &S, SourceLocation Loc)
NoteCandidates - When no template specialization match is found, prints diagnostic messages containin...
SourceLocation getLocation() const
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set.
void set(SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKeywordLoc, SourceLocation NameLoc, SourceLocation LAngleLoc, SourceLocation RAngleLoc)
Represents a type template specialization; the template must be a class template, a type alias templa...
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, ArrayRef< TemplateArgument > Converted)
Determine whether any of the given template arguments are dependent.
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
TemplateNameKind templateParameterKind() const
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
void setInheritedDefaultArgument(const ASTContext &C, TemplateTemplateParmDecl *Prev)
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateNameKind ParameterKind, bool Typename, TemplateParameterList *Params)
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
unsigned getDepth() const
Get the nesting depth of the template parameter.
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
void removeDefaultArgument()
Removes the default argument of this template parameter.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Declaration of a template type parameter.
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
void setTypeConstraint(ConceptReference *CR, Expr *ImmediatelyDeclaredConstraint, UnsignedOrNone ArgPackSubstIndex)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool isParameterPack() const
Returns whether this is a parameter pack.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, UnsignedOrNone NumExpanded=std::nullopt)
unsigned getDepth() const
Retrieve the depth of the template parameter.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter.
Wrapper for template type parameters.
TemplateTypeParmDecl * getDecl() const
unsigned getIndex() const
unsigned getDepth() const
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Declaration of an alias template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Represents a declaration of a type.
const Type * getTypeForDecl() const
SourceLocation getBeginLoc() const LLVM_READONLY
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
QualType getType() const
Get the type for which this source info wrapper provides information.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
AutoTypeLoc getContainedAutoTypeLoc() const
Get the typeloc of an AutoType whose type will be deduced for a variable with an initializer of this ...
SourceLocation getBeginLoc() const
Get the begin source location.
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
SourceLocation getNameLoc() const
void setNameLoc(SourceLocation Loc)
The base class of the type hierarchy.
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type.
bool isBooleanType() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
bool isRValueReferenceType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isVoidPointerType() const
bool isPointerType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() const
NestedNameSpecifier getPrefix() const
If this type represents a qualified-id, this returns its nested name specifier.
bool isScalarType() const
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
const Type * getArrayElementTypeNoTypeQual() const
If this is an array type, return the element type of the array, potentially with type qualifiers miss...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
bool isObjCObjectOrInterfaceType() const
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isLValueReferenceType() const
bool isBitIntType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isStructuralType() const
Determine if this type is a structural type, per C++20 [temp.param]p7.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isChar16Type() const
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
bool isMemberPointerType() const
bool isChar32Type() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
bool hasUnnamedOrLocalType() const
Whether this type is or contains a local or unnamed type.
bool isPointerOrReferenceType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isFunctionType() const
bool isVectorType() const
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
bool isWideCharType() const
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
bool isRecordType() const
QualType getUnderlyingType() const
Wrapper for source info for typedefs.
Simple class containing the result of Sema::CorrectTypo.
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
DeclClass * getCorrectionDeclAs() const
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Represents a C++ unqualified-id that has been parsed.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
void addDecl(NamedDecl *D)
The iterator over UnresolvedSets.
A set of unresolved declarations.
Wrapper for source info for unresolved typename using decls.
Represents the dependent type named by a dependently-scoped typename using declaration,...
Represents a dependent using declaration which was not marked with typename.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
Represents a variable declaration or definition.
TLSKind getTLSKind() const
bool isStaticDataMember() const
Determines whether this is a static data member.
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization,...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template,...
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization,...
Declaration of a variable template.
static VarTemplatePartialSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
void setMemberSpecialization()
Note that this member template is a specialization.
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
Represents a variable template specialization, which refers to a variable template with a given set o...
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
Represents a C array with a specified size that is not an integer-constant-expression.
Represents a GCC generic vector type.
Retains information about a function, method, or block that is currently being parsed.
Provides information about an attempted template argument deduction, whose success or failure was des...
TemplateArgumentList * takeSugared()
Take ownership of the deduced template argument lists.
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
Defines the clang::TargetInfo interface.
__inline void unsigned int _2
The JSON file list parser is used to communicate input to InstallAPI.
TypeSpecifierType
Specifies the kind of type.
@ Match
This is not an overload because the signature exactly matches an existing declaration.
bool isa(CodeGen::Address addr)
@ OR_Deleted
Succeeded, but refers to a deleted function.
@ OR_Success
Overload resolution succeeded.
@ OR_Ambiguous
Ambiguous candidates found.
@ OR_No_Viable_Function
No viable function found.
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
@ NotFound
No entity found met the criteria.
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
@ Found
Name lookup found a single declaration that met the criteria.
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
@ ovl_fail_constraints_not_satisfied
This candidate was not viable because its associated constraints were not satisfied.
OverloadCandidateDisplayKind
@ OCD_AmbiguousCandidates
Requests that only tied-for-best candidates be shown.
@ OCD_AllCandidates
Requests that all candidates be shown.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
@ OK_Ordinary
An ordinary object is located at an address in memory.
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
bool isPackProducingBuiltinTemplateName(TemplateName N)
@ IK_TemplateId
A template-id, e.g., f<int>.
@ IK_LiteralOperatorId
A user-defined literal name, e.g., operator "" _i.
@ IK_Identifier
An identifier.
@ IK_OperatorFunctionId
An overloaded operator name, e.g., operator+.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
StorageClass
Storage classes.
UnsignedOrNone getExpandedPackSize(const NamedDecl *Param)
Check whether the template parameter is a pack expansion, and if so, determine the number of paramete...
@ CRK_None
Candidate is not a rewritten candidate.
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
@ Result
The result type of a method or function.
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
@ Template
We are parsing a template declaration.
ActionResult< Expr * > ExprResult
TagTypeKind
The kind of a tag type.
@ Enum
The "enum" keyword.
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
@ Keyword
The name has been typo-corrected to a keyword.
@ Concept
The name was classified as a concept name.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
CastKind
CastKind - The kind of operation required for a conversion.
SourceRange getTemplateParamsRange(TemplateParameterList const *const *Params, unsigned NumParams)
Retrieves the range of the given template parameter lists.
bool isSubstitutedDefaultArgument(ASTContext &Ctx, TemplateArgument Arg, const NamedDecl *Param, ArrayRef< TemplateArgument > Args, unsigned Depth)
Make a best-effort determination of whether the type T can be produced by substituting Args into the ...
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
@ TNK_Var_template
The name refers to a variable template whose specialization produces a variable.
@ TNK_Type_template
The name refers to a template whose specialization produces a type.
@ TNK_Dependent_template_name
The name refers to a dependent template name:
@ TNK_Function_template
The name refers to a function template or a set of overloaded functions that includes at least one fu...
@ TNK_Concept_template
The name refers to a concept.
@ TNK_Non_template
The name does not refer to a template.
@ TNK_Undeclared_template
Lookup for the name failed, but we're assuming it was a template name anyway.
ActionResult< ParsedType > TypeResult
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
const FunctionProtoType * T
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy, const TemplateParameterList *TPL=nullptr)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
TemplateDeductionResult
Describes the result of template argument deduction.
@ ConstraintsNotSatisfied
The deduced arguments did not satisfy the constraints associated with the template.
@ CUDATargetMismatch
CUDA Target attributes do not match.
@ Success
Template argument deduction was successful.
@ AlreadyDiagnosed
Some error which was already diagnosed.
ActionResult< Decl * > DeclResult
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
@ TemplateArg
Value of a non-type template parameter.
@ TempArgStrict
As above, but applies strict template checking rules.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
@ None
No keyword precedes the qualified type name.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
@ Parens
New-expression has a C++98 paren-delimited initializer.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
SourceLocation getEndLoc() const LLVM_READONLY
ArrayRef< TemplateArgument > Args
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
bool HasSideEffects
Whether the evaluated expression has side effects.
Extra information about a function prototype.
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
NestedNameSpecifierLoc Prefix
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
Describes how types, statements, expressions, and declarations should be printed.
unsigned TerseOutput
Provide a 'terse' output.
unsigned PrintAsCanonical
Whether to print entities as written or canonically.
bool StrictPackMatch
Is set to true when, in the context of TTP matching, a pack parameter matches non-pack arguments.
bool MatchingTTP
If true, assume these template arguments are the injected template arguments for a template template ...
bool PartialOrdering
The check is being performed in the context of partial ordering.
SmallVector< TemplateArgument, 4 > SugaredConverted
The checked, converted argument will be added to the end of these vectors.
SmallVector< TemplateArgument, 4 > CanonicalConverted
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
@ BuildingDeductionGuides
We are building deduction guides for a class.
A stack object to be created when performing template instantiation.
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
Location information for a TemplateArgument.
Information about a template-id annotation token.
const IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
unsigned NumArgs
NumArgs - The number of template arguments.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)