26 #include "llvm/Support/TimeProfiler.h" 28 using namespace clang;
36 return cast<CXXRecordDecl>(DC)->isLocalClass();
41 template<
typename DeclT>
44 if (!OldDecl->getQualifierLoc())
47 assert((NewDecl->getFriendObjectKind() ||
48 !OldDecl->getLexicalDeclContext()->isDependentContext()) &&
49 "non-friend with qualified name defined in dependent context");
52 const_cast<DeclContext *>(NewDecl->getFriendObjectKind()
53 ? NewDecl->getLexicalDeclContext()
54 : OldDecl->getLexicalDeclContext()));
63 NewDecl->setQualifierInfo(NewQualifierLoc);
78 #include "clang/Sema/AttrTemplateInstantiate.inc" 82 const AlignedAttr *Aligned,
Decl *New,
bool IsPackExpansion) {
83 if (Aligned->isAlignmentExpr()) {
90 Aligned->getSpellingListIndex(), IsPackExpansion);
93 TemplateArgs, Aligned->getLocation(),
97 Aligned->getSpellingListIndex(), IsPackExpansion);
103 const AlignedAttr *Aligned,
Decl *New) {
104 if (!Aligned->isPackExpansion()) {
110 if (Aligned->isAlignmentExpr())
116 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
119 bool Expand =
true, RetainExpansion =
false;
124 Unexpanded, TemplateArgs, Expand,
125 RetainExpansion, NumExpansions))
132 for (
unsigned I = 0; I != *NumExpansions; ++I) {
141 const AssumeAlignedAttr *Aligned,
Decl *New) {
146 Expr *E, *OE =
nullptr;
152 if (Aligned->getOffset()) {
153 Result = S.
SubstExpr(Aligned->getOffset(), TemplateArgs);
160 Aligned->getSpellingListIndex());
165 const AlignValueAttr *Aligned,
Decl *New) {
172 Aligned->getSpellingListIndex());
177 const AllocAlignAttr *Align,
Decl *New) {
180 llvm::APInt(64, Align->getParamIndex().getSourceIndex()),
183 Align->getSpellingListIndex());
189 Expr *Cond =
nullptr;
203 Cond = Converted.
get();
209 S.
Diag(A->
getLocation(), diag::err_attr_cond_never_constant_expr) << A;
210 for (
const auto &
P : Diags)
211 S.
Diag(
P.first,
P.second);
221 S, TemplateArgs, EIA, EIA->getCond(), Tmpl, New);
225 EIA->getLocation(), S.
getASTContext(), Cond, EIA->getMessage(),
226 EIA->getSpellingListIndex()));
233 S, TemplateArgs, DIA, DIA->getCond(), Tmpl, New);
237 DIA->getLocation(), S.
getASTContext(), Cond, DIA->getMessage(),
238 DIA->getDiagnosticType(), DIA->getArgDependent(), New,
239 DIA->getSpellingListIndex()));
246 const CUDALaunchBoundsAttr &
Attr,
Decl *New) {
256 Expr *MinBlocks =
nullptr;
257 if (Attr.getMinBlocks()) {
258 Result = S.
SubstExpr(Attr.getMinBlocks(), TemplateArgs);
265 Attr.getSpellingListIndex());
272 S.
AddModeAttr(Attr.getRange(), New, Attr.getMode(),
273 Attr.getSpellingListIndex(),
true);
279 const OMPDeclareSimdDeclAttr &
Attr,
Decl *New) {
281 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(New))
282 New = FTD->getTemplatedDecl();
283 auto *FD = cast<FunctionDecl>(New);
284 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(FD->getDeclContext());
289 if (
auto *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts()))
290 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl())) {
293 if (FD->getNumParams() > PVD->getFunctionScopeIndex())
295 PVD, FD->getParamDecl(PVD->getFunctionScopeIndex()));
299 FD->isCXXInstanceMember());
315 if (
auto *E = Attr.getSimdlen())
318 if (Attr.uniforms_size() > 0) {
319 for(
auto *E : Attr.uniforms()) {
323 Uniforms.push_back(Inst.
get());
327 auto AI = Attr.alignments_begin();
328 for (
auto *E : Attr.aligneds()) {
332 Aligneds.push_back(Inst.
get());
336 Alignments.push_back(Inst.
get());
340 auto SI = Attr.steps_begin();
341 for (
auto *E : Attr.linears()) {
345 Linears.push_back(Inst.
get());
349 Steps.push_back(Inst.
get());
352 LinModifiers.append(Attr.modifiers_begin(), Attr.modifiers_end());
355 Uniforms, Aligneds, Alignments, Linears, LinModifiers, Steps,
361 const AMDGPUFlatWorkGroupSizeAttr &
Attr,
Decl *New) {
371 Result = S.
SubstExpr(Attr.getMax(), TemplateArgs);
372 if (Result.isInvalid())
374 Expr *MaxExpr = Result.getAs<
Expr>();
377 Attr.getSpellingListIndex());
387 Expr *Cond =
nullptr;
395 Cond = SubstResult.
get();
405 const AMDGPUWavesPerEUAttr &
Attr,
Decl *New) {
415 Expr *MaxExpr =
nullptr;
416 if (
auto Max = Attr.getMax()) {
424 Attr.getSpellingListIndex());
431 if (
NamedDecl *ND = dyn_cast<NamedDecl>(New)) {
432 for (
const auto *TmplAttr : Tmpl->
attrs()) {
436 *
this, dyn_cast_or_null<CXXRecordDecl>(ND->getDeclContext()),
440 TmplAttr, Context, *
this, TemplateArgs);
450 case clang::attr::CFConsumed:
452 case clang::attr::OSConsumed:
454 case clang::attr::NSConsumed:
457 llvm_unreachable(
"Wrong argument supplied");
465 for (
const auto *TmplAttr : Tmpl->
attrs()) {
467 const AlignedAttr *Aligned = dyn_cast<AlignedAttr>(TmplAttr);
468 if (Aligned && Aligned->isAlignmentDependent()) {
473 const AssumeAlignedAttr *AssumeAligned = dyn_cast<AssumeAlignedAttr>(TmplAttr);
479 const AlignValueAttr *AlignValue = dyn_cast<AlignValueAttr>(TmplAttr);
485 if (
const auto *AllocAlign = dyn_cast<AllocAlignAttr>(TmplAttr)) {
491 if (
const auto *EnableIf = dyn_cast<EnableIfAttr>(TmplAttr)) {
493 cast<FunctionDecl>(New));
497 if (
const auto *DiagnoseIf = dyn_cast<DiagnoseIfAttr>(TmplAttr)) {
499 cast<FunctionDecl>(New));
503 if (
const CUDALaunchBoundsAttr *CUDALaunchBounds =
504 dyn_cast<CUDALaunchBoundsAttr>(TmplAttr)) {
506 *CUDALaunchBounds, New);
510 if (
const ModeAttr *Mode = dyn_cast<ModeAttr>(TmplAttr)) {
515 if (
const auto *OMPAttr = dyn_cast<OMPDeclareSimdDeclAttr>(TmplAttr)) {
520 if (
const AMDGPUFlatWorkGroupSizeAttr *AMDGPUFlatWorkGroupSize =
521 dyn_cast<AMDGPUFlatWorkGroupSizeAttr>(TmplAttr)) {
523 *
this, TemplateArgs, *AMDGPUFlatWorkGroupSize, New);
526 if (
const AMDGPUWavesPerEUAttr *AMDGPUFlatWorkGroupSize =
527 dyn_cast<AMDGPUWavesPerEUAttr>(TmplAttr)) {
529 *AMDGPUFlatWorkGroupSize, New);
533 if (TmplAttr->getKind() == attr::DLLExport ||
534 TmplAttr->getKind() == attr::DLLImport) {
535 if (New->
hasAttr<DLLExportAttr>() || New->
hasAttr<DLLImportAttr>()) {
540 if (
auto ABIAttr = dyn_cast<ParameterABIAttr>(TmplAttr)) {
541 AddParameterABIAttr(ABIAttr->getRange(), New, ABIAttr->getABI(),
542 ABIAttr->getSpellingListIndex());
546 if (isa<NSConsumedAttr>(TmplAttr) || isa<OSConsumedAttr>(TmplAttr) ||
547 isa<CFConsumedAttr>(TmplAttr)) {
548 AddXConsumedAttr(New, TmplAttr->getRange(),
549 TmplAttr->getSpellingListIndex(),
555 assert(!TmplAttr->isPackExpansion());
556 if (TmplAttr->isLateParsed() && LateAttrs) {
560 if (CurrentInstantiationScope)
561 Saved = CurrentInstantiationScope->
cloneScopes(OuterMostScope);
572 *
this, TemplateArgs);
583 template<
typename DeclT>
585 DeclT *
Result = D->getPreviousDecl();
590 if (Result && isa<CXXRecordDecl>(D->getDeclContext()) &&
591 D->getLexicalDeclContext() != Result->getLexicalDeclContext())
599 llvm_unreachable(
"Translation units cannot be instantiated");
604 llvm_unreachable(
"pragma comment cannot be instantiated");
607 Decl *TemplateDeclInstantiator::VisitPragmaDetectMismatchDecl(
609 llvm_unreachable(
"pragma comment cannot be instantiated");
614 llvm_unreachable(
"extern \"C\" context cannot be instantiated");
618 TemplateDeclInstantiator::VisitLabelDecl(
LabelDecl *D) {
626 TemplateDeclInstantiator::VisitNamespaceDecl(
NamespaceDecl *D) {
627 llvm_unreachable(
"Namespaces cannot be instantiated");
646 bool Invalid =
false;
690 TagDecl *oldTag = oldTagType->getDecl();
709 Typedef->setPreviousDecl(InstPrevTypedef);
747 if (getPreviousDeclForInstantiation<TypedefNameDecl>(Pattern)) {
749 if (!Found.
empty()) {
762 AliasInst->setDescribedAliasTemplate(Inst);
763 if (PrevAliasTemplate)
768 if (!PrevAliasTemplate)
788 NewBindings.push_back(cast<BindingDecl>(VisitBindingDecl(OldBD)));
791 auto *NewDD = cast_or_null<DecompositionDecl>(
794 if (!NewDD || NewDD->isInvalidDecl())
795 for (
auto *NewBD : NewBindings)
796 NewBD->setInvalidDecl();
806 bool InstantiatingVarTemplate,
817 SemaRef.
Diag(D->
getLocation(), diag::err_variable_instantiates_to_function)
847 StartingScope, InstantiatingVarTemplate);
850 QualType ReturnType = cast<FunctionDecl>(DC)->getReturnType();
852 Var->setNRVOVariable(
true);
857 if (Var->isStaticLocal())
871 Decl *TemplateDeclInstantiator::VisitFieldDecl(
FieldDecl *D) {
872 bool Invalid =
false;
888 SemaRef.
Diag(D->
getLocation(), diag::err_field_instantiates_to_function)
905 = SemaRef.
SubstExpr(BitWidth, TemplateArgs);
910 BitWidth = InstantiatedBitWidth.
getAs<
Expr>();
915 cast<RecordDecl>(Owner),
924 cast<Decl>(Owner)->setInvalidDecl();
930 if (Field->hasAttrs())
934 Field->setInvalidDecl();
936 if (!Field->getDeclName()) {
941 if (
Parent->isAnonymousStructOrUnion() &&
942 Parent->getRedeclContext()->isFunctionOrMethod())
954 bool Invalid =
false;
958 SemaRef.
Diag(D->
getLocation(), diag::err_property_is_variably_modified)
974 SemaRef.
Diag(D->
getLocation(), diag::err_field_instantiates_to_function)
1003 for (
auto *PI : D->
chain()) {
1009 NamedChain[i++] = Next;
1012 QualType T = cast<FieldDecl>(NamedChain[i-1])->getType();
1022 Owner->
addDecl(IndirectField);
1023 return IndirectField;
1038 InstTy = SemaRef.
SubstType(Ty, TemplateArgs,
1056 assert(ND &&
"friend decl must be a decl or a type!");
1063 if (!NewND)
return nullptr;
1082 = SemaRef.
SubstExpr(AssertExpr, TemplateArgs);
1087 InstantiatedAssertExpr.
get(),
1093 Decl *TemplateDeclInstantiator::VisitEnumDecl(
EnumDecl *D) {
1099 if (!Prev)
return nullptr;
1100 PrevDecl = cast<EnumDecl>(Prev);
1118 Enum->setIntegerTypeSourceInfo(NewTI);
1121 &&
"Dependent type without type source info");
1144 if (Def && Def != D) {
1151 SemaRef.
SubstType(TI->getType(), TemplateArgs,
1154 DefnUnderlying,
true, Enum);
1186 if (
Expr *UninstValue = EC->getInitExpr()) {
1191 Value = SemaRef.
SubstExpr(UninstValue, TemplateArgs);
1217 Enumerators.push_back(EnumConst);
1218 LastEnumConst = EnumConst;
1234 llvm_unreachable(
"EnumConstantDecls can only occur within EnumDecls.");
1239 llvm_unreachable(
"BuiltinTemplateDecls cannot be instantiated.");
1271 if (!Found.
empty()) {
1273 if (PrevClassTemplate)
1286 SS.
Adopt(QualifierLoc);
1288 if (!DC)
return nullptr;
1302 if (R.isSingleResult()) {
1304 if (PrevClassTemplate)
1308 if (!PrevClassTemplate && QualifierLoc) {
1315 bool AdoptedPreviousTemplateParams =
false;
1316 if (PrevClassTemplate) {
1317 bool Complain =
true;
1329 cast<NamespaceDecl>(DC)->
getIdentifier()->isStr(
"__detail")) {
1333 cast<NamespaceDecl>(DCParent)->
getIdentifier()->isStr(
"tr1")) {
1334 if (cast<Decl>(DCParent)->isInStdNamespace())
1349 AdoptedPreviousTemplateParams =
true;
1350 InstParams = PrevParams;
1355 if (!AdoptedPreviousTemplateParams &&
1382 if (PrevClassTemplate)
1392 if (!PrevClassTemplate)
1415 if (!PrevClassTemplate) {
1421 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I)
1422 if (PartialSpecs[I]->getFirstDecl()->isOutOfLine())
1423 OutOfLinePartialSpecs.push_back(std::make_pair(Inst, PartialSpecs[I]));
1430 TemplateDeclInstantiator::VisitClassTemplatePartialSpecializationDecl(
1443 if (!InstClassTemplate)
1455 "Only static data member templates are allowed.");
1471 PrevVarTemplate = dyn_cast<VarTemplateDecl>(Found.
front());
1477 if (!VarInst)
return nullptr;
1488 if (!PrevVarTemplate)
1498 if (!PrevVarTemplate) {
1504 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I)
1505 if (PartialSpecs[I]->getFirstDecl()->isOutOfLine())
1506 OutOfLineVarPartialSpecs.push_back(
1507 std::make_pair(Inst, PartialSpecs[I]));
1513 Decl *TemplateDeclInstantiator::VisitVarTemplatePartialSpecializationDecl(
1516 "Only static data member templates are allowed.");
1522 assert(!Found.
empty() &&
"Instantiation found nothing?");
1525 assert(InstVarTemplate &&
"Instantiation did not find a variable template?");
1528 InstVarTemplate->findPartialSpecInstantiatedFromMember(D))
1562 = Instantiated->getDescribedFunctionTemplate();
1564 assert(InstTemplate &&
1565 "VisitFunctionDecl/CXXMethodDecl didn't create a template!");
1583 return InstTemplate;
1589 PrevDecl = cast<CXXRecordDecl>(Owner);
1594 if (!Prev)
return nullptr;
1595 PrevDecl = cast<CXXRecordDecl>(Prev);
1621 Record->setObjectOfFriendDecl();
1625 Record->setAnonymousStructOrUnion(
true);
1657 if (!D->isCXXClassMember())
1663 LocalInstantiations.
perform();
1684 if (OrigFunc->
getExtInfo() == NewFunc->getExtInfo())
1690 NewFunc->getParamTypes(), NewEPI);
1703 if (FunctionTemplate && !TemplateParams) {
1706 void *InsertPos =
nullptr;
1716 if (FunctionTemplate)
1721 bool MergeWithParentScope = (TemplateParams !=
nullptr) ||
1723 !(isa<Decl>(Owner) &&
1724 cast<Decl>(Owner)->isDefinedOutsideFunctionOrMethod());
1728 if (
auto *DGuide = dyn_cast<CXXDeductionGuideDecl>(D)) {
1730 SemaRef, TemplateArgs, DGuide->getExplicitSpecifier(), DGuide);
1731 if (InstantiatedExplicitSpecifier.
isInvalid())
1756 }
else if (isFriend && QualifierLoc) {
1758 SS.
Adopt(QualifierLoc);
1760 if (!DC)
return nullptr;
1770 if (
auto *DGuide = dyn_cast<CXXDeductionGuideDecl>(D)) {
1773 InstantiatedExplicitSpecifier, NameInfo, T, TInfo,
1775 if (DGuide->isCopyDeductionCandidate())
1804 for (
unsigned P = 0;
P < Params.size(); ++
P)
1806 Params[
P]->setOwningFunction(Function);
1807 Function->setParams(Params);
1809 if (TemplateParams) {
1827 TemplateParams, Function);
1836 }
else if (FunctionTemplate) {
1839 Function->setFunctionTemplateSpecialization(FunctionTemplate,
1856 bool IsExplicitSpecialization =
false;
1867 assert(isFriend &&
"non-friend has dependent specialization info?");
1871 Info->getRAngleLoc());
1872 if (SemaRef.
Subst(Info->getTemplateArgs(), Info->getNumTemplateArgs(),
1873 ExplicitArgs, TemplateArgs))
1877 for (
unsigned I = 0, E = Info->getNumTemplates(); I != E; ++I) {
1879 Info->getTemplate(I),
1881 if (!Temp)
return nullptr;
1883 Previous.addDecl(cast<FunctionTemplateDecl>(Temp));
1891 IsExplicitSpecialization =
true;
1899 Info->getRAngleLoc());
1900 if (SemaRef.
Subst(Info->getTemplateArgs(), Info->getNumTemplateArgs(),
1901 ExplicitArgs, TemplateArgs))
1909 IsExplicitSpecialization =
true;
1910 }
else if (TemplateParams || !FunctionTemplate) {
1925 IsExplicitSpecialization);
1927 NamedDecl *PrincipalDecl = (TemplateParams
1928 ? cast<NamedDecl>(FunctionTemplate)
1936 FT->setObjectOfFriendDecl();
1939 bool QueuedInstantiation =
false;
1950 for (
auto R : Function->
redecls()) {
1956 if (!QueuedInstantiation && R->isUsed(
false)) {
1959 if (MSInfo->getPointOfInstantiation().isInvalid()) {
1961 MSInfo->setPointOfInstantiation(Loc);
1963 std::make_pair(Function, Loc));
1964 QueuedInstantiation =
true;
1993 assert(!D->
isDefaulted() &&
"only methods should be defaulted");
2000 ClassScopeSpecializationArgs) {
2002 if (FunctionTemplate && !TemplateParams) {
2008 void *InsertPos =
nullptr;
2018 if (FunctionTemplate)
2023 bool MergeWithParentScope = (TemplateParams !=
nullptr) ||
2024 !(isa<Decl>(Owner) &&
2025 cast<Decl>(Owner)->isDefinedOutsideFunctionOrMethod());
2030 unsigned NumTempParamLists = 0;
2032 TempParamLists.resize(NumTempParamLists);
2033 for (
unsigned I = 0; I != NumTempParamLists; ++I) {
2038 TempParamLists[I] = InstParams;
2045 if (InstantiatedExplicitSpecifier.
isInvalid())
2066 SS.
Adopt(QualifierLoc);
2076 if (!DC)
return nullptr;
2088 SemaRef.
Context, Record, StartLoc, NameInfo, T, TInfo,
2089 InstantiatedExplicitSpecifier, Constructor->isInlineSpecified(),
false,
2090 Constructor->getConstexprKind());
2094 StartLoc, NameInfo, T, TInfo,
2095 Destructor->isInlineSpecified(),
2100 SemaRef.
Context, Record, StartLoc, NameInfo, T, TInfo,
2101 Conversion->isInlineSpecified(), InstantiatedExplicitSpecifier,
2102 Conversion->getConstexprKind(), Conversion->getEndLoc());
2114 Method->setQualifierInfo(QualifierLoc);
2116 if (TemplateParams) {
2132 Method->getDeclName(),
2133 TemplateParams, Method);
2139 Method->setDescribedFunctionTemplate(FunctionTemplate);
2140 }
else if (FunctionTemplate) {
2143 Method->setFunctionTemplateSpecialization(FunctionTemplate,
2147 }
else if (!isFriend) {
2156 if (NumTempParamLists)
2157 Method->setTemplateParameterListsInfo(
2159 llvm::makeArrayRef(TempParamLists.data(), NumTempParamLists));
2161 Method->setLexicalDeclContext(Owner);
2162 Method->setObjectOfFriendDecl();
2167 for (
unsigned P = 0;
P < Params.size(); ++
P)
2168 Params[
P]->setOwningFunction(Method);
2169 Method->setParams(Params);
2172 Method->setInvalidDecl();
2177 bool IsExplicitSpecialization =
false;
2183 assert(isFriend &&
"non-friend has dependent specialization info?");
2187 Info->getRAngleLoc());
2188 if (SemaRef.
Subst(Info->getTemplateArgs(), Info->getNumTemplateArgs(),
2189 ExplicitArgs, TemplateArgs))
2193 for (
unsigned I = 0, E = Info->getNumTemplates(); I != E; ++I) {
2195 Info->getTemplate(I),
2197 if (!Temp)
return nullptr;
2199 Previous.
addDecl(cast<FunctionTemplateDecl>(Temp));
2205 Method->setInvalidDecl();
2207 IsExplicitSpecialization =
true;
2209 ClassScopeSpecializationArgs.getValueOr(
2214 Info->getRAngleLoc());
2215 if (SemaRef.
Subst(Info->getTemplateArgs(), Info->getNumTemplateArgs(),
2216 ExplicitArgs, TemplateArgs))
2222 Method->setInvalidDecl();
2224 IsExplicitSpecialization =
true;
2225 }
else if (ClassScopeSpecializationArgs) {
2230 Method->setInvalidDecl();
2232 IsExplicitSpecialization =
true;
2233 }
else if (!FunctionTemplate || TemplateParams || isFriend) {
2245 IsExplicitSpecialization);
2253 if (isFriend && Method->getPreviousDecl())
2254 Method->setAccess(Method->getPreviousDecl()->getAccess());
2257 if (FunctionTemplate)
2258 FunctionTemplate->
setAccess(Method->getAccess());
2271 if (IsExplicitSpecialization && !isFriend)
2275 if (FunctionTemplate) {
2279 }
else if (Method->isInvalidDecl() && !Previous.
empty()) {
2283 }
else if (isFriend) {
2300 if (Method->hasAttr<UsedAttr>()) {
2301 if (
const auto *A = dyn_cast<CXXRecordDecl>(Owner)) {
2304 A->getMemberSpecializationInfo())
2305 Loc = MSInfo->getPointOfInstantiation();
2306 else if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(A))
2307 Loc = Spec->getPointOfInstantiation();
2332 Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl(
2347 if (InstantiatedDefaultArg)
2348 Inst->setDefaultArgument(InstantiatedDefaultArg);
2358 Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl(
2364 bool IsExpandedParameterPack =
false;
2367 bool Invalid =
false;
2386 ExpandedParameterPackTypesAsWritten.push_back(NewDI);
2387 ExpandedParameterPackTypes.push_back(NewT);
2390 IsExpandedParameterPack =
true;
2405 bool RetainExpansion =
false;
2410 Pattern.getSourceRange(),
2413 Expand, RetainExpansion,
2418 for (
unsigned I = 0; I != *NumExpansions; ++I) {
2431 ExpandedParameterPackTypesAsWritten.push_back(NewDI);
2432 ExpandedParameterPackTypes.push_back(NewT);
2438 IsExpandedParameterPack =
true;
2475 if (IsExpandedParameterPack)
2480 ExpandedParameterPackTypesAsWritten);
2489 Param->setInvalidDecl();
2496 Param->setDefaultArgument(Value.
get());
2509 for (
const auto &
P : *Params) {
2510 if (
P->isTemplateParameterPack())
2522 TemplateDeclInstantiator::VisitTemplateTemplateParmDecl(
2529 bool IsExpandedParameterPack =
false;
2543 ExpandedParams.push_back(Expansion);
2546 IsExpandedParameterPack =
true;
2547 InstParams = TempParams;
2559 bool RetainExpansion =
false;
2565 Expand, RetainExpansion,
2570 for (
unsigned I = 0; I != *NumExpansions; ++I) {
2576 ExpandedParams.push_back(Expansion);
2582 IsExpandedParameterPack =
true;
2583 InstParams = TempParams;
2605 if (IsExpandedParameterPack)
2624 Param->setDefaultArgument(
2659 Decl *TemplateDeclInstantiator::VisitUsingDecl(
UsingDecl *D) {
2680 if (
auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.
CurContext))
2687 bool CheckRedeclaration = Owner->
isRecord();
2699 SS.
Adopt(QualifierLoc);
2700 if (CheckRedeclaration) {
2731 for (
auto *Shadow : D->
shadows()) {
2734 NamedDecl *OldTarget = Shadow->getTargetDecl();
2735 if (
auto *CUSD = dyn_cast<ConstructorUsingShadowDecl>(Shadow))
2736 if (
auto *BaseShadow = CUSD->getNominatedBaseClassShadowDecl())
2737 OldTarget = BaseShadow;
2741 Shadow->getLocation(), OldTarget, TemplateArgs));
2746 if (CheckRedeclaration) {
2752 Shadow->getLocation(), OldPrev, TemplateArgs));
2760 if (isFunctionScope)
2772 Decl *TemplateDeclInstantiator::VisitConstructorUsingShadowDecl(
2778 template <
typename T>
2779 Decl *TemplateDeclInstantiator::instantiateUnresolvedUsingDecl(
2780 T *D,
bool InstantiatingPackElement) {
2782 if (D->isPackExpansion() && !InstantiatingPackElement) {
2790 bool RetainExpansion =
false;
2793 D->getEllipsisLoc(), D->
getSourceRange(), Unexpanded, TemplateArgs,
2794 Expand, RetainExpansion, NumExpansions))
2799 assert(!RetainExpansion &&
2800 "should never need to retain an expansion for UsingPackDecl");
2806 return instantiateUnresolvedUsingDecl(D,
true);
2817 SemaRef.
Diag(D->getEllipsisLoc(),
2818 diag::err_using_decl_redeclaration_expansion);
2824 for (
unsigned I = 0; I != *NumExpansions; ++I) {
2826 Decl *Slice = instantiateUnresolvedUsingDecl(D,
true);
2833 Expansions.push_back(cast<NamedDecl>(Slice));
2852 SS.
Adopt(QualifierLoc);
2859 bool InstantiatingSlice = D->getEllipsisLoc().isValid() &&
2865 nullptr, D->
getAccess(), D->getUsingLoc(),
2866 TD, TypenameLoc, SS, NameInfo, EllipsisLoc,
2875 Decl *TemplateDeclInstantiator::VisitUnresolvedUsingTypenameDecl(
2877 return instantiateUnresolvedUsingDecl(D);
2880 Decl *TemplateDeclInstantiator::VisitUnresolvedUsingValueDecl(
2882 return instantiateUnresolvedUsingDecl(D);
2890 Expansions.push_back(NewUD);
2901 Decl *TemplateDeclInstantiator::VisitClassScopeFunctionSpecializationDecl(
2904 return cast_or_null<CXXMethodDecl>(
2908 Decl *TemplateDeclInstantiator::VisitOMPThreadPrivateDecl(
2913 assert(isa<DeclRefExpr>(Var) &&
"threadprivate arg is not a DeclRefExpr");
2914 Vars.push_back(Var);
2926 Decl *TemplateDeclInstantiator::VisitOMPAllocateDecl(
OMPAllocateDecl *D) {
2930 assert(isa<DeclRefExpr>(Var) &&
"allocate arg is not a DeclRefExpr");
2931 Vars.push_back(Var);
2936 auto *AC = cast<OMPAllocatorClause>(
C);
2938 if (!NewE.isUsable())
2941 NewE.get(), AC->getBeginLoc(), AC->getLParenLoc(), AC->getEndLoc());
2942 Clauses.push_back(IC);
2947 if (Res.
get().isNull())
2949 return Res.
get().getSingleDecl();
2952 Decl *TemplateDeclInstantiator::VisitOMPRequiresDecl(
OMPRequiresDecl *D) {
2954 "Requires directive cannot be instantiated within a dependent context");
2957 Decl *TemplateDeclInstantiator::VisitOMPDeclareReductionDecl(
2960 const bool RequiresInstantiation =
2965 if (RequiresInstantiation) {
2971 SubstReductionType = D->
getType();
2973 if (SubstReductionType.
isNull())
2975 bool IsCorrect = !SubstReductionType.
isNull();
2977 std::pair<QualType, SourceLocation> ReductionTypes[] = {
2978 std::make_pair(SubstReductionType, D->
getLocation())};
2980 if (PrevDeclInScope && !PrevDeclInScope->isInvalidDecl()) {
2981 PrevDeclInScope = cast<OMPDeclareReductionDecl>(
2988 auto *NewDRD = cast<OMPDeclareReductionDecl>(DRD.get().getSingleDecl());
2990 if (!RequiresInstantiation) {
2993 NewDRD->setCombiner(Combiner);
3003 Expr *SubstCombiner =
nullptr;
3004 Expr *SubstInitializer =
nullptr;
3011 cast<DeclRefExpr>(NewDRD->getCombinerIn())->getDecl());
3014 cast<DeclRefExpr>(NewDRD->getCombinerOut())->getDecl());
3015 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(Owner);
3027 cast<DeclRefExpr>(NewDRD->getInitOrig())->getDecl());
3030 cast<DeclRefExpr>(NewDRD->getInitPriv())->getDecl());
3035 IsCorrect = IsCorrect && OmpPrivParm->
hasInit();
3038 NewDRD, SubstInitializer, OmpPrivParm);
3041 IsCorrect && SubstCombiner &&
3044 SubstInitializer) ||
3046 !SubstInitializer && !SubstInitializer));
3060 const bool RequiresInstantiation =
3066 if (RequiresInstantiation) {
3074 if (SubstMapperTy.
isNull())
3078 if (PrevDeclInScope && !PrevDeclInScope->isInvalidDecl()) {
3079 PrevDeclInScope = cast<OMPDeclareMapperDecl>(
3088 bool IsCorrect =
true;
3089 if (!RequiresInstantiation) {
3094 Clauses.push_back(
C);
3101 NewDMD,
nullptr, SubstMapperTy, D->
getLocation(), VN);
3105 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(Owner);
3110 auto *OldC = cast<OMPMapClause>(
C);
3112 for (
Expr *OE : OldC->varlists()) {
3118 NewVars.push_back(NE);
3126 SS.
Adopt(NewQualifierLoc);
3128 OldC->getMapperIdInfo(), TemplateArgs);
3132 OldC->getMapTypeModifiers(), OldC->getMapTypeModifiersLoc(), SS,
3133 NewNameInfo, OldC->getMapType(), OldC->isImplicitMapType(),
3134 OldC->getMapLoc(), OldC->getColonLoc(), NewVars, Locs);
3135 Clauses.push_back(NewC);
3146 Decl *TemplateDeclInstantiator::VisitOMPCapturedExprDecl(
3148 llvm_unreachable(
"Should not be met in templates");
3167 Decl *TemplateDeclInstantiator::VisitRecordDecl(
RecordDecl *D) {
3168 llvm_unreachable(
"There are only CXXRecordDecls in C++");
3172 TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl(
3179 "can only instantiate an explicit specialization " 3180 "for a member class template");
3187 if (!InstClassTemplate)
3193 castAs<TemplateSpecializationTypeLoc>();
3197 for (
unsigned I = 0; I != Loc.
getNumArgs(); ++I)
3199 if (SemaRef.
Subst(ArgLocs.data(), ArgLocs.size(),
3200 InstTemplateArgs, TemplateArgs))
3215 void *InsertPos =
nullptr;
3217 InstClassTemplate->findSpecialization(Converted, InsertPos);
3247 diag::note_previous_definition);
3255 D->
getLocation(), InstClassTemplate, Converted, PrevDecl);
3260 InstClassTemplate->AddSpecialization(InstD, InsertPos);
3310 assert(VarTemplate &&
3311 "A template specialization without specialized template?");
3316 if (!InstVarTemplate)
3325 TemplateArgsInfo.
size(), VarTemplateArgsInfo, TemplateArgs))
3331 VarTemplateArgsInfo,
false, Converted))
3335 void *InsertPos =
nullptr;
3349 InstVarTemplate, D, InsertPos, VarTemplateArgsInfo, Converted, PrevDecl);
3366 SemaRef.
Diag(D->
getLocation(), diag::err_variable_instantiates_to_function)
3384 StartingScope,
false, PrevDecl);
3390 llvm_unreachable(
"@defs is not supported in Objective-C++");
3397 "cannot instantiate %0 yet");
3404 Decl *TemplateDeclInstantiator::VisitConceptDecl(
ConceptDecl *D) {
3405 llvm_unreachable(
"Concept definitions cannot reside inside a template");
3409 llvm_unreachable(
"Unexpected decl");
3418 return Instantiator.
Visit(D);
3430 bool Invalid =
false;
3432 unsigned N = L->
size();
3436 for (
auto &
P : *L) {
3438 Params.push_back(D);
3447 Expr *
const UninstantiatedRequiresClause = L->getRequiresClause();
3451 L->getLAngleLoc(), Params,
3453 UninstantiatedRequiresClause);
3499 InstTemplateArgs, TemplateArgs))
3520 void *InsertPos =
nullptr;
3560 SemaRef.
Diag(PartialSpec->
getLocation(), diag::err_partial_spec_redeclared)
3562 SemaRef.
Diag(PrevDecl->
getLocation(), diag::note_prev_partial_spec_here)
3573 ClassTemplate, Converted, InstTemplateArgs, CanonType,
nullptr);
3586 ClassTemplate->AddPartialSpecialization(InstPartialSpec,
3588 return InstPartialSpec;
3626 InstTemplateArgs, TemplateArgs))
3633 InstTemplateArgs,
false, Converted))
3644 void *InsertPos =
nullptr;
3681 diag::err_var_partial_spec_redeclared)
3684 diag::note_var_prev_partial_spec_here);
3697 diag::err_variable_instantiates_to_function)
3721 VarTemplate->AddPartialSpecialization(InstPartialSpec,
nullptr);
3724 LateAttrs, Owner, StartingScope);
3726 return InstPartialSpec;
3733 assert(OldTInfo &&
"substituting function without type source info");
3734 assert(Params.empty() &&
"parameter vector is non-empty at start");
3739 ThisContext = cast<CXXRecordDecl>(Owner);
3740 ThisTypeQuals = Method->getMethodQualifiers();
3747 ThisContext, ThisTypeQuals);
3753 if (NewTInfo != OldTInfo) {
3757 unsigned NewIdx = 0;
3758 for (
unsigned OldIdx = 0, NumOldParams = OldProtoLoc.getNumParams();
3759 OldIdx != NumOldParams; ++OldIdx) {
3760 ParmVarDecl *OldParam = OldProtoLoc.getParam(OldIdx);
3765 NumArgumentsInExpansion =
3768 if (!NumArgumentsInExpansion) {
3772 Params.push_back(NewParam);
3777 for (
unsigned I = 0; I != *NumArgumentsInExpansion; ++I) {
3779 Params.push_back(NewParam);
3789 cast<FunctionProtoType>(OldProtoLoc.getType());
3790 for (
unsigned i = 0, i_end = OldProtoLoc.getNumParams();
i != i_end;
3800 cast_or_null<ParmVarDecl>(VisitParmVarDecl(OldParam));
3803 Params.push_back(Parm);
3820 TemplateArgs, ParamTypes, &Params,
3835 unsigned FParamIdx = 0;
3836 for (
unsigned I = 0, N = PatternDecl->
getNumParams(); I != N; ++I) {
3840 assert(FParamIdx < Function->getNumParams());
3867 if (NumArgumentsInExpansion) {
3870 for (
unsigned Arg = 0; Arg < *NumArgumentsInExpansion; ++Arg) {
3903 UpdateExceptionSpec(Decl,
EST_None);
3909 Diag(PointOfInstantiation, diag::err_exception_spec_cycle) << Decl;
3910 UpdateExceptionSpec(Decl,
EST_None);
3920 getTemplateInstantiationArgs(Decl,
nullptr,
true);
3925 UpdateExceptionSpec(Decl,
EST_None);
3959 if (ActiveInst.Kind == ActiveInstType::ExplicitTemplateArgumentSubstitution ||
3960 ActiveInst.Kind == ActiveInstType::DeducedTemplateArgumentSubstitution) {
3962 = dyn_cast<FunctionTemplateDecl>(ActiveInst.Entity)) {
3963 assert(FunTmpl->getTemplatedDecl() == Tmpl &&
3964 "Deduction from the wrong function template?");
3967 ActiveInst.Kind = ActiveInstType::TemplateInstantiation;
3968 ActiveInst.Entity = New;
3974 assert(Proto &&
"Function template without prototype?");
3998 assert(NewProto &&
"Template instantiation without function prototype?");
4016 LateAttrs, StartingScope);
4032 if (isa<CXXDestructorDecl>(New) && SemaRef.
getLangOpts().CPlusPlus11)
4056 *
this, Loc, FTD, Args->
asArray(),
4057 CodeSynthesisContext::ExplicitTemplateArgumentSubstitution, Info);
4058 if (Inst.isInvalid())
4064 return cast_or_null<FunctionDecl>(SubstDecl(FD, FD->
getParent(), MArgs));
4078 DLLExportAttr *
Attr = Ctor->
getAttr<DLLExportAttr>();
4081 for (
unsigned I = 0; I != NumParams; ++I) {
4108 bool DefinitionRequired,
4111 isa<CXXDeductionGuideDecl>(Function))
4123 assert(PatternDecl &&
"instantiating a non-template");
4126 Stmt *Pattern =
nullptr;
4128 Pattern = PatternDef->
getBody(PatternDef);
4129 PatternDecl = PatternDef;
4131 PatternDef =
nullptr;
4136 if (DiagnoseUninstantiableTemplate(PointOfInstantiation, Function,
4138 PatternDecl, PatternDef, TSK,
4139 DefinitionRequired)) {
4140 if (DefinitionRequired)
4147 PendingInstantiations.push_back(
4148 std::make_pair(Function, PointOfInstantiation));
4150 if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() &&
4151 !getSourceManager().isInSystemHeader(PatternDecl->
getBeginLoc())) {
4152 Diag(PointOfInstantiation, diag::warn_func_template_missing)
4155 if (getLangOpts().CPlusPlus11)
4156 Diag(PointOfInstantiation, diag::note_inst_declaration_hint)
4166 !LateTemplateParser) {
4168 LateParsedInstantiations.push_back(
4169 std::make_pair(Function, PointOfInstantiation));
4173 llvm::TimeTraceScope TimeScope(
"InstantiateFunction", [&]() {
4175 llvm::raw_string_ostream OS(Name);
4193 LateTemplateParser) {
4196 ExternalSource->ReadLateParsedTemplates(LateParsedTemplateMap);
4198 auto LPTIter = LateParsedTemplateMap.find(PatternDecl);
4199 assert(LPTIter != LateParsedTemplateMap.end() &&
4200 "missing LateParsedTemplate");
4201 LateTemplateParser(OpaqueParser, *LPTIter->second);
4202 Pattern = PatternDecl->
getBody(PatternDecl);
4208 "unexpected kind of function template definition");
4225 D->setImplicitlyInline();
4235 "instantiating function definition");
4251 bool MergeWithParentScope =
false;
4253 MergeWithParentScope = Rec->isLocalClass();
4258 SetDeclDefaulted(Function, PatternDecl->
getLocation());
4261 getTemplateInstantiationArgs(Function,
nullptr,
false, PatternDecl);
4269 ActOnStartOfFunctionDef(
nullptr, Function);
4281 ActOnSkippedFunctionBody(Function);
4286 InstantiateMemInitializers(Ctor, cast<CXXConstructorDecl>(PatternDecl),
4292 Ctor->isDefaultConstructor()) {
4298 Body = SubstStmt(Pattern, TemplateArgs);
4305 ActOnFinishFunctionBody(Function, Body.
get(),
true);
4307 PerformDependentDiagnostics(PatternDecl, TemplateArgs);
4309 if (
auto *Listener = getASTMutationListener())
4310 Listener->FunctionDefinitionInstantiated(Function);
4316 Consumer.HandleTopLevelDecl(DG);
4320 LocalInstantiations.
perform();
4322 GlobalInstantiations.perform();
4352 bool IsMemberSpec =
false;
4354 dyn_cast<VarTemplatePartialSpecializationDecl>(FromVar))
4355 IsMemberSpec = PartialSpec->isMemberSpecialization();
4357 IsMemberSpec = FromTemplate->isMemberSpecialization();
4367 return cast_or_null<VarTemplateSpecializationDecl>(
4368 Instantiator.VisitVarTemplateSpecializationDecl(
4369 VarTemplate, FromVar, InsertPos, TemplateArgsInfo, Converted));
4378 "don't have a definition to instantiate from");
4388 VarSpec->
setType(DI->getType());
4394 InstantiateVariableInitializer(VarSpec, PatternDecl, TemplateArgs);
4407 bool InstantiatingVarTemplate,
4411 bool InstantiatingVarTemplatePartialSpec =
4412 isa<VarTemplatePartialSpecializationDecl>(OldVar) &&
4413 isa<VarTemplatePartialSpecializationDecl>(NewVar);
4416 bool InstantiatingSpecFromTemplate =
4417 isa<VarTemplateSpecializationDecl>(NewVar) &&
4419 isa<VarTemplatePartialSpecializationDecl>(OldVar));
4442 if (OldVar->
isUsed(
false))
4447 InstantiateAttrs(TemplateArgs, OldVar, NewVar, LateAttrs, StartingScope);
4454 : forRedeclarationInCurContext());
4461 if (
NamedDecl *NewPrev = FindInstantiatedDecl(
4464 }
else if (!isa<VarTemplateSpecializationDecl>(NewVar) &&
4467 }
else if (PrevDeclForVarTemplateSpecialization) {
4468 Previous.addDecl(PrevDeclForVarTemplateSpecialization);
4470 CheckVariableDeclaration(NewVar,
Previous);
4472 if (!InstantiatingVarTemplate) {
4480 CurrentInstantiationScope->InstantiatedLocal(OldVar, NewVar);
4490 !InstantiatingSpecFromTemplate)
4497 dyn_cast<VarTemplateSpecializationDecl>(OldVar)) {
4499 !isa<VarTemplatePartialSpecializationDecl>(OldVTSD))
4500 cast<VarTemplateSpecializationDecl>(NewVar)->setSpecializationKind(
4509 if (InstantiatingVarTemplate || InstantiatingVarTemplatePartialSpec) {
4513 InstantiateVariableInitializer(NewVar, OldVar, TemplateArgs);
4514 }
else if (InstantiatingSpecFromTemplate ||
4521 InstantiateVariableInitializer(NewVar, OldVar, TemplateArgs);
4529 DiagnoseUnusedDecl(NewVar);
4537 L->VariableDefinitionInstantiated(Var);
4556 Init = SubstInitializer(OldVar->
getInit(), TemplateArgs,
4563 if (Var->
hasAttr<DLLImportAttr>() &&
4567 }
else if (InitExpr) {
4569 AddInitializerToDecl(Var, InitExpr, DirectInit);
4571 ActOnUninitializedDecl(Var);
4594 ActOnUninitializedDecl(Var);
4597 if (getLangOpts().CUDA)
4598 checkAllowedCUDAInitializer(Var);
4618 bool DefinitionRequired,
bool AtEndOfTU) {
4630 assert(PatternDecl &&
"no pattern for templated variable");
4632 getTemplateInstantiationArgs(Var);
4639 bool InstantiationDependent =
false;
4642 "Only instantiate variable template specializations that are " 4643 "not type-dependent");
4644 (void)InstantiationDependent;
4655 (PatternDecl = PatternDecl->
getFirstDecl())->hasInit() &&
4663 "instantiating variable initializer");
4680 InstantiateVariableInitializer(Var, PatternDecl, TemplateArgs);
4681 PreviousContext.pop();
4685 LocalInstantiations.
perform();
4687 GlobalInstantiations.
perform();
4691 "not a static data member?");
4700 if (!Def && !DefinitionRequired) {
4702 PendingInstantiations.push_back(
4703 std::make_pair(Var, PointOfInstantiation));
4706 if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() &&
4707 !getSourceManager().isInSystemHeader(PatternDecl->
getBeginLoc())) {
4708 Diag(PointOfInstantiation, diag::warn_var_template_missing)
4711 if (getLangOpts().CPlusPlus11)
4712 Diag(PointOfInstantiation, diag::note_inst_declaration_hint) << Var;
4721 if (DiagnoseUninstantiableTemplate(PointOfInstantiation, Var,
4723 PatternDecl, Def, TSK,
4724 DefinitionRequired))
4741 struct PassToConsumerRAII {
4746 : Consumer(Consumer), Var(Var) { }
4748 ~PassToConsumerRAII() {
4751 } PassToConsumerRAII(Consumer, Var);
4758 PointOfInstantiation);
4766 "instantiating variable definition");
4782 if (Def->isStaticDataMember() && !Def->isOutOfLine()) {
4785 InstantiateVariableInitializer(Var, Def, TemplateArgs);
4786 }
else if (!VarSpec) {
4787 Var = cast_or_null<VarDecl>(SubstDecl(Def, Var->
getDeclContext(),
4796 Var = cast_or_null<VarDecl>(Instantiator.VisitVarTemplateSpecializationDecl(
4805 cast<VarTemplateSpecializationDecl>(Var)->setInstantiationOf(
4809 LookupResult R(*
this, Var->getDeclName(), Var->getLocation(),
4810 LookupOrdinaryName, forRedeclarationInCurContext());
4812 MergeVarDecl(Var, R);
4815 InstantiateVariableInitializer(Var, Def, TemplateArgs);
4820 Var = CompleteVarTemplateSpecializationDecl(VarSpec, Def, TemplateArgs);
4822 PreviousContext.pop();
4825 PassToConsumerRAII.Var = Var;
4832 LocalInstantiations.
perform();
4834 GlobalInstantiations.
perform();
4846 for (
const auto *Init : Tmpl->
inits()) {
4849 if (!Init->isWritten())
4854 if (Init->isPackExpansion()) {
4856 TypeLoc BaseTL = Init->getTypeSourceInfo()->getTypeLoc();
4860 bool ShouldExpand =
false;
4861 bool RetainExpansion =
false;
4863 if (CheckParameterPacksForExpansion(Init->getEllipsisLoc(),
4866 TemplateArgs, ShouldExpand,
4873 assert(ShouldExpand &&
"Partial instantiation of base initializer?");
4876 for (
unsigned I = 0; I != *NumExpansions; ++I) {
4880 ExprResult TempInit = SubstInitializer(Init->getInit(), TemplateArgs,
4890 Init->getSourceLocation(),
4899 BaseTInfo, TempInit.
get(),
4907 NewInits.push_back(NewInit.
get());
4914 ExprResult TempInit = SubstInitializer(Init->getInit(), TemplateArgs,
4922 if (Init->isDelegatingInitializer() || Init->isBaseInitializer()) {
4925 Init->getSourceLocation(),
4933 if (Init->isBaseInitializer())
4934 NewInit = BuildBaseInitializer(TInfo->
getType(), TInfo, TempInit.
get(),
4937 NewInit = BuildDelegatingInitializer(TInfo, TempInit.
get(),
4938 cast<CXXRecordDecl>(CurContext->getParent()));
4939 }
else if (Init->isMemberInitializer()) {
4940 FieldDecl *Member = cast_or_null<FieldDecl>(FindInstantiatedDecl(
4941 Init->getMemberLocation(),
4950 NewInit = BuildMemberInitializer(Member, TempInit.
get(),
4951 Init->getSourceLocation());
4952 }
else if (Init->isIndirectMemberInitializer()) {
4954 cast_or_null<IndirectFieldDecl>(FindInstantiatedDecl(
4955 Init->getMemberLocation(),
4956 Init->getIndirectMember(), TemplateArgs));
4958 if (!IndirectMember) {
4964 NewInit = BuildMemberInitializer(IndirectMember, TempInit.
get(),
4965 Init->getSourceLocation());
4972 NewInits.push_back(NewInit.
get());
4977 ActOnMemInitializers(New,
4992 if (Pattern == Instance)
return true;
5005 if (Pattern == Instance)
return true;
5016 = cast<ClassTemplatePartialSpecializationDecl>(Pattern->
getCanonicalDecl());
5018 Instance = cast<ClassTemplatePartialSpecializationDecl>(
5020 if (Pattern == Instance)
5034 if (Pattern == Instance)
return true;
5047 if (Pattern == Instance)
return true;
5060 if (Pattern == Instance)
return true;
5079 template<
typename T>
5088 bool OtherIsPackExpansion;
5090 if (
auto *OtherUUD = dyn_cast<T>(Other)) {
5091 OtherIsPackExpansion = OtherUUD->isPackExpansion();
5093 }
else if (
auto *OtherUPD = dyn_cast<UsingPackDecl>(Other)) {
5094 OtherIsPackExpansion =
true;
5095 OtherFrom = OtherUPD->getInstantiatedFromUsingDecl();
5096 }
else if (
auto *OtherUD = dyn_cast<UsingDecl>(Other)) {
5097 OtherIsPackExpansion =
false;
5102 return Pattern->isPackExpansion() == OtherIsPackExpansion &&
5114 if (Pattern == Instance)
return true;
5124 if (
auto *UUD = dyn_cast<UnresolvedUsingTypenameDecl>(D))
5127 if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(D))
5133 if (
auto *Record = dyn_cast<CXXRecordDecl>(Other))
5136 if (
auto *Function = dyn_cast<FunctionDecl>(Other))
5139 if (
auto *Enum = dyn_cast<EnumDecl>(Other))
5142 if (
auto *Var = dyn_cast<VarDecl>(Other))
5143 if (Var->isStaticDataMember())
5146 if (
auto *Temp = dyn_cast<ClassTemplateDecl>(Other))
5149 if (
auto *Temp = dyn_cast<FunctionTemplateDecl>(Other))
5152 if (
auto *PartialSpec =
5153 dyn_cast<ClassTemplatePartialSpecializationDecl>(Other))
5157 if (
auto *Field = dyn_cast<FieldDecl>(Other)) {
5158 if (!Field->getDeclName()) {
5161 cast<FieldDecl>(D));
5165 if (
auto *Using = dyn_cast<UsingDecl>(Other))
5168 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(Other))
5172 D->
getDeclName() == cast<NamedDecl>(Other)->getDeclName();
5175 template<
typename ForwardIterator>
5178 ForwardIterator first,
5179 ForwardIterator last) {
5180 for (; first != last; ++first)
5182 return cast<NamedDecl>(*first);
5193 if (
NamedDecl *D = dyn_cast<NamedDecl>(DC)) {
5194 Decl*
ID = FindInstantiatedDecl(Loc, D, TemplateArgs,
true);
5195 return cast_or_null<DeclContext>(
ID);
5227 bool FindingInstantiatedContext) {
5246 !cast<ParmVarDecl>(D)->getType()->isInstantiationDependentType())
5248 if (isa<ParmVarDecl>(D) || isa<NonTypeTemplateParmDecl>(D) ||
5249 isa<TemplateTypeParmDecl>(D) || isa<TemplateTemplateParmDecl>(D) ||
5251 isa<OMPDeclareReductionDecl>(ParentDC) ||
5252 isa<OMPDeclareMapperDecl>(ParentDC)) &&
5254 (isa<CXXRecordDecl>(D) && cast<CXXRecordDecl>(D)->isLambda())) {
5257 if (CurrentInstantiationScope) {
5258 if (
auto Found = CurrentInstantiationScope->findInstantiationOf(D)) {
5259 if (Decl *FD = Found->dyn_cast<Decl *>())
5260 return cast<NamedDecl>(FD);
5262 int PackIdx = ArgumentPackSubstitutionIndex;
5263 assert(PackIdx != -1 &&
5264 "found declaration pack but not pack expanding");
5266 return cast<NamedDecl>((*Found->get<DeclArgumentPack *>())[PackIdx]);
5273 if (isa<NonTypeTemplateParmDecl>(D) || isa<TemplateTypeParmDecl>(D) ||
5274 isa<TemplateTemplateParmDecl>(D))
5293 bool NeedInstantiate =
false;
5295 NeedInstantiate = RD->isLocalClass();
5297 NeedInstantiate = isa<EnumDecl>(D);
5298 if (NeedInstantiate) {
5299 Decl *Inst = SubstDecl(D, CurContext, TemplateArgs);
5300 CurrentInstantiationScope->InstantiatedLocal(D, Inst);
5301 return cast<TypeDecl>(Inst);
5306 assert(isa<LabelDecl>(D));
5308 Decl *Inst = SubstDecl(D, CurContext, TemplateArgs);
5309 assert(Inst &&
"Failed to instantiate label??");
5311 CurrentInstantiationScope->InstantiatedLocal(D, Inst);
5312 return cast<LabelDecl>(Inst);
5318 dyn_cast<VarTemplateSpecializationDecl>(D)) {
5319 bool InstantiationDependent =
false;
5321 VarSpec->getTemplateArgsInfo();
5323 VarTemplateArgs, InstantiationDependent))
5324 D = cast<NamedDecl>(
5330 if (!Record->isDependentContext())
5339 = dyn_cast<ClassTemplatePartialSpecializationDecl>(Record))
5351 if (
CXXRecordDecl *InstRecord = dyn_cast<CXXRecordDecl>(DC)) {
5355 = dyn_cast<ClassTemplateSpecializationDecl>(InstRecord)){
5368 if (FD->getFriendObjectKind() && FD->getDeclContext()->isFileContext()){
5369 DC = FD->getLexicalDeclContext();
5375 if (Guide && Guide->isImplicit()) {
5383 Unpacked = Arg.pack_elements();
5386 getTrivialTemplateArgumentLoc(UnpackedArg,
QualType(), Loc));
5392 assert(SubstRecord &&
"class template id not a class type?");
5398 if (FindingInstantiatedContext &&
5399 usesPartialOrExplicitSpecialization(
5400 Loc, cast<ClassTemplateSpecializationDecl>(SubstRecord))) {
5401 Diag(Loc, diag::err_specialization_not_primary_template)
5402 << T << (SubstRecord->getTemplateSpecializationKind() ==
5421 ParentDC = FindInstantiatedContext(Loc, ParentDC, TemplateArgs);
5432 bool IsBeingInstantiated =
false;
5433 if (
CXXRecordDecl *Spec = dyn_cast<CXXRecordDecl>(ParentDC)) {
5434 if (!Spec->isDependentContext()) {
5437 assert(Tag &&
"type of non-dependent record is not a RecordType");
5439 IsBeingInstantiated =
true;
5441 RequireCompleteType(Loc, T, diag::err_incomplete_type))
5453 Name = SubstDeclarationNameInfo(NameInfo, TemplateArgs).getName();
5473 if (isa<UsingShadowDecl>(D)) {
5475 }
else if (Diags.hasErrorOccurred()) {
5479 }
else if (IsBeingInstantiated) {
5485 Diag(Loc, diag::err_member_not_yet_instantiated)
5493 EnumDecl *Enum = cast<EnumDecl>(ED->getLexicalDeclContext());
5494 EnumDecl *Spec = cast<EnumDecl>(FindInstantiatedDecl(Loc, Enum,
5496 assert(Spec->getTemplateSpecializationKind() ==
5498 Diag(Loc, diag::err_enumerator_does_not_exist)
5501 Diag(Spec->getLocation(), diag::note_enum_specialized_here)
5505 llvm_unreachable(
"Unable to find instantiation of declaration!");
5518 while (!PendingLocalImplicitInstantiations.empty() ||
5519 (!LocalOnly && !PendingInstantiations.empty())) {
5522 if (PendingLocalImplicitInstantiations.empty()) {
5523 Inst = PendingInstantiations.front();
5524 PendingInstantiations.pop_front();
5526 Inst = PendingLocalImplicitInstantiations.front();
5527 PendingLocalImplicitInstantiations.pop_front();
5531 if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(Inst.first)) {
5532 bool DefinitionRequired = Function->getTemplateSpecializationKind() ==
5534 if (Function->isMultiVersion()) {
5535 getASTContext().forEachMultiversionedFunctionVersion(
5536 Function, [
this, Inst, DefinitionRequired](
FunctionDecl *CurFD) {
5537 InstantiateFunctionDefinition( Inst.second, CurFD,
true,
5538 DefinitionRequired,
true);
5543 InstantiateFunctionDefinition( Inst.second, Function,
true,
5544 DefinitionRequired,
true);
5545 if (Function->isDefined())
5546 Function->setInstantiationIsPending(
false);
5552 VarDecl *Var = cast<VarDecl>(Inst.first);
5555 isa<VarTemplateSpecializationDecl>(Var)) &&
5556 "Not a static data member, nor a variable template" 5557 " specialization?");
5569 llvm_unreachable(
"Cannot instantitiate an undeclared specialization.");
5584 "instantiating variable definition");
5590 InstantiateVariableDefinition( Inst.second, Var,
true,
5591 DefinitionRequired,
true);
5597 for (
auto DD : Pattern->
ddiags()) {
5598 switch (DD->getKind()) {
5600 HandleDependentAccessCheck(*DD, TemplateArgs);
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
clauselist_range clauselists()
The lookup results will be used for redeclaration of a name with external linkage; non-visible lookup...
Defines the clang::ASTContext interface.
FunctionDecl * getDefinition()
Get the definition for this declaration.
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 ...
static void collectUnexpandedParameterPacks(Sema &S, TemplateParameterList *Params, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
bool mightBeUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value might be usable in a constant expression, according to the re...
void setImplicit(bool I=true)
Represents a function declaration or definition.
NamespaceDecl * getStdNamespace() const
OMPDeclareMapperDecl * getPrevDeclInScope()
Get reference to previous declare mapper construct in the same scope with the same name...
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.
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=CSK_unspecified)
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
no exception specification
OMPDeclareMapperDecl * ActOnOpenMPDeclareMapperDirectiveStart(Scope *S, DeclContext *DC, DeclarationName Name, QualType MapperType, SourceLocation StartLoc, DeclarationName VN, AccessSpecifier AS, Decl *PrevDeclInScope=nullptr)
Called on start of '#pragma omp declare mapper'.
virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *D)
HandleCXXStaticMemberVarInstantiation - Tell the consumer that this.
bool TemplateParameterListsAreEqual(TemplateParameterList *New, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
void InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
A (possibly-)qualified type.
void ActOnOpenMPDeclareReductionCombinerStart(Scope *S, Decl *D)
Initialize declare reduction construct initializer.
const char * getDeclKindName() const
void InstantiatedLocal(const Decl *D, Decl *Inst)
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
Decl * VisitVarDecl(VarDecl *D, bool InstantiatingVarTemplate, ArrayRef< BindingDecl *> *Bindings=nullptr)
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
Decl * VisitCXXMethodDecl(CXXMethodDecl *D, TemplateParameterList *TemplateParams, Optional< const ASTTemplateArgumentListInfo *> ClassScopeSpecializationArgs=llvm::None)
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
A stack-allocated class that identifies which local variable declaration instantiations are present i...
const TypeClass * getTypePtr() const
void InstantiateExceptionSpec(SourceLocation PointOfInstantiation, FunctionDecl *Function)
void EndOpenMPDSABlock(Stmt *CurDirective)
Called on end of data sharing attribute block.
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained)...
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
FunctionDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
SourceRange getBraceRange() const
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
static void instantiateDependentAllocAlignAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AllocAlignAttr *Align, Decl *New)
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
NestedNameSpecifierLoc getTemplateQualifierLoc() const
void addOuterTemplateArguments(const TemplateArgumentList *TemplateArgs)
Add a new outermost level to the multi-level template argument list.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Expr * getUnderlyingExpr() const
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, llvm::MutableArrayRef< NamedDecl *> CH)
Stmt - This represents one statement.
Expr * getBitWidth() const
We are matching the template parameter lists of two templates that might be redeclarations.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
This represents '#pragma omp allocate ...' directive.
const ASTTemplateArgumentListInfo * getTemplateSpecializationArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
Provides information about an attempted template argument deduction, whose success or failure was des...
static bool isDeclWithinFunction(const Decl *D)
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
void AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, unsigned SpellingListIndex, bool IsPackExpansion)
AddAlignedAttr - Adds an aligned attribute to a particular declaration.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function...
An instance of this object exists for each enum constant that is defined.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
Represents the declaration of a typedef-name via the 'typedef' type specifier.
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...
void AddAllocAlignAttr(SourceRange AttrRange, Decl *D, Expr *ParamExpr, unsigned SpellingListIndex)
AddAllocAlignAttr - Adds an alloc_align attribute to a particular declaration.
VarTemplateSpecializationDecl * BuildVarTemplateInstantiation(VarTemplateDecl *VarTemplate, VarDecl *FromVar, const TemplateArgumentList &TemplateArgList, const TemplateArgumentListInfo &TemplateArgsInfo, SmallVectorImpl< TemplateArgument > &Converted, SourceLocation PointOfInstantiation, void *InsertPos, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *StartingScope=nullptr)
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params)
bool isSingleTagDecl() const
Asks if the result is a single tag decl.
NamedDecl * BuildUsingDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS, DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList, bool IsInstantiation)
Builds a using declaration.
const Type * getTypeForDecl() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
void setRangeEnd(SourceLocation E)
SourceLocation getBeginLoc() const LLVM_READONLY
static Expr * instantiateDependentFunctionAttrCondition(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const Attr *A, Expr *OldCond, const Decl *Tmpl, FunctionDecl *New)
IdentifierInfo * getGetterId() const
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
ThreadStorageClassSpecifier getTSCSpec() const
llvm::PointerUnion< Decl *, DeclArgumentPack * > * findInstantiationOf(const Decl *D)
Find the instantiation of the declaration D within the current instantiation scope.
Defines the C++ template declaration subclasses.
bool hasWrittenPrototype() const
Whether this function has a written prototype.
Decl * VisitVarTemplateSpecializationDecl(VarTemplateDecl *VarTemplate, VarDecl *FromVar, void *InsertPos, const TemplateArgumentListInfo &TemplateArgsInfo, ArrayRef< TemplateArgument > Converted, VarTemplateSpecializationDecl *PrevDecl=nullptr)
Decl * InstantiateTypedefNameDecl(TypedefNameDecl *D, bool IsTypeAlias)
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
FunctionDecl * InstantiateFunctionDeclaration(FunctionTemplateDecl *FTD, const TemplateArgumentList *Args, SourceLocation Loc)
Instantiate (or find existing instantiation of) a function template with a given set of template argu...
SourceLocation getColonLoc() const
The location of the colon following the access specifier.
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement...
ExplicitSpecKind getKind() const
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
Declaration of a variable template.
void ActOnOpenMPDeclareMapperDirectiveVarDecl(OMPDeclareMapperDecl *DMD, Scope *S, QualType MapperType, SourceLocation StartLoc, DeclarationName VN)
Build the mapper variable of '#pragma omp declare mapper'.
Represent a C++ namespace.
SourceLocation getEndLoc() const LLVM_READONLY
const TargetInfo & getTargetInfo() const
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
A container of type source information.
Store information needed for an explicit specifier.
Wrapper for void* pointer.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
std::pair< ValueDecl *, SourceLocation > PendingImplicitInstantiation
An entity for which implicit template instantiation is required.
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field)
clauselist_iterator clauselist_begin()
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
bool isDefined(const FunctionDecl *&Definition) const
Returns true if the function has a definition that does not need to be instantiated.
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
Appends a human-readable name for this declaration into the given stream.
void setInitStyle(InitializationStyle Style)
VarTemplatePartialSpecializationDecl * InstantiateVarTemplatePartialSpecialization(VarTemplateDecl *VarTemplate, VarTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a variable template partial specialization.
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs, SmallVectorImpl< TemplateArgument > &Converted, bool UpdateArgsWithConversions=true)
Check that the given template arguments can be be provided to the given template, converting the argu...
Represents a C++ constructor within a class.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
TemplateName SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs)
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
Instantiate or parse a C++ default argument expression as necessary.
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3)
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
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.
static void instantiateDependentEnableIfAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const EnableIfAttr *EIA, const Decl *Tmpl, FunctionDecl *New)
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
void AddModeAttr(SourceRange AttrRange, Decl *D, IdentifierInfo *Name, unsigned SpellingListIndex, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
NamedDecl * BuildUsingPackDecl(NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl *> Expansions)
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
void setRAngleLoc(SourceLocation Loc)
unsigned getDepth() const
Get the nesting depth of the template parameter.
enumerator_range enumerators() const
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
RAII object that enters a new expression evaluation context.
Represents a variable declaration or definition.
QualType getReturnType() const
bool SubstQualifier(const DeclaratorDecl *OldDecl, DeclaratorDecl *NewDecl)
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
static void instantiateDependentAlignedAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AlignedAttr *Aligned, Decl *New, bool IsPackExpansion)
const T * getAs() const
Member-template getAs<specific type>'.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
Extra information about a function prototype.
Declaration context for names declared as extern "C" in C++.
static MSPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL, IdentifierInfo *Getter, IdentifierInfo *Setter)
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.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
static void instantiateDependentCUDALaunchBoundsAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const CUDALaunchBoundsAttr &Attr, Decl *New)
bool isInvalidDecl() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
static void instantiateDependentAssumeAlignedAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AssumeAlignedAttr *Aligned, Decl *New)
Look up an ordinary name that is going to be redeclared as a name with linkage.
Represents a parameter to a function.
static AccessSpecDecl * Create(ASTContext &C, AccessSpecifier AS, DeclContext *DC, SourceLocation ASLoc, SourceLocation ColonLoc)
Defines the clang::Expr interface and subclasses for C++ expressions.
Provides information about a dependent function-template specialization declaration.
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
The collection of all-type qualifiers we support.
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation)
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
DeclGroupPtrTy ActOnOpenMPDeclareReductionDirectiveStart(Scope *S, DeclContext *DC, DeclarationName Name, ArrayRef< std::pair< QualType, SourceLocation >> ReductionTypes, AccessSpecifier AS, Decl *PrevDeclInScope=nullptr)
Called on start of '#pragma omp declare reduction'.
DeclGroupPtrTy ActOnOpenMPDeclareSimdDirective(DeclGroupPtrTy DG, OMPDeclareSimdDeclAttr::BranchStateTy BS, Expr *Simdlen, ArrayRef< Expr *> Uniforms, ArrayRef< Expr *> Aligneds, ArrayRef< Expr *> Alignments, ArrayRef< Expr *> Linears, ArrayRef< unsigned > LinModifiers, ArrayRef< Expr *> Steps, SourceRange SR)
Called on well-formed '#pragma omp declare simd' after parsing of the associated method/function.
void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T)
Mark all of the declarations referenced within a particular AST node as referenced.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
bool isLexicallyWithinFunctionOrMethod() const
Returns true if this declaration lexically is inside a function.
Base wrapper for a particular "section" of type source info.
AccessResult CheckFriendAccess(NamedDecl *D)
Checks access to the target of a friend declaration.
Represents a struct/union/class.
bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename, const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, SourceLocation NameLoc)
Checks that the given nested-name qualifier used in a using decl in the current context is appropriat...
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists...
FunctionType::ExtInfo ExtInfo
Represents a class template specialization, which refers to a class template with a given set of temp...
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
unsigned getDepth() const
Retrieve the depth of the template parameter.
StringLiteral * getMessage()
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
DeclGroupPtrTy ActOnOpenMPDeclareMapperDirectiveEnd(OMPDeclareMapperDecl *D, Scope *S, ArrayRef< OMPClause *> ClauseList)
Called at the end of '#pragma omp declare mapper'.
void setManglingNumber(const NamedDecl *ND, unsigned Number)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifierLoc SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const MultiLevelTemplateArgumentList &TemplateArgs)
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
ArrayRef< QualType > getParamTypes() const
The results of name lookup within a DeclContext.
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
ConstexprSpecKind getConstexprKind() const
void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl)
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
void setObjCForDecl(bool FRD)
NameKind getNameKind() const
Determine what kind of name this is.
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
static DecompositionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation LSquareLoc, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< BindingDecl *> Bindings)
bool hasSkippedBody() const
True if the function was a definition but its body was skipped.
Represents a member of a struct/union/class.
The current expression is potentially evaluated at run time, which means that code may be generated t...
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
unsigned getStaticLocalNumber(const VarDecl *VD) const
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible...
void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern)
Remember that the using decl Inst is an instantiation of the using decl Pattern of a class template...
void startDefinition()
Starts the definition of this tag declaration.
void StartOpenMPDSABlock(OpenMPDirectiveKind K, const DeclarationNameInfo &DirName, Scope *CurScope, SourceLocation Loc)
Called on start of new data sharing attribute block.
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
bool isReferenceType() const
InitKind getInitializerKind() const
Get initializer kind.
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
bool isInIdentifierNamespace(unsigned NS) const
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
ParmVarDecl * getParam(unsigned i) const
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
QualType ActOnOpenMPDeclareMapperType(SourceLocation TyLoc, TypeResult ParsedType)
Check if the specified type is allowed to be used in 'omp declare mapper' construct.
void Exit()
Exit this local instantiation scope early.
bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand, bool &RetainExpansion, Optional< unsigned > &NumExpansions)
Determine whether we could expand a pack expansion with the given set of parameter packs into separat...
Represents an access specifier followed by colon ':'.
DeclarationNameInfo SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo, const MultiLevelTemplateArgumentList &TemplateArgs)
Do template substitution on declaration name info.
SourceLocation getBeginLoc() const LLVM_READONLY
Declaration of a function specialization at template class scope.
static void instantiateDependentAMDGPUWavesPerEUAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AMDGPUWavesPerEUAttr &Attr, Decl *New)
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
TypeSourceInfo * getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &Args, QualType Canon=QualType()) const
ArrayRef< ParmVarDecl * > parameters() const
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
void InstantiateMemInitializers(CXXConstructorDecl *New, const CXXConstructorDecl *Tmpl, const MultiLevelTemplateArgumentList &TemplateArgs)
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
SourceLocation getLAngleLoc() const
Expr * getMapperVarRef()
Get the variable declared in the mapper.
Represents a C++ using-declaration.
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
ArrayRef< BindingDecl * > bindings() const
static void instantiateDependentDiagnoseIfAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const DiagnoseIfAttr *DIA, const Decl *Tmpl, FunctionDecl *New)
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
static CXXDeductionGuideDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation)
Represents the results of name lookup.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
TagKind getTagKind() const
bool isReferenced() const
Whether any declaration of this entity was referenced.
A convenient class for passing around template argument information.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
Look up all declarations in a scope with the given name, including resolved using declarations...
bool CheckUsingShadowDecl(UsingDecl *UD, NamedDecl *Target, const LookupResult &PreviousDecls, UsingShadowDecl *&PrevShadow)
Determines whether to create a using shadow decl for a particular decl, given the set of decls existi...
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
ArrayRef< NamedDecl * > chain() const
bool InitFunctionInstantiation(FunctionDecl *New, FunctionDecl *Tmpl)
Initializes the common fields of an instantiation function declaration (New) from the corresponding f...
SourceLocation getBeginLoc() const LLVM_READONLY
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack)
void PerformPendingInstantiations(bool LocalOnly=false)
Performs template instantiation for all implicit template instantiations we have seen until this poin...
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
void setInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *PartialSpec)
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
const TemplateArgumentLoc * getArgumentArray() const
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
void setSpecializationKind(TemplateSpecializationKind TSK)
Scope - A scope is a transient data structure that is used while parsing the program.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type...
Represents a C++ nested-name-specifier or a global scope specifier.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New)
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
const LangOptions & getLangOpts() const
static NamespaceAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Namespace)
TemplateArgumentLoc getArgLoc(unsigned i) const
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'.
void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization, retrieves the function from which it was instantiated.
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor())
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
SourceLocation getTypeSpecStartLoc() const
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
void CheckStaticLocalForDllExport(VarDecl *VD)
Check if VD needs to be dllexport/dllimport due to being in a dllexport/import function.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
unsigned getNumArgs() const
A binding in a decomposition declaration.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization, retrieves the member specialization information.
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
RAII object used to change the argument pack substitution index within a Sema object.
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
UsingShadowDecl * BuildUsingShadowDecl(Scope *S, UsingDecl *UD, NamedDecl *Target, UsingShadowDecl *PrevDecl)
Builds a shadow declaration corresponding to a 'using' declaration.
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.
A helper class for building up ExtParameterInfos.
VarDecl * ActOnOpenMPDeclareReductionInitializerStart(Scope *S, Decl *D)
Initialize declare reduction construct initializer.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
SourceLocation getRParenLoc() const
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
DiagnosticsEngine & getDiagnostics() const
void MakeInstantiatedLocalArgPack(const Decl *D)
TypeSourceInfo * SubstFunctionDeclType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals)
A form of SubstType intended specifically for instantiating the type of a FunctionDecl.
Sema - This implements semantic analysis and AST building for C.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
Represents a prototype with parameter type info, e.g.
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
bool inferObjCARCLifetime(ValueDecl *decl)
Represents a ValueDecl that came out of a declarator.
DeclarationNameTable DeclarationNames
bool CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, TemplateSpecializationKind NewTSK, NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK, SourceLocation PrevPtOfInstantiation, bool &SuppressNew)
Diagnose cases where we have an explicit template specialization before/after an explicit template in...
static QualType adjustFunctionTypeForInstantiation(ASTContext &Context, FunctionDecl *D, TypeSourceInfo *TInfo)
Adjust the given function type for an instantiation of the given declaration, to cope with modificati...
DeclarationName getVarName()
Get the name of the variable declared in the mapper.
unsigned getNumSubstitutedLevels() const
Determine the number of substituted levels in this template argument list.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
bool isInlineSpecified() const
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
TypeSourceInfo * getTypeSourceInfo() const
This represents '#pragma omp requires...' directive.
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isImplicitlyDeclared)
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
void CheckAlignasUnderalignment(Decl *D)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
static CXXConversionDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, ExplicitSpecifier ES, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation)
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, Optional< unsigned > NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
This represents one expression.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
void setCompleteDefinition()
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern)
unsigned getChainingSize() const
SourceLocation getAliasLoc() const
Returns the location of the alias name, i.e.
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos, QualType CanonInjectedType, ClassTemplatePartialSpecializationDecl *PrevDecl)
bool isDefaulted() const
Whether this function is defaulted per C++0x.
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
void ActOnOpenMPDeclareReductionCombinerEnd(Decl *D, Expr *Combiner)
Finish current declare reduction construct initializer.
Declaration of a template type parameter.
OMPThreadPrivateDecl * CheckOMPThreadPrivateDecl(SourceLocation Loc, ArrayRef< Expr *> VarList)
Builds a new OpenMPThreadPrivateDecl and checks its correctness.
ClassTemplatePartialSpecializationDecl * InstantiateClassTemplatePartialSpecialization(ClassTemplateDecl *ClassTemplate, ClassTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a class template partial specialization.
DeclarationNameInfo getNameInfo() const
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
void setHideTags(bool Hide)
Sets whether tag declarations should be hidden by non-tag declarations during resolution.
void PerformDependentDiagnostics(const DeclContext *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
OMPDeclareReductionDecl * getPrevDeclInScope()
Get reference to previous declare reduction construct in the same scope with the same name...
const T * castAs() const
Member-template castAs<specific type>.
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
static DeclT * getPreviousDeclForInstantiation(DeclT *D)
Get the previous declaration of a declaration for the purposes of template instantiation.
Represents a C++ destructor within a class.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
bool CheckInheritingConstructorUsingDecl(UsingDecl *UD)
Additional checks for a using declaration referring to a constructor name.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage.
bool isFileContext() const
TemplateParameterList * getTemplateParameterList(unsigned index) const
ParmVarDecl * SubstParmVarDecl(ParmVarDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, Optional< unsigned > NumExpansions, bool ExpectParameterPack)
DeclContext * getDeclContext()
CXXRecordDecl * getDefinition() const
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
SourceLocation getEllipsisLoc() const
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
Represents the type decltype(expr) (C++11).
const Expr * getExpr() const
EnumDecl * getDefinition() const
static void InstantiateDefaultCtorDefaultArgs(Sema &S, CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
Defines the clang::TypeLoc interface and its subclasses.
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
void DiscardCleanupsInEvaluationContext()
VarDecl * getTemplateInstantiationPattern() const
Retrieve the variable declaration from which this variable could be instantiated, if it is an instant...
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
void setConstexpr(bool IC)
FieldDecl * CheckFieldDecl(DeclarationName Name, QualType T, TypeSourceInfo *TInfo, RecordDecl *Record, SourceLocation Loc, bool Mutable, Expr *BitfieldWidth, InClassInitStyle InitStyle, SourceLocation TSSL, AccessSpecifier AS, NamedDecl *PrevDecl, Declarator *D=nullptr)
Build a new FieldDecl and check its well-formedness.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
bool isFunctionOrMethod() const
bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, bool IsFixed, const EnumDecl *Prev)
Check whether this is a valid redeclaration of a previous enumeration.
StorageClass
Storage classes.
IdentifierInfo * getSetterId() const
Declaration of an alias template.
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Data structure that captures multiple levels of template argument lists for use in template instantia...
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc)
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
QualType getRecordType(const RecordDecl *Decl) const
SourceLocation getEnd() const
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
clauselist_range clauselists()
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
void setLocation(SourceLocation L)
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Expr * getInitPriv()
Get Priv variable of the initializer.
NamedDecl * getInstantiatedFromUsingDecl(NamedDecl *Inst)
If the given using decl Inst is an instantiation of a (possibly unresolved) using decl from a templat...
Represents a C++ deduction guide declaration.
void setDescribedClassTemplate(ClassTemplateDecl *Template)
Represents a C++ conversion function within a class.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
The result type of a method or function.
This template specialization was implicitly instantiated from a template.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
static StringRef getIdentifier(const Token &Tok)
void AddAlignValueAttr(SourceRange AttrRange, Decl *D, Expr *E, unsigned SpellingListIndex)
AddAlignValueAttr - Adds an align_value attribute to a particular declaration.
static void instantiateOMPDeclareSimdDeclAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const OMPDeclareSimdDeclAttr &Attr, Decl *New)
Instantiation of 'declare simd' attribute and its arguments.
static void instantiateDependentModeAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const ModeAttr &Attr, Decl *New)
DeclContext * FindInstantiatedContext(SourceLocation Loc, DeclContext *DC, const MultiLevelTemplateArgumentList &TemplateArgs)
Finds the instantiation of the given declaration context within the current instantiation.
TypeSourceInfo * SubstFunctionType(FunctionDecl *D, SmallVectorImpl< ParmVarDecl *> &Params)
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
NamedDecl * FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, bool FindingInstantiatedContext=false)
Find the instantiation of the given declaration within the current instantiation. ...
bool isDirectInit() const
Whether the initializer is a direct-initializer (list or call).
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
Attr * instantiateTemplateAttribute(const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
RecordDecl * getDecl() const
TypeSourceInfo * getExpansionTypeSourceInfo(unsigned I) const
Retrieve a particular expansion type source info within an expanded parameter pack.
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr, SkipBodyInfo *SkipBody=nullptr)
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
TypeLoc getPatternLoc() const
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...
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
ExceptionSpecificationType Type
The kind of exception specification this is.
TypeLoc IgnoreParens() const
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
A stack object to be created when performing template instantiation.
ExtProtoInfo getExtProtoInfo() const
Attr * instantiateTemplateAttributeForDecl(const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
bool Subst(const TemplateArgumentLoc *Args, unsigned NumArgs, TemplateArgumentListInfo &Result, const MultiLevelTemplateArgumentList &TemplateArgs)
ClassTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *D)
Find a class template partial specialization which was instantiated from the given member partial spe...
ASTContext & getASTContext() const
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList *> FriendTypeTPLists=None)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
bool isParameterPack() const
Returns whether this is a parameter pack.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
QualType getReturnType() const
bool isPure() const
Whether this virtual function is pure, i.e.
void atTemplateBegin(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange)
Mark the given method pure.
This represents '#pragma omp declare reduction ...' directive.
decl_iterator decls_begin() const
Pseudo declaration for capturing expressions.
static bool isInstantiationOfUnresolvedUsingDecl(T *Pattern, Decl *Other, ASTContext &Ctx)
Decl * BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *AssertMessageExpr, SourceLocation RParenLoc, bool Failed)
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
Attr * clone(ASTContext &C) const
static ExplicitSpecifier instantiateExplicitSpecifier(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES, FunctionDecl *New)
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
DeclGroupPtrTy ActOnOpenMPAllocateDirective(SourceLocation Loc, ArrayRef< Expr *> VarList, ArrayRef< OMPClause *> Clauses, DeclContext *Owner=nullptr)
Called on well-formed '#pragma omp allocate'.
unsigned getManglingNumber(const NamedDecl *ND) const
OMPClause * ActOnOpenMPAllocatorClause(Expr *Allocator, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocator' clause.
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
DeclarationName getName() const
getName - Returns the embedded declaration name.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
Represents the declaration of a struct/union/class/enum.
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
TemplateParameterList * SubstTemplateParams(TemplateParameterList *List)
Instantiates a nested template parameter list in the current instantiation context.
void addAMDGPUFlatWorkGroupSizeAttr(SourceRange AttrRange, Decl *D, Expr *Min, Expr *Max, unsigned SpellingListIndex)
addAMDGPUFlatWorkGroupSizeAttr - Adds an amdgpu_flat_work_group_size attribute to a particular declar...
void setReferenced(bool R=true)
Represents the declaration of a label.
Represents a dependent using declaration which was not marked with typename.
void setIsCopyDeductionCandidate(bool isCDC=true)
Represents a static or instance method of a struct/union/class.
TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
static bool isInstantiationOf(ClassTemplateDecl *Pattern, ClassTemplateDecl *Instance)
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
EnumDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc)
Decl * VisitDecl(Decl *D)
SourceLocation getIdentLocation() const
Returns the location of this using declaration's identifier.
const ParmVarDecl * getParamDecl(unsigned i) const
static void instantiateDependentAlignValueAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AlignValueAttr *Aligned, Decl *New)
SourceLocation getLocation() const
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
This is a basic class for representing single OpenMP clause.
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
void setDeclName(DeclarationName N)
Set the name of this declaration.
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
const TemplateArgumentListInfo & getTemplateArgsInfo() const
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
ClassTemplateDecl * getMostRecentDecl()
void InstantiateEnumDefinition(EnumDecl *Enum, EnumDecl *Pattern)
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
void setMapperVarRef(Expr *MapperVarRefE)
Set the variable declared in the mapper.
static ExplicitSpecifier Invalid()
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
This template specialization was instantiated from a template due to an explicit instantiation defini...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc, bool HasTypenameKeyword, const CXXScopeSpec &SS, SourceLocation NameLoc, const LookupResult &Previous)
Checks that the given using declaration is not an invalid redeclaration.
static ExplicitSpecifier getFromDecl(FunctionDecl *Function)
SourceLocation getRAngleLoc() const
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
DeclarationNameInfo getNameInfo() const
Represents a C++11 static_assert declaration.
void setInstantiatedFromMember(VarTemplatePartialSpecializationDecl *PartialSpec)
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
Optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
void InstantiatedLocalPackArg(const Decl *D, VarDecl *Inst)
void setLAngleLoc(SourceLocation Loc)
SourceLocation getAccessSpecifierLoc() const
The location of the access specifier.
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate the initializer of the vari...
void addArgument(const TemplateArgumentLoc &Loc)
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl, Expr *AssociatedConstraints=nullptr)
Create a class template node.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isTemplateTypeParmType() const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
Expr * getInitOrig()
Get Orig variable of the initializer.
void setVirtualAsWritten(bool V)
State that this function is marked as virtual explicitly.
Represents a pack expansion of types.
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments.
ddiag_range ddiags() const
void AddAssumeAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, Expr *OE, unsigned SpellingListIndex)
AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular declaration.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template...
Base class for declarations which introduce a typedef-name.
Represents a template argument.
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument. ...
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
static bool isInvalid(LocType Loc, bool *Invalid)
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
bool isNull() const
Determine whether this template name is NULL.
static bool addInstantiatedParametersToScope(Sema &S, FunctionDecl *Function, const FunctionDecl *PatternDecl, LocalInstantiationScope &Scope, const MultiLevelTemplateArgumentList &TemplateArgs)
Introduce the instantiated function parameters into the local instantiation scope, and set the parameter names to those used in the template.
Dataflow Directional Tag Classes.
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
ExtInfo getExtInfo() const
Decl * VisitFunctionDecl(FunctionDecl *D, TemplateParameterList *TemplateParams)
Normal class members are of more specific types and therefore don't make it here. ...
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
const TemplateArgument & getArgument() const
not evaluated yet, for special member function
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
LocalInstantiationScope * cloneScopes(LocalInstantiationScope *Outermost)
Clone this scope, and all outer scopes, down to the given outermost scope.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
void InstantiateVariableInitializer(VarDecl *Var, VarDecl *OldVar, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the initializer of a variable.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a field injected from an anonymous union/struct into the parent scope. ...
QualType getUnderlyingType() const
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
CanQualType UnsignedLongLongTy
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
const Expr * getInit() const
AccessSpecifier getAccess() const
static NamedDecl * findInstantiationOf(ASTContext &Ctx, NamedDecl *D, ForwardIterator first, ForwardIterator last)
A decomposition declaration.
void addAMDGPUWavesPerEUAttr(SourceRange AttrRange, Decl *D, Expr *Min, Expr *Max, unsigned SpellingListIndex)
addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a particular declaration.
This template specialization was instantiated from a template due to an explicit instantiation declar...
unsigned getIndex() const
Retrieve the index of the template parameter.
Represents a dependent using declaration which was marked with typename.
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
The name of a declaration.
void setInstantiationIsPending(bool IC)
State that the instantiation of this function is pending.
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.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined...
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
unsigned getNumTemplateParameterLists() const
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
void setInlineSpecified()
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack...
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
DeclGroupPtrTy ActOnOpenMPDeclareReductionDirectiveEnd(Scope *S, DeclGroupPtrTy DeclReductions, bool IsValid)
Called at the end of '#pragma omp declare reduction'.
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
void setPreviousDeclInSameBlockScope(bool Same)
static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration...
void setInitCapture(bool IC)
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration...
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
void setImplicitlyInline()
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Location wrapper for a TemplateArgument.
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
Decl * Visit(PTR(Decl) D)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD)
TemplateSpecializationKind getTemplateSpecializationKindForInstantiation() const
Get the template specialization kind of this variable for the purposes of template instantiation...
This template specialization was declared or defined by an explicit specialization (C++ [temp...
bool isConstantInitializer(ASTContext &Ctx, bool ForRef, const Expr **Culprit=nullptr) const
isConstantInitializer - Returns true if this expression can be emitted to IR as a constant...
void setNonMemberOperator()
Specifies that this declaration is a C++ overloaded non-member.
static VarTemplatePartialSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl *> Elements, Scope *S, const ParsedAttributesView &Attr)
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
bool isObjCForDecl() const
Determine whether this variable is a for-loop declaration for a for-in statement in Objective-C...
bool isFunctionType() const
void ActOnOpenMPDeclareReductionInitializerEnd(Decl *D, Expr *Initializer, VarDecl *OmpPrivParm)
Finish current declare reduction construct initializer.
void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK)
Specify that this variable is an instantiation of the static data member VD.
static bool SubstQualifier(Sema &SemaRef, const DeclT *OldDecl, DeclT *NewDecl, const MultiLevelTemplateArgumentList &TemplateArgs)
TypeSourceInfo * getTypeSourceInfo() const
DeclaratorDecl * getDeclaratorForUnnamedTagDecl(const TagDecl *TD)
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
QualType ActOnOpenMPDeclareReductionType(SourceLocation TyLoc, TypeResult ParsedType)
Check if the specified type is allowed to be used in 'omp declare reduction' construct.
void setCXXForRangeDecl(bool FRD)
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
void addDecl(Decl *D)
Add the declaration D into this context.
void setInstantiationOfMemberClass(CXXRecordDecl *RD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member class RD.
void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto, const MultiLevelTemplateArgumentList &Args)
The template argument is actually a parameter pack.
TemplateSpecializationKind getTemplateSpecializationKindForInstantiation() const
Determine the kind of template specialization this function represents for the purpose of template in...
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
bool hasTypename() const
Return true if the using declaration has 'typename'.
void setInnerLocStart(SourceLocation L)
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id)
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
RedeclarationKind forRedeclarationInCurContext()
void CheckTemplatePartialSpecialization(ClassTemplatePartialSpecializationDecl *Partial)
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool isAlreadyInstantiating() const
Determine whether we are already instantiating this specialization in some surrounding active instant...
A template argument list.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
shadow_range shadows() const
QualType getParamType(unsigned i) const
Call-style initialization (C++98)
Represents a field declaration created by an @defs(...).
QualType CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI, SourceLocation Loc)
Check that the type of a non-type template parameter is well-formed.
void CheckOverrideControl(NamedDecl *D)
CheckOverrideControl - Check C++11 override control semantics.
TypedefNameDecl * getTypedefNameForAnonDecl() const
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization)
Perform semantic checking of a new function declaration.
bool isMutable() const
Determines whether this field is mutable (C++ only).
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
Represents a C++ struct/union/class.
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization, returns the templated static data member from which it was instantiated.
void setTSCSpec(ThreadStorageClassSpecifier TSC)
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO)...
void setDescribedVarTemplate(VarTemplateDecl *Template)
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member...
VarTemplateSpecializationDecl * CompleteVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiates a variable template specialization by completing it with appropriate type information an...
void addHiddenDecl(Decl *D)
Add the declaration D to this context without modifying any lookup tables.
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
Provides information a specialization of a member of a class template, which may be a member function...
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
void atTemplateEnd(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void setUnsupportedFriend(bool Unsupported)
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
Declaration of a class template.
CXXMethodDecl * getSpecialization() const
SourceManager & getSourceManager() const
This represents '#pragma omp declare mapper ...' directive.
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const
getInjectedClassNameType - Return the unique reference to the injected class name type for the specif...
static bool isInstantiationOfStaticDataMember(VarDecl *Pattern, VarDecl *Instance)
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
Decl * SubstDecl(Decl *D, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs)
SourceLocation getLAngleLoc() const
FriendDecl * CheckFriendTypeDecl(SourceLocation LocStart, SourceLocation FriendLoc, TypeSourceInfo *TSInfo)
Perform semantic analysis of the given friend type declaration.
Expr * getCombinerIn()
Get In variable of the combiner.
static Sema::RetainOwnershipKind attrToRetainOwnershipKind(const Attr *A)
static OpaquePtr make(QualType P)
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
The top declaration context.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Optional< unsigned > getNumArgumentsInExpansion(QualType T, const MultiLevelTemplateArgumentList &TemplateArgs)
Determine the number of arguments in the given pack expansion type.
bool isDeleted() const
Whether this function has been deleted.
SourceLocation getTemplateNameLoc() const
bool isCopyElisionCandidate(QualType ReturnType, const VarDecl *VD, CopyElisionSemanticsKind CESK)
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
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.
This structure contains most locations needed for by an OMPVarListClause.
bool isStaticDataMember() const
Determines whether this is a static data member.
An instance of this class represents the declaration of a property member.
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
static bool isPotentialConstantExprUnevaluated(Expr *E, const FunctionDecl *FD, SmallVectorImpl< PartialDiagnosticAt > &Diags)
isPotentialConstantExprUnevaluted - Return true if this expression might be usable in a constant expr...
TemplateParameterList * SubstTemplateParams(TemplateParameterList *Params, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs)
bool empty() const
Return true if no decls were found.
void AddLaunchBoundsAttr(SourceRange AttrRange, Decl *D, Expr *MaxThreads, Expr *MinBlocks, unsigned SpellingListIndex)
AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular declaration. ...
A trivial tuple used to represent a source range.
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
void setLexicalDeclContext(DeclContext *DC)
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
This represents a decl that may have a name.
FunctionDecl * getExceptionSpecTemplate() const
If this function type has an uninstantiated exception specification, this is the function whose excep...
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
void setAccess(AccessSpecifier AS)
bool tryResolveExplicitSpecifier(ExplicitSpecifier &ExplicitSpec)
tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
Represents a C++ namespace alias.
bool isInline() const
Whether this variable is (C++1z) inline.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
Declaration of a friend template.
ArrayRef< NamedDecl * > expansions() const
Get the set of using declarations that this pack expanded into.
Represents C++ using-directive.
Represents a #pragma detect_mismatch line.
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
SourceLocation getRAngleLoc() const
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
attr::Kind getKind() const
bool SubstParmTypes(SourceLocation Loc, ArrayRef< ParmVarDecl *> Params, const FunctionProtoType::ExtParameterInfo *ExtParamInfos, const MultiLevelTemplateArgumentList &TemplateArgs, SmallVectorImpl< QualType > &ParamTypes, SmallVectorImpl< ParmVarDecl *> *OutParams, ExtParameterInfoBuilder &ParamInfos)
Substitute the given template arguments into the given set of parameters, producing the set of parame...
Expr * getCombinerOut()
Get Out variable of the combiner.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
void setType(QualType newType)
static void instantiateDependentAMDGPUFlatWorkGroupSizeAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AMDGPUFlatWorkGroupSizeAttr &Attr, Decl *New)
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
bool isInvalid() const
Return true if the ExplicitSpecifier isn't valid.
bool InitMethodInstantiation(CXXMethodDecl *New, CXXMethodDecl *Tmpl)
Initializes common fields of an instantiated method declaration (New) from the corresponding fields o...
void setDeletedAsWritten(bool D=true)
This represents '#pragma omp threadprivate ...' directive.
bool isUnsupportedFriend() const
Determines if this friend kind is unsupported.
ExceptionSpecInfo ExceptionSpec
Declaration of a template function.
bool hasLinkage() const
Determine whether this declaration has linkage.
Attr - This represents one attribute.
bool isDeletedAsWritten() const
SourceLocation getLocation() const
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Represents a pack of using declarations that a single using-declarator pack-expanded into...
QualType getType() const
Return the type wrapped by this type source info.
void BuildVariableInstantiation(VarDecl *NewVar, VarDecl *OldVar, const MultiLevelTemplateArgumentList &TemplateArgs, LateInstantiatedAttrVec *LateAttrs, DeclContext *Owner, LocalInstantiationScope *StartingScope, bool InstantiatingVarTemplate=false, VarTemplateSpecializationDecl *PrevVTSD=nullptr)
BuildVariableInstantiation - Used after a new variable has been created.
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
decl_iterator decls_end() const
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
OMPClause * ActOnOpenMPMapClause(ArrayRef< OpenMPMapModifierKind > MapTypeModifiers, ArrayRef< SourceLocation > MapTypeModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef< Expr *> VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr *> UnresolvedMappers=llvm::None)
Called on well-formed 'map' clause.
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)