42#include "llvm/ADT/SmallBitVector.h"
43#include "llvm/ADT/StringExtras.h"
44#include "llvm/Support/Casting.h"
45#include "llvm/Support/SaveAndRestore.h"
56 return SourceRange(Ps[0]->getTemplateLoc(), Ps[N-1]->getRAngleLoc());
70 auto ParamsAtDepth = [&](
unsigned D) { Depth = std::max(Depth, D + 1); };
75 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(FSI)) {
76 if (!LSI->TemplateParams.empty()) {
77 ParamsAtDepth(LSI->AutoTemplateParameterDepth);
80 if (LSI->GLTemplateParameterList) {
81 ParamsAtDepth(LSI->GLTemplateParameterList->getDepth());
91 if (!Info.TemplateParams.empty()) {
92 ParamsAtDepth(Info.AutoTemplateParameterDepth);
107 bool AllowFunctionTemplates,
108 bool AllowDependent) {
118 if (
const auto *
Record = dyn_cast<CXXRecordDecl>(D)) {
130 if (
Record->isInjectedClassName()) {
132 if (
Record->getDescribedClassTemplate())
133 return Record->getDescribedClassTemplate();
135 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(
Record))
136 return Spec->getSpecializedTemplate();
152 bool AllowFunctionTemplates,
153 bool AllowDependent) {
164 bool AllowFunctionTemplates,
166 bool AllowNonTemplateFunctions) {
170 if (AllowNonTemplateFunctions &&
180 bool hasTemplateKeyword,
183 bool EnteringContext,
185 bool &MemberOfUnknownSpecialization,
186 bool Disambiguation) {
190 MemberOfUnknownSpecialization =
false;
198 TName =
Context.DeclarationNames.getCXXOperatorName(
219 MemberOfUnknownSpecialization = R.wasNotFoundInCurrentInstantiation();
235 UsingShadowDecl *FoundUsingShadow = dyn_cast<UsingShadowDecl>(*R.begin());
236 if (R.isAmbiguous()) {
239 bool AnyFunctionTemplates =
false;
243 AnyFunctionTemplates =
true;
246 FoundUsingShadow = dyn_cast<UsingShadowDecl>(FoundD);
254 if (!D && !AnyFunctionTemplates) {
255 R.suppressDiagnostics();
272 unsigned ResultCount = R.end() - R.begin();
273 if (!D && ResultCount > 1) {
280 R.suppressDiagnostics();
284 assert(D &&
"unambiguous result is not a template name");
289 MemberOfUnknownSpecialization =
true;
296 assert(!FoundUsingShadow || FoundUsingShadow->
getTargetDecl() == TD);
299 Template =
Context.getQualifiedTemplateName(Qualifier, hasTemplateKeyword,
307 R.suppressDiagnostics();
314 ? dyn_cast<TemplateTemplateParmDecl>(TD)->templateParameterKind()
323 Diag(Name.
getBeginLoc(), diag::err_builtin_pack_outside_template) << TName;
342 if (R.empty())
return false;
343 if (R.isAmbiguous()) {
345 R.suppressDiagnostics();
379 {SS->getScopeRep(), &II, false}));
380 Diag(IILoc, diag::err_template_kw_missing)
381 << SuggestedTemplate.
get()
388 QualType ObjectType,
bool EnteringContext,
391 bool AllowTypoCorrection) {
398 Found.setTemplateNameLookup(
true);
402 bool IsDependent =
false;
403 if (!ObjectType.
isNull()) {
406 assert(SS.
isEmpty() &&
"ObjectType and scope specifier cannot coexist");
410 !ObjectType->
getAs<TagType>() ||
411 ObjectType->
castAs<TagType>()->getDecl()->isEntityBeingDefined()) &&
412 "Caller should have completed object type");
444 bool ObjectTypeSearchedInScope =
false;
445 bool AllowFunctionTemplatesInLookup =
true;
461 IsDependent |=
Found.wasNotFoundInCurrentInstantiation();
477 if (!ObjectType.
isNull()) {
481 AllowFunctionTemplatesInLookup =
false;
482 ObjectTypeSearchedInScope =
true;
485 IsDependent |=
Found.wasNotFoundInCurrentInstantiation();
488 if (
Found.isAmbiguous())
505 if (AllFunctions || (
Found.empty() && !IsDependent)) {
509 *ATK = (
Found.empty() &&
Found.getLookupName().isIdentifier())
517 if (
Found.empty() && !IsDependent && AllowTypoCorrection) {
528 Found.getLookupNameInfo(),
Found.getLookupKind(), S, &SS, FilterCCC,
530 if (
auto *ND = Corrected.getFoundDecl())
533 if (
Found.isAmbiguous()) {
535 }
else if (!
Found.empty()) {
538 AllowFunctionTemplatesInLookup =
true;
539 Found.setLookupName(Corrected.getCorrection());
541 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
542 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
545 << Name << LookupCtx << DroppedSpecifier
559 Found.setNotFoundInCurrentInstantiation();
565 if (ExampleLookupResult && RequiredTemplate) {
566 Diag(
Found.getNameLoc(), diag::err_template_kw_refers_to_non_template)
571 diag::note_template_kw_refers_to_non_template)
572 <<
Found.getLookupName();
579 if (S && !ObjectType.
isNull() && !ObjectTypeSearchedInScope &&
596 if (FoundOuter.
empty()) {
606 }
else if (!
Found.isSuppressingAmbiguousDiagnostics()) {
610 if (!
Found.isSingleResult() ||
614 diag::ext_nested_name_member_ref_lookup_ambiguous)
615 <<
Found.getLookupName()
617 Diag(
Found.getRepresentativeDecl()->getLocation(),
618 diag::note_ambig_member_ref_object_type)
621 diag::note_ambig_member_ref_scope);
644 bool MissingTemplateKeyword =
false;
647 if (
auto *DRE = dyn_cast<DeclRefExpr>(
TemplateName.get())) {
648 NameInfo = DRE->getNameInfo();
649 SS.
Adopt(DRE->getQualifierLoc());
651 Found = DRE->getFoundDecl();
652 }
else if (
auto *ME = dyn_cast<MemberExpr>(
TemplateName.get())) {
653 NameInfo = ME->getMemberNameInfo();
654 SS.
Adopt(ME->getQualifierLoc());
656 LookupCtx = ME->getBase()->getType()->getAsCXXRecordDecl();
657 Found = ME->getMemberDecl();
658 }
else if (
auto *DSDRE =
659 dyn_cast<DependentScopeDeclRefExpr>(
TemplateName.get())) {
660 NameInfo = DSDRE->getNameInfo();
661 SS.
Adopt(DSDRE->getQualifierLoc());
662 MissingTemplateKeyword =
true;
663 }
else if (
auto *DSME =
664 dyn_cast<CXXDependentScopeMemberExpr>(
TemplateName.get())) {
665 NameInfo = DSME->getMemberNameInfo();
666 SS.
Adopt(DSME->getQualifierLoc());
667 MissingTemplateKeyword =
true;
669 llvm_unreachable(
"unexpected kind of potential template name");
674 if (MissingTemplateKeyword) {
683 TemplateCandidateFilter(
Sema &S) : S(S) {
684 WantTypeSpecifiers =
false;
685 WantExpressionKeywords =
false;
686 WantRemainingKeywords =
false;
687 WantCXXNamedCasts =
true;
689 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
695 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
696 return std::make_unique<TemplateCandidateFilter>(*
this);
701 TemplateCandidateFilter CCC(*
this);
705 auto *ND = Corrected.getFoundDecl();
708 if (ND || Corrected.isKeyword()) {
710 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
711 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
714 PDiag(diag::err_non_template_in_member_template_id_suggest)
715 << Name << LookupCtx << DroppedSpecifier
719 PDiag(diag::err_non_template_in_template_id_suggest)
724 diag::note_non_template_in_template_id_found);
729 Diag(NameInfo.
getLoc(), diag::err_non_template_in_template_id)
732 Diag(
Found->getLocation(), diag::note_non_template_in_template_id_found);
739 bool isAddressOfOperand,
755 nullptr, NameInfo, TemplateArgs);
784 bool refParam =
true;
787 refParam = Replacement->isLValue();
788 if (refParam && Replacement->getType()->isRecordType()) {
793 if (
const auto *PET = dyn_cast<PackExpansionType>(ParamType))
794 ParamType = PET->getPattern();
799 SemaRef.BuildExpressionFromNonTypeTemplateArgument(Arg, Loc);
802 Replacement = result.
get();
806 Replacement->getType(), Replacement->getValueKind(), Loc, Replacement,
807 AssociatedDecl, NTTP->
getIndex(), PackIndex, refParam, Final);
812 bool InstantiatedFromMember,
816 bool Complain,
bool *Unreachable) {
820 bool IsEntityBeingDefined =
false;
821 if (
const TagDecl *TD = dyn_cast_or_null<TagDecl>(PatternDef))
822 IsEntityBeingDefined = TD->isBeingDefined();
824 if (PatternDef && !IsEntityBeingDefined) {
841 if (!Complain || (PatternDef && PatternDef->
isInvalidDecl()))
845 if (
TagDecl *TD = dyn_cast<TagDecl>(Instantiation))
846 InstantiationTy =
Context.getCanonicalTagType(TD);
848 Diag(PointOfInstantiation,
849 diag::err_template_instantiate_within_definition)
855 }
else if (InstantiatedFromMember) {
857 Diag(PointOfInstantiation,
858 diag::err_explicit_instantiation_undefined_member)
863 assert(
isa<TagDecl>(Instantiation) &&
"Must be a TagDecl!");
864 Diag(PointOfInstantiation,
865 diag::err_implicit_instantiate_member_undefined)
871 Diag(PointOfInstantiation,
872 diag::err_explicit_instantiation_undefined_func_template)
876 Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
881 assert(
isa<VarDecl>(Instantiation) &&
"Must be a VarDecl!");
883 Diag(PointOfInstantiation,
884 diag::err_explicit_instantiation_undefined_var_template)
888 Diag(PointOfInstantiation,
889 diag::err_explicit_instantiation_undefined_member)
906 bool SupportedForCompatibility) {
919 ? diag::ext_template_param_shadow
920 : (SupportedForCompatibility ? diag::ext_compat_template_param_shadow
921 : diag::err_template_param_shadow);
923 Diag(Loc, DiagId) << ND->getDeclName();
928 if (
TemplateDecl *Temp = dyn_cast_or_null<TemplateDecl>(D)) {
929 D = Temp->getTemplatedDecl();
938 "Only template template arguments can be pack expansions here");
939 assert(
getAsTemplate().get().containsUnexpandedParameterPack() &&
940 "Template template argument pack expansion without packs");
942 Result.EllipsisLoc = EllipsisLoc;
977 llvm_unreachable(
"Unhandled parsed template argument");
982 for (
unsigned I = 0,
Last = TemplateArgsIn.size(); I !=
Last; ++I)
1002 assert(TInfo &&
"template argument with no location");
1010 EllipsisLoc = PET.getEllipsisLoc();
1011 TL = PET.getPatternLoc();
1015 TemplateName Name = DTST.getTypePtr()->getTemplateName();
1017 SS.
Adopt(DTST.getQualifierLoc());
1020 DTST.getTemplateNameLoc());
1041 unsigned Depth,
unsigned Position,
1044 bool HasTypeConstraint) {
1046 "Template type parameter not in template parameter scope!");
1048 bool IsParameterPack = EllipsisLoc.
isValid();
1051 KeyLoc, ParamNameLoc, Depth, Position,
1052 ParamName,
Typename, IsParameterPack,
1056 if (Param->isParameterPack())
1058 CSI->LocalPacks.push_back(Param);
1071 if (DefaultArg && IsParameterPack) {
1072 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1073 DefaultArg =
nullptr;
1081 assert(DefaultTInfo &&
"expected source information for type");
1090 Param->setInvalidDecl();
1094 Param->setDefaultArgument(
1109 return TemplateArgs;
1116 bool IsTypeConcept =
false;
1117 bool RequiresArguments =
false;
1119 IsTypeConcept = TTP->isTypeConceptTemplateParam();
1121 TTP->getTemplateParameters()->getMinRequiredArguments() > 1;
1127 ->getTemplateParameters()
1128 ->getMinRequiredArguments() > 1;
1134 if (!IsTypeConcept) {
1136 diag::err_type_constraint_non_type_concept);
1145 if (!WereArgsSpecified && RequiresArguments) {
1147 diag::err_type_constraint_missing_arguments)
1166 bool AllowUnexpandedPack) {
1183 if (EllipsisLoc.
isInvalid() && !AllowUnexpandedPack) {
1194 ConstrainedParameter, EllipsisLoc);
1197template <
typename ArgumentLocAppender>
1212 Appender(ConstraintArgs);
1220 if (
auto *CD = dyn_cast<ConceptDecl>(NamedConcept)) {
1223 FoundDecl ? FoundDecl : CD, CD, &ConstraintArgs,
1229 auto *CDT = dyn_cast<TemplateTemplateParmDecl>(NamedConcept);
1234 return ImmediatelyDeclaredConstraint;
1250 ImmediatelyDeclaredConstraint.
get(), BO_LAnd,
1251 EllipsisLoc,
nullptr,
1268 *TemplateArgs) :
nullptr;
1273 *
this,
NS, NameInfo, NamedConcept, FoundDecl,
1276 ParamAsArgument, ConstrainedParameter->
getLocation(),
1279 for (const auto &ArgLoc : TemplateArgs->arguments())
1280 ConstraintArgs.addArgument(ArgLoc);
1283 if (ImmediatelyDeclaredConstraint.
isInvalid())
1293 CL, ImmediatelyDeclaredConstraint.
get(), std::nullopt);
1304 diag::err_unsupported_placeholder_constraint)
1323 for (unsigned I = 0, C = TL.getNumArgs(); I != C; ++I)
1324 ConstraintArgs.addArgument(TL.getArgLoc(I));
1327 if (ImmediatelyDeclaredConstraint.
isInvalid() ||
1328 !ImmediatelyDeclaredConstraint.
isUsable())
1332 ImmediatelyDeclaredConstraint.
get());
1354 if (T->isDependentType())
1360 if (T->isStructuralType())
1364 if (T->isRValueReferenceType()) {
1365 Diag(Loc, diag::err_template_nontype_parm_rvalue_ref) << T;
1374 (!T->isScalarType() && !T->isRecordType())) {
1375 Diag(Loc, diag::err_template_nontype_parm_bad_type) << T;
1383 Diag(Loc, diag::err_template_nontype_parm_not_structural) << T;
1390 for (
const FieldDecl *FD : RD->fields()) {
1392 Diag(FD->getLocation(), diag::note_not_structural_non_public) << T << 0;
1395 if (FD->isMutable()) {
1396 Diag(FD->getLocation(), diag::note_not_structural_mutable_field) << T;
1399 if (FD->getType()->isRValueReferenceType()) {
1400 Diag(FD->getLocation(), diag::note_not_structural_rvalue_ref_field)
1407 for (
const auto &BaseSpec : RD->bases()) {
1408 if (BaseSpec.getAccessSpecifier() !=
AS_public) {
1409 Diag(BaseSpec.getBaseTypeLoc(), diag::note_not_structural_non_public)
1420 for (
const FieldDecl *FD : RD->fields()) {
1422 if (!T->isStructuralType()) {
1423 SubLoc = FD->getLocation();
1431 for (
const auto &BaseSpec : RD->bases()) {
1433 if (!T->isStructuralType()) {
1434 SubLoc = BaseSpec.getBaseTypeLoc();
1442 assert(Kind != -1 &&
"couldn't find reason why type is not structural");
1443 Diag(SubLoc, diag::note_not_structural_subobject)
1444 << T << Kind << SubType;
1456 if (T->isVariablyModifiedType()) {
1457 Diag(Loc, diag::err_variably_modified_nontype_template_param)
1462 if (T->isBlockPointerType()) {
1463 Diag(Loc, diag::err_template_nontype_parm_bad_type) << T;
1473 if (T->isIntegralOrEnumerationType() ||
1475 T->isPointerType() ||
1477 T->isLValueReferenceType() ||
1479 T->isMemberPointerType() ||
1481 T->isNullPtrType() ||
1483 T->isUndeducedType()) {
1486 return T.getUnqualifiedType();
1494 if (T->isArrayType() || T->isFunctionType())
1495 return Context.getDecayedType(T);
1503 if (T->isDependentType())
1504 return T.getUnqualifiedType();
1515 Diag(Loc, diag::err_template_nontype_parm_bad_structural_type) << T;
1519 Diag(Loc, diag::warn_cxx17_compat_template_nontype_parm_type) << T;
1520 return T.getUnqualifiedType();
1531 auto CheckValidDeclSpecifiers = [
this, &D] {
1545 Diag(Loc, diag::err_invalid_decl_specifier_in_nontype_parm)
1582 CheckValidDeclSpecifiers();
1587 diag::warn_cxx14_compat_template_nontype_parm_auto_type)
1591 "Non-type template parameter not in template parameter scope!");
1611 if (TL.isConstrained()) {
1613 T->containsUnexpandedParameterPack()) {
1614 assert(TL.getConceptReference()->getTemplateArgsAsWritten());
1616 TL.getConceptReference()->getTemplateArgsAsWritten()->arguments())
1626 Param->setInvalidDecl();
1628 if (Param->isParameterPack())
1630 CSI->LocalPacks.push_back(Param);
1644 if (
Default && IsParameterPack) {
1645 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1655 Param->setDefaultArgument(
1674 "Template template parameter not in template parameter scope!");
1676 bool IsParameterPack = EllipsisLoc.
isValid();
1688 NameLoc.
isInvalid() ? TmpLoc : NameLoc, Depth, Position, IsParameterPack,
1692 if (Param->isParameterPack())
1694 LSI->LocalPacks.push_back(Param);
1705 if (Params->
size() == 0) {
1706 Diag(Param->getLocation(), diag::err_template_template_parm_no_parms)
1712 Param->setInvalidDecl();
1717 if (IsParameterPack && !
Default.isInvalid()) {
1718 Diag(EqualLoc, diag::err_template_param_pack_default_arg);
1733 Diag(DefaultArg.
getLocation(), diag::err_template_arg_not_valid_template)
1752 Param->setDefaultArgument(
Context, DefaultArg);
1759class ConstraintRefersToContainingTemplateChecker
1764 unsigned TemplateDepth = 0;
1768 bool CheckIfContainingRecord(
const CXXRecordDecl *CheckingRD) {
1774 DC && !DC->isFileContext(); DC = DC->getParent())
1775 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
1776 if (CheckingRD == RD->getMostRecentDecl()) {
1784 bool CheckNonTypeTemplateParmDecl(
const NonTypeTemplateParmDecl *D) {
1790 return TraverseType(D->
getType());
1794 ConstraintRefersToContainingTemplateChecker(
const FunctionDecl *
Friend,
1795 unsigned TemplateDepth)
1798 bool getResult()
const {
return Result; }
1804 bool VisitTemplateTypeParmType(
const TemplateTypeParmType *
Type)
override {
1805 if (
Type->getDecl()->getDepth() < TemplateDepth) {
1812 bool TraverseDeclRefExpr(
const DeclRefExpr *E)
override {
1813 return TraverseDecl(E->
getDecl());
1816 bool TraverseTypedefType(
const TypedefType *TT,
1818 return TraverseType(TT->
desugar());
1821 bool TraverseTypeLoc(TypeLoc TL,
bool TraverseQualifier)
override {
1823 return TraverseType(TL.
getType(), TraverseQualifier);
1826 bool VisitTagType(
const TagType *T)
override {
1827 return TraverseDecl(T->getDecl());
1830 bool TraverseDecl(
const Decl *D)
override {
1836 if (
auto *TD = dyn_cast<TypedefNameDecl>(D))
1837 return TraverseType(TD->getUnderlyingType());
1838 if (
auto *NTTPD = dyn_cast<NonTypeTemplateParmDecl>(D))
1839 return CheckNonTypeTemplateParmDecl(NTTPD);
1840 if (
auto *VD = dyn_cast<ValueDecl>(D))
1841 return TraverseType(VD->getType());
1844 if (
auto *RD = dyn_cast<CXXRecordDecl>(D))
1845 return CheckIfContainingRecord(RD);
1850 llvm_unreachable(
"Don't know how to handle this declaration type yet");
1858 const Expr *Constraint) {
1859 assert(
Friend->getFriendObjectKind() &&
"Only works on a friend");
1860 ConstraintRefersToContainingTemplateChecker Checker(
Friend, TemplateDepth);
1861 Checker.TraverseStmt(Constraint);
1862 return Checker.getResult();
1872 Expr *RequiresClause) {
1874 Diag(ExportLoc, diag::warn_template_export_unsupported);
1926 assert(TemplateParams && TemplateParams->
size() > 0 &&
1927 "No template parameters");
1929 "Can only declare or define class templates");
1938 "can't build template of enumerated type");
1942 Diag(KWLoc, diag::err_template_unnamed_class);
1957 if (!SemanticContext) {
1962 ? diag::warn_template_qualified_friend_ignored
1963 : diag::err_template_qualified_declarator_no_match)
2039 dyn_cast_or_null<ClassTemplateDecl>(PrevDecl);
2044 if (!PrevClassTemplate && isa_and_nonnull<CXXRecordDecl>(PrevDecl) &&
2052 ->getSpecializedTemplate();
2075 PrevDecl = PrevClassTemplate =
nullptr;
2076 SemanticContext = OutermostContext;
2094 SemanticContext, S, SS.
isValid()))
2095 PrevDecl = PrevClassTemplate =
nullptr;
2097 if (
auto *Shadow = dyn_cast_or_null<UsingShadowDecl>(
2098 PrevDecl ?
Previous.getRepresentativeDecl() :
nullptr)) {
2100 !(PrevClassTemplate &&
2103 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
2104 Diag(Shadow->getTargetDecl()->getLocation(),
2105 diag::note_using_decl_target);
2106 Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl) << 0;
2108 PrevDecl = PrevClassTemplate =
nullptr;
2112 if (PrevClassTemplate) {
2121 TemplateParams, PrevClassTemplate,
2134 Diag(KWLoc, diag::err_use_with_wrong_tag)
2147 bool HiddenDefVisible =
false;
2152 if (!HiddenDefVisible && Hidden) {
2155 assert(Tmpl &&
"original definition of a class template is not a "
2161 Diag(NameLoc, diag::err_redefinition) << Name;
2162 Diag(Def->getLocation(), diag::note_previous_definition);
2169 }
else if (PrevDecl) {
2175 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
2189 (SS.
isSet() && SemanticContext && SemanticContext->
isRecord() &&
2202 ? diag::err_friend_decl_does_not_match
2203 : diag::err_member_decl_does_not_match)
2204 << Name << SemanticContext <<
true << SS.
getRange();
2214 bool ShouldAddRedecl =
2218 Context, Kind, SemanticContext, KWLoc, NameLoc, Name,
2219 PrevClassTemplate && ShouldAddRedecl
2223 if (NumOuterTemplateParamLists > 0)
2226 llvm::ArrayRef(OuterTemplateParamLists, NumOuterTemplateParamLists));
2242 if (ShouldAddRedecl)
2247 if (ModulePrivateLoc.
isValid())
2252 if (PrevClassTemplate &&
2270 if (PrevClassTemplate)
2306 if (PrevClassTemplate)
2345 S.
DiagCompat(ParamLoc, diag_compat::templ_default_in_function_templ)
2354 S.
Diag(ParamLoc, diag::err_template_parameter_default_template_member)
2363 S.
Diag(ParamLoc, diag::err_template_parameter_default_friend_template)
2372 llvm_unreachable(
"Invalid TemplateParamListContext!");
2385 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
2390 if (TC->hasExplicitTemplateArgs())
2391 for (
auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
2399 if (!NTTP->isParameterPack() &&
2401 NTTP->getTypeSourceInfo(),
2409 = dyn_cast<TemplateTemplateParmDecl>(P))
2429 bool SawDefaultArgument =
false;
2435 OldParam = OldParams->
begin();
2437 bool RemoveDefaultArguments =
false;
2439 NewParamEnd = NewParams->
end();
2440 NewParam != NewParamEnd; ++NewParam) {
2443 bool RedundantDefaultArg =
false;
2446 bool InconsistentDefaultArg =
false;
2448 std::string PrevModuleName;
2454 bool MissingDefaultArg =
false;
2457 bool SawParameterPack =
false;
2460 = dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
2462 if (NewTypeParm->hasDefaultArgument() &&
2464 *
this, TPC, NewTypeParm->getLocation(),
2465 NewTypeParm->getDefaultArgument().getSourceRange()))
2466 NewTypeParm->removeDefaultArgument();
2471 if (NewTypeParm->isParameterPack()) {
2472 assert(!NewTypeParm->hasDefaultArgument() &&
2473 "Parameter packs can't have a default argument!");
2474 SawParameterPack =
true;
2476 NewTypeParm->hasDefaultArgument() &&
2479 NewDefaultLoc = NewTypeParm->getDefaultArgumentLoc();
2480 SawDefaultArgument =
true;
2483 RedundantDefaultArg =
true;
2484 else if (!
getASTContext().isSameDefaultTemplateArgument(OldTypeParm,
2486 InconsistentDefaultArg =
true;
2490 PreviousDefaultArgLoc = NewDefaultLoc;
2494 NewTypeParm->setInheritedDefaultArgument(
Context, OldTypeParm);
2496 }
else if (NewTypeParm->hasDefaultArgument()) {
2497 SawDefaultArgument =
true;
2498 PreviousDefaultArgLoc = NewTypeParm->getDefaultArgumentLoc();
2499 }
else if (SawDefaultArgument)
2500 MissingDefaultArg =
true;
2502 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
2507 !NewNonTypeParm->isParameterPack() &&
2509 NewNonTypeParm->getTypeSourceInfo(),
2516 if (NewNonTypeParm->hasDefaultArgument() &&
2518 *
this, TPC, NewNonTypeParm->getLocation(),
2519 NewNonTypeParm->getDefaultArgument().getSourceRange())) {
2520 NewNonTypeParm->removeDefaultArgument();
2526 if (NewNonTypeParm->isParameterPack()) {
2527 assert(!NewNonTypeParm->hasDefaultArgument() &&
2528 "Parameter packs can't have a default argument!");
2529 if (!NewNonTypeParm->isPackExpansion())
2530 SawParameterPack =
true;
2532 NewNonTypeParm->hasDefaultArgument() &&
2535 NewDefaultLoc = NewNonTypeParm->getDefaultArgumentLoc();
2536 SawDefaultArgument =
true;
2538 RedundantDefaultArg =
true;
2540 OldNonTypeParm, NewNonTypeParm)) {
2541 InconsistentDefaultArg =
true;
2545 PreviousDefaultArgLoc = NewDefaultLoc;
2549 NewNonTypeParm->setInheritedDefaultArgument(
Context, OldNonTypeParm);
2551 }
else if (NewNonTypeParm->hasDefaultArgument()) {
2552 SawDefaultArgument =
true;
2553 PreviousDefaultArgLoc = NewNonTypeParm->getDefaultArgumentLoc();
2554 }
else if (SawDefaultArgument)
2555 MissingDefaultArg =
true;
2578 "Parameter packs can't have a default argument!");
2580 SawParameterPack =
true;
2581 }
else if (OldTemplateParm &&
2587 SawDefaultArgument =
true;
2589 RedundantDefaultArg =
true;
2591 OldTemplateParm, NewTemplateParm)) {
2592 InconsistentDefaultArg =
true;
2596 PreviousDefaultArgLoc = NewDefaultLoc;
2601 PreviousDefaultArgLoc
2604 SawDefaultArgument =
true;
2605 PreviousDefaultArgLoc
2607 }
else if (SawDefaultArgument)
2608 MissingDefaultArg =
true;
2614 if (SawParameterPack && (NewParam + 1) != NewParamEnd &&
2616 Diag((*NewParam)->getLocation(),
2617 diag::err_template_param_pack_must_be_last_template_parameter);
2634 if (RedundantDefaultArg) {
2635 Diag(NewDefaultLoc, diag::err_template_param_default_arg_redefinition);
2636 Diag(OldDefaultLoc, diag::note_template_param_prev_default_arg);
2638 }
else if (InconsistentDefaultArg) {
2642 diag::err_template_param_default_arg_inconsistent_redefinition);
2644 diag::note_template_param_prev_default_arg_in_other_module)
2647 }
else if (MissingDefaultArg &&
2655 Diag((*NewParam)->getLocation(),
2656 diag::err_template_param_default_arg_missing);
2657 Diag(PreviousDefaultArgLoc, diag::note_template_param_prev_default_arg);
2659 RemoveDefaultArguments =
true;
2670 if (RemoveDefaultArguments) {
2672 NewParamEnd = NewParams->
end();
2673 NewParam != NewParamEnd; ++NewParam) {
2675 TTP->removeDefaultArgument();
2677 = dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
2678 NTTP->removeDefaultArgument();
2698 bool IgnoreNonTypeDependent;
2703 DependencyChecker(
unsigned Depth,
bool IgnoreNonTypeDependent)
2704 : Depth(Depth), IgnoreNonTypeDependent(IgnoreNonTypeDependent),
2708 : IgnoreNonTypeDependent(IgnoreNonTypeDependent),
Match(
false) {
2711 Depth = PD->getDepth();
2712 }
else if (NonTypeTemplateParmDecl *PD =
2713 dyn_cast<NonTypeTemplateParmDecl>(ND)) {
2714 Depth = PD->getDepth();
2720 bool Matches(
unsigned ParmDepth, SourceLocation Loc = SourceLocation()) {
2721 if (ParmDepth >= Depth) {
2729 bool TraverseStmt(Stmt *S)
override {
2734 if (
auto *E = dyn_cast_or_null<Expr>(S))
2735 if (IgnoreNonTypeDependent && !E->isTypeDependent())
2740 bool TraverseTypeLoc(TypeLoc TL,
bool TraverseQualifier =
true)
override {
2741 if (IgnoreNonTypeDependent && !TL.
isNull() &&
2747 bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL)
override {
2751 bool VisitTemplateTypeParmType(TemplateTypeParmType *T)
override {
2753 return IgnoreNonTypeDependent || !Matches(T->getDepth());
2757 if (TemplateTemplateParmDecl *PD =
2759 if (Matches(PD->getDepth()))
2764 bool VisitDeclRefExpr(DeclRefExpr *E)
override {
2765 if (NonTypeTemplateParmDecl *PD =
2766 dyn_cast<NonTypeTemplateParmDecl>(E->
getDecl()))
2767 if (Matches(PD->getDepth(), E->
getExprLoc()))
2769 return DynamicRecursiveASTVisitor::VisitDeclRefExpr(E);
2772 bool VisitUnresolvedLookupExpr(UnresolvedLookupExpr *ULE)
override {
2775 if (Matches(TTP->getDepth(), ULE->
getExprLoc()))
2781 return DynamicRecursiveASTVisitor::VisitUnresolvedLookupExpr(ULE);
2784 bool VisitSubstTemplateTypeParmType(SubstTemplateTypeParmType *T)
override {
2785 return TraverseType(T->getReplacementType());
2788 bool VisitSubstTemplateTypeParmPackType(
2789 SubstTemplateTypeParmPackType *T)
override {
2790 return TraverseTemplateArgument(T->getArgumentPack());
2793 bool TraverseInjectedClassNameType(InjectedClassNameType *T,
2794 bool TraverseQualifier)
override {
2797 return TraverseTemplateArguments(
2798 T->getTemplateArgs(T->getDecl()->getASTContext()));
2807 if (!Params->
size())
2810 DependencyChecker Checker(Params,
false);
2811 Checker.TraverseType(T);
2812 return Checker.Match;
2838 bool &IsMemberSpecialization,
bool &
Invalid,
bool SuppressDiagnostic) {
2839 IsMemberSpecialization =
false;
2853 T =
QualType(Qualifier.getAsType(), 0);
2861 while (!T.isNull()) {
2862 NestedTypes.push_back(T);
2868 = dyn_cast<ClassTemplateSpecializationDecl>(
Record)) {
2871 ExplicitSpecLoc = Spec->getLocation();
2874 }
else if (
Record->getTemplateSpecializationKind()
2876 ExplicitSpecLoc =
Record->getLocation();
2881 T =
Context.getTypeDeclType(Parent);
2887 if (
const TemplateSpecializationType *TST
2888 = T->getAs<TemplateSpecializationType>()) {
2901 T =
Context.getTypeDeclType(Parent);
2909 if (
const DependentNameType *DependentName = T->getAs<DependentNameType>()){
2919 if (
const EnumType *EnumT = T->getAsCanonical<EnumType>()) {
2925 if (
TypeDecl *Parent = dyn_cast<TypeDecl>(
Enum->getParent()))
2926 T =
Context.getCanonicalTypeDeclType(Parent);
2936 std::reverse(NestedTypes.begin(), NestedTypes.end());
2944 bool SawNonEmptyTemplateParameterList =
false;
2946 auto CheckExplicitSpecialization = [&](
SourceRange Range,
bool Recovery) {
2947 if (SawNonEmptyTemplateParameterList) {
2948 if (!SuppressDiagnostic)
2949 Diag(DeclLoc, diag::err_specialize_member_of_template)
2950 << !Recovery << Range;
2952 IsMemberSpecialization =
false;
2959 auto DiagnoseMissingExplicitSpecialization = [&] (
SourceRange Range) {
2961 if (CheckExplicitSpecialization(Range,
true))
2966 if (!ParamLists.empty())
2967 ExpectedTemplateLoc = ParamLists[0]->getTemplateLoc();
2969 ExpectedTemplateLoc = DeclStartLoc;
2971 if (!SuppressDiagnostic)
2972 Diag(DeclLoc, diag::err_template_spec_needs_header)
2979 for (
unsigned TypeIdx = 0, NumTypes = NestedTypes.size(); TypeIdx != NumTypes;
2981 T = NestedTypes[TypeIdx];
2984 bool NeedEmptyTemplateHeader =
false;
2987 bool NeedNonemptyTemplateHeader =
false;
3000 = dyn_cast<ClassTemplatePartialSpecializationDecl>(
Record)) {
3001 ExpectedTemplateParams = Partial->getTemplateParameters();
3002 NeedNonemptyTemplateHeader =
true;
3003 }
else if (
Record->isDependentType()) {
3004 if (
Record->getDescribedClassTemplate()) {
3005 ExpectedTemplateParams =
Record->getDescribedClassTemplate()
3006 ->getTemplateParameters();
3007 NeedNonemptyTemplateHeader =
true;
3010 = dyn_cast<ClassTemplateSpecializationDecl>(
Record)) {
3016 NeedEmptyTemplateHeader =
true;
3019 }
else if (
Record->getTemplateSpecializationKind()) {
3020 if (
Record->getTemplateSpecializationKind()
3022 TypeIdx == NumTypes - 1)
3023 IsMemberSpecialization =
true;
3027 }
else if (
const auto *TST = T->getAs<TemplateSpecializationType>()) {
3030 ExpectedTemplateParams =
Template->getTemplateParameters();
3031 NeedNonemptyTemplateHeader =
true;
3035 NeedNonemptyTemplateHeader =
false;
3046 if (
ParamIdx < ParamLists.size()) {
3047 if (ParamLists[
ParamIdx]->size() == 0) {
3048 if (CheckExplicitSpecialization(ParamLists[
ParamIdx]->getSourceRange(),
3052 SawNonEmptyTemplateParameterList =
true;
3055 if (NeedEmptyTemplateHeader) {
3058 if (TypeIdx == NumTypes - 1)
3059 IsMemberSpecialization =
true;
3061 if (
ParamIdx < ParamLists.size()) {
3062 if (ParamLists[
ParamIdx]->size() > 0) {
3064 if (!SuppressDiagnostic)
3066 diag::err_template_param_list_matches_nontemplate)
3069 ParamLists[
ParamIdx]->getRAngleLoc())
3081 if (DiagnoseMissingExplicitSpecialization(
3088 if (NeedNonemptyTemplateHeader) {
3093 if (IsFriend && T->isDependentType()) {
3094 if (
ParamIdx < ParamLists.size() &&
3096 ExpectedTemplateParams =
nullptr;
3101 if (
ParamIdx < ParamLists.size()) {
3103 if (ExpectedTemplateParams &&
3105 ExpectedTemplateParams,
3118 if (!SuppressDiagnostic)
3119 Diag(DeclLoc, diag::err_template_spec_needs_template_parameters)
3130 if (
ParamIdx >= ParamLists.size()) {
3131 if (TemplateId && !IsFriend) {
3147 if (
ParamIdx < ParamLists.size() - 1) {
3148 bool HasAnyExplicitSpecHeader =
false;
3149 bool AllExplicitSpecHeaders =
true;
3150 for (
unsigned I =
ParamIdx, E = ParamLists.size() - 1; I != E; ++I) {
3151 if (ParamLists[I]->size() == 0)
3152 HasAnyExplicitSpecHeader =
true;
3154 AllExplicitSpecHeaders =
false;
3157 if (!SuppressDiagnostic)
3159 AllExplicitSpecHeaders ? diag::ext_template_spec_extra_headers
3160 : diag::err_template_spec_extra_headers)
3162 ParamLists[ParamLists.size() - 2]->getRAngleLoc());
3167 if (ExplicitSpecLoc.
isValid() && HasAnyExplicitSpecHeader &&
3168 !SuppressDiagnostic)
3169 Diag(ExplicitSpecLoc,
3170 diag::note_explicit_template_spec_does_not_need_header)
3171 << NestedTypes.back();
3176 if (!AllExplicitSpecHeaders)
3187 if (ParamLists.back()->size() == 0 &&
3188 CheckExplicitSpecialization(ParamLists[
ParamIdx]->getSourceRange(),
3194 return ParamLists.back();
3199 Diag(
Template->getLocation(), diag::note_template_declared_here)
3215 Diag((*I)->getLocation(), diag::note_template_declared_here)
3216 << 0 << (*I)->getDeclName();
3246 Keyword, BaseTemplate, TemplateLoc, Args,
3252 return BaseTemplateInst;
3257 switch (Ts.size()) {
3267 return lookUpCommonType(Ts[0], Ts[0]);
3281 return lookUpCommonType(D1, D2);
3286 auto CheckConditionalOperands = [&](
bool ConstRefQual) ->
QualType {
3325 if (
auto Res = CheckConditionalOperands(
false); !Res.isNull())
3338 return CheckConditionalOperands(
true);
3348 QualType Result = Ts.front().getAsType();
3349 for (
auto T : llvm::drop_begin(Ts)) {
3350 Result = lookUpCommonType(Result, T.getAsType());
3351 if (Result.isNull())
3360 DeclContext *DC = RT->getDecl()->getDeclContext();
3375 bool Literal =
false;
3378 auto SpecDecl = dyn_cast<ClassTemplateSpecializationDecl>(RT->getDecl());
3382 QualType ConstantType = LiteralArgs[0].getAsType();
3385 LiteralLoc = SpecDecl->getSourceRange().getBegin();
3389 RT->getDecl()->getName() ==
"integral_constant") {
3390 auto SpecDecl = dyn_cast<ClassTemplateSpecializationDecl>(RT->getDecl());
3395 QualType ConstantType = ConstantArgs[0].getAsType();
3396 llvm::APInt
Value = ConstantArgs[1].getAsIntegral();
3399 return SpirvOperand::createLiteral(
Value);
3400 return SpirvOperand::createConstant(ConstantType,
Value);
3401 }
else if (Literal) {
3402 SemaRef.
Diag(LiteralLoc, diag::err_hlsl_vk_literal_must_contain_constant);
3403 return SpirvOperand();
3407 diag::err_call_incomplete_argument))
3408 return SpirvOperand();
3409 return SpirvOperand::createType(OperandArg);
3419 "Builtin template arguments do not match its parameters");
3422 case BTK__make_integer_seq: {
3426 QualType OrigType = Converted[1].getAsType();
3430 SemaRef.
Diag(TemplateArgs[1].getLocation(),
3431 diag::err_integer_sequence_integral_element_type);
3445 OrigType, TemplateArgs[1].getLocation())));
3447 if (llvm::APSInt NumArgs = NumArgsArg.
getAsIntegral(); NumArgs >= 0) {
3449 for (llvm::APSInt I(NumArgs.getBitWidth(), NumArgs.isUnsigned());
3453 TA, OrigType, TemplateArgs[2].getLocation()));
3458 SemaRef.
Diag(TemplateArgs[2].getLocation(),
3459 diag::err_integer_sequence_negative_length);
3466 TemplateLoc, SyntheticTemplateArgs,
3471 case BTK__type_pack_element: {
3475 assert(Converted.size() == 2 &&
3476 "__type_pack_element should be given an index and a parameter pack");
3483 assert(Index >= 0 &&
"the index used with __type_pack_element should be of "
3484 "type std::size_t, and hence be non-negative");
3486 if (Index >= Ts.pack_size()) {
3487 SemaRef.
Diag(TemplateArgs[0].getLocation(),
3488 diag::err_type_pack_element_out_of_bounds);
3493 int64_t N = Index.getExtValue();
3494 return Ts.getPackAsArray()[N].getAsType();
3497 case BTK__builtin_common_type: {
3498 assert(Converted.size() == 4);
3499 if (llvm::any_of(Converted, [](
auto &
C) {
return C.isDependent(); }))
3502 TemplateName BaseTemplate = Converted[0].getAsTemplate();
3510 CT, TemplateArgs[1].getLocation())));
3511 TemplateName HasTypeMember = Converted[1].getAsTemplate();
3516 QualType HasNoTypeMember = Converted[2].getAsType();
3517 return HasNoTypeMember;
3520 case BTK__hlsl_spirv_type: {
3521 assert(Converted.size() == 4);
3523 if (!Context.getTargetInfo().getTriple().isSPIRV()) {
3524 SemaRef.
Diag(TemplateLoc, diag::err_hlsl_spirv_only) << BTD;
3527 if (llvm::any_of(Converted, [](
auto &
C) {
return C.isDependent(); }))
3530 uint64_t Opcode = Converted[0].getAsIntegral().getZExtValue();
3531 uint64_t Size = Converted[1].getAsIntegral().getZExtValue();
3532 uint64_t Alignment = Converted[2].getAsIntegral().getZExtValue();
3538 for (
auto &OperandTA : OperandArgs) {
3539 QualType OperandArg = OperandTA.getAsType();
3541 TemplateArgs[3].getLocation());
3542 if (!Operand.isValid())
3544 Operands.push_back(Operand);
3547 return Context.getHLSLInlineSpirvType(Opcode, Size, Alignment, Operands);
3549 case BTK__builtin_dedup_pack: {
3550 assert(Converted.size() == 1 &&
"__builtin_dedup_pack should be given "
3551 "a parameter pack");
3560 llvm::SmallDenseSet<QualType> Seen;
3564 if (!Seen.insert(T.getAsType().getCanonicalType()).second)
3566 OutArgs.push_back(T);
3568 return Context.getSubstBuiltinTemplatePack(
3572 llvm_unreachable(
"unexpected BuiltinTemplateDecl!");
3590 if (
auto BinOp = dyn_cast<BinaryOperator>(Clause->IgnoreParenImpCasts())) {
3591 if (BinOp->getOpcode() == BO_LAnd) {
3598 Terms.push_back(Clause);
3606 auto *BinOp = dyn_cast<BinaryOperator>(
Cond->IgnoreParenImpCasts());
3607 if (!BinOp)
return Cond;
3609 if (BinOp->getOpcode() != BO_LOr)
return Cond;
3612 Expr *LHS = BinOp->getLHS();
3614 if (!InnerBinOp)
return Cond;
3616 if (InnerBinOp->getOpcode() != BO_EQ ||
3627 if (MacroName ==
"CONCEPT_REQUIRES" || MacroName ==
"CONCEPT_REQUIRES_")
3628 return BinOp->getRHS();
3638class FailedBooleanConditionPrinterHelper :
public PrinterHelper {
3640 explicit FailedBooleanConditionPrinterHelper(
const PrintingPolicy &P)
3643 bool handledStmt(Stmt *E, raw_ostream &OS)
override {
3644 const auto *DR = dyn_cast<DeclRefExpr>(E);
3645 if (DR && DR->getQualifier()) {
3648 DR->getQualifier().print(OS, Policy,
true);
3650 const ValueDecl *VD = DR->getDecl();
3652 if (
const auto *IV = dyn_cast<VarTemplateSpecializationDecl>(VD)) {
3654 printTemplateArgumentList(
3655 OS, IV->getTemplateArgs().asArray(), Policy,
3656 IV->getSpecializedTemplate()->getTemplateParameters());
3664 const PrintingPolicy Policy;
3669std::pair<Expr *, std::string>
3678 Expr *FailedCond =
nullptr;
3679 for (
Expr *Term : Terms) {
3693 if (Term->EvaluateAsBooleanCondition(Succeeded,
Context) &&
3695 FailedCond = TermAsWritten;
3700 FailedCond =
Cond->IgnoreParenImpCasts();
3702 std::string Description;
3704 llvm::raw_string_ostream Out(Description);
3707 FailedBooleanConditionPrinterHelper Helper(Policy);
3708 FailedCond->
printPretty(Out, &Helper, Policy, 0,
"\n",
nullptr);
3710 return { FailedCond, Description };
3726 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
3727 return std::make_unique<CandidateCallback>(*
this);
3738 std::nullopt,
false,
3754 if (
const auto *S = UnderlyingName.getAsSubstTemplateTemplateParmPack()) {
3756 }
else if (
const auto *DTN = UnderlyingName.getAsDependentTemplateName()) {
3757 if (DTN->getName().getIdentifier())
3765 }
else if (
const auto *ATN = UnderlyingName.getAsAssumedTemplateName()) {
3767 *
this,
Scope, ATN, TemplateLoc);
3768 CorrectedName.isNull()) {
3769 Diag(TemplateLoc, diag::err_no_template) << ATN->getDeclName();
3772 Name = CorrectedName;
3780 if (ForNestedNameSpecifier)
3781 Diag(TemplateLoc, diag::err_non_type_template_in_nested_name_specifier)
3782 << isa_and_nonnull<VarTemplateDecl>(
Template) << Name << R;
3784 Diag(TemplateLoc, diag::err_template_id_not_a_type) << Name << R;
3809 dyn_cast<TypeAliasTemplateDecl>(
Template)) {
3817 SemaRef.Diag(TemplateLoc, diag::err_tag_reference_non_tag)
3854 std::optional<ContextRAII> SavedContext;
3856 SavedContext.emplace(*
this,
AliasTemplate->getDeclContext());
3861 if (CanonType.
isNull()) {
3868 Trap ? Trap->getDeductionInfo() :
nullptr) {
3871 diag::err_typename_nested_not_found_enable_if &&
3872 TemplateArgs[0].getArgument().getKind() ==
3875 std::string FailedDescription;
3876 std::tie(FailedCond, FailedDescription) =
3888 PDiag(diag::err_typename_nested_not_found_requirement)
3896 }
else if (
auto *BTD = dyn_cast<BuiltinTemplateDecl>(
Template)) {
3900 TemplateSpecializationType::anyDependentTemplateArguments(
3909 CanonType =
Context.getCanonicalTemplateSpecializationType(
3911 Context.getCanonicalTemplateName(Name,
true),
3924 if (Ctx->isFileContext())
break;
3933 !
Record->getDescribedClassTemplate())
3942 if (CanonType != Injected)
3955 dyn_cast<ClassTemplateDecl>(
Template)) {
3958 void *InsertPos =
nullptr;
3995 "type of non-dependent specialization is not a RecordType");
3997 llvm_unreachable(
"Unhandled template kind");
4003 return Context.getTemplateSpecializationType(
4015 assert(ATN &&
"not an assumed template name");
4016 II = ATN->getDeclName().getAsIdentifierInfo();
4033 SourceLocation RAngleLoc,
bool IsCtorOrDtorName,
bool IsClassName,
4038 if (!IsCtorOrDtorName && !IsClassName && SS.
isSet()) {
4064 TemplateD, TemplateII, TemplateIILoc, LAngleLoc,
4065 TemplateArgsIn, RAngleLoc);
4072 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
4073 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
4076 ? diag::err_out_of_line_qualified_id_type_names_constructor
4077 : diag::ext_out_of_line_qualified_id_type_names_constructor)
4088 ElaboratedKeyword, TemplateD.
get(), TemplateIILoc, TemplateArgs,
4097 TemplateIILoc, TemplateArgs);
4130 if (
const RecordType *RT =
Result->getAs<RecordType>()) {
4134 assert(Id &&
"templated class must have an identifier");
4138 Diag(TagLoc, diag::err_use_with_wrong_tag)
4175 const TemplateTypeParmType *TPT =
4177 return TPT && !
Type.hasQualifiers() &&
4178 TPT->getDepth() == Depth && TPT->getIndex() == Index;
4186 dyn_cast<NonTypeTemplateParmDecl>(DRE->
getDecl());
4192 dyn_cast_or_null<TemplateTemplateParmDecl>(
4196 llvm_unreachable(
"unexpected kind of template argument");
4202 if (Params->
size() != Args.size() || Params->
size() != SpecParams->
size())
4205 unsigned Depth = Params->
getDepth();
4207 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
4225 if (
auto *SpecNTTP =
4226 dyn_cast<NonTypeTemplateParmDecl>(SpecParams->
getParam(I))) {
4227 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(I));
4228 if (!NTTP || NTTP->getType().getCanonicalType() !=
4229 SpecNTTP->getType().getCanonicalType())
4237template<
typename PartialSpecDecl>
4239 if (Partial->getDeclContext()->isDependentContext())
4248 auto *
Template = Partial->getSpecializedTemplate();
4249 S.
Diag(Partial->getLocation(),
4250 diag::ext_partial_spec_not_more_specialized_than_primary)
4260 diag::note_partial_spec_not_more_specialized_than_primary)
4266 Template->getAssociatedConstraints(TemplateAC);
4267 Partial->getAssociatedConstraints(PartialAC);
4274 const llvm::SmallBitVector &DeducibleParams) {
4275 for (
unsigned I = 0, N = DeducibleParams.size(); I != N; ++I) {
4276 if (!DeducibleParams[I]) {
4278 if (Param->getDeclName())
4279 S.
Diag(Param->getLocation(), diag::note_non_deducible_parameter)
4280 << Param->getDeclName();
4282 S.
Diag(Param->getLocation(), diag::note_non_deducible_parameter)
4289template<
typename PartialSpecDecl>
4291 PartialSpecDecl *Partial) {
4304 auto *TemplateParams = Partial->getTemplateParameters();
4305 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
4307 TemplateParams->getDepth(), DeducibleParams);
4309 if (!DeducibleParams.all()) {
4310 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
4311 S.
Diag(Partial->getLocation(), diag::ext_partial_specs_not_deducible)
4313 << (NumNonDeducible > 1)
4315 Partial->getTemplateArgsAsWritten()->RAngleLoc);
4336 llvm::SmallBitVector DeducibleParams(TemplateParams->size());
4338 for (
unsigned I = 0; I != TemplateParams->size(); ++I) {
4340 auto *Param = TemplateParams->getParam(I);
4342 DeducibleParams[I] =
true;
4345 if (!DeducibleParams.all()) {
4346 unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
4347 Diag(TD->
getLocation(), diag::err_deduction_guide_template_not_deducible)
4348 << (NumNonDeducible > 1);
4359 "Variable template specialization is declared with a template id.");
4376 FnTemplate = *OTS->begin();
4386 if (
const auto *DSA =
VarTemplate->getAttr<NoSpecializationsAttr>()) {
4387 auto Message = DSA->getMessage();
4388 Diag(TemplateNameLoc, diag::warn_invalid_specialization)
4390 Diag(DSA->getLoc(), diag::note_marked_here) << DSA;
4394 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
4414 TemplateArgs.
size(),
4421 !TemplateSpecializationType::anyDependentTemplateArguments(
4423 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
4430 (!
Context.getLangOpts().CPlusPlus20 ||
4436 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
4446 void *InsertPos =
nullptr;
4450 PrevDecl =
VarTemplate->findPartialSpecialization(
4476 cast_or_null<VarTemplatePartialSpecializationDecl>(PrevDecl);
4485 VarTemplate->AddPartialSpecialization(Partial, InsertPos);
4524 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
4528 diag::note_instantiation_required_here)
4558struct PartialSpecMatchResult {
4566 if (Var->
getName() !=
"format_kind" ||
4587 bool SetWrittenArgs) {
4588 assert(
Template &&
"A variable template id without template?");
4600 if (
Template->getDeclContext()->isDependentContext() ||
4601 TemplateSpecializationType::anyDependentTemplateArguments(
4608 return Context.isSameTemplateArgument(Arg1, Arg2);
4614 !IsLibstdcxxStdFormatKind(
PP, Var) &&
4618 IsSameTemplateArg)) {
4619 Diag(TemplateNameLoc,
4620 diag::err_auto_variable_cannot_appear_in_own_initializer)
4621 << diag::ParsingInitFor::VarTemplate << Var << Var->
getType();
4626 Template->getPartialSpecializations(PartialSpecs);
4630 Partial->getTemplateArgs().asArray(),
4631 IsSameTemplateArg)) {
4632 Diag(TemplateNameLoc,
4633 diag::err_auto_variable_cannot_appear_in_own_initializer)
4634 << diag::ParsingInitFor::VarTemplatePartialSpec << Partial
4635 << Partial->getType();
4644 void *InsertPos =
nullptr;
4648 if (Spec->getType()->isUndeducedType()) {
4650 Diag(TemplateNameLoc,
4651 diag::err_auto_variable_cannot_appear_in_own_initializer)
4652 << diag::ParsingInitFor::VarTemplateExplicitSpec << Spec
4657 Diag(TemplateNameLoc, diag::err_var_template_spec_type_depends_on_self)
4658 << Spec << Spec->getType();
4672 bool AmbiguousPartialSpec =
false;
4673 typedef PartialSpecMatchResult MatchResult;
4685 Template->getPartialSpecializations(PartialSpecs);
4697 if (
Template->getMostRecentDecl()->isMemberSpecialization() &&
4698 !Partial->getMostRecentDecl()->isMemberSpecialization())
4713 Matched.push_back(PartialSpecMatchResult());
4714 Matched.back().Partial = Partial;
4719 if (Matched.size() >= 1) {
4721 if (Matched.size() == 1) {
4734 PEnd = Matched.end();
4737 PointOfInstantiation) ==
4745 PEnd = Matched.end();
4748 P->Partial, Best->Partial,
4749 PointOfInstantiation) != Best->Partial) {
4750 AmbiguousPartialSpec =
true;
4757 InstantiationPattern = Best->Partial;
4758 PartialSpecArgs = Best->Args;
4769 if (AmbiguousPartialSpec) {
4771 Diag(PointOfInstantiation, diag::err_partial_spec_ordering_ambiguous)
4774 for (MatchResult P : Matched)
4775 Diag(P.Partial->getLocation(), diag::note_partial_spec_match)
4787 Decl->setTemplateArgsAsWritten(TemplateArgs);
4790 dyn_cast<VarTemplatePartialSpecializationDecl>(InstantiationPattern))
4791 Decl->setInstantiationOf(D, PartialSpecArgs);
4795 assert(
Decl &&
"No variable template specialization?");
4805 *TemplateArgs,
false);
4806 if (
Decl.isInvalid())
4825 assert(
Template &&
"A variable template id without template?");
4828 Template->templateParameterKind() !=
4853 SourceLocation(), NameInfo,
false, TemplateArgs, R.begin(), R.end(),
4860 Diag(Loc, diag::err_template_missing_args)
4868 bool TemplateKeyword,
4880 bool DoCheckConstraintSatisfaction) {
4881 assert(NamedConcept &&
"A concept template id without a template?");
4888 NamedConcept, ConceptNameInfo.
getLoc(),
4907 bool AreArgsDependent =
4908 TemplateSpecializationType::anyDependentTemplateArguments(
4915 TemplateKWLoc, ConceptNameInfo, FoundDecl, NamedConcept,
4919 if (
const auto *
Concept = dyn_cast<ConceptDecl>(NamedConcept);
4921 DoCheckConstraintSatisfaction) {
4940 Context,
CL, CSD, AreArgsDependent ?
nullptr : &Satisfaction);
4959 assert(!R.isAmbiguous() &&
"ambiguous lookup when building templateid");
4965 SS, TemplateKWLoc.
isValid(), TD, R.getNameLoc());
4969 bool KnownDependent =
false;
4974 R.getRepresentativeDecl(), TemplateKWLoc, TemplateArgs);
4978 KnownDependent =
true;
4982 R.suppressDiagnostics();
4986 R.getRepresentativeDecl(),
4996 TemplateKWLoc, TemplateArgs);
5001 TemplateKWLoc, R.getLookupNameInfo(), RequiresADL, TemplateArgs,
5002 R.begin(), R.end(), KnownDependent,
5007 if (ULE->
getType() ==
Context.OverloadTy && R.isSingleResult() &&
5008 !R.getFoundDecl()->getAsFunction())
5018 assert(TemplateArgs || TemplateKWLoc.
isValid());
5022 false, TemplateKWLoc))
5025 if (R.isAmbiguous())
5028 if (R.wasNotFoundInCurrentInstantiation() || SS.
isInvalid())
5051 bool EnteringContext,
5053 bool AllowInjectedClassName) {
5057 diag::warn_cxx98_compat_template_outside_of_template :
5058 diag::ext_template_outside_of_template)
5068 else if (ObjectType)
5087 bool MemberOfUnknownSpecialization;
5089 ObjectType, EnteringContext,
Result,
5090 MemberOfUnknownSpecialization);
5093 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
5094 if (!AllowInjectedClassName && SS.
isNotEmpty() && LookupRD &&
5107 diag::ext_out_of_line_qualified_id_type_names_constructor)
5115 if (!MemberOfUnknownSpecialization) {
5146 {Qualifier, Name.Identifier, TemplateKWLoc.isValid()}));
5151 {Qualifier, Name.OperatorFunctionId.Operator,
5152 TemplateKWLoc.isValid()}));
5167 diag::err_template_kw_refers_to_dependent_non_template)
5169 << TemplateKWLoc.
isValid() << TemplateKWLoc;
5206 dyn_cast<DependentScopeDeclRefExpr>(Arg.
getAsExpr())) {
5207 SS.
Adopt(ArgExpr->getQualifierLoc());
5208 NameInfo = ArgExpr->getNameInfo();
5210 dyn_cast<CXXDependentScopeMemberExpr>(Arg.
getAsExpr())) {
5211 if (ArgExpr->isImplicitAccess()) {
5212 SS.
Adopt(ArgExpr->getQualifierLoc());
5213 NameInfo = ArgExpr->getMemberNameInfo();
5222 Result.wasNotFoundInCurrentInstantiation()) {
5223 assert(SS.
getScopeRep() &&
"dependent scope expr must has a scope!");
5227 ? diag::ext_ms_template_type_arg_missing_typename
5228 : diag::err_template_arg_must_be_type_suggest)
5261 SugaredConverted.push_back(Arg);
5262 CanonicalConverted.push_back(Arg);
5268 Diag(SR.
getBegin(), diag::err_template_arg_must_be_type) << SR;
5282 ArgType->isObjCLifetimeType() &&
5290 CanonicalConverted.push_back(
5325 Output = Param->getDefaultArgument();
5339 for (
unsigned i = 0, e = Param->getDepth(); i != e; ++i)
5342 bool ForLambdaCallOperator =
false;
5343 if (
const auto *Rec = dyn_cast<CXXRecordDecl>(
Template->getDeclContext()))
5344 ForLambdaCallOperator = Rec->isLambda();
5346 !ForLambdaCallOperator);
5349 Param->getDefaultArgumentLoc(),
5350 Param->getDeclName()))
5394 for (
unsigned i = 0, e = Param->getDepth(); i != e; ++i)
5401 TemplateArgLists, Output);
5438 SugaredConverted,
SourceRange(TemplateLoc, RAngleLoc));
5445 for (
unsigned i = 0, e = Param->getDepth(); i != e; ++i)
5462 HasDefaultArg =
false;
5468 HasDefaultArg =
true;
5471 RAngleLoc, TypeParm, SugaredConverted,
5472 CanonicalConverted, Output))
5478 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
5482 HasDefaultArg =
true;
5485 RAngleLoc, NonTypeParm, SugaredConverted,
5486 CanonicalConverted, Output))
5496 HasDefaultArg =
true;
5500 *
this,
Template, TemplateKWLoc, TemplateNameLoc, RAngleLoc, TempTempParm,
5501 SugaredConverted, CanonicalConverted, QualifierLoc);
5525 TemplateName Name = TagLoc.getTypePtr()->getTemplateName(Context);
5531 TagLoc.getQualifierLoc(), TagLoc.getNameLoc());
5538 unsigned ArgumentPackIndex,
5552 QualType NTTPType = NTTP->getType();
5553 if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack())
5554 NTTPType = NTTP->getExpansionType(ArgumentPackIndex);
5568 if (
auto *PET = NTTPType->
getAs<PackExpansionType>()) {
5570 NTTPType =
SubstType(PET->getPattern(), MLTAL, NTTP->getLocation(),
5571 NTTP->getDeclName());
5573 NTTPType =
SubstType(NTTPType, MLTAL, NTTP->getLocation(),
5574 NTTP->getDeclName());
5581 NTTP->getLocation());
5586 auto checkExpr = [&](
Expr *E) ->
Expr * {
5589 NTTP, NTTPType, E, SugaredResult, CanonicalResult,
5601 llvm_unreachable(
"Should never see a NULL template argument here");
5605 Expr *R = checkExpr(E);
5630 assert(R.isUsable());
5631 if (!checkExpr(R.get()))
5670 NTTP, NTTPType, E.
get(), SugaredResult, CanonicalResult,
5702 if (T->isFunctionType())
5703 Diag(SR.
getBegin(), diag::err_template_arg_nontype_ambig) << SR << T;
5705 Diag(SR.
getBegin(), diag::err_template_arg_must_be_expr) << SR;
5711 llvm_unreachable(
"Caller must expand template argument packs");
5756 ArgLoc = ConvertedArg;
5761 llvm_unreachable(
"Should never see a NULL template argument here");
5772 Context.getCanonicalTemplateArgument(Arg));
5800 llvm_unreachable(
"non-type argument with template template parameter");
5803 llvm_unreachable(
"Caller must expand template argument packs");
5810template<
typename TemplateParmDecl>
5813 const TemplateParmDecl *D,
5818 ->getTemplateParameters()
5819 ->getParam(D->getIndex()));
5826 D->getDefaultArgumentLoc(), Modules,
5837 S.
Diag(Loc, diag::err_template_arg_list_different_arity)
5854 DefaultArgs, PartialTemplateArgs, CTAI, UpdateArgsWithConversions,
5885 unsigned ArgIdx = 0, NumArgs = NewArgs.
size();
5888 ParamEnd = Params->
end(),
5892 if (
size_t ParamIdx = Param - ParamBegin;
5895 assert(ArgIdx == NumArgs &&
"bad default argument deduction");
5897 assert(Param + DefaultArgs.
Args.size() <= ParamEnd);
5902 Context.getCanonicalTemplateArgument(DefArg));
5912 if (*Expansions == SugaredArgumentPack.size()) {
5917 SugaredArgumentPack.clear();
5921 CanonicalArgumentPack.clear();
5926 }
else if (ArgIdx == NumArgs && !PartialTemplateArgs) {
5928 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
5940 dyn_cast<NonTypeTemplateParmDecl>(*Param);
5942 auto TL = NTTP->getTypeSourceInfo()
5947 for (
const auto &UPP : Unexpanded) {
5948 auto *TST = UPP.first.dyn_cast<
const TemplateSpecializationType *>();
5953 Diag(TL.getEllipsisLoc(),
5954 diag::err_unsupported_builtin_template_pack_expansion)
5955 << TST->getTemplateName();
5960 if (ArgIdx < NumArgs) {
5962 bool NonPackParameter =
5972 if (!(*Param)->isTemplateParameterPack() ||
5979 RAngleLoc, SugaredArgumentPack.size(), CTAI,
5984 clang::isSubstitutedDefaultArgument(
Context, Arg, *Param,
5994 RAngleLoc, SugaredArgumentPack.size(), CTAI,
6001 if (ArgIsExpansion && NonPackParameter) {
6011 diag::err_template_expansion_into_fixed_list)
6022 if (ArgIsExpansion && (CTAI.
MatchingTTP || NonPackParameter)) {
6026 if (!SugaredArgumentPack.empty()) {
6030 SugaredArgumentPack.begin(),
6031 SugaredArgumentPack.end());
6032 SugaredArgumentPack.clear();
6035 CanonicalArgumentPack.begin(),
6036 CanonicalArgumentPack.end());
6037 CanonicalArgumentPack.clear();
6040 while (ArgIdx < NumArgs) {
6044 Context.getCanonicalTemplateArgument(Arg));
6051 if ((*Param)->isTemplateParameterPack()) {
6066 if (PartialTemplateArgs) {
6067 if ((*Param)->isTemplateParameterPack() && !SugaredArgumentPack.empty()) {
6078 if ((*Param)->isTemplateParameterPack()) {
6080 "Should have dealt with this already");
6085 if (Param + 1 != ParamEnd) {
6087 (
Template->getMostRecentDecl()->getKind() != Decl::Kind::Concept) &&
6088 "Concept templates must have parameter packs at the end.");
6094 SugaredArgumentPack.clear();
6098 CanonicalArgumentPack.clear();
6117 if (!HasDefaultArg) {
6122 dyn_cast<NonTypeTemplateParmDecl>(*Param))
6156 if (isTemplateTemplateParameter)
6171 while (ArgIdx < NumArgs &&
6172 NewArgs[ArgIdx].
getArgument().isPackExpansion()) {
6176 Context.getCanonicalTemplateArgument(Arg));
6182 if (ArgIdx < NumArgs) {
6183 Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
6194 if (UpdateArgsWithConversions)
6195 TemplateArgs = std::move(NewArgs);
6197 if (!PartialTemplateArgs) {
6204 if (
auto *TD = dyn_cast<TemplateDecl>(NewContext))
6206 auto *RD = dyn_cast<CXXRecordDecl>(NewContext);
6210 dyn_cast_or_null<CXXMethodDecl>(
Template->getTemplatedDecl()))
6211 ThisQuals =
Method->getMethodQualifiers();
6235 class UnnamedLocalNoLinkageFinder
6236 :
public TypeVisitor<UnnamedLocalNoLinkageFinder, bool>
6244 UnnamedLocalNoLinkageFinder(
Sema &S,
SourceRange SR) : S(S), SR(SR) { }
6247 return T.isNull() ?
false : inherited::Visit(T.getTypePtr());
6250#define TYPE(Class, Parent) \
6251 bool Visit##Class##Type(const Class##Type *);
6252#define ABSTRACT_TYPE(Class, Parent) \
6253 bool Visit##Class##Type(const Class##Type *) { return false; }
6254#define NON_CANONICAL_TYPE(Class, Parent) \
6255 bool Visit##Class##Type(const Class##Type *) { return false; }
6256#include "clang/AST/TypeNodes.inc"
6258 bool VisitTagDecl(
const TagDecl *Tag);
6263bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(
const BuiltinType*) {
6267bool UnnamedLocalNoLinkageFinder::VisitComplexType(
const ComplexType* T) {
6271bool UnnamedLocalNoLinkageFinder::VisitPointerType(
const PointerType* T) {
6275bool UnnamedLocalNoLinkageFinder::VisitBlockPointerType(
6280bool UnnamedLocalNoLinkageFinder::VisitLValueReferenceType(
6285bool UnnamedLocalNoLinkageFinder::VisitRValueReferenceType(
6290bool UnnamedLocalNoLinkageFinder::VisitMemberPointerType(
6295 return VisitTagDecl(RD);
6299bool UnnamedLocalNoLinkageFinder::VisitConstantArrayType(
6304bool UnnamedLocalNoLinkageFinder::VisitIncompleteArrayType(
6309bool UnnamedLocalNoLinkageFinder::VisitVariableArrayType(
6314bool UnnamedLocalNoLinkageFinder::VisitDependentSizedArrayType(
6319bool UnnamedLocalNoLinkageFinder::VisitDependentSizedExtVectorType(
6324bool UnnamedLocalNoLinkageFinder::VisitDependentSizedMatrixType(
6329bool UnnamedLocalNoLinkageFinder::VisitDependentAddressSpaceType(
6334bool UnnamedLocalNoLinkageFinder::VisitVectorType(
const VectorType* T) {
6338bool UnnamedLocalNoLinkageFinder::VisitDependentVectorType(
6343bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(
const ExtVectorType* T) {
6347bool UnnamedLocalNoLinkageFinder::VisitConstantMatrixType(
6352bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
6362bool UnnamedLocalNoLinkageFinder::VisitFunctionNoProtoType(
6367bool UnnamedLocalNoLinkageFinder::VisitUnresolvedUsingType(
6372bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(
const TypeOfExprType*) {
6376bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(
const TypeOfType* T) {
6377 return Visit(T->getUnmodifiedType());
6380bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(
const DecltypeType*) {
6384bool UnnamedLocalNoLinkageFinder::VisitPackIndexingType(
6385 const PackIndexingType *) {
6389bool UnnamedLocalNoLinkageFinder::VisitUnaryTransformType(
6390 const UnaryTransformType*) {
6394bool UnnamedLocalNoLinkageFinder::VisitAutoType(
const AutoType *T) {
6395 return Visit(T->getDeducedType());
6398bool UnnamedLocalNoLinkageFinder::VisitDeducedTemplateSpecializationType(
6399 const DeducedTemplateSpecializationType *T) {
6400 return Visit(T->getDeducedType());
6403bool UnnamedLocalNoLinkageFinder::VisitRecordType(
const RecordType* T) {
6404 return VisitTagDecl(T->getDecl()->getDefinitionOrSelf());
6407bool UnnamedLocalNoLinkageFinder::VisitEnumType(
const EnumType* T) {
6408 return VisitTagDecl(T->getDecl()->getDefinitionOrSelf());
6411bool UnnamedLocalNoLinkageFinder::VisitTemplateTypeParmType(
6412 const TemplateTypeParmType*) {
6416bool UnnamedLocalNoLinkageFinder::VisitSubstTemplateTypeParmPackType(
6417 const SubstTemplateTypeParmPackType *) {
6421bool UnnamedLocalNoLinkageFinder::VisitSubstBuiltinTemplatePackType(
6422 const SubstBuiltinTemplatePackType *) {
6426bool UnnamedLocalNoLinkageFinder::VisitTemplateSpecializationType(
6427 const TemplateSpecializationType*) {
6431bool UnnamedLocalNoLinkageFinder::VisitInjectedClassNameType(
6432 const InjectedClassNameType* T) {
6433 return VisitTagDecl(T->getDecl()->getDefinitionOrSelf());
6436bool UnnamedLocalNoLinkageFinder::VisitDependentNameType(
6437 const DependentNameType* T) {
6438 return VisitNestedNameSpecifier(T->getQualifier());
6441bool UnnamedLocalNoLinkageFinder::VisitPackExpansionType(
6442 const PackExpansionType* T) {
6443 return Visit(T->getPattern());
6446bool UnnamedLocalNoLinkageFinder::VisitObjCObjectType(
const ObjCObjectType *) {
6450bool UnnamedLocalNoLinkageFinder::VisitObjCInterfaceType(
6455bool UnnamedLocalNoLinkageFinder::VisitObjCObjectPointerType(
6460bool UnnamedLocalNoLinkageFinder::VisitAtomicType(
const AtomicType* T) {
6464bool UnnamedLocalNoLinkageFinder::VisitOverflowBehaviorType(
6465 const OverflowBehaviorType *T) {
6466 return Visit(T->getUnderlyingType());
6469bool UnnamedLocalNoLinkageFinder::VisitPipeType(
const PipeType* T) {
6473bool UnnamedLocalNoLinkageFinder::VisitBitIntType(
const BitIntType *T) {
6477bool UnnamedLocalNoLinkageFinder::VisitArrayParameterType(
6479 return VisitConstantArrayType(T);
6482bool UnnamedLocalNoLinkageFinder::VisitDependentBitIntType(
6487bool UnnamedLocalNoLinkageFinder::VisitTagDecl(
const TagDecl *Tag) {
6488 if (
Tag->getDeclContext()->isFunctionOrMethod()) {
6489 S.Diag(SR.getBegin(), S.getLangOpts().CPlusPlus11
6490 ? diag::warn_cxx98_compat_template_arg_local_type
6491 : diag::ext_template_arg_local_type)
6492 << S.Context.getCanonicalTagType(Tag) << SR;
6496 if (!
Tag->hasNameForLinkage()) {
6497 S.Diag(SR.getBegin(),
6498 S.getLangOpts().CPlusPlus11 ?
6499 diag::warn_cxx98_compat_template_arg_unnamed_type :
6500 diag::ext_template_arg_unnamed_type) << SR;
6501 S.Diag(
Tag->getLocation(), diag::note_template_unnamed_type_here);
6508bool UnnamedLocalNoLinkageFinder::VisitNestedNameSpecifier(
6519 llvm_unreachable(
"Invalid NestedNameSpecifier::Kind!");
6522bool UnnamedLocalNoLinkageFinder::VisitHLSLAttributedResourceType(
6523 const HLSLAttributedResourceType *T) {
6524 if (T->hasContainedType() && Visit(T->getContainedType()))
6526 return Visit(T->getWrappedType());
6529bool UnnamedLocalNoLinkageFinder::VisitHLSLInlineSpirvType(
6530 const HLSLInlineSpirvType *T) {
6531 for (
auto &Operand : T->getOperands())
6533 if (Visit(
Operand.getResultType()))
6539 assert(ArgInfo &&
"invalid TypeSourceInfo");
6545 return Diag(SR.
getBegin(), diag::err_variably_modified_template_arg) << Arg;
6546 }
else if (
Context.hasSameUnqualifiedType(Arg,
Context.OverloadTy)) {
6547 return Diag(SR.
getBegin(), diag::err_template_arg_overload_type) << SR;
6558 UnnamedLocalNoLinkageFinder Finder(*
this, SR);
6559 (void)Finder.Visit(CanonArg);
6576 Decl *Entity =
nullptr) {
6582 if (Entity && Entity->hasAttr<DLLImportAttr>())
6587 "Incomplete parameter type in isNullPointerValueTemplateArgument!");
6600 EvalResult.
Diag = &Notes;
6608 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
6609 diag::note_invalid_subexpr_in_const_expr) {
6610 DiagLoc = Notes[0].first;
6614 S.
Diag(DiagLoc, diag::err_template_arg_not_address_constant)
6616 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
6617 S.
Diag(Notes[I].first, Notes[I].second);
6635 bool ObjCLifetimeConversion;
6638 ObjCLifetimeConversion))
6643 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
6662 std::string Code =
"static_cast<" + ParamType.
getAsString() +
">(";
6663 S.
Diag(Arg->
getExprLoc(), diag::err_template_arg_untyped_null_constant)
6683 bool ObjCLifetimeConversion;
6687 ObjCLifetimeConversion)) {
6692 if (!ParamRef->getPointeeType()->isFunctionType()) {
6702 unsigned ParamQuals = ParamRef->getPointeeType().getCVRQualifiers();
6703 unsigned ArgQuals = ArgType.getCVRQualifiers();
6705 if ((ParamQuals | ArgQuals) != ParamQuals) {
6707 diag::err_template_arg_ref_bind_ignores_quals)
6744 bool AddressTaken =
false;
6751 bool ExtWarnMSTemplateArg =
false;
6754 while (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(Arg)) {
6756 if (UnOpKind == UO_Deref)
6757 ExtWarnMSTemplateArg =
true;
6758 if (UnOpKind == UO_AddrOf || UnOpKind == UO_Deref) {
6761 FirstOpKind = UnOpKind;
6762 FirstOpLoc = UnOp->getOperatorLoc();
6768 if (ExtWarnMSTemplateArg)
6772 if (FirstOpKind == UO_AddrOf)
6773 AddressTaken =
true;
6777 assert(FirstOpKind == UO_Deref);
6800 bool ExtraParens =
false;
6802 if (!
Invalid && !ExtraParens) {
6808 Arg =
Parens->getSubExpr();
6812 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6816 if (UnOp->getOpcode() == UO_AddrOf) {
6817 Arg = UnOp->getSubExpr();
6818 AddressTaken =
true;
6819 AddrOpLoc = UnOp->getOperatorLoc();
6824 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
6829 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Arg))
6830 Entity = DRE->getDecl();
6832 Entity = CUE->getGuidDecl();
6839 S.
Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
6842 CanonicalConverted =
6859 CanonicalConverted =
6880 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Entity)) {
6881 if (!Method->isStatic()) {
6890 VarDecl *Var = dyn_cast<VarDecl>(Entity);
6891 MSGuidDecl *Guid = dyn_cast<MSGuidDecl>(Entity);
6894 if (!
Func && !Var && !Guid) {
6906 ? diag::warn_cxx98_compat_template_arg_object_internal
6907 : diag::ext_template_arg_object_internal)
6909 S.
Diag(Entity->
getLocation(), diag::note_template_arg_internal_object)
6914 S.
Diag(Entity->
getLocation(), diag::note_template_arg_internal_object)
6943 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
6949 S.
Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
6991 CanonicalConverted =
7005 Expr *Arg = ResultArg;
7006 bool ObjCLifetimeConversion;
7018 bool ExtraParens =
false;
7020 if (!
Invalid && !ExtraParens) {
7026 Arg =
Parens->getSubExpr();
7030 dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
7035 if (UnOp->getOpcode() == UO_AddrOf) {
7036 DRE = dyn_cast<DeclRefExpr>(UnOp->getSubExpr());
7042 else if ((DRE = dyn_cast<DeclRefExpr>(Arg))) {
7048 CanonicalConverted =
7052 CanonicalConverted =
7071 S.
Diag(ResultArg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
7083 ObjCLifetimeConversion)) {
7090 S.
Diag(ResultArg->
getBeginLoc(), diag::err_template_arg_not_convertible)
7098 diag::err_template_arg_not_pointer_to_member_form)
7107 ->isImplicitObjectMemberFunction()) &&
7108 "Only non-static member pointers can make it here");
7114 CanonicalConverted =
7119 CanonicalConverted =
7127 S.
Diag(Arg->
getBeginLoc(), diag::err_template_arg_not_pointer_to_member_form)
7147 auto *ArgPE = dyn_cast<PackExpansionExpr>(Arg);
7148 Expr *DeductionArg = ArgPE ? ArgPE->getPattern() : Arg;
7149 auto setDeductionArg = [&](
Expr *NewDeductionArg) {
7150 DeductionArg = NewDeductionArg;
7154 DeductionArg, ArgPE->getEllipsisLoc(), ArgPE->getNumExpansions());
7162 bool IsDeduced = DeducedT && DeducedT->getDeducedType().isNull();
7168 Context.getTrivialTypeSourceInfo(ParamType, Param->getLocation());
7173 DeductionArg->
getBeginLoc(),
false, DeductionArg);
7181 Param->getTemplateDepth() + 1);
7197 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param))
7199 diag::err_non_type_template_parm_type_deduction_failure)
7200 << Param->getDeclName() << NTTP->getType() << Arg->
getType()
7206 assert(!ParamType.
isNull() &&
"substituting DependentTy can't fail");
7214 if (ParamType.
isNull()) {
7222 "non-type template parameter type cannot be qualified");
7236 setDeductionArg(E.
get());
7240 Context.getCanonicalTemplateArgument(SugaredConverted));
7249 : !
Context.hasSameUnqualifiedType(ParamType,
7255 Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
7268 if (ArgPE && !StrictCheck) {
7271 Context.getCanonicalTemplateArgument(SugaredConverted));
7285 Context.hasSameUnqualifiedType(ParamType, InnerArg->
getType())) {
7287 if (
auto *TPO = dyn_cast<TemplateParamObjectDecl>(ND)) {
7296 CanonicalConverted =
7297 Context.getCanonicalTemplateArgument(SugaredConverted);
7307 bool IsConvertedConstantExpression =
true;
7310 StartLoc,
false, DeductionArg);
7326 IsConvertedConstantExpression =
false;
7335 if (IsConvertedConstantExpression) {
7337 DeductionArg, ParamType,
7345 ArgResult = DeductionArg;
7351 setDeductionArg(ArgResult.
get());
7353 CanonicalConverted =
7354 Context.getCanonicalTemplateArgument(SugaredConverted);
7361 false, PreNarrowingValue);
7364 setDeductionArg(ArgResult.
get());
7366 if (
Value.isLValue()) {
7385 if (
Value.hasLValuePath() &&
Value.getLValuePath().size() == 1 && VD &&
7387 Value.getLValuePath()[0].getAsArrayIndex() == 0 &&
7391 CanonicalConverted =
7392 Context.getCanonicalTemplateArgument(SugaredConverted);
7395 CanonicalConverted =
7404 if (!
Value.hasLValuePath() ||
Value.getLValuePath().size() ||
7405 Value.isLValueOnePastTheEnd()) {
7406 Diag(StartLoc, diag::err_non_type_template_arg_subobject)
7411 "null reference should not be a constant expression");
7413 "non-null value of type nullptr_t?");
7417 if (
Value.isAddrLabelDiff())
7418 return Diag(StartLoc, diag::err_non_type_template_arg_addr_label_diff);
7422 CanonicalConverted =
7423 Context.getCanonicalTemplateArgument(SugaredConverted);
7426 CanonicalConverted =
7433 assert(!ArgPE && !StrictCheck);
7465 Arg = ArgResult.
get();
7470 CanonicalConverted =
7471 Context.getCanonicalTemplateArgument(SugaredConverted);
7480 IntegerType = ED->getIntegerType();
7482 ?
Context.getIntWidth(IntegerType)
7483 :
Context.getTypeSize(IntegerType));
7486 CanonicalConverted =
7494 Arg = ArgResult.
get();
7506 if (!
ArgType->isIntegralOrEnumerationType()) {
7507 Diag(Arg->
getBeginLoc(), diag::err_template_arg_not_integral_or_enumeral)
7517 TmplArgICEDiagnoser(
QualType T) : T(T) { }
7521 return S.
Diag(Loc, diag::err_template_arg_not_ice) << T;
7546 Diag(StartLoc, diag::err_template_arg_not_convertible)
7559 CanonicalConverted =
7560 Context.getCanonicalTemplateArgument(SugaredConverted);
7566 IntegerType = ED->getIntegerType();
7572 unsigned AllowedBits =
Context.getTypeSize(IntegerType);
7573 if (
Value.getBitWidth() != AllowedBits)
7577 llvm::APSInt OldValue =
Value;
7582 ?
Context.getIntWidth(IntegerType)
7583 :
Context.getTypeSize(IntegerType);
7584 if (
Value.getBitWidth() != AllowedBits)
7590 (OldValue.isSigned() && OldValue.isNegative())) {
7598 unsigned RequiredBits;
7600 RequiredBits = OldValue.getActiveBits();
7601 else if (OldValue.isUnsigned())
7602 RequiredBits = OldValue.getActiveBits() + 1;
7604 RequiredBits = OldValue.getSignificantBits();
7605 if (RequiredBits > AllowedBits) {
7615 CanonicalConverted =
7665 *
this, Param, ParamType, Arg, SugaredConverted,
7666 CanonicalConverted))
7672 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
7683 "Only object pointers allowed here");
7686 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
7698 assert(ParamRefType->getPointeeType()->isIncompleteOrObjectType() &&
7699 "Only object references allowed here");
7703 ParamRefType->getPointeeType(),
7718 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
7727 CanonicalConverted =
7728 Context.getCanonicalTemplateArgument(SugaredConverted);
7735 << Arg->
getType() << ParamType;
7743 Diag(Arg->
getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
7757 *
this, Param, ParamType, Arg, SugaredConverted, CanonicalConverted))
7780 unsigned DiagFoundKind = 0;
7782 if (
auto *TTP = llvm::dyn_cast<TemplateTemplateParmDecl>(
Template)) {
7783 switch (TTP->templateParameterKind()) {
7794 Kind = TTP->templateParameterKind();
7810 assert(
false &&
"Unexpected Decl");
7813 if (Kind == Param->templateParameterKind()) {
7817 unsigned DiagKind = 0;
7818 switch (Param->templateParameterKind()) {
7831 Diag(
Template->getLocation(), diag::note_template_arg_refers_to_template_here)
7845 bool *StrictPackMatch) {
7852 assert(Name.
isDependent() &&
"Non-dependent template isn't a declaration?");
7879 if (ParamsAC.empty())
7882 Template->getAssociatedConstraints(TemplateAC);
7884 bool IsParamAtLeastAsConstrained;
7886 IsParamAtLeastAsConstrained))
7888 if (!IsParamAtLeastAsConstrained) {
7890 diag::err_template_template_parameter_not_at_least_as_constrained)
7892 Diag(Param->getLocation(), diag::note_entity_declared_at) << Param;
7902 unsigned HereDiagID,
7903 unsigned ExternalDiagID) {
7908 llvm::raw_svector_ostream Out(Str);
7916 std::optional<SourceRange> ParamRange) {
7919 diag::note_template_decl_external);
7920 if (ParamRange && ParamRange->isValid()) {
7922 "Parameter range has location when Decl does not");
7929 diag::note_template_param_external);
7945 ParamType =
Context.getArrayDecayedType(ParamType);
7947 ParamType =
Context.getPointerType(ParamType);
7956 ? CK_NullToMemberPointer
7957 : CK_NullToPointer);
7960 "Only declaration template arguments permitted here");
7997 "arg for class template param not a template parameter object");
8002 "unexpected type for decl template argument");
8004 dyn_cast_if_present<NonTypeTemplateParmDecl>(
TemplateParam)) {
8005 QualType TemplateParamType = NTTP->getType();
8006 const AutoType *AT = TemplateParamType->
getAs<AutoType>();
8007 if (AT && AT->isDecltypeAuto()) {
8019 "value kind mismatch for non-type template argument");
8038 "unexpected conversion required for non-type template argument");
8065 T = ED->getIntegerType();
8068 if (T->isAnyCharacterType()) {
8070 if (T->isWideCharType())
8072 else if (T->isChar8Type() && S.
getLangOpts().Char8)
8074 else if (T->isChar16Type())
8076 else if (T->isChar32Type())
8082 }
else if (T->isBooleanType()) {
8116 llvm_unreachable(
"unexpected template argument value");
8141 return MakeInitList(
8154 return MakeInitList(Elts);
8158 llvm_unreachable(
"Matrix template argument expression not yet supported");
8162 llvm_unreachable(
"Unexpected APValue kind.");
8171 if (T->isReferenceType()) {
8172 T = T->getPointeeType();
8178 llvm_unreachable(
"Unhandled APValue::ValueKind enum");
8190 llvm_unreachable(
"not a non-type template argument");
8208 llvm_unreachable(
"Unhandled TemplateArgument::ArgKind enum");
8215 const NamedDecl *OldInstFrom,
bool Complain,
8220 unsigned NextDiag = diag::err_template_param_different_kind;
8221 if (TemplateArgLoc.
isValid()) {
8222 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
8223 NextDiag = diag::note_template_param_different_kind;
8225 S.
Diag(
New->getLocation(), NextDiag)
8240 unsigned NextDiag = diag::err_template_parameter_pack_non_pack;
8241 if (TemplateArgLoc.
isValid()) {
8242 S.
Diag(TemplateArgLoc,
8243 diag::err_template_arg_template_params_mismatch);
8244 NextDiag = diag::note_template_parameter_pack_non_pack;
8250 S.
Diag(
New->getLocation(), NextDiag)
8251 << ParamKind <<
New->isParameterPack();
8260 dyn_cast<NonTypeTemplateParmDecl>(Old)) {
8268 (!OldNTTP->getType()->isDependentType() &&
8278 unsigned NextDiag = diag::err_template_nontype_parm_different_type;
8279 if (TemplateArgLoc.
isValid()) {
8280 S.
Diag(TemplateArgLoc,
8281 diag::err_template_arg_template_params_mismatch);
8282 NextDiag = diag::note_template_nontype_parm_different_type;
8286 S.
Diag(OldNTTP->getLocation(),
8287 diag::note_template_nontype_parm_prev_declaration)
8288 << OldNTTP->getType();
8298 dyn_cast<TemplateTemplateParmDecl>(Old)) {
8304 OldTTP->getTemplateParameters(), Complain,
8315 const Expr *NewC =
nullptr, *OldC =
nullptr;
8319 NewC = TC->getImmediatelyDeclaredConstraint();
8321 OldC = TC->getImmediatelyDeclaredConstraint();
8324 ->getPlaceholderTypeConstraint())
8327 ->getPlaceholderTypeConstraint())
8330 llvm_unreachable(
"unexpected template parameter type");
8332 auto Diagnose = [&] {
8334 diag::err_template_different_type_constraint);
8336 diag::note_template_prev_declaration) << 0;
8339 if (!NewC != !OldC) {
8366 unsigned NextDiag = diag::err_template_param_list_different_arity;
8367 if (TemplateArgLoc.
isValid()) {
8368 S.
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
8369 NextDiag = diag::note_template_param_list_different_arity;
8371 S.
Diag(
New->getTemplateLoc(), NextDiag)
8372 << (
New->size() > Old->
size())
8384 if (Old->
size() !=
New->size()) {
8401 OldParmEnd = Old->
end();
8402 OldParm != OldParmEnd; ++OldParm, ++NewParm) {
8403 if (NewParm == NewParmEnd) {
8410 OldInstFrom, Complain, Kind,
8416 if (NewParm != NewParmEnd) {
8425 const Expr *NewRC =
New->getRequiresClause();
8430 diag::err_template_different_requires_clause);
8432 diag::note_template_prev_declaration) << 0;
8435 if (!NewRC != !OldRC) {
8471 Diag(Range.getBegin(), diag::err_template_linkage) << Range;
8473 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
8493 if (RD->isLocalClass())
8495 diag::err_template_inside_local_class)
8503 diag::err_template_outside_namespace_or_class_scope)
8514 return Record->getTemplateSpecializationKind();
8515 if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(D))
8516 return Function->getTemplateSpecializationKind();
8517 if (
VarDecl *Var = dyn_cast<VarDecl>(D))
8570 S.
Diag(Loc, diag::err_template_spec_unknown_kind)
8580 S.
Diag(Loc, diag::err_template_spec_decl_function_scope)
8595 : DC->
Equals(SpecializedContext))) {
8597 S.
Diag(Loc, diag::err_template_spec_redecl_global_scope)
8598 << EntityKind << Specialized;
8601 int Diag = diag::err_template_spec_redecl_out_of_scope;
8603 Diag = diag::ext_ms_template_spec_redecl_out_of_scope;
8604 S.
Diag(Loc,
Diag) << EntityKind << Specialized
8605 << ND << isa<CXXRecordDecl>(ND);
8608 S.
Diag(Specialized->getLocation(), diag::note_specialized_entity);
8622 DependencyChecker Checker(Depth,
true);
8623 Checker.TraverseStmt(E);
8626 return Checker.MatchLoc;
8632 DependencyChecker Checker(Depth,
true);
8633 Checker.TraverseTypeLoc(TL);
8636 return Checker.MatchLoc;
8644 bool HasError =
false;
8645 for (
unsigned I = 0; I != NumArgs; ++I) {
8648 S, TemplateNameLoc, Param, Args[I].pack_begin(),
8649 Args[I].pack_size(), IsDefaultArgument))
8666 ArgExpr = Expansion->getPattern();
8670 ArgExpr = ICE->getSubExpr();
8680 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ArgExpr))
8684 if (
auto *ULE = dyn_cast<UnresolvedLookupExpr>(ArgExpr);
8706 if (ParamUseRange.
isValid()) {
8707 if (IsDefaultArgument) {
8708 S.
Diag(TemplateNameLoc,
8709 diag::err_dependent_non_type_arg_in_partial_spec);
8711 diag::note_dependent_non_type_default_arg_in_partial_spec)
8715 diag::err_dependent_non_type_arg_in_partial_spec)
8722 Param->getDepth(), Param->getTypeSourceInfo()->getTypeLoc());
8723 if (ParamUseRange.
isValid()) {
8725 diag::err_dependent_typed_non_type_arg_in_partial_spec)
8726 << Param->getType();
8745 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
8747 = dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->
getParam(I));
8752 Param, &TemplateArgs[I],
8753 1, I >= NumExplicit))
8777 Diag(TemplateNameLoc, diag::err_not_class_template_specialization)
8783 if (
const auto *DSA =
ClassTemplate->getAttr<NoSpecializationsAttr>()) {
8784 auto Message = DSA->getMessage();
8785 Diag(TemplateNameLoc, diag::warn_invalid_specialization)
8787 Diag(DSA->getLoc(), diag::note_marked_here) << DSA;
8795 bool isMemberSpecialization =
false;
8796 bool isPartialSpecialization =
false;
8801 TemplateNameLoc, &TemplateId,
8813 KWLoc, TemplateNameLoc, SS, &TemplateId, TemplateParameterLists,
8828 if (TemplateParams && TemplateParams->
size() > 0) {
8829 isPartialSpecialization =
true;
8832 Diag(KWLoc, diag::err_partial_specialization_friend)
8840 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
8843 if (TTP->hasDefaultArgument()) {
8844 Diag(TTP->getDefaultArgumentLoc(),
8845 diag::err_default_arg_in_partial_spec);
8846 TTP->removeDefaultArgument();
8849 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
8850 if (NTTP->hasDefaultArgument()) {
8851 Diag(NTTP->getDefaultArgumentLoc(),
8852 diag::err_default_arg_in_partial_spec)
8853 << NTTP->getDefaultArgument().getSourceRange();
8854 NTTP->removeDefaultArgument();
8860 diag::err_default_arg_in_partial_spec)
8866 }
else if (TemplateParams) {
8868 Diag(KWLoc, diag::err_template_spec_friend)
8875 "should have a 'template<>' for this decl");
8882 "Invalid enum tag in class template spec!");
8886 Diag(KWLoc, diag::err_use_with_wrong_tag)
8891 diag::note_previous_use);
8900 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
8902 isPartialSpecialization
8918 if (isPartialSpecialization) {
8920 TemplateArgs.
size(),
8927 !TemplateSpecializationType::anyDependentTemplateArguments(
8929 Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
8931 isPartialSpecialization =
false;
8936 void *InsertPos =
nullptr;
8939 if (isPartialSpecialization)
8953 isPartialSpecialization))
8956 if (!isPartialSpecialization) {
8964 if (TemplateParameterLists.size() > 0) {
8966 TemplateParameterLists);
8973 Context.getCanonicalTemplateSpecializationType(
8980 (!
Context.getLangOpts().CPlusPlus20 ||
8989 Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
8997 TemplateParameterLists.data());
9002 cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl);
9005 Context, Kind, DC, KWLoc, TemplateNameLoc, TemplateParams,
9009 if (TemplateParameterLists.size() > 1 && SS.
isSet()) {
9011 Context, TemplateParameterLists.drop_back(1));
9015 ClassTemplate->AddPartialSpecialization(Partial, InsertPos);
9044 Diag(TemplateNameLoc, diag::err_specialization_after_instantiation)
9048 diag::note_instantiation_required_here)
9063 bool HiddenDefVisible =
false;
9064 if (Def && SkipBody &&
9068 if (!HiddenDefVisible && Hidden)
9091 if (ModulePrivateLoc.
isValid())
9093 << (isPartialSpecialization? 1 : 0)
9161 diag::err_concept_decls_may_only_appear_in_global_namespace_scope);
9165 if (TemplateParameterLists.size() > 1) {
9166 Diag(NameLoc, diag::err_concept_extra_headers);
9172 if (Params->
size() == 0) {
9173 Diag(NameLoc, diag::err_concept_no_parameters);
9180 ParamEnd = Params->
end();
9181 ParamIt != ParamEnd; ++ParamIt) {
9182 Decl const *Param = *ParamIt;
9183 if (Param->isParameterPack()) {
9184 if (++ParamIt == ParamEnd)
9186 Diag(Param->getLocation(),
9187 diag::err_template_param_pack_must_be_last_template_parameter);
9198 Diag(NameLoc, diag::err_concept_no_associated_constraints);
9235 Expr *ConstraintExpr,
9237 assert(!
C->hasDefinition() &&
"Concept already defined");
9239 C->setInvalidDecl();
9242 C->setDefinition(ConstraintExpr);
9253 bool AddToScope =
true;
9257 if (!WasAlreadyAdded && AddToScope)
9270 auto *OldConcept = dyn_cast<ConceptDecl>(
Previous.getRepresentativeDecl()->getUnderlyingDecl());
9272 auto *Old =
Previous.getRepresentativeDecl();
9280 bool IsSame =
Context.isSameEntity(NewDecl, OldConcept);
9282 Diag(NewDecl->
getLocation(), diag::err_redefinition_different_concept)
9306 if (
auto *CE = llvm::dyn_cast<ConceptDecl>(
Concept);
9307 CE && !CE->isInvalidDecl() && !CE->hasDefinition()) {
9308 Diag(Loc, diag::err_recursive_concept) << CE;
9309 Diag(CE->getLocation(), diag::note_declared_at);
9322 D->
dropAttrs<DLLImportAttr, DLLExportAttr>();
9325 FD->setInlineSpecified(
false);
9336 for (
Decl *Prev = D; Prev && !PrevDiagLoc.
isValid();
9337 Prev = Prev->getPreviousDecl()) {
9338 PrevDiagLoc = Prev->getLocation();
9340 assert(PrevDiagLoc.
isValid() &&
9341 "Explicit instantiation without point of instantiation?");
9351 bool &HasNoEffect) {
9352 HasNoEffect =
false;
9359 "previous declaration must be implicit!");
9372 if (PrevPointOfInstantiation.
isInvalid()) {
9376 PrevDecl,
Context.getTargetInfo().getTriple().isOSCygMing());
9385 PrevPointOfInstantiation.
isValid()) &&
9386 "Explicit instantiation without point of instantiation?");
9400 Diag(NewLoc, diag::err_specialization_after_instantiation)
9402 Diag(PrevPointOfInstantiation, diag::note_instantiation_required_here)
9407 llvm_unreachable(
"The switch over PrevTSK must be exhaustive.");
9437 diag::err_explicit_instantiation_declaration_after_definition);
9443 diag::note_explicit_instantiation_definition_here);
9447 llvm_unreachable(
"Unexpected TemplateSpecializationKind!");
9463 Diag(NewLoc, diag::warn_explicit_instantiation_after_specialization)
9466 diag::note_previous_template_specialization);
9497 ? diag::ext_explicit_instantiation_duplicate
9498 : diag::err_explicit_instantiation_duplicate)
9501 diag::note_previous_explicit_instantiation);
9507 llvm_unreachable(
"Missing specialization/instantiation case?");
9517 enum DiscardReason { NotAFunctionTemplate, NotAMemberOfEnclosing };
9523 DiscardedCandidates.push_back(std::make_pair(NotAFunctionTemplate, D));
9530 DiscardedCandidates.push_back(std::make_pair(NotAMemberOfEnclosing, D));
9538 Diag(FD->
getLocation(), diag::err_dependent_function_template_spec_no_match)
9540 for (
auto &P : DiscardedCandidates)
9541 Diag(P.second->getLocation(),
9542 diag::note_dependent_function_template_spec_discard_reason)
9543 << P.first << IsFriend;
9548 ExplicitTemplateArgs);
9561 llvm::SmallDenseMap<FunctionDecl *, TemplateArgumentListInfo, 8>
9562 ConvertedTemplateArgs;
9585 if (
auto *NewMD = dyn_cast<CXXMethodDecl>(FD);
9586 !
getLangOpts().CPlusPlus14 && NewMD && NewMD->isConstexpr() &&
9588 auto *OldMD = dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl());
9589 if (OldMD && OldMD->isConst()) {
9599 if (ExplicitTemplateArgs)
9600 Args = *ExplicitTemplateArgs;
9613 ExplicitTemplateArgs ? &Args :
nullptr, FT,
Specialization, Info);
9618 I.getPair(), FunTmpl->getTemplatedDecl(),
9632 CUDA().IdentifyTarget(FD,
true)) {
9634 I.getPair(), FunTmpl->getTemplatedDecl(),
9641 if (ExplicitTemplateArgs)
9650 if (QualifiedFriend && Candidates.
empty()) {
9656 if (
auto *OldFD = dyn_cast<FunctionDecl>(OldND->getUnderlyingDecl()))
9667 PDiag(diag::err_function_template_spec_ambiguous)
9668 << FD->
getDeclName() << (ExplicitTemplateArgs !=
nullptr),
9669 PDiag(diag::note_function_template_spec_matched));
9678 const auto *DSA = PT->getAttr<NoSpecializationsAttr>()) {
9679 auto Message = DSA->getMessage();
9681 << PT << !Message.empty() << Message;
9682 Diag(DSA->getLoc(), diag::note_marked_here) << DSA;
9710 auto *SpecializationFPT =
9721 assert(SpecInfo &&
"Function template specialization info missing?");
9759 bool HasNoEffect =
false;
9774 !isFriend || (InstFrom && InstFrom->getDependentSpecializationInfo())) {
9788 "This must be the only existing declaration of this specialization");
9803 FD->setFunctionTemplateSpecialization(
9806 ExplicitTemplateArgs ? &ConvertedTemplateArgs[
Specialization] :
nullptr);
9825 assert(!
Member->isTemplateDecl() && !
Member->getDescribedTemplate() &&
9826 "Only for non-template members");
9829 NamedDecl *FoundInstantiation =
nullptr;
9839 auto *
Method = dyn_cast<CXXMethodDecl>(Candidate->getUnderlyingDecl());
9857 Method->getTrailingRequiresClause() &&
9861 !Satisfaction.IsSatisfied))
9864 Candidates.
addDecl(Candidate);
9868 if (Candidates.
empty())
9885 FoundInstantiation = *Best;
9886 Instantiation = BestMethod;
9903 Diag(
Member->getLocation(), diag::err_function_member_spec_ambiguous)
9904 <<
Member << (InstantiatedFrom ? InstantiatedFrom : Instantiation);
9905 for (
NamedDecl *Candidate : Candidates) {
9906 Candidate = Candidate->getUnderlyingDecl();
9907 Diag(Candidate->getLocation(), diag::note_function_member_spec_matched)
9915 (PrevVar = dyn_cast<VarDecl>(
Previous.getFoundDecl())))
9917 FoundInstantiation =
Previous.getRepresentativeDecl();
9918 Instantiation = PrevVar;
9925 (PrevRecord = dyn_cast<CXXRecordDecl>(
Previous.getFoundDecl()))) {
9926 FoundInstantiation =
Previous.getRepresentativeDecl();
9927 Instantiation = PrevRecord;
9934 (PrevEnum = dyn_cast<EnumDecl>(
Previous.getFoundDecl()))) {
9935 FoundInstantiation =
Previous.getRepresentativeDecl();
9936 Instantiation = PrevEnum;
9942 if (!Instantiation) {
9967 Previous.addDecl(FoundInstantiation);
9972 if (!InstantiatedFrom) {
9973 Diag(
Member->getLocation(), diag::err_spec_member_not_instantiated)
9985 assert(MSInfo &&
"Member specialization info missing?");
9987 bool HasNoEffect =
false;
9999 Instantiation,
Member->getLocation(),
10005 if (
auto *MemberFunction = dyn_cast<FunctionDecl>(
Member)) {
10011 if (InstantiationFunction->
isDeleted()) {
10014 InstantiationFunction);
10020 MemberFunction->setInstantiationOfMemberFunction(
10022 }
else if (
auto *MemberVar = dyn_cast<VarDecl>(
Member)) {
10023 MemberVar->setInstantiationOfStaticDataMember(
10025 }
else if (
auto *MemberClass = dyn_cast<CXXRecordDecl>(
Member)) {
10026 MemberClass->setInstantiationOfMemberClass(
10028 }
else if (
auto *MemberEnum = dyn_cast<EnumDecl>(
Member)) {
10029 MemberEnum->setInstantiationOfMemberEnum(
10032 llvm_unreachable(
"unknown member specialization kind");
10038 Previous.addDecl(FoundInstantiation);
10047template<
typename DeclT>
10058 OrigD->setLocation(Loc);
10064 if (Instantiation ==
Member)
10067 if (
auto *
Function = dyn_cast<CXXMethodDecl>(Instantiation))
10069 else if (
auto *Var = dyn_cast<VarDecl>(Instantiation))
10071 else if (
auto *
Record = dyn_cast<CXXRecordDecl>(Instantiation))
10073 else if (
auto *
Enum = dyn_cast<EnumDecl>(Instantiation))
10076 llvm_unreachable(
"unknown member specialization kind");
10084 bool WasQualifiedName) {
10089 S.
Diag(InstLoc, diag::err_explicit_instantiation_in_class)
10102 if (WasQualifiedName) {
10103 if (CurContext->
Encloses(OrigContext))
10110 if (
NamespaceDecl *NS = dyn_cast<NamespaceDecl>(OrigContext)) {
10111 if (WasQualifiedName)
10114 diag::err_explicit_instantiation_out_of_scope :
10115 diag::warn_explicit_instantiation_out_of_scope_0x)
10120 diag::err_explicit_instantiation_unqualified_wrong_namespace :
10121 diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x)
10126 diag::err_explicit_instantiation_must_be_global :
10127 diag::warn_explicit_instantiation_must_be_global_0x)
10136 bool WasQualifiedName,
10143 S.
Diag(InstLoc, diag::err_explicit_instantiation_internal_linkage) << D;
10171 NNS = T->getPrefix();
10180 auto *A = cast_or_null<InheritableAttr>(
getDLLAttr(Def));
10181 assert(A &&
"dllExportImportClassTemplateSpecialization called "
10182 "on Def without dllexport or dllimport");
10187 "delayed exports present at explicit instantiation");
10191 for (
auto &B : Def->
bases()) {
10192 if (
auto *BT = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
10193 B.getType()->getAsCXXRecordDecl()))
10213 "Invalid enum tag in class template explicit instantiation!");
10219 Diag(TemplateNameLoc, diag::err_tag_reference_non_tag) << TD << NTK << Kind;
10225 Kind,
false, KWLoc,
10227 Diag(KWLoc, diag::err_use_with_wrong_tag)
10232 diag::note_previous_use);
10245 !
Context.getTargetInfo().getTriple().isOSCygMing()) {
10249 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
10251 diag::warn_attribute_dllexport_explicit_instantiation_decl);
10252 Diag(AL.getLoc(), diag::note_attribute);
10257 if (
auto *A =
ClassTemplate->getTemplatedDecl()->getAttr<DLLExportAttr>()) {
10259 diag::warn_attribute_dllexport_explicit_instantiation_decl);
10260 Diag(A->getLocation(), diag::note_attribute);
10266 bool DLLImportExplicitInstantiationDef =
false;
10268 Context.getTargetInfo().getCXXABI().isMicrosoft()) {
10271 ClassTemplate->getTemplatedDecl()->getAttr<DLLImportAttr>();
10273 if (AL.getKind() == ParsedAttr::AT_DLLImport)
10275 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
10283 DLLImportExplicitInstantiationDef =
true;
10302 void *InsertPos =
nullptr;
10310 Context.getTargetInfo().getTriple().isOSCygMing()) {
10314 if (AL.getKind() == ParsedAttr::AT_DLLExport) {
10315 if (PrevDecl->
hasAttr<DLLExportAttr>()) {
10316 Diag(AL.getLoc(), diag::warn_attr_dllexport_explicit_inst_def);
10319 diag::warn_attr_dllexport_explicit_inst_def_mismatch);
10320 Diag(PrevDecl->
getLocation(), diag::note_prev_decl_missing_dllexport);
10328 !
Context.getTargetInfo().getTriple().isWindowsGNUEnvironment() &&
10330 return AL.getKind() == ParsedAttr::AT_DLLExport;
10332 if (
const auto *DEA = PrevDecl->
getAttr<DLLExportOnDeclAttr>()) {
10333 Diag(TemplateLoc, diag::warn_dllexport_on_decl_ignored);
10334 Diag(DEA->getLoc(), diag::note_dllexport_on_decl);
10344 bool HasNoEffect =
false;
10347 PrevDecl, PrevDecl_TSK,
10364 PrevDecl =
nullptr;
10368 DLLImportExplicitInstantiationDef) {
10370 HasNoEffect =
false;
10385 if (
const auto *A = PrevDecl->
getAttr<MSInheritanceAttr>()) {
10387 Clone->setInherited(
true);
10393 if (!HasNoEffect && !PrevDecl) {
10406 bool PreviouslyDLLExported =
Specialization->hasAttr<DLLExportAttr>();
10431 = cast_or_null<ClassTemplateSpecializationDecl>(
10443 Def = cast_or_null<ClassTemplateSpecializationDecl>(
10451 DLLImportExplicitInstantiationDef)) {
10456 Context.getTargetInfo().shouldDLLImportComdatSymbols()) {
10462 A->setInherited(
true);
10470 bool NewlyDLLExported =
10471 !PreviouslyDLLExported &&
Specialization->hasAttr<DLLExportAttr>();
10473 Context.getTargetInfo().shouldDLLImportComdatSymbols()) {
10487 "Def and Specialization should match for implicit instantiation");
10494 Context.getTargetInfo().getTriple().isOSCygMing() &&
10495 PrevDecl->
hasAttr<DLLExportAttr>()) {
10519 bool Owned =
false;
10520 bool IsDependent =
false;
10528 assert(!IsDependent &&
"explicit instantiation of dependent name not yet handled");
10534 assert(!Tag->isEnum() &&
"shouldn't see enumerations here");
10536 if (Tag->isInvalidDecl())
10542 Diag(TemplateLoc, diag::err_explicit_instantiation_nontemplate_type)
10544 Diag(
Record->getLocation(), diag::note_nontemplate_decl_here);
10555 Diag(TemplateLoc, diag::ext_explicit_instantiation_without_qualified_id)
10570 = cast_or_null<CXXRecordDecl>(
Record->getPreviousDecl());
10571 if (!PrevDecl &&
Record->getDefinition())
10575 bool HasNoEffect =
false;
10576 assert(MSInfo &&
"No member specialization information?");
10588 = cast_or_null<CXXRecordDecl>(
Record->getDefinition());
10596 Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member)
10597 << 0 <<
Record->getDeclName() <<
Record->getDeclContext();
10607 RecordDef = cast_or_null<CXXRecordDecl>(
Record->getDefinition());
10638 diag::err_explicit_instantiation_requires_name)
10677 diag::err_explicit_instantiation_inline :
10678 diag::warn_explicit_instantiation_inline_0x)
10684 diag::err_explicit_instantiation_constexpr);
10706 if (!R->isFunctionType()) {
10720 if (!PrevTemplate) {
10727 Diag((*P)->getLocation(), diag::note_explicit_instantiation_here);
10734 diag::err_explicit_instantiation_data_member_not_instantiated)
10748 if (R->isUndeducedType()) {
10749 Diag(T->getTypeLoc().getBeginLoc(),
10750 diag::err_auto_not_allowed_var_inst);
10759 diag::err_explicit_instantiation_without_template_id)
10761 Diag(PrevTemplate->getLocation(),
10762 diag::note_explicit_instantiation_here);
10772 TemplateArgs,
true);
10801 diag::ext_explicit_instantiation_without_qualified_id)
10809 bool HasNoEffect =
false;
10811 PrevTSK, POI, HasNoEffect))
10814 if (!HasNoEffect) {
10817 if (
auto *VTSD = dyn_cast<VarTemplatePartialSpecializationDecl>(Prev)) {
10818 VTSD->setExternKeywordLoc(ExternLoc);
10819 VTSD->setTemplateKeywordLoc(TemplateLoc);
10833 Diag(T->getTypeLoc().getBeginLoc(),
10834 diag::err_invalid_var_template_spec_type)
10835 << 0 << PrevTemplate << R << Prev->
getType();
10836 Diag(PrevTemplate->getLocation(), diag::note_template_declared_here)
10837 << 2 << PrevTemplate->getDeclName();
10842 return (
Decl*)
nullptr;
10847 bool HasExplicitTemplateArgs =
false;
10851 HasExplicitTemplateArgs =
true;
10866 if (!HasExplicitTemplateArgs) {
10870 if (
Context.hasSameUnqualifiedType(
Method->getType(), Adjusted)) {
10871 if (
Method->getPrimaryTemplate()) {
10875 C.FoundDecl = P.getPair();
10879 if (
Method->getTrailingRequiresClause() &&
10898 FunTmpl, (HasExplicitTemplateArgs ? &TemplateArgs :
nullptr), R,
10929 if (!NonTemplateMatches.
empty()) {
10940 Msg = diag::err_explicit_instantiation_ambiguous;
10944 Msg = diag::err_explicit_instantiation_no_candidate;
10960 TemplateMatches.
begin(), TemplateMatches.
end(),
10962 PDiag(diag::err_explicit_instantiation_not_known) << Name,
10963 PDiag(diag::err_explicit_instantiation_ambiguous) << Name,
10964 PDiag(diag::note_explicit_instantiation_candidate));
10980 if (FPT->hasExceptionSpec()) {
10982 diag::err_mismatched_exception_spec_explicit_instantiation;
10984 DiagID = diag::ext_mismatched_exception_spec_explicit_instantiation;
10987 PDiag(diag::note_explicit_instantiation_here),
10998 diag::err_explicit_instantiation_member_function_not_instantiated)
11007 if (!PrevDecl &&
Specialization->isThisDeclarationADefinition())
11011 bool HasNoEffect =
false;
11022 return (
Decl*)
nullptr;
11033 if (
auto *RD = dyn_cast<CXXRecordDecl>(
Specialization->getDeclContext()))
11034 if (RD->getIdentifier() && RD->getIdentifier()->isStr(
"valarray") &&
11035 RD->isInStdNamespace())
11036 return (
Decl*)
nullptr;
11046 Context.getTargetInfo().getCXXABI().isMicrosoft())
11070 diag::ext_explicit_instantiation_without_qualified_id)
11080 return (
Decl*)
nullptr;
11089 assert(Name &&
"Expected a name in a dependent tag");
11098 Diag(NameLoc, diag::err_dependent_tag_decl)
11125 DiagCompat(TypenameLoc, diag_compat::typename_outside_of_template)
11133 TypenameLoc, QualifierLoc, II, IdLoc, &TSI,
11149 ? diag::compat_cxx11_typename_outside_of_template
11150 : diag::compat_pre_cxx11_typename_outside_of_template)
11158 if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
11159 Diag(TemplateIILoc,
11160 diag::ext_out_of_line_qualified_id_type_names_constructor)
11162 << (TemplateKWLoc.
isValid() ? 1 : 0 );
11173 TemplateIn.
get(), TemplateIILoc, TemplateArgs,
11183 TemplateIILoc, TemplateArgs);
11193 if (!II.
isStr(
"type"))
11201 auto EnableIfTSTLoc =
11203 if (!EnableIfTSTLoc || EnableIfTSTLoc.getNumArgs() == 0)
11205 const TemplateSpecializationType *EnableIfTST = EnableIfTSTLoc.
getTypePtr();
11209 EnableIfTST->getTemplateName().getAsTemplateDecl();
11210 if (!EnableIfDecl || EnableIfTST->isIncompleteType())
11216 if (!EnableIfII || !EnableIfII->
isStr(
"enable_if"))
11220 CondRange = EnableIfTSTLoc.getArgLoc(0).getSourceRange();
11224 if (EnableIfTSTLoc.getArgLoc(0).getArgument().getKind()
11228 Cond = EnableIfTSTLoc.getArgLoc(0).getSourceExpression();
11244 bool DeducedTSTContext) {
11246 DeducedTSTContext);
11253 TL.setElaboratedKeywordLoc(KeywordLoc);
11254 TL.setQualifierLoc(QualifierLoc);
11255 TL.setNameLoc(IILoc);
11258 TL.setElaboratedKeywordLoc(KeywordLoc);
11259 TL.setQualifierLoc(QualifierLoc);
11260 TL.setNameLoc(IILoc);
11264 assert(!QualifierLoc);
11268 TL.setElaboratedKeywordLoc(KeywordLoc);
11269 TL.setQualifierLoc(QualifierLoc);
11270 TL.setNameLoc(IILoc);
11291 SS.
Adopt(QualifierLoc);
11294 if (QualifierLoc) {
11321 unsigned DiagID = 0;
11322 Decl *Referenced =
nullptr;
11323 switch (
Result.getResultKind()) {
11334 std::string FailedDescription;
11335 std::tie(FailedCond, FailedDescription) =
11339 diag::err_typename_nested_not_found_requirement)
11340 << FailedDescription
11346 diag::err_typename_nested_not_found_enable_if)
11347 << Ctx << CondRange;
11351 DiagID = Ctx ? diag::err_typename_nested_not_found
11352 : diag::err_unknown_typename;
11361 Diag(IILoc, diag::err_typename_refers_to_using_value_decl)
11362 << Name << Ctx << FullRange;
11364 = dyn_cast<UnresolvedUsingValueDecl>(
Result.getRepresentativeDecl())){
11366 Diag(Loc, diag::note_using_value_decl_missing_typename)
11406 assert(!QualifierLoc);
11409 return Context.getTypeDeclType(
11419 if (!DeducedTSTContext) {
11422 Diag(IILoc, diag::err_dependent_deduced_tst)
11424 <<
QualType(Qualifier.getAsType(), 0);
11426 Diag(IILoc, diag::err_deduced_tst)
11434 return Context.getDeducedTemplateSpecializationType(
11440 DiagID = Ctx ? diag::err_typename_nested_not_type
11441 : diag::err_typename_not_type;
11442 Referenced =
Result.getFoundDecl();
11446 DiagID = Ctx ? diag::err_typename_nested_not_type
11447 : diag::err_typename_not_type;
11448 Referenced = *
Result.begin();
11460 Diag(IILoc, DiagID) << FullRange << Name << Ctx;
11462 Diag(IILoc, DiagID) << FullRange << Name;
11465 Ctx ? diag::note_typename_member_refers_here
11466 : diag::note_typename_refers_here)
11473 class CurrentInstantiationRebuilder
11481 CurrentInstantiationRebuilder(
Sema &SemaRef,
11485 Loc(Loc), Entity(Entity) { }
11492 bool AlreadyTransformed(
QualType T) {
11493 return T.isNull() || !T->isInstantiationDependentType();
11498 SourceLocation getBaseLocation() {
return Loc; }
11501 DeclarationName getBaseEntity() {
return Entity; }
11505 void setBase(SourceLocation Loc, DeclarationName Entity) {
11507 this->Entity = Entity;
11520 if (!T || !T->getType()->isInstantiationDependentType())
11523 CurrentInstantiationRebuilder Rebuilder(*
this, Loc, Name);
11524 return Rebuilder.TransformType(T);
11528 CurrentInstantiationRebuilder Rebuilder(*
this, E->
getExprLoc(),
11530 return Rebuilder.TransformExpr(E);
11541 = Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
11551 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
11560 = dyn_cast<TemplateTemplateParmDecl>(Param)) {
11562 TTP->getTemplateParameters()))
11604 unsigned NumArgs) {
11606 llvm::raw_svector_ostream Out(Str);
11608 if (!Params || Params->
size() == 0 || NumArgs == 0)
11609 return std::string();
11611 for (
unsigned I = 0, N = Params->
size(); I != N; ++I) {
11621 Out << Id->getName();
11633 return std::string(Out.str());
11641 auto LPT = std::make_unique<LateParsedTemplate>();
11644 LPT->Toks.swap(Toks);
11691class ExplicitSpecializationVisibilityChecker {
11700 : S(S), Loc(Loc), Kind(Kind) {}
11703 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
11704 return checkImpl(FD);
11705 if (
auto *RD = dyn_cast<CXXRecordDecl>(ND))
11706 return checkImpl(RD);
11707 if (
auto *VD = dyn_cast<VarDecl>(ND))
11708 return checkImpl(VD);
11709 if (
auto *ED = dyn_cast<EnumDecl>(ND))
11710 return checkImpl(ED);
11714 void diagnose(NamedDecl *D,
bool IsPartialSpec) {
11715 auto Kind = IsPartialSpec ? Sema::MissingImportKind::PartialSpecialization
11716 : Sema::MissingImportKind::ExplicitSpecialization;
11717 const bool Recover =
true;
11722 if (Modules.empty())
11728 bool CheckMemberSpecialization(
const NamedDecl *D) {
11729 return Kind == Sema::AcceptableKind::Visible
11734 bool CheckExplicitSpecialization(
const NamedDecl *D) {
11735 return Kind == Sema::AcceptableKind::Visible
11740 bool CheckDeclaration(
const NamedDecl *D) {
11757 template<
typename SpecDecl>
11758 void checkImpl(SpecDecl *Spec) {
11759 bool IsHiddenExplicitSpecialization =
false;
11763 if constexpr (std::is_same_v<SpecDecl, FunctionDecl>)
11764 SpecKind = Spec->getTemplateSpecializationKindForInstantiation();
11766 IsHiddenExplicitSpecialization = Spec->getMemberSpecializationInfo()
11767 ? !CheckMemberSpecialization(Spec)
11768 : !CheckExplicitSpecialization(Spec);
11770 checkInstantiated(Spec);
11773 if (IsHiddenExplicitSpecialization)
11774 diagnose(Spec->getMostRecentDecl(),
false);
11777 void checkInstantiated(FunctionDecl *FD) {
11782 void checkInstantiated(CXXRecordDecl *RD) {
11783 auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(RD);
11787 auto From = SD->getSpecializedTemplateOrPartial();
11788 if (
auto *TD = From.dyn_cast<ClassTemplateDecl *>())
11790 else if (
auto *TD =
11791 From.dyn_cast<ClassTemplatePartialSpecializationDecl *>()) {
11792 if (!CheckDeclaration(TD))
11793 diagnose(TD,
true);
11798 void checkInstantiated(VarDecl *RD) {
11799 auto *SD = dyn_cast<VarTemplateSpecializationDecl>(RD);
11803 auto From = SD->getSpecializedTemplateOrPartial();
11804 if (
auto *TD = From.dyn_cast<VarTemplateDecl *>())
11806 else if (
auto *TD =
11807 From.dyn_cast<VarTemplatePartialSpecializationDecl *>()) {
11808 if (!CheckDeclaration(TD))
11809 diagnose(TD,
true);
11814 void checkInstantiated(EnumDecl *FD) {}
11816 template<
typename TemplDecl>
11817 void checkTemplate(TemplDecl *TD) {
11818 if (TD->isMemberSpecialization()) {
11819 if (!CheckMemberSpecialization(TD))
11820 diagnose(TD->getMostRecentDecl(),
false);
11830 ExplicitSpecializationVisibilityChecker(*
this, Loc,
11840 ExplicitSpecializationVisibilityChecker(*
this, Loc,
11848 if (
const auto *FD = dyn_cast<FunctionDecl>(N)) {
11856 if (!CSC.isInstantiationRecord() || CSC.PointOfInstantiation.isInvalid())
11858 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)
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.
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 SourceRange findTemplateParameterInType(unsigned Depth, Expr *E)
static Sema::SemaDiagnosticBuilder noteLocation(Sema &S, const NamedDecl &Decl, unsigned HereDiagID, unsigned ExternalDiagID)
static SourceRange getRangeOfTypeInNestedNameSpecifier(ASTContext &Context, QualType T, const CXXScopeSpec &SS)
static Expr * BuildExpressionFromIntegralTemplateArgumentValue(Sema &S, QualType OrigT, const llvm::APSInt &Int, SourceLocation Loc)
Construct a new expression that refers to the given integral template argument with the given source-...
static SourceRange findTemplateParameter(unsigned Depth, TypeLoc TL)
static 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 bool isTemplateArgumentTemplateParameter(const TemplateArgument &Arg, unsigned Depth, unsigned Index)
static bool CheckTemplateArgumentIsCompatibleWithParameter(Sema &S, NamedDecl *Param, QualType ParamType, Expr *ArgIn, Expr *Arg, QualType ArgType)
Checks whether the given template argument is compatible with its template parameter.
static bool isInVkNamespace(const RecordType *RT)
static ExprResult formImmediatelyDeclaredConstraint(Sema &S, NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, NamedDecl *NamedConcept, NamedDecl *FoundDecl, SourceLocation LAngleLoc, SourceLocation RAngleLoc, QualType ConstrainedType, SourceLocation ParamNameLoc, ArgumentLocAppender Appender, SourceLocation EllipsisLoc)
static TemplateArgumentListInfo makeTemplateArgumentListInfo(Sema &S, TemplateIdAnnotation &TemplateId)
Convert the parser's template argument list representation into our form.
static void collectConjunctionTerms(Expr *Clause, SmallVectorImpl< Expr * > &Terms)
Collect all of the separable terms in the given condition, which might be a conjunction.
static void checkMoreSpecializedThanPrimary(Sema &S, PartialSpecDecl *Partial)
static SpirvOperand checkHLSLSpirvTypeOperand(Sema &SemaRef, QualType OperandArg, SourceLocation Loc)
static SourceLocation DiagLocForExplicitInstantiation(NamedDecl *D, SourceLocation PointOfInstantiation)
Compute the diagnostic location for an explicit instantiation.
static bool RemoveLookupResult(LookupResult &R, NamedDecl *C)
static bool CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, NamedDecl *Param, QualType ParamType, Expr *ArgIn, TemplateArgument &SugaredConverted, TemplateArgument &CanonicalConverted)
Checks whether the given template argument is the address of an object or function according to C++ [...
static bool isEnableIfAliasTemplate(TypeAliasTemplateDecl *AliasTemplate)
Determine whether this alias template is "enable_if_t".
static bool DiagnoseUnexpandedParameterPacks(Sema &S, TemplateTemplateParmDecl *TTP)
Check for unexpanded parameter packs within the template parameters of a template template parameter,...
static bool CheckExplicitInstantiationScope(Sema &S, NamedDecl *D, SourceLocation InstLoc, bool WasQualifiedName)
Check the scope of an explicit instantiation.
static TemplateArgumentLoc translateTemplateArgument(Sema &SemaRef, const ParsedTemplateArgument &Arg)
static NullPointerValueKind isNullPointerValueTemplateArgument(Sema &S, NamedDecl *Param, QualType ParamType, Expr *Arg, Decl *Entity=nullptr)
Determine whether the given template argument is a null pointer value of the appropriate type.
static void checkTemplatePartialSpecialization(Sema &S, PartialSpecDecl *Partial)
static bool CheckExplicitInstantiation(Sema &S, NamedDecl *D, SourceLocation InstLoc, bool WasQualifiedName, TemplateSpecializationKind TSK)
Common checks for whether an explicit instantiation of D is valid.
static Expr * lookThroughRangesV3Condition(Preprocessor &PP, Expr *Cond)
static bool DiagnoseDefaultTemplateArgument(Sema &S, Sema::TemplateParamListContext TPC, SourceLocation ParamLoc, SourceRange DefArgRange)
Diagnose the presence of a default template argument on a template parameter, which is ill-formed in ...
static void noteNonDeducibleParameters(Sema &S, TemplateParameterList *TemplateParams, const llvm::SmallBitVector &DeducibleParams)
static void completeMemberSpecializationImpl(Sema &S, DeclT *OrigD, SourceLocation Loc)
Complete the explicit specialization of a member of a class template by updating the instantiated mem...
static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc, TemplateDecl *TD, const TemplateParmDecl *D, TemplateArgumentListInfo &Args)
Diagnose a missing template argument.
static bool CheckTemplateArgumentPointerToMember(Sema &S, NamedDecl *Param, QualType ParamType, Expr *&ResultArg, TemplateArgument &SugaredConverted, TemplateArgument &CanonicalConverted)
Checks whether the given template argument is a pointer to member constant according to C++ [temp....
static bool MatchTemplateParameterKind(Sema &S, NamedDecl *New, const Sema::TemplateCompareNewDeclInfo &NewInstFrom, NamedDecl *Old, const NamedDecl *OldInstFrom, bool Complain, Sema::TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc)
Match two template parameters within template parameter lists.
static void dllExportImportClassTemplateSpecialization(Sema &S, ClassTemplateSpecializationDecl *Def)
Make a dllexport or dllimport attr on a class template specialization take effect.
Defines the clang::SourceLocation class and associated facilities.
Allows QualTypes to be sorted and hence used in maps and sets.
static const TemplateArgument & getArgument(const TemplateArgument &A)
C Language Family Type Representation.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
const LValueBase getLValueBase() const
APSInt & getComplexIntImag()
ValueKind getKind() const
APFixedPoint & getFixedPoint()
const ValueDecl * getMemberPointerDecl() const
APValue & getVectorElt(unsigned I)
unsigned getVectorLength() const
bool isMemberPointer() const
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
@ Indeterminate
This object has an indeterminate value (C++ [basic.indet]).
@ None
There is no such object (it's outside its lifetime).
bool isNullPointer() const
APSInt & getComplexIntReal()
APFloat & getComplexFloatImag()
APFloat & getComplexFloatReal()
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,...
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.
QualType getElementType() const
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.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Attr - This represents one attribute.
AutoTypeKeyword getAutoKeyword() const
const NestedNameSpecifierLoc getNestedNameSpecifierLoc() const
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
NamedDecl * getFoundDecl() const
TemplateDecl * getNamedConcept() const
DeclarationNameInfo getConceptNameInfo() const
A fixed int type of a specified bitwidth.
QualType getPointeeType() const
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
BuiltinTemplateKind getBuiltinTemplateKind() const
This class is used for builtin types like 'int'.
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, FPOptionsOverride FPO, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
static CXXBoolLiteralExpr * Create(const ASTContext &C, bool Val, QualType Ty, SourceLocation Loc)
Represents a C++ member access expression where the actual member referenced could not be resolved be...
static CXXDependentScopeMemberExpr * Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Represents a static or instance method of a struct/union/class.
The null pointer literal (C++11 [lex.nullptr])
Represents a C++ struct/union/class.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr)
CXXRecordDecl * getMostRecentDecl()
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
CXXRecordDecl * getDefinition() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
void setDescribedClassTemplate(ClassTemplateDecl *Template)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization,...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
CXXRecordDecl * getPreviousDecl()
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
char * location_data() const
Retrieve the data associated with the source-location information.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
SourceRange getRange() const
SourceLocation getBeginLoc() const
bool isSet() const
Deprecated.
NestedNameSpecifier getScopeRep() const
Retrieve the representation of the nested-name-specifier.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isEmpty() const
No scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
static CanQual< Type > CreateUnsafe(QualType Other)
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
Declaration of a class template.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a class template node.
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, CanQualType CanonInjectedTST, ClassTemplatePartialSpecializationDecl *PrevDecl)
void setMemberSpecialization()
Note that this member template is a specialization.
Represents a class template specialization, which refers to a class template with a given set of temp...
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, bool StrictPackMatch, ClassTemplateSpecializationDecl *PrevDecl)
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
Complex values, per C99 6.2.5p11.
QualType getElementType() const
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, TemplateDecl *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...
bool WantExpressionKeywords
bool WantRemainingKeywords
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 ...
bool isStdNamespace() const
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
bool isFunctionOrMethod() const
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
bool 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,...
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)
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.
QualType getPointeeType() const
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.
QualType getElementType() const
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Represents a vector type where either the type or size is dependent.
QualType getElementType() const
virtual bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc)
virtual bool TraverseTypeLoc(TypeLoc TL, bool TraverseQualifier=true)
virtual bool TraverseStmt(MaybeConst< Stmt > *S)
virtual bool TraverseTemplateName(TemplateName Template)
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...
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={}, ArrayRef< TemplateParameterList * > FriendTypeTPLists={})
Represents a function declaration or definition.
ConstexprSpecKind getConstexprKind() const
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
SourceLocation getPointOfInstantiation() const
Retrieve the (first) point of instantiation of a function template specialization or a member of a cl...
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization,...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isDeleted() const
Whether this function has been deleted.
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo *TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization.
void setLateTemplateParsed(bool ILT=true)
State that this templated function will be late parsed.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
void setDeletedAsWritten(bool D=true, StringLiteral *Message=nullptr)
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization,...
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Represents a prototype with parameter type info, e.g.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > getParamTypes() const
ArrayRef< QualType > param_types() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
bool isExplicitSpecialization() const
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
QualType getReturnType() const
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
QualType getElementType() const
Returns type of the elements being stored in the matrix.
A pointer to member type per C++ 8.3.3 - Pointers to members.
NestedNameSpecifier getQualifier() const
CXXRecordDecl * getMostRecentCXXRecordDecl() const
Note: this can trigger extra deserialization when external AST sources are used.
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.
QualType getExpansionType(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, const IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
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.
bool isVarDeclReference() const
TemplateTemplateParmDecl * getTemplateTemplateDecl() const
bool isConceptReference() const
ArrayRef< TemplateArgumentLoc > template_arguments() const
A structure for storing the information associated with an overloaded template name.
NamedDecl *const * iterator
Represents a C++11 pack expansion that produces a sequence of expressions.
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...
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.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false) const
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S',...
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
LookupNameKind
Describes the kind of name lookup to perform.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
ExprResult ActOnConstantExpression(ExprResult Res)
bool LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType, bool EnteringContext, RequiredTemplateKind RequiredTemplate=SourceLocation(), AssumedTemplateKind *ATK=nullptr, bool AllowTypoCorrection=true)
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, NamedDecl *PrevMemberDecl, AccessSpecifier LexicalAS)
SetMemberAccessSpecifier - Set the access specifier of a member.
bool BuildTypeConstraint(const CXXScopeSpec &SS, TemplateIdAnnotation *TypeConstraint, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc, bool AllowUnexpandedPack)
NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK)
Given a non-tag type declaration, returns an enum useful for indicating what kind of non-tag type thi...
bool diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC, DeclarationName Name, SourceLocation Loc, TemplateIdAnnotation *TemplateId, bool IsMemberSpecialization)
Diagnose a declaration whose declarator-id has the given nested-name-specifier.
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
bool ActOnTypeConstraint(const CXXScopeSpec &SS, TemplateIdAnnotation *TypeConstraint, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is visible.
bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info)
DiagnoseClassNameShadow - Implement C++ [class.mem]p13: If T is the name of a class,...
void NoteAllFoundTemplates(TemplateName Name)
TemplateName SubstTemplateName(SourceLocation TemplateKWLoc, NestedNameSpecifierLoc &QualifierLoc, TemplateName Name, SourceLocation NameLoc, const MultiLevelTemplateArgumentList &TemplateArgs)
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, const IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
void InstantiateClassTemplateSpecializationMembers(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK)
Instantiate the definitions of all of the members of the given class template specialization,...
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
bool TemplateParameterListsAreEqual(const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New, const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
ExprResult BuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, const NonTypeTemplateParmDecl *NTTP, SourceLocation loc, TemplateArgument Replacement, UnsignedOrNone PackIndex, bool Final)
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)
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization, bool Disambiguation=false)
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
ExprResult BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
void propagateDLLAttrToBaseClassTemplate(CXXRecordDecl *Class, Attr *ClassAttr, ClassTemplateSpecializationDecl *BaseTemplateSpec, SourceLocation BaseLoc)
Perform propagation of DLL attributes from a derived class to a templated base class for MS compatibi...
bool isRedefinitionAllowedFor(NamedDecl *D, NamedDecl **Suggested, bool &Visible)
Determine if D has a definition which allows we redefine it in current TU.
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over....
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
void checkSpecializationReachability(SourceLocation Loc, NamedDecl *Spec)
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
ASTContext & getASTContext() const
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd, TemplateSpecCandidateSet &FailedCandidates, SourceLocation Loc, const PartialDiagnostic &NoneDiag, const PartialDiagnostic &AmbigDiag, const PartialDiagnostic &CandidateDiag, bool Complain=true, QualType TargetType=QualType())
Retrieve the most specialized of the given function template specializations.
bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
IsIntegralPromotion - Determines whether the conversion from the expression From (whose potentially-a...
TypeSourceInfo * SubstType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, bool AllowDeducedTST=false)
Perform substitution on the type T with a given set of template arguments.
bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const
Check the redefinition in C++20 Modules.
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
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)
void AddPushedVisibilityAttribute(Decl *RD)
AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, add an appropriate visibility at...
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
ExprResult DefaultLvalueConversion(Expr *E)
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
void NoteOverloadCandidate(const NamedDecl *Found, const FunctionDecl *Fn, OverloadCandidateRewriteKind RewriteKind=OverloadCandidateRewriteKind(), QualType DestType=QualType(), bool TakingAddress=false)
bool hasReachableDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a reachable default argument.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(const NamedDecl *D, const DeclContext *DC=nullptr, bool Final=false, std::optional< ArrayRef< TemplateArgument > > Innermost=std::nullopt, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr, bool ForConstraintInstantiation=false, bool SkipForSpecialization=false, bool ForDefaultArgumentSubstitution=false)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
QualType BuiltinDecay(QualType BaseType, SourceLocation Loc)
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool CheckFunctionConstraints(const FunctionDecl *FD, ConstraintSatisfaction &Satisfaction, SourceLocation UsageLoc=SourceLocation(), bool ForOverloadResolution=false)
Check whether the given function decl's trailing requires clause is satisfied, if any.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
bool CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, TemplateSpecializationKind ActOnExplicitInstantiationNewTSK, NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK, SourceLocation PrevPtOfInstantiation, bool &SuppressNew)
Diagnose cases where we have an explicit template specialization before/after an explicit template in...
bool CheckTypeConstraint(TemplateIdAnnotation *TypeConstraint)
TemplateNameKind ActOnTemplateName(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool AllowInjectedClassName=false)
Form a template name from a name that is syntactically required to name a template,...
void diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName, SourceLocation Less, SourceLocation Greater)
ExprResult FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
QualType CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI, SourceLocation Loc)
Check that the type of a non-type template parameter is well-formed.
void diagnoseMissingImport(SourceLocation Loc, const NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, TemplateDecl *NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
TemplateArgumentLoc SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, SourceLocation TemplateKWLoc, SourceLocation TemplateNameLoc, SourceLocation RAngleLoc, Decl *Param, ArrayRef< TemplateArgument > SugaredConverted, ArrayRef< TemplateArgument > CanonicalConverted, bool &HasDefaultArg)
If the given template parameter has a default template argument, substitute into that default templat...
void FilterAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true)
TypeSourceInfo * SubstAutoTypeSourceInfoDependent(TypeSourceInfo *TypeWithAuto)
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams)
Check whether a template can be declared within this scope.
void AddMsStructLayoutForRecord(RecordDecl *RD)
AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
TemplateParameterList * SubstTemplateParams(TemplateParameterList *Params, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs, bool EvaluateConstraints=true)
SourceLocation getTopMostPointOfInstantiation(const NamedDecl *) const
Returns the top most location responsible for the definition of N.
bool 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.
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.
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)
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)
TypeResult ActOnTemplateIdType(Scope *S, ElaboratedTypeKeyword ElaboratedKeyword, SourceLocation ElaboratedKeywordLoc, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, const IdentifierInfo *TemplateII, SourceLocation TemplateIILoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false, bool IsClassName=false, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No)
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC, SkipBodyInfo *SkipBody=nullptr)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
bool isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl *T, sema::TemplateDeductionInfo &Info)
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
ExprResult CheckVarOrConceptTemplateTemplateId(const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, TemplateTemplateParmDecl *Template, SourceLocation TemplateLoc, const TemplateArgumentListInfo *TemplateArgs)
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...
@ 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.
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
TemplateDeductionResult DeduceAutoType(TypeLoc AutoTypeLoc, Expr *Initializer, QualType &Result, sema::TemplateDeductionInfo &Info, bool DependentDeduction=false, bool IgnoreConstraints=false, TemplateSpecCandidateSet *FailedTSC=nullptr)
Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
QualType adjustCCAndNoReturn(QualType ArgFunctionType, QualType FunctionType, bool AdjustExceptionSpec=false)
Adjust the type ArgFunctionType to match the calling convention, noreturn, and optionally the excepti...
void NoteTemplateParameterLocation(const NamedDecl &Decl)
IdentifierResolver IdResolver
ArrayRef< sema::FunctionScopeInfo * > getFunctionScopes() const
void checkTypeDeclType(DeclContext *LookupCtx, DiagCtorKind DCK, TypeDecl *TD, SourceLocation NameLoc)
Returns the TypeDeclType for the given type declaration, as ASTContext::getTypeDeclType would,...
void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD)
TypeResult ActOnTagTemplateIdType(TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc)
Parsed an elaborated-type-specifier that refers to a template-id, such as class T::template apply.
bool hasReachableDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is reachable.
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
bool DiagnoseUnexpandedParameterPacks(SourceLocation Loc, UnexpandedParameterPackContext UPPC, ArrayRef< UnexpandedParameterPack > Unexpanded)
Diagnose unexpanded parameter packs.
void warnOnReservedIdentifier(const NamedDecl *D)
void inferNullableClassAttribute(CXXRecordDecl *CRD)
Add _Nullable attributes for std:: types.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
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...
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)
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateNameKind ParameterKind, bool Typename, TemplateParameterList *Params)
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
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)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, UnsignedOrNone NumExpanded=std::nullopt)
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
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isVoidPointerType() const
bool isPointerType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() const
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)
void setMemberSpecialization()
Note that this member template is a specialization.
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
Represents a variable template specialization, which refers to a variable template with a given set o...
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
Represents a C array with a specified size that is not an integer-constant-expression.
Represents a GCC generic vector type.
QualType getElementType() const
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,...
The JSON file list parser is used to communicate input to InstallAPI.
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.
@ 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)
@ 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
@ 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.
@ Type
The name was classified as a type.
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.
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.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
SourceLocation getEndLoc() const LLVM_READONLY
ArrayRef< TemplateArgument > Args
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
bool HasSideEffects
Whether the evaluated expression has side effects.
Extra information about a function prototype.
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
NestedNameSpecifierLoc Prefix
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
Describes how types, statements, expressions, and declarations should be printed.
unsigned TerseOutput
Provide a 'terse' output.
unsigned PrintAsCanonical
Whether to print entities as written or canonically.
bool StrictPackMatch
Is set to true when, in the context of TTP matching, a pack parameter matches non-pack arguments.
bool MatchingTTP
If true, assume these template arguments are the injected template arguments for a template template ...
bool PartialOrdering
The check is being performed in the context of partial ordering.
SmallVector< TemplateArgument, 4 > SugaredConverted
The checked, converted argument will be added to the end of these vectors.
SmallVector< TemplateArgument, 4 > CanonicalConverted
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
@ BuildingDeductionGuides
We are building deduction guides for a class.
A stack object to be created when performing template instantiation.
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
Location information for a TemplateArgument.
Information about a template-id annotation token.
const IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
unsigned NumArgs
NumArgs - The number of template arguments.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
OverloadedOperatorKind Operator
The kind of overloaded operator.