44#include "llvm/ADT/STLExtras.h"
45#include "llvm/ADT/SmallBitVector.h"
46#include "llvm/ADT/StringExtras.h"
47#include "llvm/Support/Casting.h"
48#include "llvm/Support/SaveAndRestore.h"
59 return SourceRange(Ps[0]->getTemplateLoc(), Ps[N-1]->getRAngleLoc());
73 auto ParamsAtDepth = [&](
unsigned D) { Depth = std::max(Depth, D + 1); };
78 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(FSI)) {
79 if (!LSI->TemplateParams.empty()) {
80 ParamsAtDepth(LSI->AutoTemplateParameterDepth);
83 if (LSI->GLTemplateParameterList) {
84 ParamsAtDepth(LSI->GLTemplateParameterList->getDepth());
94 if (!Info.TemplateParams.empty()) {
95 ParamsAtDepth(Info.AutoTemplateParameterDepth);
110 bool AllowFunctionTemplates,
111 bool AllowDependent) {
121 if (
const auto *
Record = dyn_cast<CXXRecordDecl>(D)) {
133 if (
Record->isInjectedClassName()) {
135 if (
Record->getDescribedClassTemplate())
136 return Record->getDescribedClassTemplate();
138 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(
Record))
139 return Spec->getSpecializedTemplate();
155 bool AllowFunctionTemplates,
156 bool AllowDependent) {
167 bool AllowFunctionTemplates,
169 bool AllowNonTemplateFunctions) {
173 if (AllowNonTemplateFunctions &&
184 bool EnteringContext,
TemplateTy &TemplateResult,
185 bool &MemberOfUnknownSpecialization,
186 bool AllowTypoCorrection) {
190 MemberOfUnknownSpecialization =
false;
198 TName =
Context.DeclarationNames.getCXXOperatorName(
216 &AssumedTemplate, AllowTypoCorrection))
218 MemberOfUnknownSpecialization = R.wasNotFoundInCurrentInstantiation();
234 UsingShadowDecl *FoundUsingShadow = dyn_cast<UsingShadowDecl>(*R.begin());
235 if (R.isAmbiguous()) {
238 bool AnyFunctionTemplates =
false;
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) {
279 R.suppressDiagnostics();
283 assert(D &&
"unambiguous result is not a template name");
288 MemberOfUnknownSpecialization =
true;
295 assert(!FoundUsingShadow || FoundUsingShadow->
getTargetDecl() == TD);
298 Template =
Context.getQualifiedTemplateName(Qualifier, hasTemplateKeyword,
306 R.suppressDiagnostics();
313 ? dyn_cast<TemplateTemplateParmDecl>(TD)->templateParameterKind()
322 Diag(Name.
getBeginLoc(), diag::err_builtin_pack_outside_template) << TName;
341 if (R.empty())
return false;
342 if (R.isAmbiguous()) {
344 R.suppressDiagnostics();
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");
409 !ObjectType->
getAs<TagType>() ||
410 ObjectType->
castAs<TagType>()->getDecl()->isEntityBeingDefined()) &&
411 "Caller should have completed object type");
443 bool ObjectTypeSearchedInScope =
false;
444 bool AllowFunctionTemplatesInLookup =
true;
460 IsDependent |=
Found.wasNotFoundInCurrentInstantiation();
476 if (!ObjectType.
isNull()) {
480 AllowFunctionTemplatesInLookup =
false;
481 ObjectTypeSearchedInScope =
true;
484 IsDependent |=
Found.wasNotFoundInCurrentInstantiation();
487 if (
Found.isAmbiguous())
504 if (AllFunctions || (
Found.empty() && !IsDependent)) {
508 *ATK = (
Found.empty() &&
Found.getLookupName().isIdentifier())
516 if (
Found.empty() && !IsDependent && AllowTypoCorrection) {
522 class TemplateNameLookupValidatorCCC final
534 std::unique_ptr<CorrectionCandidateCallback> clone()
final {
535 return std::make_unique<TemplateNameLookupValidatorCCC>(*
this);
539 TemplateNameLookupValidatorCCC FilterCCC(!SS.
isEmpty());
540 FilterCCC.WantTypeSpecifiers =
false;
541 FilterCCC.WantExpressionKeywords =
false;
542 FilterCCC.WantRemainingKeywords =
false;
543 FilterCCC.WantCXXNamedCasts =
true;
545 Found.getLookupNameInfo(),
Found.getLookupKind(), S, &SS, FilterCCC,
547 if (
auto *ND = Corrected.getFoundDecl())
550 if (
Found.isAmbiguous()) {
552 }
else if (!
Found.empty()) {
555 AllowFunctionTemplatesInLookup =
true;
556 Found.setLookupName(Corrected.getCorrection());
558 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
559 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
562 << Name << LookupCtx << DroppedSpecifier
568 if (Corrected.WillReplaceSpecifier()) {
584 Found.setNotFoundInCurrentInstantiation();
590 if (ExampleLookupResult && RequiredTemplate) {
591 Diag(
Found.getNameLoc(), diag::err_template_kw_refers_to_non_template)
596 diag::note_template_kw_refers_to_non_template)
597 <<
Found.getLookupName();
604 if (S && !ObjectType.
isNull() && !ObjectTypeSearchedInScope &&
621 if (FoundOuter.
empty()) {
631 }
else if (!
Found.isSuppressingAmbiguousDiagnostics()) {
635 if (!
Found.isSingleResult() ||
639 diag::ext_nested_name_member_ref_lookup_ambiguous)
640 <<
Found.getLookupName()
642 Diag(
Found.getRepresentativeDecl()->getLocation(),
643 diag::note_ambig_member_ref_object_type)
646 diag::note_ambig_member_ref_scope);
669 bool MissingTemplateKeyword =
false;
672 if (
auto *DRE = dyn_cast<DeclRefExpr>(
TemplateName.get())) {
673 NameInfo = DRE->getNameInfo();
674 SS.
Adopt(DRE->getQualifierLoc());
676 Found = DRE->getFoundDecl();
677 }
else if (
auto *ME = dyn_cast<MemberExpr>(
TemplateName.get())) {
678 NameInfo = ME->getMemberNameInfo();
679 SS.
Adopt(ME->getQualifierLoc());
681 LookupCtx = ME->getBase()->getType()->getAsCXXRecordDecl();
682 Found = ME->getMemberDecl();
683 }
else if (
auto *DSDRE =
684 dyn_cast<DependentScopeDeclRefExpr>(
TemplateName.get())) {
685 NameInfo = DSDRE->getNameInfo();
686 SS.
Adopt(DSDRE->getQualifierLoc());
687 MissingTemplateKeyword =
true;
688 }
else if (
auto *DSME =
689 dyn_cast<CXXDependentScopeMemberExpr>(
TemplateName.get())) {
690 NameInfo = DSME->getMemberNameInfo();
691 SS.
Adopt(DSME->getQualifierLoc());
692 MissingTemplateKeyword =
true;
694 llvm_unreachable(
"unexpected kind of potential template name");
699 if (MissingTemplateKeyword) {
708 TemplateCandidateFilter(
Sema &S) : S(S) {
709 WantTypeSpecifiers =
false;
710 WantExpressionKeywords =
false;
711 WantRemainingKeywords =
false;
712 WantCXXNamedCasts =
true;
714 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
720 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
721 return std::make_unique<TemplateCandidateFilter>(*
this);
726 TemplateCandidateFilter CCC(*
this);
730 auto *ND = Corrected.getFoundDecl();
733 if (ND || Corrected.isKeyword()) {
735 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
736 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
739 PDiag(diag::err_non_template_in_member_template_id_suggest)
740 << Name << LookupCtx << DroppedSpecifier
744 PDiag(diag::err_non_template_in_template_id_suggest)
749 diag::note_non_template_in_template_id_found);
754 Diag(NameInfo.
getLoc(), diag::err_non_template_in_template_id)
757 Diag(
Found->getLocation(), diag::note_non_template_in_template_id_found);
764 bool isAddressOfOperand,
780 nullptr, NameInfo, TemplateArgs);
814 SemaRef.BuildExpressionFromNonTypeTemplateArgument(Arg, Loc);
817 Replacement = result.
get();
820 Replacement->getType(), Replacement->getValueKind(), Loc, Replacement,
821 AssociatedDecl, ParamType, Index,
PackIndex, Final);
826 bool InstantiatedFromMember,
830 bool Complain,
bool *Unreachable) {
834 bool IsEntityBeingDefined =
false;
835 if (
const TagDecl *TD = dyn_cast_or_null<TagDecl>(PatternDef))
836 IsEntityBeingDefined = TD->isBeingDefined();
838 if (PatternDef && !IsEntityBeingDefined) {
855 if (!Complain || (PatternDef && PatternDef->
isInvalidDecl()))
859 if (
TagDecl *TD = dyn_cast<TagDecl>(Instantiation))
860 InstantiationTy =
Context.getCanonicalTagType(TD);
862 Diag(PointOfInstantiation,
863 diag::err_template_instantiate_within_definition)
869 }
else if (InstantiatedFromMember) {
871 Diag(PointOfInstantiation,
872 diag::err_explicit_instantiation_undefined_member)
877 assert(
isa<TagDecl>(Instantiation) &&
"Must be a TagDecl!");
878 Diag(PointOfInstantiation,
879 diag::err_implicit_instantiate_member_undefined)
885 Diag(PointOfInstantiation,
886 diag::err_explicit_instantiation_undefined_func_template)
890 Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
895 assert(
isa<VarDecl>(Instantiation) &&
"Must be a VarDecl!");
897 Diag(PointOfInstantiation,
898 diag::err_explicit_instantiation_undefined_var_template)
902 Diag(PointOfInstantiation,
903 diag::err_explicit_instantiation_undefined_member)
920 bool SupportedForCompatibility) {
933 ? diag::ext_template_param_shadow
934 : (SupportedForCompatibility ? diag::ext_compat_template_param_shadow
935 : diag::err_template_param_shadow);
937 Diag(Loc, DiagId) << ND->getDeclName();
942 if (
TemplateDecl *Temp = dyn_cast_or_null<TemplateDecl>(D)) {
943 D = Temp->getTemplatedDecl();
952 "Only template template arguments can be pack expansions here");
953 assert(
getAsTemplate().get().containsUnexpandedParameterPack() &&
954 "Template template argument pack expansion without packs");
956 Result.EllipsisLoc = EllipsisLoc;
991 llvm_unreachable(
"Unhandled parsed template argument");
996 for (
unsigned I = 0,
Last = TemplateArgsIn.size(); I !=
Last; ++I)
1016 assert(TInfo &&
"template argument with no location");
1024 EllipsisLoc = PET.getEllipsisLoc();
1025 TL = PET.getPatternLoc();
1029 TemplateName Name = DTST.getTypePtr()->getTemplateName();
1031 SS.
Adopt(DTST.getQualifierLoc());
1034 DTST.getTemplateNameLoc());
1055 unsigned Depth,
unsigned Position,
1058 bool HasTypeConstraint) {
1060 "Template type parameter not in template parameter scope!");
1062 bool IsParameterPack = EllipsisLoc.
isValid();
1065 KeyLoc, ParamNameLoc, Depth, Position,
1066 ParamName,
Typename, IsParameterPack,
1070 if (Param->isParameterPack())
1072 CSI->LocalPacks.push_back(Param);
1085 if (DefaultArg && IsParameterPack) {
1086 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1087 DefaultArg =
nullptr;
1095 assert(DefaultTInfo &&
"expected source information for type");
1104 Param->setInvalidDecl();
1108 Param->setDefaultArgument(
1123 return TemplateArgs;
1130 bool IsTypeConcept =
false;
1131 bool RequiresArguments =
false;
1133 IsTypeConcept = TTP->isTypeConceptTemplateParam();
1135 TTP->getTemplateParameters()->getMinRequiredArguments() > 1;
1141 ->getTemplateParameters()
1142 ->getMinRequiredArguments() > 1;
1148 if (!IsTypeConcept) {
1150 diag::err_type_constraint_non_type_concept);
1159 if (!WereArgsSpecified && RequiresArguments) {
1161 diag::err_type_constraint_missing_arguments)
1180 bool AllowUnexpandedPack) {
1197 if (EllipsisLoc.
isInvalid() && !AllowUnexpandedPack) {
1209 ConstrainedParameter, EllipsisLoc);
1212template <
typename ArgumentLocAppender>
1227 Appender(ConstraintArgs);
1239 FoundDecl ? FoundDecl : CD, CD, &ConstraintArgs,
1245 assert(SS.
isEmpty() &&
"template parameter with a scope specifier?");
1247 NameInfo, NamedConcept, &ConstraintArgs);
1250 return ImmediatelyDeclaredConstraint;
1266 ImmediatelyDeclaredConstraint.
get(), BO_LAnd,
1267 EllipsisLoc,
nullptr,
1283 *TemplateArgs) :
nullptr;
1288 *
this,
NS, NameInfo, NamedConcept, FoundDecl,
1291 ParamAsArgument, ConstrainedParameter->
getLocation(),
1294 for (const auto &ArgLoc : TemplateArgs->arguments())
1295 ConstraintArgs.addArgument(ArgLoc);
1298 if (ImmediatelyDeclaredConstraint.
isInvalid())
1308 CL, ImmediatelyDeclaredConstraint.
get(), std::nullopt);
1319 diag::err_unsupported_placeholder_constraint)
1339 for (unsigned I = 0, C = TL.getNumArgs(); I != C; ++I)
1340 ConstraintArgs.addArgument(TL.getArgLoc(I));
1343 if (ImmediatelyDeclaredConstraint.
isInvalid() ||
1344 !ImmediatelyDeclaredConstraint.
isUsable())
1348 ImmediatelyDeclaredConstraint.
get());
1370 if (
T->isDependentType())
1376 if (
T->isStructuralType())
1380 if (
T->isRValueReferenceType()) {
1381 Diag(Loc, diag::err_template_nontype_parm_rvalue_ref) <<
T;
1390 (!
T->isScalarType() && !
T->isRecordType())) {
1391 Diag(Loc, diag::err_template_nontype_parm_bad_type) <<
T;
1399 Diag(Loc, diag::err_template_nontype_parm_not_structural) <<
T;
1406 for (
const FieldDecl *FD : RD->fields()) {
1408 Diag(FD->getLocation(), diag::note_not_structural_non_public) <<
T << 0;
1411 if (FD->isMutable()) {
1412 Diag(FD->getLocation(), diag::note_not_structural_mutable_field) <<
T;
1415 if (FD->getType()->isRValueReferenceType()) {
1416 Diag(FD->getLocation(), diag::note_not_structural_rvalue_ref_field)
1423 for (
const auto &BaseSpec : RD->bases()) {
1424 if (BaseSpec.getAccessSpecifier() !=
AS_public) {
1425 Diag(BaseSpec.getBaseTypeLoc(), diag::note_not_structural_non_public)
1436 for (
const FieldDecl *FD : RD->fields()) {
1438 if (!
T->isStructuralType()) {
1439 SubLoc = FD->getLocation();
1447 for (
const auto &BaseSpec : RD->bases()) {
1449 if (!
T->isStructuralType()) {
1450 SubLoc = BaseSpec.getBaseTypeLoc();
1458 assert(Kind != -1 &&
"couldn't find reason why type is not structural");
1459 Diag(SubLoc, diag::note_not_structural_subobject)
1460 <<
T << Kind << SubType;
1462 RD =
T->getAsCXXRecordDecl();
1472 if (
T->isVariablyModifiedType()) {
1473 Diag(Loc, diag::err_variably_modified_nontype_template_param)
1478 if (
T->isBlockPointerType()) {
1479 Diag(Loc, diag::err_template_nontype_parm_bad_type) <<
T;
1489 if (
T->isIntegralOrEnumerationType() ||
1491 T->isPointerType() ||
1493 T->isLValueReferenceType() ||
1495 T->isMemberPointerType() ||
1497 T->isNullPtrType() ||
1499 T->isUndeducedType()) {
1502 return T.getUnqualifiedType();
1510 if (
T->isArrayType() ||
T->isFunctionType())
1519 if (
T->isDependentType())
1520 return T.getUnqualifiedType();
1531 Diag(Loc, diag::err_template_nontype_parm_bad_structural_type) <<
T;
1535 Diag(Loc, diag::warn_cxx17_compat_template_nontype_parm_type) <<
T;
1536 return T.getUnqualifiedType();
1547 auto CheckValidDeclSpecifiers = [
this, &D] {
1561 Diag(Loc, diag::err_invalid_decl_specifier_in_nontype_parm)
1598 CheckValidDeclSpecifiers();
1603 diag::warn_cxx14_compat_template_nontype_parm_auto_type)
1607 "Non-type template parameter not in template parameter scope!");
1627 if (TL.isConstrained()) {
1629 T->containsUnexpandedParameterPack()) {
1630 assert(TL.getConceptReference()->getTemplateArgsAsWritten());
1632 TL.getConceptReference()->getTemplateArgsAsWritten()->arguments())
1642 Param->setInvalidDecl();
1644 if (Param->isParameterPack())
1646 CSI->LocalPacks.push_back(Param);
1660 if (
Default && IsParameterPack) {
1661 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1671 Param->setDefaultArgument(
1690 "Template template parameter not in template parameter scope!");
1692 bool IsParameterPack = EllipsisLoc.
isValid();
1695 if (Params->
size() == 0) {
1696 Diag(Loc, diag::err_template_template_parm_no_parms)
1703 Depth + 1, 0,
nullptr,
1720 IsParameterPack, Name, Kind,
Typename, Params);
1723 if (Param->isParameterPack())
1725 LSI->LocalPacks.push_back(Param);
1737 Param->setInvalidDecl();
1742 if (IsParameterPack && !
Default.isInvalid()) {
1743 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1758 Diag(DefaultArg.
getLocation(), diag::err_template_arg_not_valid_template)
1777 Param->setDefaultArgument(
Context, DefaultArg);
1784class ConstraintRefersToContainingTemplateChecker
1789 unsigned TemplateDepth = 0;
1793 bool CheckIfContainingRecord(
const CXXRecordDecl *CheckingRD) {
1799 DC && !DC->isFileContext(); DC = DC->getParent())
1800 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
1801 if (CheckingRD == RD->getMostRecentDecl()) {
1809 bool CheckNonTypeTemplateParmDecl(
const NonTypeTemplateParmDecl *D) {
1815 return TraverseType(D->
getType());
1819 ConstraintRefersToContainingTemplateChecker(
const FunctionDecl *
Friend,
1820 unsigned TemplateDepth)
1823 bool getResult()
const {
return Result; }
1829 bool VisitTemplateTypeParmType(
const TemplateTypeParmType *
Type)
override {
1830 if (
Type->getDecl()->getDepth() < TemplateDepth) {
1837 bool TraverseDeclRefExpr(
const DeclRefExpr *E)
override {
1838 return TraverseDecl(E->
getDecl());
1841 bool TraverseTypedefType(
const TypedefType *TT,
1843 return TraverseType(TT->
desugar());
1846 bool TraverseTypeLoc(TypeLoc TL,
bool TraverseQualifier)
override {
1848 return TraverseType(TL.
getType(), TraverseQualifier);
1851 bool VisitTagType(
const TagType *
T)
override {
1852 return TraverseDecl(
T->getDecl());
1855 bool TraverseDecl(
const Decl *D)
override {
1861 if (
auto *TD = dyn_cast<TypedefNameDecl>(D))
1862 return TraverseType(TD->getUnderlyingType());
1863 if (
auto *NTTPD = dyn_cast<NonTypeTemplateParmDecl>(D))
1864 return CheckNonTypeTemplateParmDecl(NTTPD);
1865 if (
auto *VD = dyn_cast<ValueDecl>(D))
1866 return TraverseType(VD->getType());
1869 if (
auto *RD = dyn_cast<CXXRecordDecl>(D))
1870 return CheckIfContainingRecord(RD);
1875 llvm_unreachable(
"Don't know how to handle this declaration type yet");
1883 const Expr *Constraint) {
1884 assert(
Friend->getFriendObjectKind() &&
"Only works on a friend");
1885 ConstraintRefersToContainingTemplateChecker Checker(
Friend, TemplateDepth);
1886 Checker.TraverseStmt(Constraint);
1887 return Checker.getResult();
1897 Expr *RequiresClause) {
1899 Diag(ExportLoc, diag::warn_template_export_unsupported);
1952 assert(TemplateParams && TemplateParams->
size() > 0 &&
1953 "No template parameters");
1955 "Can only declare or define class templates");
1964 "can't build template of enumerated type");
1968 Diag(KWLoc, diag::err_template_unnamed_class);
1983 if (!SemanticContext) {
1984 Diag(NameLoc, diag::err_template_qualified_declarator_no_match)
2004 IsMemberSpecialization))
2061 dyn_cast_or_null<ClassTemplateDecl>(PrevDecl);
2066 if (!PrevClassTemplate && isa_and_nonnull<CXXRecordDecl>(PrevDecl) &&
2074 ->getSpecializedTemplate();
2097 PrevDecl = PrevClassTemplate =
nullptr;
2098 SemanticContext = OutermostContext;
2115 }
else if (PrevDecl &&
2117 SemanticContext, S, SS.
isValid()))
2118 PrevDecl = PrevClassTemplate =
nullptr;
2120 if (
auto *Shadow = dyn_cast_or_null<UsingShadowDecl>(
2121 PrevDecl ?
Previous.getRepresentativeDecl() :
nullptr)) {
2123 !(PrevClassTemplate &&
2126 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
2127 Diag(Shadow->getTargetDecl()->getLocation(),
2128 diag::note_using_decl_target);
2129 Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl) << 0;
2131 PrevDecl = PrevClassTemplate =
nullptr;
2135 if (PrevClassTemplate) {
2144 TemplateParams, PrevClassTemplate,
2157 Diag(KWLoc, diag::err_use_with_wrong_tag)
2170 bool HiddenDefVisible =
false;
2175 if (!HiddenDefVisible && Hidden) {
2178 assert(Tmpl &&
"original definition of a class template is not a "
2184 Diag(NameLoc, diag::err_redefinition) << Name;
2185 Diag(Def->getLocation(), diag::note_previous_definition);
2192 }
else if (PrevDecl) {
2198 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
2212 (SS.
isSet() && SemanticContext && SemanticContext->
isRecord() &&
2225 ? diag::err_friend_decl_does_not_match
2226 : diag::err_member_decl_does_not_match)
2227 << Name << SemanticContext <<
true
2236 bool ShouldAddRedecl =
2240 Context, Kind, SemanticContext, KWLoc, NameLoc, Name,
2241 PrevClassTemplate && ShouldAddRedecl
2245 if (NumOuterTemplateParamLists > 0)
2248 llvm::ArrayRef(OuterTemplateParamLists, NumOuterTemplateParamLists));
2264 if (ShouldAddRedecl)
2269 if (ModulePrivateLoc.
isValid())
2272 if (IsMemberSpecialization) {
2273 assert(PrevClassTemplate &&
2274 "Member specialization without a primary template?");
2292 if (PrevClassTemplate) {
2330 if (PrevClassTemplate)
2369 S.
DiagCompat(ParamLoc, diag_compat::templ_default_in_function_templ)
2378 S.
Diag(ParamLoc, diag::err_template_parameter_default_template_member)
2387 S.
Diag(ParamLoc, diag::err_template_parameter_default_friend_template)
2396 llvm_unreachable(
"Invalid TemplateParamListContext!");
2409 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
2414 if (TC->hasExplicitTemplateArgs())
2415 for (
auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
2423 if (!NTTP->isParameterPack() &&
2425 NTTP->getTypeSourceInfo(),
2433 = dyn_cast<TemplateTemplateParmDecl>(P))
2453 bool SawDefaultArgument =
false;
2459 OldParam = OldParams->
begin();
2461 bool RemoveDefaultArguments =
false;
2463 NewParamEnd = NewParams->
end();
2464 NewParam != NewParamEnd; ++NewParam) {
2467 bool RedundantDefaultArg =
false;
2470 bool InconsistentDefaultArg =
false;
2472 std::string PrevModuleName;
2478 bool MissingDefaultArg =
false;
2481 bool SawParameterPack =
false;
2484 = dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
2486 if (NewTypeParm->hasDefaultArgument() &&
2488 *
this, TPC, NewTypeParm->getLocation(),
2489 NewTypeParm->getDefaultArgument().getSourceRange()))
2490 NewTypeParm->removeDefaultArgument();
2495 if (NewTypeParm->isParameterPack()) {
2496 assert(!NewTypeParm->hasDefaultArgument() &&
2497 "Parameter packs can't have a default argument!");
2498 SawParameterPack =
true;
2500 NewTypeParm->hasDefaultArgument() &&
2503 NewDefaultLoc = NewTypeParm->getDefaultArgumentLoc();
2504 SawDefaultArgument =
true;
2507 RedundantDefaultArg =
true;
2508 else if (!
getASTContext().isSameDefaultTemplateArgument(OldTypeParm,
2510 InconsistentDefaultArg =
true;
2514 PreviousDefaultArgLoc = NewDefaultLoc;
2518 NewTypeParm->setInheritedDefaultArgument(
Context, OldTypeParm);
2520 }
else if (NewTypeParm->hasDefaultArgument()) {
2521 SawDefaultArgument =
true;
2522 PreviousDefaultArgLoc = NewTypeParm->getDefaultArgumentLoc();
2523 }
else if (SawDefaultArgument)
2524 MissingDefaultArg =
true;
2526 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
2531 !NewNonTypeParm->isParameterPack() &&
2533 NewNonTypeParm->getTypeSourceInfo(),
2540 if (NewNonTypeParm->hasDefaultArgument() &&
2542 *
this, TPC, NewNonTypeParm->getLocation(),
2543 NewNonTypeParm->getDefaultArgument().getSourceRange())) {
2544 NewNonTypeParm->removeDefaultArgument();
2550 if (NewNonTypeParm->isParameterPack()) {
2551 assert(!NewNonTypeParm->hasDefaultArgument() &&
2552 "Parameter packs can't have a default argument!");
2553 if (!NewNonTypeParm->isPackExpansion())
2554 SawParameterPack =
true;
2556 NewNonTypeParm->hasDefaultArgument() &&
2559 NewDefaultLoc = NewNonTypeParm->getDefaultArgumentLoc();
2560 SawDefaultArgument =
true;
2562 RedundantDefaultArg =
true;
2564 OldNonTypeParm, NewNonTypeParm)) {
2565 InconsistentDefaultArg =
true;
2569 PreviousDefaultArgLoc = NewDefaultLoc;
2573 NewNonTypeParm->setInheritedDefaultArgument(
Context, OldNonTypeParm);
2575 }
else if (NewNonTypeParm->hasDefaultArgument()) {
2576 SawDefaultArgument =
true;
2577 PreviousDefaultArgLoc = NewNonTypeParm->getDefaultArgumentLoc();
2578 }
else if (SawDefaultArgument)
2579 MissingDefaultArg =
true;
2602 "Parameter packs can't have a default argument!");
2604 SawParameterPack =
true;
2605 }
else if (OldTemplateParm &&
2611 SawDefaultArgument =
true;
2613 RedundantDefaultArg =
true;
2615 OldTemplateParm, NewTemplateParm)) {
2616 InconsistentDefaultArg =
true;
2620 PreviousDefaultArgLoc = NewDefaultLoc;
2625 PreviousDefaultArgLoc
2628 SawDefaultArgument =
true;
2629 PreviousDefaultArgLoc
2631 }
else if (SawDefaultArgument)
2632 MissingDefaultArg =
true;
2638 if (SawParameterPack && (NewParam + 1) != NewParamEnd &&
2640 Diag((*NewParam)->getLocation(),
2641 diag::err_template_param_pack_must_be_last_template_parameter);
2658 if (RedundantDefaultArg) {
2659 Diag(NewDefaultLoc, diag::err_template_param_default_arg_redefinition);
2660 Diag(OldDefaultLoc, diag::note_template_param_prev_default_arg);
2662 }
else if (InconsistentDefaultArg) {
2666 diag::err_template_param_default_arg_inconsistent_redefinition);
2668 diag::note_template_param_prev_default_arg_in_other_module)
2671 }
else if (MissingDefaultArg &&
2679 Diag((*NewParam)->getLocation(),
2680 diag::err_template_param_default_arg_missing);
2681 Diag(PreviousDefaultArgLoc, diag::note_template_param_prev_default_arg);
2683 RemoveDefaultArguments =
true;
2694 if (RemoveDefaultArguments) {
2696 NewParamEnd = NewParams->
end();
2697 NewParam != NewParamEnd; ++NewParam) {
2699 TTP->removeDefaultArgument();
2701 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
2702 NTTP->removeDefaultArgument();
2722 bool IgnoreNonTypeDependent;
2727 DependencyChecker(
unsigned Depth,
bool IgnoreNonTypeDependent)
2728 : Depth(Depth), IgnoreNonTypeDependent(IgnoreNonTypeDependent),
2732 : IgnoreNonTypeDependent(IgnoreNonTypeDependent),
Match(
false) {
2735 Depth = PD->getDepth();
2736 }
else if (NonTypeTemplateParmDecl *PD =
2737 dyn_cast<NonTypeTemplateParmDecl>(ND)) {
2738 Depth = PD->getDepth();
2744 bool Matches(
unsigned ParmDepth, SourceLocation Loc = SourceLocation()) {
2745 if (ParmDepth >= Depth) {
2753 bool TraverseStmt(Stmt *S)
override {
2758 if (
auto *E = dyn_cast_or_null<Expr>(S))
2759 if (IgnoreNonTypeDependent && !E->isTypeDependent())
2764 bool TraverseTypeLoc(TypeLoc TL,
bool TraverseQualifier =
true)
override {
2765 if (IgnoreNonTypeDependent && !TL.
isNull() &&
2771 bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL)
override {
2775 bool VisitTemplateTypeParmType(TemplateTypeParmType *
T)
override {
2777 return IgnoreNonTypeDependent || !Matches(
T->getDepth());
2780 bool TraverseTemplateName(
TemplateName N,
bool TraverseQualifier)
override {
2781 if (TemplateTemplateParmDecl *PD =
2783 if (Matches(PD->getDepth()))
2789 bool VisitDeclRefExpr(DeclRefExpr *E)
override {
2790 if (NonTypeTemplateParmDecl *PD =
2791 dyn_cast<NonTypeTemplateParmDecl>(E->
getDecl()))
2792 if (Matches(PD->getDepth(), E->
getExprLoc()))
2794 return DynamicRecursiveASTVisitor::VisitDeclRefExpr(E);
2797 bool VisitDependentTemplateIdExpr(DependentTemplateIdExpr *E)
override {
2800 return DynamicRecursiveASTVisitor::VisitDependentTemplateIdExpr(E);
2803 bool VisitSubstTemplateTypeParmType(SubstTemplateTypeParmType *
T)
override {
2804 return TraverseType(
T->getReplacementType());
2807 bool VisitSubstTemplateTypeParmPackType(
2808 SubstTemplateTypeParmPackType *
T)
override {
2809 return TraverseTemplateArgument(
T->getArgumentPack());
2812 bool TraverseInjectedClassNameType(InjectedClassNameType *
T,
2813 bool TraverseQualifier)
override {
2816 return TraverseTemplateArguments(
2817 T->getTemplateArgs(
T->getDecl()->getASTContext()));
2826 if (!Params->
size())
2829 DependencyChecker Checker(Params,
false);
2830 Checker.TraverseType(
T);
2831 return Checker.Match;
2857 bool &IsMemberSpecialization,
bool &
Invalid,
bool SuppressDiagnostic) {
2858 IsMemberSpecialization =
false;
2880 while (!
T.isNull()) {
2881 NestedTypes.push_back(
T);
2887 = dyn_cast<ClassTemplateSpecializationDecl>(
Record)) {
2890 ExplicitSpecLoc = Spec->getLocation();
2893 }
else if (
Record->getTemplateSpecializationKind()
2895 ExplicitSpecLoc =
Record->getLocation();
2900 T =
Context.getTypeDeclType(Parent);
2906 if (
const TemplateSpecializationType *TST
2907 =
T->getAs<TemplateSpecializationType>()) {
2920 T =
Context.getTypeDeclType(Parent);
2928 if (
const DependentNameType *DependentName =
T->getAs<DependentNameType>()){
2938 if (
const EnumType *EnumT =
T->getAsCanonical<EnumType>()) {
2944 if (
TypeDecl *Parent = dyn_cast<TypeDecl>(
Enum->getParent()))
2945 T =
Context.getCanonicalTypeDeclType(Parent);
2955 std::reverse(NestedTypes.begin(), NestedTypes.end());
2963 bool SawNonEmptyTemplateParameterList =
false;
2965 auto CheckExplicitSpecialization = [&](
SourceRange Range,
bool Recovery) {
2966 if (SawNonEmptyTemplateParameterList) {
2967 if (!SuppressDiagnostic)
2968 Diag(DeclLoc, diag::err_specialize_member_of_template)
2969 << !Recovery << Range;
2971 IsMemberSpecialization =
false;
2978 auto DiagnoseMissingExplicitSpecialization = [&] (
SourceRange Range) {
2980 if (CheckExplicitSpecialization(Range,
true))
2985 if (!ParamLists.empty())
2986 ExpectedTemplateLoc = ParamLists[0]->getTemplateLoc();
2988 ExpectedTemplateLoc = DeclStartLoc;
2990 if (!SuppressDiagnostic)
2991 Diag(DeclLoc, diag::err_template_spec_needs_header)
2998 for (
unsigned TypeIdx = 0, NumTypes = NestedTypes.size(); TypeIdx != NumTypes;
3000 T = NestedTypes[TypeIdx];
3003 bool NeedEmptyTemplateHeader =
false;
3006 bool NeedNonemptyTemplateHeader =
false;
3019 = dyn_cast<ClassTemplatePartialSpecializationDecl>(
Record)) {
3020 ExpectedTemplateParams = Partial->getTemplateParameters();
3021 NeedNonemptyTemplateHeader =
true;
3022 }
else if (
Record->isDependentType()) {
3023 if (
Record->getDescribedClassTemplate()) {
3024 ExpectedTemplateParams =
Record->getDescribedClassTemplate()
3025 ->getTemplateParameters();
3026 NeedNonemptyTemplateHeader =
true;
3029 = dyn_cast<ClassTemplateSpecializationDecl>(
Record)) {
3035 NeedEmptyTemplateHeader =
true;
3038 }
else if (
Record->getTemplateSpecializationKind()) {
3039 if (
Record->getTemplateSpecializationKind()
3041 TypeIdx == NumTypes - 1)
3042 IsMemberSpecialization =
true;
3046 }
else if (
const auto *TST =
T->getAs<TemplateSpecializationType>()) {
3049 ExpectedTemplateParams =
Template->getTemplateParameters();
3050 NeedNonemptyTemplateHeader =
true;
3052 NeedNonemptyTemplateHeader =
true;
3056 NeedNonemptyTemplateHeader =
false;
3067 if (
ParamIdx < ParamLists.size()) {
3068 if (ParamLists[
ParamIdx]->size() == 0) {
3069 if (CheckExplicitSpecialization(ParamLists[
ParamIdx]->getSourceRange(),
3073 SawNonEmptyTemplateParameterList =
true;
3076 if (NeedEmptyTemplateHeader) {
3079 if (TypeIdx == NumTypes - 1)
3080 IsMemberSpecialization =
true;
3082 if (
ParamIdx < ParamLists.size()) {
3083 if (ParamLists[
ParamIdx]->size() > 0) {
3085 if (!SuppressDiagnostic)
3087 diag::err_template_param_list_matches_nontemplate)
3090 ParamLists[
ParamIdx]->getRAngleLoc())
3102 if (DiagnoseMissingExplicitSpecialization(
3109 if (NeedNonemptyTemplateHeader) {
3114 if (IsFriend &&
T->isDependentType()) {
3115 if (
ParamIdx < ParamLists.size() &&
3117 ExpectedTemplateParams =
nullptr;
3122 if (
ParamIdx < ParamLists.size()) {
3124 if (ExpectedTemplateParams &&
3126 ExpectedTemplateParams,
3139 if (!SuppressDiagnostic)
3140 Diag(DeclLoc, diag::err_template_spec_needs_template_parameters)
3151 if (
ParamIdx >= ParamLists.size()) {
3152 if (TemplateId && !IsFriend) {
3168 if (
ParamIdx < ParamLists.size() - 1) {
3169 bool HasAnyExplicitSpecHeader =
false;
3170 bool AllExplicitSpecHeaders =
true;
3171 for (
unsigned I =
ParamIdx, E = ParamLists.size() - 1; I != E; ++I) {
3172 if (ParamLists[I]->size() == 0)
3173 HasAnyExplicitSpecHeader =
true;
3175 AllExplicitSpecHeaders =
false;
3178 if (!SuppressDiagnostic)
3180 AllExplicitSpecHeaders ? diag::ext_template_spec_extra_headers
3181 : diag::err_template_spec_extra_headers)
3183 ParamLists[ParamLists.size() - 2]->getRAngleLoc());
3188 if (ExplicitSpecLoc.
isValid() && HasAnyExplicitSpecHeader &&
3189 !SuppressDiagnostic)
3190 Diag(ExplicitSpecLoc,
3191 diag::note_explicit_template_spec_does_not_need_header)
3192 << NestedTypes.back();
3197 if (!AllExplicitSpecHeaders)
3208 if (ParamLists.back()->size() == 0 &&
3209 CheckExplicitSpecialization(ParamLists[
ParamIdx]->getSourceRange(),
3215 return ParamLists.back();
3220 Diag(
Template->getLocation(), diag::note_template_declared_here)
3236 Diag((*I)->getLocation(), diag::note_template_declared_here)
3237 << 0 << (*I)->getDeclName();
3267 Keyword, BaseTemplate, TemplateLoc, Args,
3273 return BaseTemplateInst;
3278 switch (Ts.size()) {
3288 return lookUpCommonType(Ts[0], Ts[0]);
3302 return lookUpCommonType(D1, D2);
3307 auto CheckConditionalOperands = [&](
bool ConstRefQual) ->
QualType {
3346 if (
auto Res = CheckConditionalOperands(
false); !Res.isNull())
3359 return CheckConditionalOperands(
true);
3370 for (
auto T : llvm::drop_begin(Ts)) {
3381 DeclContext *DC = RT->getDecl()->getDeclContext();
3396 bool Literal =
false;
3399 auto SpecDecl = dyn_cast<ClassTemplateSpecializationDecl>(RT->getDecl());
3403 QualType ConstantType = LiteralArgs[0].getAsType();
3406 LiteralLoc = SpecDecl->getSourceRange().getBegin();
3410 RT->getDecl()->getName() ==
"integral_constant") {
3411 auto SpecDecl = dyn_cast<ClassTemplateSpecializationDecl>(RT->getDecl());
3416 QualType ConstantType = ConstantArgs[0].getAsType();
3417 llvm::APInt
Value = ConstantArgs[1].getAsIntegral();
3420 return SpirvOperand::createLiteral(
Value);
3421 return SpirvOperand::createConstant(ConstantType,
Value);
3422 }
else if (Literal) {
3423 SemaRef.
Diag(LiteralLoc, diag::err_hlsl_vk_literal_must_contain_constant);
3424 return SpirvOperand();
3428 diag::err_call_incomplete_argument))
3429 return SpirvOperand();
3430 return SpirvOperand::createType(OperandArg);
3436 std::unique_ptr<MangleContext> MC(Context.createMangleContext());
3439 llvm::transform(InputArgs, SortedArgs.begin(),
3441 assert(Arg.getKind() == TemplateArgument::Type);
3442 std::string MangledName;
3443 llvm::raw_string_ostream OS(MangledName);
3444 MC->mangleCanonicalTypeName(Arg.getAsType(), OS);
3445 return std::pair<std::string, TemplateArgument>(
3446 std::move(MangledName), Arg);
3448 llvm::stable_sort(SortedArgs, llvm::less_first());
3450 auto OutArgs = llvm::to_vector(llvm::make_second_range(SortedArgs));
3451 return Context.getSubstBuiltinTemplatePack(
3462 "Builtin template arguments do not match its parameters");
3465 case BTK__make_integer_seq: {
3469 QualType OrigType = Converted[1].getAsType();
3473 SemaRef.
Diag(TemplateArgs[1].getLocation(),
3474 diag::err_integer_sequence_integral_element_type);
3488 OrigType, TemplateArgs[1].getLocation())));
3490 if (llvm::APSInt NumArgs = NumArgsArg.
getAsIntegral(); NumArgs >= 0) {
3492 for (llvm::APSInt I(NumArgs.getBitWidth(), NumArgs.isUnsigned());
3496 TA, OrigType, TemplateArgs[2].getLocation()));
3501 SemaRef.
Diag(TemplateArgs[2].getLocation(),
3502 diag::err_integer_sequence_negative_length);
3509 TemplateLoc, SyntheticTemplateArgs,
3514 case BTK__type_pack_element: {
3518 assert(Converted.size() == 2 &&
3519 "__type_pack_element should be given an index and a parameter pack");
3526 assert(Index >= 0 &&
"the index used with __type_pack_element should be of "
3527 "type std::size_t, and hence be non-negative");
3529 if (Index >= Ts.pack_size()) {
3530 SemaRef.
Diag(TemplateArgs[0].getLocation(),
3531 diag::err_type_pack_element_out_of_bounds);
3536 int64_t N = Index.getExtValue();
3537 return Ts.getPackAsArray()[N].getAsType();
3540 case BTK__builtin_common_type: {
3541 assert(Converted.size() == 4);
3542 if (llvm::any_of(Converted, [](
auto &
C) {
return C.isDependent(); }))
3545 TemplateName BaseTemplate = Converted[0].getAsTemplate();
3553 CT, TemplateArgs[1].getLocation())));
3554 TemplateName HasTypeMember = Converted[1].getAsTemplate();
3559 QualType HasNoTypeMember = Converted[2].getAsType();
3560 return HasNoTypeMember;
3563 case BTK__hlsl_spirv_type: {
3564 assert(Converted.size() == 4);
3566 if (!Context.getTargetInfo().getTriple().isSPIRV()) {
3567 SemaRef.
Diag(TemplateLoc, diag::err_hlsl_spirv_only) << BTD;
3570 if (llvm::any_of(Converted, [](
auto &
C) {
return C.isDependent(); }))
3573 uint64_t Opcode = Converted[0].getAsIntegral().getZExtValue();
3574 uint64_t Size = Converted[1].getAsIntegral().getZExtValue();
3575 uint64_t Alignment = Converted[2].getAsIntegral().getZExtValue();
3581 for (
auto &OperandTA : OperandArgs) {
3582 QualType OperandArg = OperandTA.getAsType();
3584 TemplateArgs[3].getLocation());
3585 if (!Operand.isValid())
3587 Operands.push_back(Operand);
3590 return Context.getHLSLInlineSpirvType(Opcode, Size, Alignment, Operands);
3592 case BTK__builtin_dedup_pack: {
3593 assert(Converted.size() == 1 &&
"__builtin_dedup_pack should be given "
3594 "a parameter pack");
3603 llvm::SmallDenseSet<QualType> Seen;
3607 if (!Seen.insert(
T.getAsType().getCanonicalType()).second)
3609 OutArgs.push_back(
T);
3611 return Context.getSubstBuiltinTemplatePack(
3614 case BTK__builtin_sort_pack: {
3615 assert(Converted.size() == 1 &&
3616 "__builtin_sort_pack should be given a parameter pack");
3624 llvm_unreachable(
"unexpected BuiltinTemplateDecl!");
3642 if (
auto BinOp = dyn_cast<BinaryOperator>(Clause->IgnoreParenImpCasts())) {
3643 if (BinOp->getOpcode() == BO_LAnd) {
3650 Terms.push_back(Clause);
3659 if (!BinOp)
return Cond;
3661 if (BinOp->getOpcode() != BO_LOr)
return Cond;
3664 Expr *LHS = BinOp->getLHS();
3666 if (!InnerBinOp)
return Cond;
3668 if (InnerBinOp->getOpcode() != BO_EQ ||
3679 if (MacroName ==
"CONCEPT_REQUIRES" || MacroName ==
"CONCEPT_REQUIRES_")
3680 return BinOp->getRHS();
3690class FailedBooleanConditionPrinterHelper :
public PrinterHelper {
3692 explicit FailedBooleanConditionPrinterHelper(
const PrintingPolicy &P)
3695 bool handledStmt(Stmt *E, raw_ostream &OS)
override {
3696 const auto *DR = dyn_cast<DeclRefExpr>(E);
3697 if (DR && DR->getQualifier()) {
3700 DR->getQualifier().print(OS, Policy,
true);
3702 const ValueDecl *VD = DR->getDecl();
3704 if (
const auto *IV = dyn_cast<VarTemplateSpecializationDecl>(VD)) {
3706 printTemplateArgumentList(
3707 OS, IV->getTemplateArgs().asArray(), Policy,
3708 IV->getSpecializedTemplate()->getTemplateParameters());
3716 const PrintingPolicy Policy;
3721std::pair<Expr *, std::string>
3730 Expr *FailedCond =
nullptr;
3731 for (
Expr *Term : Terms) {
3745 if (Term->EvaluateAsBooleanCondition(Succeeded,
Context) &&
3747 FailedCond = TermAsWritten;
3754 std::string Description;
3756 llvm::raw_string_ostream Out(Description);
3758 Policy.PrintAsCanonical =
true;
3759 FailedBooleanConditionPrinterHelper Helper(Policy);
3760 FailedCond->
printPretty(Out, &Helper, Policy, 0,
"\n",
nullptr);
3762 return { FailedCond, Description };
3778 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
3779 return std::make_unique<CandidateCallback>(*
this);
3790 std::nullopt,
false,
3806 if (
const auto *S = UnderlyingName.getAsSubstTemplateTemplateParmPack()) {
3808 }
else if (
const auto *PI = UnderlyingName.getAsPackIndexingTemplate()) {
3811 Template = PI->getPattern().getAsTemplateDecl();
3812 }
else if (
const auto *DTN = UnderlyingName.getAsDependentTemplateName()) {
3813 if (DTN->getName().getIdentifier())
3821 }
else if (
const auto *ATN = UnderlyingName.getAsAssumedTemplateName()) {
3823 *
this,
Scope, ATN, TemplateLoc);
3824 CorrectedName.isNull()) {
3825 Diag(TemplateLoc, diag::err_no_template) << ATN->getDeclName();
3828 Name = CorrectedName;
3836 if (ForNestedNameSpecifier)
3837 Diag(TemplateLoc, diag::err_non_type_template_in_nested_name_specifier)
3838 << isa_and_nonnull<VarTemplateDecl>(
Template) << Name << R;
3840 Diag(TemplateLoc, diag::err_template_id_not_a_type) << Name << R;
3865 dyn_cast<TypeAliasTemplateDecl>(
Template)) {
3873 SemaRef.Diag(TemplateLoc, diag::err_tag_reference_non_tag)
3910 std::optional<ContextRAII> SavedContext;
3912 SavedContext.emplace(*
this,
AliasTemplate->getDeclContext());
3917 if (CanonType.
isNull()) {
3924 Trap ? Trap->getDeductionInfo() :
nullptr) {
3927 diag::err_typename_nested_not_found_enable_if &&
3928 TemplateArgs[0].getArgument().getKind() ==
3931 std::string FailedDescription;
3932 std::tie(FailedCond, FailedDescription) =
3944 PDiag(diag::err_typename_nested_not_found_requirement)
3952 }
else if (
auto *BTD = dyn_cast<BuiltinTemplateDecl>(
Template)) {
3956 TemplateSpecializationType::anyDependentTemplateArguments(
3965 CanonType =
Context.getCanonicalTemplateSpecializationType(
3967 Context.getCanonicalTemplateName(Name,
true),
3980 if (Ctx->isFileContext())
break;
3989 !
Record->getDescribedClassTemplate())
3998 if (CanonType != Injected)
4011 dyn_cast<ClassTemplateDecl>(
Template)) {
4014 llvm::FoldingSetInsertToken InsertToken;
4051 "type of non-dependent specialization is not a RecordType");
4053 llvm_unreachable(
"Unhandled template kind");
4059 return Context.getTemplateSpecializationType(
4071 assert(ATN &&
"not an assumed template name");
4072 II = ATN->getDeclName().getAsIdentifierInfo();
4089 SourceLocation RAngleLoc,
bool IsCtorOrDtorName,
bool IsClassName,
4094 if (!IsCtorOrDtorName && !IsClassName && SS.
isSet()) {
4120 TemplateD, TemplateII, TemplateIILoc, LAngleLoc,
4121 TemplateArgsIn, RAngleLoc);
4128 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
4129 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
4132 ? diag::err_out_of_line_qualified_id_type_names_constructor
4133 : diag::ext_out_of_line_qualified_id_type_names_constructor)
4144 ElaboratedKeyword, TemplateD.
get(), TemplateIILoc, TemplateArgs,
4153 TemplateIILoc, TemplateArgs);
4186 if (
const RecordType *RT =
Result->getAs<RecordType>()) {
4190 assert(Id &&
"templated class must have an identifier");
4194 Diag(TagLoc, diag::err_use_with_wrong_tag)
4231 const TemplateTypeParmType *TPT =
4233 return TPT && !
Type.hasQualifiers() &&
4234 TPT->getDepth() == Depth && TPT->getIndex() == Index;
4242 dyn_cast<NonTypeTemplateParmDecl>(DRE->
getDecl());
4248 dyn_cast_or_null<TemplateTemplateParmDecl>(
4252 llvm_unreachable(
"unexpected kind of template argument");
4258 if (Params->
size() != Args.size() || Params->
size() != SpecParams->
size())
4261 unsigned Depth = Params->
getDepth();
4263 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
4281 if (
auto *SpecNTTP =
4282 dyn_cast<NonTypeTemplateParmDecl>(SpecParams->
getParam(I))) {
4283 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(I));
4284 if (!NTTP || NTTP->getType().getCanonicalType() !=
4285 SpecNTTP->getType().getCanonicalType())
4293template<
typename PartialSpecDecl>
4295 if (Partial->getDeclContext()->isDependentContext())
4304 auto *
Template = Partial->getSpecializedTemplate();
4305 S.
Diag(Partial->getLocation(),
4306 diag::ext_partial_spec_not_more_specialized_than_primary)
4316 diag::note_partial_spec_not_more_specialized_than_primary)
4322 Template->getAssociatedConstraints(TemplateAC);
4323 Partial->getAssociatedConstraints(PartialAC);
4330 const llvm::SmallBitVector &DeducibleParams) {
4331 for (
unsigned I = 0, N = DeducibleParams.size(); I != N; ++I) {
4332 if (!DeducibleParams[I]) {
4334 if (Param->getDeclName())
4335 S.
Diag(Param->getLocation(), diag::note_non_deducible_parameter)
4336 << Param->getDeclName();
4338 S.
Diag(Param->getLocation(), diag::note_non_deducible_parameter)
4345template<
typename PartialSpecDecl>
4347 PartialSpecDecl *Partial) {
4360 auto *TemplateParams = Partial->getTemplateParameters();
4361 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
4363 TemplateParams->getDepth(), DeducibleParams);
4365 if (!DeducibleParams.all()) {
4366 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
4367 S.
Diag(Partial->getLocation(), diag::ext_partial_specs_not_deducible)
4369 << (NumNonDeducible > 1)
4371 Partial->getTemplateArgsAsWritten()->RAngleLoc);
4392 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
4394 for (
unsigned I = 0; I != TemplateParams->size(); ++I) {
4396 auto *Param = TemplateParams->getParam(I);
4398 DeducibleParams[I] =
true;
4401 if (!DeducibleParams.all()) {
4402 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
4403 Diag(TD->
getLocation(), diag::err_deduction_guide_template_not_deducible)
4404 << (NumNonDeducible > 1);
4415 "Variable template specialization is declared with a template id.");
4432 FnTemplate = *OTS->begin();
4442 if (
const auto *DSA =
VarTemplate->getAttr<NoSpecializationsAttr>()) {
4443 auto Message = DSA->getMessage();
4444 Diag(TemplateNameLoc, diag::warn_invalid_specialization)
4446 Diag(DSA->getLoc(), diag::note_marked_here) << DSA;
4450 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
4470 TemplateArgs.
size(),
4477 !TemplateSpecializationType::anyDependentTemplateArguments(
4479 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
4486 (!
Context.getLangOpts().CPlusPlus20 ||
4492 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
4502 llvm::FoldingSetInsertToken InsertToken;
4506 PrevDecl =
VarTemplate->findPartialSpecialization(
4532 cast_or_null<VarTemplatePartialSpecializationDecl>(PrevDecl);
4541 VarTemplate->AddPartialSpecialization(Partial, InsertToken);
4575 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
4579 diag::note_instantiation_required_here)
4609struct PartialSpecMatchResult {
4617 if (Var->
getName() !=
"format_kind" ||
4638 bool SetWrittenArgs) {
4639 assert(
Template &&
"A variable template id without template?");
4651 if (
Template->getDeclContext()->isDependentContext() ||
4652 TemplateSpecializationType::anyDependentTemplateArguments(
4659 return Context.isSameTemplateArgument(Arg1, Arg2);
4665 !IsLibstdcxxStdFormatKind(
PP, Var) &&
4669 IsSameTemplateArg)) {
4670 Diag(TemplateNameLoc,
4671 diag::err_auto_variable_cannot_appear_in_own_initializer)
4672 << diag::ParsingInitFor::VarTemplate << Var << Var->
getType();
4677 Template->getPartialSpecializations(PartialSpecs);
4681 Partial->getTemplateArgs().asArray(),
4682 IsSameTemplateArg)) {
4683 Diag(TemplateNameLoc,
4684 diag::err_auto_variable_cannot_appear_in_own_initializer)
4685 << diag::ParsingInitFor::VarTemplatePartialSpec << Partial
4686 << Partial->getType();
4695 llvm::FoldingSetInsertToken InsertToken;
4699 if (Spec->getType()->isUndeducedType()) {
4701 Diag(TemplateNameLoc,
4702 diag::err_auto_variable_cannot_appear_in_own_initializer)
4703 << diag::ParsingInitFor::VarTemplateExplicitSpec << Spec
4708 Diag(TemplateNameLoc, diag::err_var_template_spec_type_depends_on_self)
4709 << Spec << Spec->getType();
4723 bool AmbiguousPartialSpec =
false;
4724 typedef PartialSpecMatchResult MatchResult;
4736 Template->getPartialSpecializations(PartialSpecs);
4748 if (
Template->isMemberSpecialization() &&
4749 !Partial->isMemberSpecialization())
4764 Matched.push_back(PartialSpecMatchResult());
4765 Matched.back().Partial = Partial;
4770 if (Matched.size() >= 1) {
4772 if (Matched.size() == 1) {
4785 PEnd = Matched.end();
4788 PointOfInstantiation) ==
4796 PEnd = Matched.end();
4799 P->Partial, Best->Partial,
4800 PointOfInstantiation) != Best->Partial) {
4801 AmbiguousPartialSpec =
true;
4808 InstantiationPattern = Best->Partial;
4809 PartialSpecArgs = Best->Args;
4820 if (AmbiguousPartialSpec) {
4822 Diag(PointOfInstantiation, diag::err_partial_spec_ordering_ambiguous)
4825 for (MatchResult P : Matched)
4826 Diag(P.Partial->getLocation(), diag::note_partial_spec_match)
4838 Decl->setTemplateArgsAsWritten(TemplateArgs);
4841 dyn_cast<VarTemplatePartialSpecializationDecl>(InstantiationPattern))
4842 Decl->setInstantiationOf(D, PartialSpecArgs);
4846 assert(
Decl &&
"No variable template specialization?");
4856 *TemplateArgs,
false);
4857 if (
Decl.isInvalid())
4876 Template.getAsTemplateTemplateParmDecl();
4877 assert(
Parameter &&
"A variable template id without template?");
4879 if (
Parameter->templateParameterKind() !=
4903 Diag(Loc, diag::err_template_missing_args)
4911 bool TemplateKeyword,
4923 bool DoCheckConstraintSatisfaction) {
4924 assert(NamedConcept &&
"A concept template id without a template?");
4931 NamedConcept, ConceptNameInfo.
getLoc(),
4950 bool AreArgsDependent =
4951 TemplateSpecializationType::anyDependentTemplateArguments(
4958 TemplateKWLoc, ConceptNameInfo, FoundDecl,
TemplateName(NamedConcept),
4962 if (
const auto *
Concept = dyn_cast<ConceptDecl>(NamedConcept);
4964 DoCheckConstraintSatisfaction) {
4983 Context,
CL, CSD, AreArgsDependent ?
nullptr : &Satisfaction);
5002 assert(!R.isAmbiguous() &&
"ambiguous lookup when building templateid");
5008 SS, TemplateKWLoc.
isValid(), TD, R.getNameLoc());
5012 bool KnownDependent =
false;
5017 R.getRepresentativeDecl(), TemplateKWLoc, TemplateArgs);
5021 KnownDependent =
true;
5025 R.suppressDiagnostics();
5029 R.getRepresentativeDecl(),
5037 assert(SS.
isEmpty() &&
"template parameter with a scope specifier?");
5039 "template keyword in front of a template parameter?");
5041 R.getLookupNameInfo(),
5048 TemplateKWLoc, R.getLookupNameInfo(), RequiresADL, TemplateArgs,
5049 R.begin(), R.end(), KnownDependent,
5054 if (ULE->
getType() ==
Context.OverloadTy && R.isSingleResult() &&
5055 !R.getFoundDecl()->getAsFunction())
5065 assert(TemplateArgs || TemplateKWLoc.
isValid());
5069 false, TemplateKWLoc))
5072 if (R.isAmbiguous())
5075 if (R.wasNotFoundInCurrentInstantiation() || SS.
isInvalid())
5098 bool EnteringContext,
5100 bool AllowInjectedClassName) {
5102 DiagCompat(TemplateKWLoc, diag_compat::template_outside_of_template)
5112 else if (ObjectType)
5131 bool MemberOfUnknownSpecialization;
5133 ObjectType, EnteringContext,
Result,
5134 MemberOfUnknownSpecialization);
5137 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
5138 if (!AllowInjectedClassName && SS.
isNotEmpty() && LookupRD &&
5151 diag::ext_out_of_line_qualified_id_type_names_constructor)
5159 if (!MemberOfUnknownSpecialization) {
5190 {Qualifier, Name.Identifier, TemplateKWLoc.isValid()}));
5195 {Qualifier, Name.OperatorFunctionId.Operator,
5196 TemplateKWLoc.isValid()}));
5211 diag::err_template_kw_refers_to_dependent_non_template)
5213 << TemplateKWLoc.
isValid() << TemplateKWLoc;
5254 dyn_cast<DependentScopeDeclRefExpr>(E)) {
5255 SS.
Adopt(ArgExpr->getQualifierLoc());
5256 NameInfo = ArgExpr->getNameInfo();
5258 dyn_cast<CXXDependentScopeMemberExpr>(E)) {
5259 if (ArgExpr->isImplicitAccess()) {
5260 SS.
Adopt(ArgExpr->getQualifierLoc());
5261 NameInfo = ArgExpr->getMemberNameInfo();
5270 Result.wasNotFoundInCurrentInstantiation()) {
5271 assert(SS.
getScopeRep() &&
"dependent scope expr must has a scope!");
5275 ? diag::ext_ms_template_type_arg_missing_typename
5276 : diag::err_template_arg_must_be_type_suggest)
5315 SugaredConverted.push_back(Arg);
5316 CanonicalConverted.push_back(Arg);
5322 Diag(SR.
getBegin(), diag::err_template_arg_must_be_type) << SR;
5336 ArgType->isObjCLifetimeType() &&
5344 CanonicalConverted.push_back(
5379 Output = Param->getDefaultArgument();
5393 for (
unsigned i = 0, e = Param->getDepth(); i != e; ++i)
5396 bool ForLambdaCallOperator =
false;
5397 if (
const auto *Rec = dyn_cast<CXXRecordDecl>(
Template->getDeclContext()))
5398 ForLambdaCallOperator = Rec->isLambda();
5400 !ForLambdaCallOperator);
5403 Param->getDefaultArgumentLoc(),
5404 Param->getDeclName()))
5448 for (
unsigned i = 0, e = Param->getDepth(); i != e; ++i)
5455 TemplateArgLists, Output);
5492 SugaredConverted,
SourceRange(TemplateLoc, RAngleLoc));
5499 for (
unsigned i = 0, e = Param->getDepth(); i != e; ++i)
5516 HasDefaultArg =
false;
5522 HasDefaultArg =
true;
5525 RAngleLoc, TypeParm, SugaredConverted,
5526 CanonicalConverted, Output))
5532 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
5536 HasDefaultArg =
true;
5539 RAngleLoc, NonTypeParm, SugaredConverted,
5540 CanonicalConverted, Output))
5550 HasDefaultArg =
true;
5554 *
this,
Template, TemplateKWLoc, TemplateNameLoc, RAngleLoc, TempTempParm,
5555 SugaredConverted, CanonicalConverted, QualifierLoc);
5579 TemplateName Name = TagLoc.getTypePtr()->getTemplateName(Context);
5585 TagLoc.getQualifierLoc(), TagLoc.getNameLoc());
5592 unsigned ArgumentPackIndex,
5606 QualType NTTPType = NTTP->getType();
5607 if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack())
5608 NTTPType = NTTP->getExpansionType(ArgumentPackIndex);
5616 const AutoType *AT =
T->getContainedAutoType();
5618 AT->getDeducedType().isNull();
5621 isUndeducedAuto(NTTPType,
false) &&
5638 if (
auto *PET = NTTPType->
getAs<PackExpansionType>()) {
5640 NTTPType =
SubstType(PET->getPattern(), MLTAL, NTTP->getLocation(),
5641 NTTP->getDeclName());
5643 NTTPType =
SubstType(NTTPType, MLTAL, NTTP->getLocation(),
5644 NTTP->getDeclName());
5651 NTTP->getLocation());
5656 auto checkExpr = [&](
Expr *E) ->
Expr * {
5659 NTTP, NTTPType, E, SugaredResult, CanonicalResult,
5671 llvm_unreachable(
"Should never see a NULL template argument here");
5675 Expr *R = checkExpr(E);
5700 assert(R.isUsable());
5701 if (!checkExpr(R.get()))
5740 NTTP, NTTPType, E.
get(), SugaredResult, CanonicalResult,
5772 if (
T->isFunctionType())
5773 Diag(SR.
getBegin(), diag::err_template_arg_nontype_ambig) << SR <<
T;
5775 Diag(SR.
getBegin(), diag::err_template_arg_must_be_expr) << SR;
5781 llvm_unreachable(
"Caller must expand template argument packs");
5826 ArgLoc = ConvertedArg;
5831 llvm_unreachable(
"Should never see a NULL template argument here");
5842 Context.getCanonicalTemplateArgument(Arg));
5870 llvm_unreachable(
"non-type argument with template template parameter");
5873 llvm_unreachable(
"Caller must expand template argument packs");
5880template <
typename TemplateParmDecl>
5883 const TemplateParmDecl *D) {
5887 ->getTemplateParameters()
5888 ->getParam(D->getIndex()));
5895 D->getDefaultArgumentLoc(), Modules,
5906 S.
Diag(Loc, diag::err_template_arg_list_different_arity)
5922 DefaultArgs, PartialTemplateArgs, CTAI, UpdateArgsWithConversions,
5953 unsigned ArgIdx = 0, NumArgs = NewArgs.
size();
5956 ParamEnd = Params->
end(),
5960 if (
size_t ParamIdx = Param - ParamBegin;
5963 assert(ArgIdx == NumArgs &&
"bad default argument deduction");
5965 assert(Param + DefaultArgs.
Args.size() <= ParamEnd);
5970 Context.getCanonicalTemplateArgument(DefArg));
5980 if (*Expansions == SugaredArgumentPack.size()) {
5985 SugaredArgumentPack.clear();
5989 CanonicalArgumentPack.clear();
5994 }
else if (ArgIdx == NumArgs && !PartialTemplateArgs) {
5996 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
6008 dyn_cast<NonTypeTemplateParmDecl>(*Param);
6010 auto TL = NTTP->getTypeSourceInfo()
6015 for (
const auto &UPP : Unexpanded) {
6016 auto *TST = dyn_cast<const TemplateSpecializationType *>(UPP.first);
6021 Diag(TL.getEllipsisLoc(),
6022 diag::err_unsupported_builtin_template_pack_expansion)
6023 << TST->getTemplateName();
6028 if (ArgIdx < NumArgs) {
6030 bool NonPackParameter =
6040 if (!(*Param)->isTemplateParameterPack() ||
6047 RAngleLoc, SugaredArgumentPack.size(), CTAI,
6052 clang::isSubstitutedDefaultArgument(
Context, Arg, *Param,
6062 RAngleLoc, SugaredArgumentPack.size(), CTAI,
6069 if (ArgIsExpansion && NonPackParameter) {
6079 diag::err_template_expansion_into_fixed_list)
6090 if (ArgIsExpansion && (CTAI.
MatchingTTP || NonPackParameter)) {
6094 if (!SugaredArgumentPack.empty()) {
6098 SugaredArgumentPack.begin(),
6099 SugaredArgumentPack.end());
6100 SugaredArgumentPack.clear();
6103 CanonicalArgumentPack.begin(),
6104 CanonicalArgumentPack.end());
6105 CanonicalArgumentPack.clear();
6108 while (ArgIdx < NumArgs) {
6112 Context.getCanonicalTemplateArgument(Arg));
6119 if ((*Param)->isTemplateParameterPack()) {
6134 if (PartialTemplateArgs) {
6135 if ((*Param)->isTemplateParameterPack() && !SugaredArgumentPack.empty()) {
6146 if ((*Param)->isTemplateParameterPack()) {
6148 "Should have dealt with this already");
6153 if (Param + 1 != ParamEnd) {
6155 (
Template->getMostRecentDecl()->getKind() != Decl::Kind::Concept) &&
6156 "Concept templates must have parameter packs at the end.");
6162 SugaredArgumentPack.clear();
6166 CanonicalArgumentPack.clear();
6185 if (!HasDefaultArg) {
6186 if (
auto *TTP = dyn_cast<TemplateTypeParmDecl>(*Param))
6188 else if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*Param))
6221 if (isTemplateTemplateParameter)
6236 while (ArgIdx < NumArgs &&
6237 NewArgs[ArgIdx].
getArgument().isPackExpansion()) {
6241 Context.getCanonicalTemplateArgument(Arg));
6247 if (ArgIdx < NumArgs) {
6248 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
6259 if (UpdateArgsWithConversions)
6260 TemplateArgs = std::move(NewArgs);
6262 if (!PartialTemplateArgs) {
6269 if (
auto *TD = dyn_cast<TemplateDecl>(NewContext))
6271 auto *RD = dyn_cast<CXXRecordDecl>(NewContext);
6275 dyn_cast_or_null<CXXMethodDecl>(
Template->getTemplatedDecl()))
6276 ThisQuals =
Method->getMethodQualifiers();
6300 class UnnamedLocalNoLinkageFinder
6301 :
public TypeVisitor<UnnamedLocalNoLinkageFinder, bool>
6309 UnnamedLocalNoLinkageFinder(
Sema &S,
SourceRange SR) : S(S), SR(SR) { }
6312 return T.isNull() ?
false : inherited::Visit(
T.getTypePtr());
6315#define TYPE(Class, Parent) \
6316 bool Visit##Class##Type(const Class##Type *);
6317#define ABSTRACT_TYPE(Class, Parent) \
6318 bool Visit##Class##Type(const Class##Type *) { return false; }
6319#define NON_CANONICAL_TYPE(Class, Parent) \
6320 bool Visit##Class##Type(const Class##Type *) { return false; }
6321#include "clang/AST/TypeNodes.inc"
6323 bool VisitTagDecl(
const TagDecl *Tag);
6328bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(
const BuiltinType*) {
6332bool UnnamedLocalNoLinkageFinder::VisitComplexType(
const ComplexType*
T) {
6333 return Visit(
T->getElementType());
6336bool UnnamedLocalNoLinkageFinder::VisitPointerType(
const PointerType*
T) {
6337 return Visit(
T->getPointeeType());
6340bool UnnamedLocalNoLinkageFinder::VisitBlockPointerType(
6342 return Visit(
T->getPointeeType());
6345bool UnnamedLocalNoLinkageFinder::VisitLValueReferenceType(
6347 return Visit(
T->getPointeeType());
6350bool UnnamedLocalNoLinkageFinder::VisitRValueReferenceType(
6352 return Visit(
T->getPointeeType());
6355bool UnnamedLocalNoLinkageFinder::VisitMemberPointerType(
6357 if (Visit(
T->getPointeeType()))
6359 if (
auto *RD =
T->getMostRecentCXXRecordDecl())
6360 return VisitTagDecl(RD);
6361 return VisitNestedNameSpecifier(
T->getQualifier());
6364bool UnnamedLocalNoLinkageFinder::VisitConstantArrayType(
6366 return Visit(
T->getElementType());
6369bool UnnamedLocalNoLinkageFinder::VisitIncompleteArrayType(
6371 return Visit(
T->getElementType());
6374bool UnnamedLocalNoLinkageFinder::VisitVariableArrayType(
6376 return Visit(
T->getElementType());
6379bool UnnamedLocalNoLinkageFinder::VisitDependentSizedArrayType(
6381 return Visit(
T->getElementType());
6384bool UnnamedLocalNoLinkageFinder::VisitDependentSizedExtVectorType(
6386 return Visit(
T->getElementType());
6389bool UnnamedLocalNoLinkageFinder::VisitDependentSizedMatrixType(
6391 return Visit(
T->getElementType());
6394bool UnnamedLocalNoLinkageFinder::VisitDependentAddressSpaceType(
6396 return Visit(
T->getPointeeType());
6399bool UnnamedLocalNoLinkageFinder::VisitVectorType(
const VectorType*
T) {
6400 return Visit(
T->getElementType());
6403bool UnnamedLocalNoLinkageFinder::VisitDependentVectorType(
6405 return Visit(
T->getElementType());
6408bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(
const ExtVectorType*
T) {
6409 return Visit(
T->getElementType());
6412bool UnnamedLocalNoLinkageFinder::VisitConstantMatrixType(
6414 return Visit(
T->getElementType());
6417bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
6419 for (
const auto &A :
T->param_types()) {
6424 return Visit(
T->getReturnType());
6427bool UnnamedLocalNoLinkageFinder::VisitFunctionNoProtoType(
6429 return Visit(
T->getReturnType());
6432bool UnnamedLocalNoLinkageFinder::VisitUnresolvedUsingType(
6437bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(
const TypeOfExprType*) {
6441bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(
const TypeOfType*
T) {
6442 return Visit(
T->getUnmodifiedType());
6445bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(
const DecltypeType*) {
6449bool UnnamedLocalNoLinkageFinder::VisitPackIndexingType(
6450 const PackIndexingType *) {
6454bool UnnamedLocalNoLinkageFinder::VisitUnaryTransformType(
6455 const UnaryTransformType*) {
6459bool UnnamedLocalNoLinkageFinder::VisitAutoType(
const AutoType *
T) {
6460 return Visit(
T->getDeducedType());
6463bool UnnamedLocalNoLinkageFinder::VisitDeducedTemplateSpecializationType(
6464 const DeducedTemplateSpecializationType *
T) {
6465 return Visit(
T->getDeducedType());
6468bool UnnamedLocalNoLinkageFinder::VisitRecordType(
const RecordType*
T) {
6469 return VisitTagDecl(
T->getDecl()->getDefinitionOrSelf());
6472bool UnnamedLocalNoLinkageFinder::VisitEnumType(
const EnumType*
T) {
6473 return VisitTagDecl(
T->getDecl()->getDefinitionOrSelf());
6476bool UnnamedLocalNoLinkageFinder::VisitTemplateTypeParmType(
6477 const TemplateTypeParmType*) {
6481bool UnnamedLocalNoLinkageFinder::VisitSubstTemplateTypeParmPackType(
6482 const SubstTemplateTypeParmPackType *) {
6486bool UnnamedLocalNoLinkageFinder::VisitSubstBuiltinTemplatePackType(
6487 const SubstBuiltinTemplatePackType *) {
6491bool UnnamedLocalNoLinkageFinder::VisitTemplateSpecializationType(
6492 const TemplateSpecializationType*) {
6496bool UnnamedLocalNoLinkageFinder::VisitInjectedClassNameType(
6497 const InjectedClassNameType*
T) {
6498 return VisitTagDecl(
T->getDecl()->getDefinitionOrSelf());
6501bool UnnamedLocalNoLinkageFinder::VisitDependentNameType(
6502 const DependentNameType*
T) {
6503 return VisitNestedNameSpecifier(
T->getQualifier());
6506bool UnnamedLocalNoLinkageFinder::VisitPackExpansionType(
6507 const PackExpansionType*
T) {
6508 return Visit(
T->getPattern());
6511bool UnnamedLocalNoLinkageFinder::VisitObjCObjectType(
const ObjCObjectType *) {
6515bool UnnamedLocalNoLinkageFinder::VisitObjCInterfaceType(
6520bool UnnamedLocalNoLinkageFinder::VisitObjCObjectPointerType(
6525bool UnnamedLocalNoLinkageFinder::VisitAtomicType(
const AtomicType*
T) {
6526 return Visit(
T->getValueType());
6529bool UnnamedLocalNoLinkageFinder::VisitOverflowBehaviorType(
6530 const OverflowBehaviorType *
T) {
6531 return Visit(
T->getUnderlyingType());
6534bool UnnamedLocalNoLinkageFinder::VisitPipeType(
const PipeType*
T) {
6538bool UnnamedLocalNoLinkageFinder::VisitBitIntType(
const BitIntType *
T) {
6542bool UnnamedLocalNoLinkageFinder::VisitArrayParameterType(
6544 return VisitConstantArrayType(
T);
6547bool UnnamedLocalNoLinkageFinder::VisitDependentBitIntType(
6552bool UnnamedLocalNoLinkageFinder::VisitTagDecl(
const TagDecl *Tag) {
6553 if (
Tag->getDeclContext()->isFunctionOrMethod()) {
6554 S.Diag(SR.getBegin(), S.getLangOpts().CPlusPlus11
6555 ? diag::warn_cxx98_compat_template_arg_local_type
6556 : diag::ext_template_arg_local_type)
6557 << S.Context.getCanonicalTagType(Tag) << SR;
6561 if (!
Tag->hasNameForLinkage()) {
6562 S.Diag(SR.getBegin(),
6563 S.getLangOpts().CPlusPlus11 ?
6564 diag::warn_cxx98_compat_template_arg_unnamed_type :
6565 diag::ext_template_arg_unnamed_type) << SR;
6566 S.Diag(
Tag->getLocation(), diag::note_template_unnamed_type_here);
6573bool UnnamedLocalNoLinkageFinder::VisitNestedNameSpecifier(
6584 llvm_unreachable(
"Invalid NestedNameSpecifier::Kind!");
6587bool UnnamedLocalNoLinkageFinder::VisitHLSLAttributedResourceType(
6588 const HLSLAttributedResourceType *
T) {
6589 if (
T->hasContainedType() && Visit(
T->getContainedType()))
6591 return Visit(
T->getWrappedType());
6594bool UnnamedLocalNoLinkageFinder::VisitHLSLInlineSpirvType(
6595 const HLSLInlineSpirvType *
T) {
6596 for (
auto &Operand :
T->getOperands())
6598 if (Visit(
Operand.getResultType()))
6604 assert(ArgInfo &&
"invalid TypeSourceInfo");
6610 return Diag(SR.
getBegin(), diag::err_variably_modified_template_arg) << Arg;
6611 }
else if (
Context.hasSameUnqualifiedType(Arg,
Context.OverloadTy)) {
6612 return Diag(SR.
getBegin(), diag::err_template_arg_overload_type) << SR;
6623 UnnamedLocalNoLinkageFinder Finder(*
this, SR);
6624 (void)Finder.Visit(CanonArg);
6641 Decl *Entity =
nullptr) {
6647 if (Entity && Entity->hasAttr<DLLImportAttr>())
6652 "Incomplete parameter type in isNullPointerValueTemplateArgument!");
6665 EvalResult.
Diag = &Notes;
6673 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
6674 diag::note_invalid_subexpr_in_const_expr) {
6675 DiagLoc = Notes[0].first;
6679 S.
Diag(DiagLoc, diag::err_template_arg_not_address_constant)
6681 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
6682 S.
Diag(Notes[I].first, Notes[I].second);
6700 bool ObjCLifetimeConversion;
6703 ObjCLifetimeConversion))
6708 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
6727 std::string Code =
"static_cast<" + ParamType.
getAsString() +
">(";
6728 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_untyped_null_constant)
6748 bool ObjCLifetimeConversion;
6752 ObjCLifetimeConversion)) {
6757 if (!ParamRef->getPointeeType()->isFunctionType()) {
6767 unsigned ParamQuals = ParamRef->getPointeeType().getCVRQualifiers();
6768 unsigned ArgQuals = ArgType.getCVRQualifiers();
6770 if ((ParamQuals | ArgQuals) != ParamQuals) {
6772 diag::err_template_arg_ref_bind_ignores_quals)
6809 bool AddressTaken =
false;
6816 bool ExtWarnMSTemplateArg =
false;
6819 while (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(Arg)) {
6821 if (UnOpKind == UO_Deref)
6822 ExtWarnMSTemplateArg =
true;
6823 if (UnOpKind == UO_AddrOf || UnOpKind == UO_Deref) {
6826 FirstOpKind = UnOpKind;
6827 FirstOpLoc = UnOp->getOperatorLoc();
6833 if (ExtWarnMSTemplateArg)
6837 if (FirstOpKind == UO_AddrOf)
6838 AddressTaken =
true;
6842 assert(FirstOpKind == UO_Deref);
6867 bool ExtraParens =
false;
6871 diag_compat::template_arg_extra_parens)
6876 Arg =
Parens->getSubExpr();
6881 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6885 if (UnOp->getOpcode() == UO_AddrOf) {
6886 Arg = UnOp->getSubExpr();
6887 AddressTaken =
true;
6888 AddrOpLoc = UnOp->getOperatorLoc();
6893 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6898 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Arg))
6899 Entity = DRE->getDecl();
6901 Entity = CUE->getGuidDecl();
6908 S.
Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
6911 CanonicalConverted =
6928 CanonicalConverted =
6949 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Entity)) {
6950 if (!Method->isStatic()) {
6959 VarDecl *Var = dyn_cast<VarDecl>(Entity);
6960 MSGuidDecl *Guid = dyn_cast<MSGuidDecl>(Entity);
6963 if (!
Func && !Var && !Guid) {
6975 S.
Diag(Entity->
getLocation(), diag::note_template_arg_internal_object)
6980 S.
Diag(Entity->
getLocation(), diag::note_template_arg_internal_object)
7009 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
7015 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
7057 CanonicalConverted =
7071 Expr *Arg = ResultArg;
7072 bool ObjCLifetimeConversion;
7084 bool ExtraParens =
false;
7086 if (!
Invalid && !ExtraParens) {
7092 Arg =
Parens->getSubExpr();
7096 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
7101 if (UnOp->getOpcode() == UO_AddrOf) {
7102 DRE = dyn_cast<DeclRefExpr>(UnOp->getSubExpr());
7108 else if ((DRE = dyn_cast<DeclRefExpr>(Arg))) {
7114 CanonicalConverted =
7118 CanonicalConverted =
7137 S.
Diag(ResultArg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
7149 ObjCLifetimeConversion)) {
7156 S.
Diag(ResultArg->
getBeginLoc(), diag::err_template_arg_not_convertible)
7164 diag::err_template_arg_not_pointer_to_member_form)
7173 ->isImplicitObjectMemberFunction()) &&
7174 "Only non-static member pointers can make it here");
7180 CanonicalConverted =
7185 CanonicalConverted =
7193 S.
Diag(Arg->
getBeginLoc(), diag::err_template_arg_not_pointer_to_member_form)
7213 auto *ArgPE = dyn_cast<PackExpansionExpr>(Arg);
7214 Expr *DeductionArg = ArgPE ? ArgPE->getPattern() : Arg;
7215 auto setDeductionArg = [&](
Expr *NewDeductionArg) {
7216 DeductionArg = NewDeductionArg;
7220 DeductionArg, ArgPE->getEllipsisLoc(), ArgPE->getNumExpansions());
7228 bool IsDeduced = DeducedT && DeducedT->getDeducedType().isNull();
7234 Context.getTrivialTypeSourceInfo(ParamType, Param->getLocation());
7239 DeductionArg->
getBeginLoc(),
false, DeductionArg);
7247 Param->getTemplateDepth() + 1);
7263 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param))
7265 diag::err_non_type_template_parm_type_deduction_failure)
7266 << Param->getDeclName() << NTTP->getType() << Arg->
getType()
7272 assert(!ParamType.
isNull() &&
"substituting DependentTy can't fail");
7280 if (ParamType.
isNull()) {
7288 "non-type template parameter type cannot be qualified");
7302 setDeductionArg(E.
get());
7306 Context.getCanonicalTemplateArgument(SugaredConverted));
7315 : !
Context.hasSameUnqualifiedType(ParamType,
7321 Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
7334 if (ArgPE && !StrictCheck) {
7337 Context.getCanonicalTemplateArgument(SugaredConverted));
7351 Context.hasSameUnqualifiedType(ParamType, InnerArg->
getType())) {
7353 if (
auto *TPO = dyn_cast<TemplateParamObjectDecl>(ND)) {
7362 CanonicalConverted =
7363 Context.getCanonicalTemplateArgument(SugaredConverted);
7373 bool IsConvertedConstantExpression =
true;
7376 StartLoc,
false, DeductionArg);
7392 IsConvertedConstantExpression =
false;
7401 if (IsConvertedConstantExpression) {
7403 DeductionArg, ParamType,
7411 ArgResult = DeductionArg;
7417 setDeductionArg(ArgResult.
get());
7419 CanonicalConverted =
7420 Context.getCanonicalTemplateArgument(SugaredConverted);
7427 false, PreNarrowingValue);
7430 setDeductionArg(ArgResult.
get());
7432 if (
Value.isLValue()) {
7451 if (
Value.hasLValuePath() &&
Value.getLValuePath().size() == 1 && VD &&
7453 Value.getLValuePath()[0].getAsArrayIndex() == 0 &&
7457 CanonicalConverted =
7458 Context.getCanonicalTemplateArgument(SugaredConverted);
7461 CanonicalConverted =
7470 if (!
Value.hasLValuePath() ||
Value.getLValuePath().size() ||
7471 Value.isLValueOnePastTheEnd()) {
7472 Diag(StartLoc, diag::err_non_type_template_arg_subobject)
7477 "null reference should not be a constant expression");
7479 "non-null value of type nullptr_t?");
7483 if (
Value.isAddrLabelDiff())
7484 return Diag(StartLoc, diag::err_non_type_template_arg_addr_label_diff);
7488 CanonicalConverted =
7489 Context.getCanonicalTemplateArgument(SugaredConverted);
7492 CanonicalConverted =
7499 assert(!ArgPE && !StrictCheck);
7531 Arg = ArgResult.
get();
7536 CanonicalConverted =
7537 Context.getCanonicalTemplateArgument(SugaredConverted);
7546 IntegerType = ED->getIntegerType();
7548 ?
Context.getIntWidth(IntegerType)
7549 :
Context.getTypeSize(IntegerType));
7552 CanonicalConverted =
7560 Arg = ArgResult.
get();
7572 if (!
ArgType->isIntegralOrEnumerationType()) {
7573 Diag(Arg->
getBeginLoc(), diag::err_template_arg_not_integral_or_enumeral)
7587 return S.
Diag(Loc, diag::err_template_arg_not_ice) <<
T;
7612 Diag(StartLoc, diag::err_template_arg_not_convertible)
7625 CanonicalConverted =
7626 Context.getCanonicalTemplateArgument(SugaredConverted);
7632 IntegerType = ED->getIntegerType();
7638 unsigned AllowedBits =
Context.getTypeSize(IntegerType);
7639 if (
Value.getBitWidth() != AllowedBits)
7643 llvm::APSInt OldValue =
Value;
7648 ?
Context.getIntWidth(IntegerType)
7649 :
Context.getTypeSize(IntegerType);
7650 if (
Value.getBitWidth() != AllowedBits)
7656 (OldValue.isSigned() && OldValue.isNegative())) {
7664 unsigned RequiredBits;
7666 RequiredBits = OldValue.getActiveBits();
7667 else if (OldValue.isUnsigned())
7668 RequiredBits = OldValue.getActiveBits() + 1;
7670 RequiredBits = OldValue.getSignificantBits();
7671 if (RequiredBits > AllowedBits) {
7681 CanonicalConverted =
7732 *
this, Param, ParamType, Arg, IsSpecified, SugaredConverted,
7733 CanonicalConverted))
7739 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
7750 "Only object pointers allowed here");
7753 *
this, Param, ParamType, Arg, IsSpecified, SugaredConverted,
7754 CanonicalConverted))
7766 assert(ParamRefType->getPointeeType()->isIncompleteOrObjectType() &&
7767 "Only object references allowed here");
7771 ParamRefType->getPointeeType(),
7786 *
this, Param, ParamType, Arg, IsSpecified, SugaredConverted,
7787 CanonicalConverted))
7796 CanonicalConverted =
7797 Context.getCanonicalTemplateArgument(SugaredConverted);
7804 << Arg->
getType() << ParamType;
7812 Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
7826 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
7849 unsigned DiagFoundKind = 0;
7851 if (
auto *TTP = llvm::dyn_cast<TemplateTemplateParmDecl>(
Template)) {
7852 switch (TTP->templateParameterKind()) {
7863 Kind = TTP->templateParameterKind();
7879 assert(
false &&
"Unexpected Decl");
7882 if (Kind == Param->templateParameterKind()) {
7886 unsigned DiagKind = 0;
7887 switch (Param->templateParameterKind()) {
7900 Diag(
Template->getLocation(), diag::note_template_arg_refers_to_template_here)
7914 bool *StrictPackMatch) {
7921 assert(Name.
isDependent() &&
"Non-dependent template isn't a declaration?");
7948 if (ParamsAC.empty())
7951 Template->getAssociatedConstraints(TemplateAC);
7953 bool IsParamAtLeastAsConstrained;
7955 IsParamAtLeastAsConstrained))
7957 if (!IsParamAtLeastAsConstrained) {
7959 diag::err_template_template_parameter_not_at_least_as_constrained)
7961 Diag(Param->getLocation(), diag::note_entity_declared_at) << Param;
7971 unsigned HereDiagID,
7972 unsigned ExternalDiagID) {
7977 llvm::raw_svector_ostream Out(Str);
7985 std::optional<SourceRange> ParamRange) {
7988 diag::note_template_decl_external);
7989 if (ParamRange && ParamRange->isValid()) {
7991 "Parameter range has location when Decl does not");
7998 diag::note_template_param_external);
8013 ParamType =
Context.getArrayDecayedType(ParamType);
8015 ParamType =
Context.getPointerType(ParamType);
8024 ? CK_NullToMemberPointer
8025 : CK_NullToPointer);
8028 "Only declaration template arguments permitted here");
8065 "arg for class template param not a template parameter object");
8070 "unexpected type for decl template argument");
8078 "value kind mismatch for non-type template argument");
8084 if (!
Context.hasSameType(SrcExprType, DestExprType)) {
8086 if (
Context.hasSimilarType(SrcExprType, DestExprType) ||
8097 "unexpected conversion required for non-type template argument");
8124 T = ED->getIntegerType();
8127 if (
T->isAnyCharacterType()) {
8129 if (
T->isWideCharType())
8133 else if (
T->isChar16Type())
8135 else if (
T->isChar32Type())
8141 }
else if (
T->isBooleanType()) {
8188 llvm_unreachable(
"unexpected template argument value");
8213 return MakeInitList(
8226 return MakeInitList(Elts);
8230 llvm_unreachable(
"Matrix template argument expression not yet supported");
8234 llvm_unreachable(
"Unexpected APValue kind.");
8243 if (
T->isReferenceType()) {
8244 T =
T->getPointeeType();
8253 llvm_unreachable(
"Unhandled APValue::ValueKind enum");
8265 llvm_unreachable(
"not a non-type template argument");
8283 llvm_unreachable(
"Unhandled TemplateArgument::ArgKind enum");
8290 const NamedDecl *OldInstFrom,
bool Complain,
8295 unsigned NextDiag = diag::err_template_param_different_kind;
8296 if (TemplateArgLoc.
isValid()) {
8297 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
8298 NextDiag = diag::note_template_param_different_kind;
8300 S.
Diag(
New->getLocation(), NextDiag)
8315 unsigned NextDiag = diag::err_template_parameter_pack_non_pack;
8316 if (TemplateArgLoc.
isValid()) {
8317 S.
Diag(TemplateArgLoc,
8318 diag::err_template_arg_template_params_mismatch);
8319 NextDiag = diag::note_template_parameter_pack_non_pack;
8325 S.
Diag(
New->getLocation(), NextDiag)
8326 << ParamKind <<
New->isParameterPack();
8335 dyn_cast<NonTypeTemplateParmDecl>(Old)) {
8343 (!OldNTTP->getType()->isDependentType() &&
8353 unsigned NextDiag = diag::err_template_nontype_parm_different_type;
8354 if (TemplateArgLoc.
isValid()) {
8355 S.
Diag(TemplateArgLoc,
8356 diag::err_template_arg_template_params_mismatch);
8357 NextDiag = diag::note_template_nontype_parm_different_type;
8361 S.
Diag(OldNTTP->getLocation(),
8362 diag::note_template_nontype_parm_prev_declaration)
8363 << OldNTTP->getType();
8373 dyn_cast<TemplateTemplateParmDecl>(Old)) {
8379 OldTTP->getTemplateParameters(), Complain,
8390 const Expr *NewC =
nullptr, *OldC =
nullptr;
8394 NewC = TC->getImmediatelyDeclaredConstraint();
8396 OldC = TC->getImmediatelyDeclaredConstraint();
8399 ->getPlaceholderTypeConstraint())
8402 ->getPlaceholderTypeConstraint())
8405 llvm_unreachable(
"unexpected template parameter type");
8407 auto Diagnose = [&] {
8409 diag::err_template_different_type_constraint);
8411 diag::note_template_prev_declaration) << 0;
8414 if (!NewC != !OldC) {
8441 unsigned NextDiag = diag::err_template_param_list_different_arity;
8442 if (TemplateArgLoc.
isValid()) {
8443 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
8444 NextDiag = diag::note_template_param_list_different_arity;
8446 S.
Diag(
New->getTemplateLoc(), NextDiag)
8447 << (
New->size() > Old->
size())
8459 if (Old->
size() !=
New->size()) {
8476 OldParmEnd = Old->
end();
8477 OldParm != OldParmEnd; ++OldParm, ++NewParm) {
8478 if (NewParm == NewParmEnd) {
8485 OldInstFrom, Complain, Kind,
8491 if (NewParm != NewParmEnd) {
8500 const Expr *NewRC =
New->getRequiresClause();
8505 diag::err_template_different_requires_clause);
8507 diag::note_template_prev_declaration) << 0;
8510 if (!NewRC != !OldRC) {
8546 Diag(Range.getBegin(), diag::err_template_linkage) << Range;
8548 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
8573 while (isa_and_nonnull<CapturedDecl, CXXRecordDecl>(OutCtx))
8578 diag::err_template_inside_local_class)
8586 diag::err_template_outside_namespace_or_class_scope)
8597 return Record->getTemplateSpecializationKind();
8598 if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(D))
8599 return Function->getTemplateSpecializationKind();
8600 if (
VarDecl *Var = dyn_cast<VarDecl>(D))
8653 S.
Diag(Loc, diag::err_template_spec_unknown_kind)
8663 S.
Diag(Loc, diag::err_template_spec_decl_function_scope)
8678 : DC->
Equals(SpecializedContext))) {
8680 S.
Diag(Loc, diag::err_template_spec_redecl_global_scope)
8681 << EntityKind << Specialized;
8684 int Diag = diag::err_template_spec_redecl_out_of_scope;
8686 Diag = diag::ext_ms_template_spec_redecl_out_of_scope;
8687 S.
Diag(Loc,
Diag) << EntityKind << Specialized
8688 << ND << isa<CXXRecordDecl>(ND);
8691 S.
Diag(Specialized->getLocation(), diag::note_specialized_entity);
8705 DependencyChecker Checker(Depth,
true);
8706 Checker.TraverseStmt(E);
8709 return Checker.MatchLoc;
8715 DependencyChecker Checker(Depth,
true);
8716 Checker.TraverseTypeLoc(TL);
8719 return Checker.MatchLoc;
8727 bool HasError =
false;
8728 for (
unsigned I = 0; I != NumArgs; ++I) {
8731 S, TemplateNameLoc, Param, Args[I].pack_begin(),
8732 Args[I].pack_size(), IsDefaultArgument))
8749 ArgExpr = Expansion->getPattern();
8753 ArgExpr = ICE->getSubExpr();
8763 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ArgExpr))
8787 if (ParamUseRange.
isValid()) {
8788 if (IsDefaultArgument) {
8789 S.
Diag(TemplateNameLoc,
8790 diag::err_dependent_non_type_arg_in_partial_spec);
8792 diag::note_dependent_non_type_default_arg_in_partial_spec)
8796 diag::err_dependent_non_type_arg_in_partial_spec)
8803 Param->getDepth(), Param->getTypeSourceInfo()->getTypeLoc());
8804 if (ParamUseRange.
isValid()) {
8806 diag::err_dependent_typed_non_type_arg_in_partial_spec)
8807 << Param->getType();
8826 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
8828 = dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->
getParam(I));
8833 Param, &TemplateArgs[I],
8834 1, I >= NumExplicit))
8858 Diag(TemplateNameLoc, diag::err_not_class_template_specialization)
8864 if (
const auto *DSA =
ClassTemplate->getAttr<NoSpecializationsAttr>()) {
8865 auto Message = DSA->getMessage();
8866 Diag(TemplateNameLoc, diag::warn_invalid_specialization)
8868 Diag(DSA->getLoc(), diag::note_marked_here) << DSA;
8876 bool isMemberSpecialization =
false;
8877 bool isPartialSpecialization =
false;
8882 TemplateNameLoc, &TemplateId,
8894 KWLoc, TemplateNameLoc, SS, &TemplateId, TemplateParameterLists,
8909 if (TemplateParams && TemplateParams->
size() > 0) {
8910 isPartialSpecialization =
true;
8913 Diag(KWLoc, diag::err_partial_specialization_friend)
8921 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
8924 if (TTP->hasDefaultArgument()) {
8925 Diag(TTP->getDefaultArgumentLoc(),
8926 diag::err_default_arg_in_partial_spec);
8927 TTP->removeDefaultArgument();
8930 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
8931 if (NTTP->hasDefaultArgument()) {
8932 Diag(NTTP->getDefaultArgumentLoc(),
8933 diag::err_default_arg_in_partial_spec)
8934 << NTTP->getDefaultArgument().getSourceRange();
8935 NTTP->removeDefaultArgument();
8941 diag::err_default_arg_in_partial_spec)
8947 }
else if (TemplateParams) {
8949 Diag(KWLoc, diag::err_template_spec_friend)
8956 "should have a 'template<>' for this decl");
8963 "Invalid enum tag in class template spec!");
8967 Diag(KWLoc, diag::err_use_with_wrong_tag)
8972 diag::note_previous_use);
8981 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
8983 isPartialSpecialization
8999 if (isPartialSpecialization) {
9001 TemplateArgs.
size(),
9008 !TemplateSpecializationType::anyDependentTemplateArguments(
9010 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
9012 isPartialSpecialization =
false;
9017 llvm::FoldingSetInsertToken InsertToken;
9020 if (isPartialSpecialization)
9034 isPartialSpecialization))
9037 if (!isPartialSpecialization) {
9045 if (TemplateParameterLists.size() > 0) {
9047 TemplateParameterLists);
9054 Context.getCanonicalTemplateSpecializationType(
9061 (!
Context.getLangOpts().CPlusPlus20 ||
9070 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
9078 TemplateParameterLists.data(), isMemberSpecialization);
9083 cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl);
9086 Context, Kind, DC, KWLoc, TemplateNameLoc, TemplateParams,
9090 if (TemplateParameterLists.size() > 1 && SS.
isSet()) {
9092 Context, TemplateParameterLists.drop_back(1));
9096 ClassTemplate->AddPartialSpecialization(Partial, InsertToken);
9101 if (isMemberSpecialization)
9125 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
9129 diag::note_instantiation_required_here)
9144 bool HiddenDefVisible =
false;
9145 if (Def && SkipBody &&
9147 HiddenDefVisible)) {
9150 if (!HiddenDefVisible && Hidden)
9173 if (ModulePrivateLoc.
isValid())
9175 << (isPartialSpecialization? 1 : 0)
9243 diag::err_concept_decls_may_only_appear_in_global_namespace_scope);
9247 if (TemplateParameterLists.size() > 1) {
9248 Diag(NameLoc, diag::err_concept_extra_headers);
9254 if (Params->
size() == 0) {
9255 Diag(NameLoc, diag::err_concept_no_parameters);
9262 ParamEnd = Params->
end();
9263 ParamIt != ParamEnd; ++ParamIt) {
9264 Decl const *Param = *ParamIt;
9265 if (Param->isParameterPack()) {
9266 if (++ParamIt == ParamEnd)
9268 Diag(Param->getLocation(),
9269 diag::err_template_param_pack_must_be_last_template_parameter);
9280 Diag(NameLoc, diag::err_concept_no_associated_constraints);
9317 Expr *ConstraintExpr,
9319 assert(!
C->hasDefinition() &&
"Concept already defined");
9321 C->setInvalidDecl();
9324 C->setDefinition(ConstraintExpr);
9335 bool AddToScope =
true;
9339 if (!WasAlreadyAdded && AddToScope)
9352 auto *OldConcept = dyn_cast<ConceptDecl>(
Previous.getRepresentativeDecl()->getUnderlyingDecl());
9354 auto *Old =
Previous.getRepresentativeDecl();
9362 bool IsSame =
Context.isSameEntity(NewDecl, OldConcept);
9364 Diag(NewDecl->
getLocation(), diag::err_redefinition_different_concept)
9388 if (
auto *CE = llvm::dyn_cast<ConceptDecl>(
Concept);
9389 CE && !CE->isInvalidDecl() && !CE->hasDefinition()) {
9390 Diag(Loc, diag::err_recursive_concept) << CE;
9391 Diag(CE->getLocation(), diag::note_declared_at);
9392 CE->setInvalidDecl();
9405 D->
dropAttrs<DLLImportAttr, DLLExportAttr>();
9408 FD->setInlineSpecified(
false);
9427 Context, CurContext, Spec, ExternLoc, TemplateLoc, QualifierLoc,
9428 ArgsAsWritten, NameLoc, TypeAsWritten, TSK);
9429 Context.addExplicitInstantiationDecl(Spec, EID);
9439 if (EID->getTemplateSpecializationKind() ==
9441 return EID->getTemplateLoc();
9447 for (
Decl *Prev = D; Prev && !PrevDiagLoc.
isValid();
9448 Prev = Prev->getPreviousDecl()) {
9449 PrevDiagLoc = Prev->getLocation();
9451 assert(PrevDiagLoc.
isValid() &&
9452 "Explicit instantiation without point of instantiation?");
9462 bool &HasNoEffect) {
9463 HasNoEffect =
false;
9470 "previous declaration must be implicit!");
9483 if (PrevPointOfInstantiation.
isInvalid()) {
9487 PrevDecl,
Context.getTargetInfo().getTriple().isOSCygMing());
9496 PrevPointOfInstantiation.
isValid()) &&
9497 "Explicit instantiation without point of instantiation?");
9511 Diag(NewLoc, diag::err_specialization_after_instantiation)
9513 Diag(PrevPointOfInstantiation, diag::note_instantiation_required_here)
9518 llvm_unreachable(
"The switch over PrevTSK must be exhaustive.");
9548 diag::err_explicit_instantiation_declaration_after_definition);
9554 diag::note_explicit_instantiation_definition_here);
9558 llvm_unreachable(
"Unexpected TemplateSpecializationKind!");
9574 Diag(NewLoc, diag::warn_explicit_instantiation_after_specialization)
9577 diag::note_previous_template_specialization);
9608 ? diag::ext_explicit_instantiation_duplicate
9609 : diag::err_explicit_instantiation_duplicate)
9612 diag::note_previous_explicit_instantiation);
9618 llvm_unreachable(
"Missing specialization/instantiation case?");
9628 enum DiscardReason { NotAFunctionTemplate, NotAMemberOfEnclosing };
9634 DiscardedCandidates.push_back(std::make_pair(NotAFunctionTemplate, D));
9641 DiscardedCandidates.push_back(std::make_pair(NotAMemberOfEnclosing, D));
9652 FriendQualifier.
getAsType()->
getAs<TemplateSpecializationType>()) {
9658 Diag(FD->
getLocation(), diag::err_dependent_function_template_spec_no_match)
9660 for (
auto &P : DiscardedCandidates)
9661 Diag(P.second->getLocation(),
9662 diag::note_dependent_function_template_spec_discard_reason)
9663 << P.first << IsFriend;
9668 ExplicitTemplateArgs);
9681 llvm::SmallDenseMap<FunctionDecl *, TemplateArgumentListInfo, 8>
9682 ConvertedTemplateArgs;
9705 if (
auto *NewMD = dyn_cast<CXXMethodDecl>(FD);
9706 !
getLangOpts().CPlusPlus14 && NewMD && NewMD->isConstexpr() &&
9708 auto *OldMD = dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl());
9709 if (OldMD && OldMD->isConst()) {
9719 if (ExplicitTemplateArgs)
9720 Args = *ExplicitTemplateArgs;
9733 ExplicitTemplateArgs ? &Args :
nullptr, FT,
Specialization, Info);
9738 I.getPair(), FunTmpl->getTemplatedDecl(),
9752 CUDA().IdentifyTarget(FD,
true)) {
9754 I.getPair(), FunTmpl->getTemplatedDecl(),
9761 if (ExplicitTemplateArgs)
9770 if (QualifiedFriend && Candidates.
empty()) {
9776 if (
auto *OldFD = dyn_cast<FunctionDecl>(OldND->getUnderlyingDecl()))
9787 PDiag(diag::err_function_template_spec_ambiguous)
9788 << FD->
getDeclName() << (ExplicitTemplateArgs !=
nullptr),
9789 PDiag(diag::note_function_template_spec_matched));
9798 const auto *DSA = PT->getAttr<NoSpecializationsAttr>()) {
9799 auto Message = DSA->getMessage();
9801 << PT << !Message.empty() << Message;
9802 Diag(DSA->getLoc(), diag::note_marked_here) << DSA;
9830 auto *SpecializationFPT =
9841 assert(SpecInfo &&
"Function template specialization info missing?");
9879 bool HasNoEffect =
false;
9894 !isFriend || (InstFrom && InstFrom->getDependentSpecializationInfo())) {
9908 "This must be the only existing declaration of this specialization");
9923 FD->setFunctionTemplateSpecialization(
9926 ExplicitTemplateArgs ? &ConvertedTemplateArgs[
Specialization] :
nullptr);
9945 assert(!
Member->isTemplateDecl() && !
Member->getDescribedTemplate() &&
9946 "Only for non-template members");
9949 NamedDecl *FoundInstantiation =
nullptr;
9959 auto *
Method = dyn_cast<CXXMethodDecl>(Candidate->getUnderlyingDecl());
9977 Method->getTrailingRequiresClause() &&
9981 !Satisfaction.IsSatisfied))
9984 Candidates.
addDecl(Candidate);
9988 if (Candidates.
empty())
10005 FoundInstantiation = *Best;
10006 Instantiation = BestMethod;
10023 Diag(
Member->getLocation(), diag::err_function_member_spec_ambiguous)
10024 <<
Member << (InstantiatedFrom ? InstantiatedFrom : Instantiation);
10025 for (
NamedDecl *Candidate : Candidates) {
10026 Candidate = Candidate->getUnderlyingDecl();
10027 Diag(Candidate->getLocation(), diag::note_function_member_spec_matched)
10035 (PrevVar = dyn_cast<VarDecl>(
Previous.getFoundDecl())))
10037 FoundInstantiation =
Previous.getRepresentativeDecl();
10038 Instantiation = PrevVar;
10045 (PrevRecord = dyn_cast<CXXRecordDecl>(
Previous.getFoundDecl()))) {
10046 FoundInstantiation =
Previous.getRepresentativeDecl();
10047 Instantiation = PrevRecord;
10054 (PrevEnum = dyn_cast<EnumDecl>(
Previous.getFoundDecl()))) {
10055 FoundInstantiation =
Previous.getRepresentativeDecl();
10056 Instantiation = PrevEnum;
10062 if (!Instantiation) {
10087 Previous.addDecl(FoundInstantiation);
10092 if (!InstantiatedFrom) {
10093 Diag(
Member->getLocation(), diag::err_spec_member_not_instantiated)
10105 assert(MSInfo &&
"Member specialization info missing?");
10107 bool HasNoEffect =
false;
10119 Instantiation,
Member->getLocation(),
10125 if (
auto *MemberFunction = dyn_cast<FunctionDecl>(
Member)) {
10131 if (InstantiationFunction->
isDeleted()) {
10134 InstantiationFunction);
10140 MemberFunction->setInstantiationOfMemberFunction(
10142 }
else if (
auto *MemberVar = dyn_cast<VarDecl>(
Member)) {
10143 MemberVar->setInstantiationOfStaticDataMember(
10145 }
else if (
auto *MemberClass = dyn_cast<CXXRecordDecl>(
Member)) {
10146 MemberClass->setInstantiationOfMemberClass(
10148 }
else if (
auto *MemberEnum = dyn_cast<EnumDecl>(
Member)) {
10149 MemberEnum->setInstantiationOfMemberEnum(
10152 llvm_unreachable(
"unknown member specialization kind");
10158 Previous.addDecl(FoundInstantiation);
10167template<
typename DeclT>
10178 OrigD->setLocation(Loc);
10184 if (Instantiation ==
Member)
10187 if (
auto *
Function = dyn_cast<CXXMethodDecl>(Instantiation))
10189 else if (
auto *Var = dyn_cast<VarDecl>(Instantiation))
10191 else if (
auto *
Record = dyn_cast<CXXRecordDecl>(Instantiation))
10193 else if (
auto *
Enum = dyn_cast<EnumDecl>(Instantiation))
10196 llvm_unreachable(
"unknown member specialization kind");
10204 bool WasQualifiedName) {
10209 S.
Diag(InstLoc, diag::err_explicit_instantiation_in_class)
10222 if (WasQualifiedName) {
10223 if (CurContext->
Encloses(OrigContext))
10230 if (
NamespaceDecl *NS = dyn_cast<NamespaceDecl>(OrigContext)) {
10231 if (WasQualifiedName)
10234 diag::err_explicit_instantiation_out_of_scope :
10235 diag::warn_explicit_instantiation_out_of_scope_0x)
10240 diag::err_explicit_instantiation_unqualified_wrong_namespace :
10241 diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x)
10246 diag::err_explicit_instantiation_must_be_global :
10247 diag::warn_explicit_instantiation_must_be_global_0x)
10256 bool WasQualifiedName,
10263 S.
Diag(InstLoc, diag::err_explicit_instantiation_internal_linkage) << D;
10291 NNS =
T->getPrefix();
10300 auto *A = cast_or_null<InheritableAttr>(
getDLLAttr(Def));
10301 assert(A &&
"dllExportImportClassTemplateSpecialization called "
10302 "on Def without dllexport or dllimport");
10307 "delayed exports present at explicit instantiation");
10311 for (
auto &B : Def->
bases()) {
10312 if (
auto *BT = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
10313 B.getType()->getAsCXXRecordDecl()))
10333 "Invalid enum tag in class template explicit instantiation!");
10339 Diag(TemplateNameLoc, diag::err_tag_reference_non_tag) << TD << NTK << Kind;
10345 Kind,
false, KWLoc,
10347 Diag(KWLoc, diag::err_use_with_wrong_tag)
10352 diag::note_previous_use);
10365 !
Context.getTargetInfo().getTriple().isOSCygMing()) {
10369 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
10371 diag::warn_attribute_dllexport_explicit_instantiation_decl);
10372 Diag(AL.getLoc(), diag::note_attribute);
10377 if (
auto *A =
ClassTemplate->getTemplatedDecl()->getAttr<DLLExportAttr>()) {
10379 diag::warn_attribute_dllexport_explicit_instantiation_decl);
10380 Diag(A->getLocation(), diag::note_attribute);
10386 bool DLLImportExplicitInstantiationDef =
false;
10388 Context.getTargetInfo().getCXXABI().isMicrosoft()) {
10391 ClassTemplate->getTemplatedDecl()->getAttr<DLLImportAttr>();
10393 if (AL.getKind() == ParsedAttr::AT_DLLImport)
10395 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
10403 DLLImportExplicitInstantiationDef =
true;
10422 llvm::FoldingSetInsertToken InsertToken;
10430 Context.getTargetInfo().getTriple().isOSCygMing()) {
10434 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
10435 if (PrevDecl->
hasAttr<DLLExportAttr>()) {
10436 Diag(AL.getLoc(), diag::warn_attr_dllexport_explicit_inst_def);
10439 diag::warn_attr_dllexport_explicit_inst_def_mismatch);
10440 Diag(PrevDecl->
getLocation(), diag::note_prev_decl_missing_dllexport);
10448 !
Context.getTargetInfo().getTriple().isWindowsGNUEnvironment() &&
10450 return AL.getKind() == ParsedAttr::AT_DLLExport;
10452 if (
const auto *DEA = PrevDecl->
getAttr<DLLExportOnDeclAttr>()) {
10453 Diag(TemplateLoc, diag::warn_dllexport_on_decl_ignored);
10454 Diag(DEA->getLoc(), diag::note_dllexport_on_decl);
10464 bool HasNoEffect =
false;
10467 PrevDecl, PrevDecl_TSK,
10484 PrevDecl =
nullptr;
10488 DLLImportExplicitInstantiationDef) {
10490 HasNoEffect =
false;
10505 if (
const auto *A = PrevDecl->
getAttr<MSInheritanceAttr>()) {
10507 Clone->setInherited(
true);
10513 if (!HasNoEffect && !PrevDecl) {
10526 bool PreviouslyDLLExported =
Specialization->hasAttr<DLLExportAttr>();
10548 TemplateNameLoc, TSI, TSK);
10560 = cast_or_null<ClassTemplateSpecializationDecl>(
10572 Def = cast_or_null<ClassTemplateSpecializationDecl>(
10580 DLLImportExplicitInstantiationDef)) {
10585 Context.getTargetInfo().shouldDLLImportComdatSymbols()) {
10591 A->setInherited(
true);
10599 bool NewlyDLLExported =
10600 !PreviouslyDLLExported &&
Specialization->hasAttr<DLLExportAttr>();
10602 Context.getTargetInfo().shouldDLLImportComdatSymbols()) {
10616 "Def and Specialization should match for implicit instantiation");
10623 Context.getTargetInfo().getTriple().isOSCygMing() &&
10624 PrevDecl->
hasAttr<DLLExportAttr>()) {
10645 TemplateNameLoc, TSI, TSK);
10656 bool Owned =
false;
10657 bool IsDependent =
false;
10665 assert(!IsDependent &&
10666 "explicit instantiation of dependent name not yet handled");
10672 assert(!Tag->isEnum() &&
"shouldn't see enumerations here");
10674 if (Tag->isInvalidDecl())
10680 Diag(TemplateLoc, diag::err_explicit_instantiation_nontemplate_type)
10682 Diag(
Record->getLocation(), diag::note_nontemplate_decl_here);
10693 Diag(TemplateLoc, diag::ext_explicit_instantiation_without_qualified_id)
10708 = cast_or_null<CXXRecordDecl>(
Record->getPreviousDecl());
10709 if (!PrevDecl &&
Record->getDefinition())
10713 bool HasNoEffect =
false;
10714 assert(MSInfo &&
"No member specialization information?");
10728 TL.setElaboratedKeywordLoc(KWLoc);
10730 TL.setNameLoc(NameLoc);
10733 nullptr, NameLoc, TSI, TSK);
10739 = cast_or_null<CXXRecordDecl>(
Record->getDefinition());
10747 Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member)
10748 << 0 <<
Record->getDeclName() <<
Record->getDeclContext();
10758 RecordDef = cast_or_null<CXXRecordDecl>(
Record->getDefinition());
10776 TL.setElaboratedKeywordLoc(KWLoc);
10778 TL.setNameLoc(NameLoc);
10781 NameLoc, TSI, TSK);
10796 diag::err_explicit_instantiation_requires_name)
10835 diag::err_explicit_instantiation_inline :
10836 diag::warn_explicit_instantiation_inline_0x)
10842 diag::err_explicit_instantiation_constexpr);
10864 if (!R->isFunctionType()) {
10879 if (!PrevTemplate) {
10886 Diag((*P)->getLocation(), diag::note_explicit_instantiation_here);
10893 diag::err_explicit_instantiation_data_member_not_instantiated)
10907 if (R->isUndeducedType()) {
10908 Diag(
T->getTypeLoc().getBeginLoc(),
10909 diag::err_auto_not_allowed_var_inst);
10918 diag::err_explicit_instantiation_without_template_id)
10920 Diag(PrevTemplate->getLocation(),
10921 diag::note_explicit_instantiation_here);
10931 TemplateArgs,
true);
10962 diag::ext_explicit_instantiation_without_qualified_id)
10970 bool HasNoEffect =
false;
10972 PrevTSK, POI, HasNoEffect))
10975 if (!HasNoEffect) {
10978 if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Prev)) {
10979 VTSD->setExternKeywordLoc(ExternLoc);
10980 VTSD->setTemplateKeywordLoc(TemplateLoc);
10994 Diag(
T->getTypeLoc().getBeginLoc(),
10995 diag::err_invalid_var_template_spec_type)
10996 << 0 << PrevTemplate << R << Prev->
getType();
10997 Diag(PrevTemplate->getLocation(), diag::note_template_declared_here)
10998 << 2 << PrevTemplate->getDeclName();
11006 return (
Decl *)
nullptr;
11011 bool HasExplicitTemplateArgs =
false;
11015 HasExplicitTemplateArgs =
true;
11030 if (!HasExplicitTemplateArgs) {
11034 if (
Context.hasSameUnqualifiedType(
Method->getType(), Adjusted)) {
11035 if (
Method->getPrimaryTemplate()) {
11039 C.FoundDecl = P.getPair();
11043 if (
Method->getTrailingRequiresClause() &&
11062 FunTmpl, (HasExplicitTemplateArgs ? &TemplateArgs :
nullptr), R,
11093 if (!NonTemplateMatches.
empty()) {
11104 Msg = diag::err_explicit_instantiation_ambiguous;
11108 Msg = diag::err_explicit_instantiation_no_candidate;
11124 TemplateMatches.
begin(), TemplateMatches.
end(),
11126 PDiag(diag::err_explicit_instantiation_not_known) << Name,
11127 PDiag(diag::err_explicit_instantiation_ambiguous) << Name,
11128 PDiag(diag::note_explicit_instantiation_candidate));
11144 if (FPT->hasExceptionSpec()) {
11146 diag::err_mismatched_exception_spec_explicit_instantiation;
11148 DiagID = diag::ext_mismatched_exception_spec_explicit_instantiation;
11151 PDiag(diag::note_explicit_instantiation_here),
11162 diag::err_explicit_instantiation_member_function_not_instantiated)
11171 if (!PrevDecl &&
Specialization->isThisDeclarationADefinition())
11175 bool HasNoEffect =
false;
11185 if (HasExplicitTemplateArgs)
11192 return (
Decl *)
nullptr;
11204 if (
auto *RD = dyn_cast<CXXRecordDecl>(
Specialization->getDeclContext()))
11205 if (RD->getIdentifier() && RD->getIdentifier()->isStr(
"valarray") &&
11206 RD->isInStdNamespace())
11207 return (
Decl*)
nullptr;
11217 Context.getTargetInfo().getCXXABI().isMicrosoft())
11228 if (
const auto *RD = dyn_cast<CXXRecordDecl>(
Specialization->getParent());
11229 RD && RD->isLambda()) {
11232 Diag(RD->getLocation(), diag::note_defined_here) << RD;
11233 return (
Decl *)
nullptr;
11250 diag::ext_explicit_instantiation_without_qualified_id)
11260 if (HasExplicitTemplateArgs)
11266 return (
Decl *)
nullptr;
11275 assert(Name &&
"Expected a name in a dependent tag");
11288 Diag(NameLoc, diag::err_dependent_tag_decl)
11315 DiagCompat(TypenameLoc, diag_compat::typename_outside_of_template)
11323 TypenameLoc, QualifierLoc, II, IdLoc, &TSI,
11339 ? diag::compat_cxx11_typename_outside_of_template
11340 : diag::compat_pre_cxx11_typename_outside_of_template)
11348 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
11349 Diag(TemplateIILoc,
11350 diag::ext_out_of_line_qualified_id_type_names_constructor)
11352 << (TemplateKWLoc.
isValid() ? 1 : 0 );
11363 TemplateIn.
get(), TemplateIILoc, TemplateArgs,
11373 TemplateIILoc, TemplateArgs);
11383 if (!II.
isStr(
"type"))
11391 auto EnableIfTSTLoc =
11393 if (!EnableIfTSTLoc || EnableIfTSTLoc.getNumArgs() == 0)
11395 const TemplateSpecializationType *EnableIfTST = EnableIfTSTLoc.
getTypePtr();
11399 EnableIfTST->getTemplateName().getAsTemplateDecl();
11400 if (!EnableIfDecl || EnableIfTST->isIncompleteType())
11406 if (!EnableIfII || !EnableIfII->
isStr(
"enable_if"))
11410 CondRange = EnableIfTSTLoc.getArgLoc(0).getSourceRange();
11414 if (EnableIfTSTLoc.getArgLoc(0).getArgument().getKind()
11418 Cond = EnableIfTSTLoc.getArgLoc(0).getSourceExpression();
11434 bool DeducedTSTContext) {
11436 DeducedTSTContext);
11443 TL.setElaboratedKeywordLoc(KeywordLoc);
11444 TL.setQualifierLoc(QualifierLoc);
11445 TL.setNameLoc(IILoc);
11448 TL.setElaboratedKeywordLoc(KeywordLoc);
11449 TL.setQualifierLoc(QualifierLoc);
11450 TL.setNameLoc(IILoc);
11454 assert(!QualifierLoc);
11458 TL.setElaboratedKeywordLoc(KeywordLoc);
11459 TL.setQualifierLoc(QualifierLoc);
11460 TL.setNameLoc(IILoc);
11481 SS.
Adopt(QualifierLoc);
11484 if (QualifierLoc) {
11511 unsigned DiagID = 0;
11512 Decl *Referenced =
nullptr;
11513 switch (
Result.getResultKind()) {
11518 Expr *Cond =
nullptr;
11519 if (Ctx &&
isEnableIf(QualifierLoc, II, CondRange, Cond)) {
11524 std::string FailedDescription;
11525 std::tie(FailedCond, FailedDescription) =
11529 diag::err_typename_nested_not_found_requirement)
11530 << FailedDescription
11536 diag::err_typename_nested_not_found_enable_if)
11537 << Ctx << CondRange;
11541 DiagID = Ctx ? diag::err_typename_nested_not_found
11542 : diag::err_unknown_typename;
11551 Diag(IILoc, diag::err_typename_refers_to_using_value_decl)
11552 << Name << Ctx << FullRange;
11554 = dyn_cast<UnresolvedUsingValueDecl>(
Result.getRepresentativeDecl())){
11556 Diag(Loc, diag::note_using_value_decl_missing_typename)
11596 assert(!QualifierLoc);
11599 return Context.getTypeDeclType(
11609 if (!DeducedTSTContext) {
11612 Diag(IILoc, diag::err_dependent_deduced_tst)
11614 <<
QualType(Qualifier.getAsType(), 0);
11616 Diag(IILoc, diag::err_deduced_tst)
11624 return Context.getDeducedTemplateSpecializationType(
11630 DiagID = Ctx ? diag::err_typename_nested_not_type
11631 : diag::err_typename_not_type;
11632 Referenced =
Result.getFoundDecl();
11636 DiagID = Ctx ? diag::err_typename_nested_not_type
11637 : diag::err_typename_not_type;
11638 Referenced = *
Result.begin();
11650 Diag(IILoc, DiagID) << FullRange << Name << Ctx;
11652 Diag(IILoc, DiagID) << FullRange << Name;
11655 Ctx ? diag::note_typename_member_refers_here
11656 : diag::note_typename_refers_here)
11663 class CurrentInstantiationRebuilder
11671 CurrentInstantiationRebuilder(
Sema &SemaRef,
11675 Loc(Loc), Entity(Entity) { }
11683 return T.isNull() || !
T->isInstantiationDependentType();
11688 SourceLocation getBaseLocation() {
return Loc; }
11691 DeclarationName getBaseEntity() {
return Entity; }
11695 void setBase(SourceLocation Loc, DeclarationName Entity) {
11697 this->Entity = Entity;
11710 if (!
T || !
T->getType()->isInstantiationDependentType())
11713 CurrentInstantiationRebuilder Rebuilder(*
this, Loc, Name);
11714 return Rebuilder.TransformType(
T);
11718 CurrentInstantiationRebuilder Rebuilder(*
this, E->
getExprLoc(),
11720 return Rebuilder.TransformExpr(E);
11731 = Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
11741 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
11750 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
11752 TTP->getTemplateParameters()))
11794 unsigned NumArgs) {
11796 llvm::raw_svector_ostream Out(Str);
11798 if (!Params || Params->
size() == 0 || NumArgs == 0)
11799 return std::string();
11801 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
11811 Out << Id->getName();
11823 return std::string(Out.str());
11831 auto LPT = std::make_unique<LateParsedTemplate>();
11834 LPT->Toks.swap(Toks);
11881class ExplicitSpecializationVisibilityChecker {
11890 : S(S), Loc(Loc), Kind(Kind) {}
11893 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
11894 return checkImpl(FD);
11895 if (
auto *RD = dyn_cast<CXXRecordDecl>(ND))
11896 return checkImpl(RD);
11897 if (
auto *VD = dyn_cast<VarDecl>(ND))
11898 return checkImpl(VD);
11899 if (
auto *ED = dyn_cast<EnumDecl>(ND))
11900 return checkImpl(ED);
11904 void diagnose(NamedDecl *D,
bool IsPartialSpec) {
11905 auto Kind = IsPartialSpec ? Sema::MissingImportKind::PartialSpecialization
11906 : Sema::MissingImportKind::ExplicitSpecialization;
11907 const bool Recover =
true;
11912 if (Modules.empty())
11918 bool CheckMemberSpecialization(
const NamedDecl *D) {
11919 return Kind == Sema::AcceptableKind::Visible
11924 bool CheckExplicitSpecialization(
const NamedDecl *D) {
11925 return Kind == Sema::AcceptableKind::Visible
11930 bool CheckDeclaration(
const NamedDecl *D) {
11947 template<
typename SpecDecl>
11948 void checkImpl(SpecDecl *Spec) {
11949 bool IsHiddenExplicitSpecialization =
false;
11953 if constexpr (std::is_same_v<SpecDecl, FunctionDecl>)
11954 SpecKind = Spec->getTemplateSpecializationKindForInstantiation();
11956 IsHiddenExplicitSpecialization = Spec->getMemberSpecializationInfo()
11957 ? !CheckMemberSpecialization(Spec)
11958 : !CheckExplicitSpecialization(Spec);
11960 checkInstantiated(Spec);
11963 if (IsHiddenExplicitSpecialization)
11964 diagnose(Spec->getMostRecentDecl(),
false);
11967 void checkInstantiated(FunctionDecl *FD) {
11972 void checkInstantiated(CXXRecordDecl *RD) {
11973 auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(RD);
11977 auto From = SD->getSpecializedTemplateOrPartial();
11978 if (
auto *TD = dyn_cast<ClassTemplateDecl *>(From))
11980 else if (
auto *TD =
11981 dyn_cast<ClassTemplatePartialSpecializationDecl *>(From)) {
11982 if (!CheckDeclaration(TD))
11983 diagnose(TD,
true);
11988 void checkInstantiated(VarDecl *RD) {
11989 auto *SD = dyn_cast<VarTemplateSpecializationDecl>(RD);
11993 auto From = SD->getSpecializedTemplateOrPartial();
11994 if (
auto *TD = dyn_cast<VarTemplateDecl *>(From))
11996 else if (
auto *TD =
11997 dyn_cast<VarTemplatePartialSpecializationDecl *>(From)) {
11998 if (!CheckDeclaration(TD))
11999 diagnose(TD,
true);
12004 void checkInstantiated(EnumDecl *FD) {}
12006 template<
typename TemplDecl>
12007 void checkTemplate(TemplDecl *TD) {
12008 if (TD->isMemberSpecialization()) {
12009 if (!CheckMemberSpecialization(TD))
12010 diagnose(TD->getMostRecentDecl(),
false);
12020 ExplicitSpecializationVisibilityChecker(*
this, Loc,
12030 ExplicitSpecializationVisibilityChecker(*
this, Loc,
12038 if (
const auto *FD = dyn_cast<FunctionDecl>(N)) {
12046 if (!CSC.isInstantiationRecord() || CSC.PointOfInstantiation.isInvalid())
12048 return CSC.PointOfInstantiation;
This file provides AST data structures related to concepts.
Defines the clang::ASTContext interface.
Defines enum values for all the target-independent builtin functions.
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Result
Implement __builtin_bit_cast and related operations.
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.
@ ForVisibleRedeclaration
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
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 void addExplicitInstantiationDecl(ASTContext &Context, DeclContext *CurContext, NamedDecl *Spec, SourceLocation ExternLoc, SourceLocation TemplateLoc, NestedNameSpecifierLoc QualifierLoc, const ASTTemplateArgumentListInfo *ArgsAsWritten, SourceLocation NameLoc, TypeSourceInfo *TypeAsWritten, TemplateSpecializationKind TSK)
Create an ExplicitInstantiationDecl to record source-location info for an explicit template instantia...
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 ExprResult BuildExpressionFromReflection(Sema &S, const APValue &RV, SourceLocation CaretCaretLoc)
Construct a new reflect expression that refers to the given entity with the given source-location of ...
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 TemplateName resolveAssumedTemplateNameAsType(Sema &S, Scope *Scope, const AssumedTemplateStorage *ATN, SourceLocation NameLoc)
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 QualType sortBuiltinTemplatePack(ASTContext &Context, ArrayRef< TemplateArgument > InputArgs)
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 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 void diagnoseMissingArgument(Sema &S, SourceLocation Loc, TemplateDecl *TD, const TemplateParmDecl *D)
Diagnose a missing template argument.
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, bool IsSpecified, 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 ExprResult formImmediatelyDeclaredConstraint(Sema &S, NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, TemplateName NamedConcept, NamedDecl *FoundDecl, SourceLocation LAngleLoc, SourceLocation RAngleLoc, QualType ConstrainedType, SourceLocation ParamNameLoc, ArgumentLocAppender Appender, SourceLocation EllipsisLoc)
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
const void * getReflectionOpaqueOperand() 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()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TranslationUnitDecl * getTranslationUnitDecl() const
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const LangOptions & getLangOpts() const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
ArrayRef< ExplicitInstantiationDecl * > getExplicitInstantiationDecls(const NamedDecl *Spec) const
Get all ExplicitInstantiationDecls for a given specialization.
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.
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
QualType getUnconstrainedType(QualType T) const
Remove any type constraints from a template parameter type, for equivalence comparison of template pa...
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
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
TemplateName getNamedConcept() const
SourceLocation getLAngleLoc() const
NamedDecl * getFoundDecl() const
DeclarationNameInfo getConceptNameInfo() 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()
static CXXReflectExpr * Create(ASTContext &C, SourceLocation OperatorLoc, const TypeSourceInfo *TSI)
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)
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.
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.
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, TemplateName NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
static ConceptSpecializationExpr * Create(const ASTContext &C, ConceptReference *ConceptRef, ImplicitConceptSpecializationDecl *SpecDecl, const ConstraintSatisfaction *Satisfaction)
const TypeClass * getTypePtr() const
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
Returns true if this DeclContext is a function, Objective-C method, or block, or a DeclContext that c...
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
const LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
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
void ClearStorageClassSpecs()
bool isNoreturnSpecified() const
SourceLocation getStorageClassSpecLoc() const
SCS getStorageClassSpec() const
SourceLocation getBeginLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getNoreturnSpecLoc() const
SourceLocation getExplicitSpecLoc() const
TSCS getThreadStorageClassSpec() const
ParsedAttributes & getAttributes()
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,...
ASTContext & getASTContext() const LLVM_READONLY
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).
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...
std::string getAsString() const
Retrieve the human-readable string for this name.
NameKind getNameKind() const
Determine what kind of name this is.
void setTypeSourceInfo(TypeSourceInfo *TI)
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
SourceLocation getIdentifierLoc() const
SourceLocation getEllipsisLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
bool isInvalidType() const
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
const IdentifierInfo * getIdentifier() const
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)
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...
static DependentTemplateIdExpr * Create(const ASTContext &Context, const DeclarationNameInfo &NameInfo, TemplateName Name, const TemplateArgumentListInfo &TemplateArgs)
TemplateTemplateParmDecl * getParameter() const
Represents a vector type where either the type or size is dependent.
virtual bool TraverseTypeLoc(TypeLoc TL, bool TraverseQualifier=true)
virtual bool TraverseTemplateName(TemplateName Template, bool TraverseQualifier=true)
virtual bool TraverseStmt(MaybeConst< Stmt > *S)
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...
static ExplicitInstantiationDecl * Create(ASTContext &C, DeclContext *DC, NamedDecl *Specialization, SourceLocation ExternLoc, SourceLocation TemplateLoc, NestedNameSpecifierLoc QualifierLoc, const ASTTemplateArgumentListInfo *ArgsAsWritten, SourceLocation NameLoc, TypeSourceInfo *TypeAsWritten, TemplateSpecializationKind TSK)
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 containsErrors() const
Whether this expression contains subexpressions which had errors.
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={})
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
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
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.
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...
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.
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].
Represents a linkage specification.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
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.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
void setTemplateNameLookup(bool TemplateName)
Sets whether this is a template-name lookup.
bool empty() const
Return true if no decls were found.
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.
UnresolvedSetImpl::iterator iterator
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...
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.
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, int D, int P, const IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
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)
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
Represents a pointer to an Objective C object.
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.
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.
void setEllipsisLoc(SourceLocation Loc)
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.
ParsedTemplateArgument()
Build an empty 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.
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.
QualType getNonPackExpansionType() const
Remove an outer pack expansion type (if any) from this type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
Callback class to reject typo corrections that look like template parameters when doing a qualified l...
bool ValidateCandidate(const TypoCorrection &Candidate) override
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
QualifiedLookupValidatorCCC(bool HasQualifier)
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.
void setMemberSpecialization()
Note that this member template is a specialization.
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.
DeclContext * getEntity() const
Get the entity corresponding to this scope.
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
Scope * getTemplateParamParent()
@ 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.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
SemaDiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId)
Emit a compatibility diagnostic.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
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.
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.
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)
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.
VarTemplateSpecializationDecl * BuildVarTemplateInstantiation(VarTemplateDecl *VarTemplate, VarDecl *FromVar, const TemplateArgumentList *PartialSpecArgs, SmallVectorImpl< TemplateArgument > &Converted, SourceLocation PointOfInstantiation, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *StartingScope=nullptr)
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)
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...
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
DiagnosticsEngine & getDiagnostics() const
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, TemplateName NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
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...
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.
ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs, bool DoCheckConstraintSatisfaction=true)
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)
bool CheckConstraintSatisfaction(ConstrainedDeclOrNestedRequirement Entity, ArrayRef< AssociatedConstraint > AssociatedConstraints, const MultiLevelTemplateArgumentList &TemplateArgLists, SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction, const ConceptReference *TopLevelConceptId=nullptr, Expr **ConvertedExpr=nullptr)
Check whether the given list of constraint expressions are satisfied (as if in a 'conjunction') given...
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()
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr)
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.
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)
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
bool DiagnosePackIndexingInFriendNNS(SourceLocation Loc, NestedNameSpecifierLoc NNSLoc)
void AddPushedVisibilityAttribute(Decl *RD)
AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, add an appropriate visibility at...
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,...
ExprResult CheckVarOrConceptTemplateTemplateId(const DeclarationNameInfo &NameInfo, TemplateName Template, const TemplateArgumentListInfo *TemplateArgs)
ExprResult BuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, unsigned Index, QualType ParamType, SourceLocation loc, TemplateArgument Replacement, UnsignedOrNone PackIndex, bool Final)
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...
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...
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 isSFINAEContext() const
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...
QualType CheckTemplateIdType(ElaboratedTypeKeyword Keyword, TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, Scope *Scope, bool ForNestedNameSpecifier)
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.
bool isRedefinitionAllowedFor(NamedDecl *D, SourceLocation NewDefinitionLoc, NamedDecl **Suggested, bool &Visible)
Determine if D has a definition which allows we redefine it in current TU.
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 ...
DeclResult ActOnVarTemplateSpecialization(Scope *S, Declarator &D, TypeSourceInfo *TSI, LookupResult &Previous, SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, StorageClass SC, bool IsPartialSpecialization)
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 inParameterMappingSubstitution() const
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.
static QualType getTypeOfConstantTemplateParameter(const TemplateArgument &Arg)
Determine the declared type of the constant template parameter that Arg names, if any.
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)
DeclResult CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation TemplateNameLoc, const TemplateArgumentListInfo &TemplateArgs, bool SetWrittenArgs)
Get the specialization of the given variable template corresponding to the specified argument list,...
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
friend class InitializationSequence
void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a templated declaration that would trigger an implicit instantiation.
QualType SubstAutoTypeDependent(QualType TypeWithAuto)
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)
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization, bool AllowTypoCorrection=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.
void CheckConceptRedefinition(ConceptDecl *NewDecl, LookupResult &Previous, bool &AddToScope)
bool isTagRedeclarationInScope(NamedDecl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false) const
Determine whether a tag-like declaration found by lookup can be redeclared in the given scope.
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.
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, bool IsMemberSpecialization, SkipBodyInfo *SkipBody=nullptr)
bool IsFunctionConversion(QualType FromType, QualType ToType) const
Determine whether the conversion from FromType to ToType is a valid conversion of ExtInfo/ExtProtoInf...
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...
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
OpaquePtr< TemplateName > TemplateTy
unsigned getTemplateDepth(Scope *S) const
Determine the number of levels of enclosing template parameters.
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)
SFINAETrap * getSFINAEContext() const
Returns a pointer to the current SFINAE context, if any.
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
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 a reference to a non-type template parameter that has been substituted with a template arg...
Represents the declaration of a struct/union/class/enum.
StringRef getKindName() const
void startDefinition()
Starts the definition of this tag declaration.
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
TagKind getTagKind() const
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.
DeducedTemplateStorage * getAsDeducedTemplateName() const
Retrieve the deduced template info, if any.
bool isNull() const
Determine whether this template name is NULL.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to,...
AssumedTemplateStorage * getAsAssumedTemplateName() const
Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...
std::pair< TemplateName, DefaultArguments > getTemplateDeclAndDefaultArgs() const
Retrieves the underlying template name that this template name refers to, along with the deduced defa...
UsingShadowDecl * getAsUsingShadowDecl() const
Retrieve the using shadow declaration through which the underlying template declaration is introduced...
TemplateTemplateParmDecl * getAsTemplateTemplateParmDecl() const
Retrieve the template template parameter that this template name refers to, if any.
bool isDependent() const
Determines whether this is a dependent template name.
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.
NamedDecl ** iterator
Iterates through the template parameters in this list.
bool hasAssociatedConstraints() const
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)
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)
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.
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, int D, int P, bool ParameterPack, IdentifierInfo *Id, TemplateNameKind ParameterKind, bool Typename, TemplateParameterList *Params)
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.
void setTypeConstraint(ConceptReference *CR, Expr *ImmediatelyDeclaredConstraint, UnsignedOrNone ArgPackSubstIndex)
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, int D, int P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, UnsignedOrNone NumExpanded=std::nullopt)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
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...
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
bool isVoidPointerType() const
bool isPointerType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() 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 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 isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
bool isMemberPointerType() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
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 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.
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
const IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId,...
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
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,...
VarDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
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)
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.
void addSFINAEDiagnostic(SourceLocation Loc, PartialDiagnostic PD)
Set the diagnostic which caused the SFINAE failure.
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
const PartialDiagnosticAt & peekSFINAEDiagnostic() const
Peek at the SFINAE diagnostic.
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
Defines the clang::TargetInfo interface.
__inline void unsigned int _2
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
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)
OpaquePtr< TemplateName > ParsedTemplateTy
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
@ 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.
@ DecltypeAuto
decltype(auto)
@ 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.
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
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...
ActionResult< Decl * > DeclResult
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
DynamicRecursiveASTVisitorBase< true > ConstDynamicRecursiveASTVisitor
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)
@ Parameter
The parameter type of a method or function.
@ Result
The result type of a method or function.
ActionResult< ParsedType > TypeResult
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
OptionalUnsigned< unsigned > UnsignedOrNone
const FunctionProtoType * T
@ Template
We are parsing a template declaration.
TagTypeKind
The kind of a tag type.
@ Enum
The "enum" keyword.
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.
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.
MutableArrayRef< ParsedTemplateArgument > ASTTemplateArgsPtr
@ Undeduced
Not deduced yet. This is for example an 'auto' which was just parsed.
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.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
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.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
DynamicRecursiveASTVisitorBase< false > DynamicRecursiveASTVisitor
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.
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,...
U cast(CodeGen::Address addr)
SmallVector< Token, 4 > CachedTokens
A set of tokens that has been cached for later parsing.
@ TemplateArg
Value of a non-type template parameter.
@ TempArgStrict
As above, but applies strict template checking rules.
@ PackIndex
Index of a pack indexing expression or specifier.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
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.
ActionResult< Expr * > ExprResult
@ Parens
New-expression has a C++98 paren-delimited initializer.
__builtin_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t uint32_t uint32_t __builtin_riscv_mhacc_i32 __builtin_riscv_mhaccu_u32 __builtin_riscv_mhaccsu_i32 __builtin_riscv_mulq_i32 int64_t
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.
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)
OverloadedOperatorKind Operator
The kind of overloaded operator.