clang  16.0.0git
DeclTemplate.cpp
Go to the documentation of this file.
1 //===- DeclTemplate.cpp - Template Declaration AST Node Implementation ----===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the C++ related Decl classes for templates.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "clang/AST/DeclTemplate.h"
14 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/DeclCXX.h"
18 #include "clang/AST/Expr.h"
20 #include "clang/AST/TemplateBase.h"
21 #include "clang/AST/TemplateName.h"
22 #include "clang/AST/Type.h"
23 #include "clang/AST/TypeLoc.h"
24 #include "clang/Basic/Builtins.h"
25 #include "clang/Basic/LLVM.h"
27 #include "llvm/ADT/ArrayRef.h"
28 #include "llvm/ADT/FoldingSet.h"
29 #include "llvm/ADT/None.h"
30 #include "llvm/ADT/PointerUnion.h"
31 #include "llvm/ADT/STLExtras.h"
32 #include "llvm/ADT/SmallVector.h"
33 #include "llvm/Support/Casting.h"
34 #include "llvm/Support/ErrorHandling.h"
35 #include <algorithm>
36 #include <cassert>
37 #include <cstdint>
38 #include <memory>
39 #include <utility>
40 
41 using namespace clang;
42 
43 //===----------------------------------------------------------------------===//
44 // TemplateParameterList Implementation
45 //===----------------------------------------------------------------------===//
46 
47 
49  SourceLocation TemplateLoc,
50  SourceLocation LAngleLoc,
51  ArrayRef<NamedDecl *> Params,
52  SourceLocation RAngleLoc,
53  Expr *RequiresClause)
54  : TemplateLoc(TemplateLoc), LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc),
55  NumParams(Params.size()), ContainsUnexpandedParameterPack(false),
56  HasRequiresClause(RequiresClause != nullptr),
57  HasConstrainedParameters(false) {
58  for (unsigned Idx = 0; Idx < NumParams; ++Idx) {
59  NamedDecl *P = Params[Idx];
60  begin()[Idx] = P;
61 
62  bool IsPack = P->isTemplateParameterPack();
63  if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(P)) {
64  if (!IsPack && NTTP->getType()->containsUnexpandedParameterPack())
65  ContainsUnexpandedParameterPack = true;
66  if (NTTP->hasPlaceholderTypeConstraint())
67  HasConstrainedParameters = true;
68  } else if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(P)) {
69  if (!IsPack &&
70  TTP->getTemplateParameters()->containsUnexpandedParameterPack())
71  ContainsUnexpandedParameterPack = true;
72  } else if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(P)) {
73  if (const TypeConstraint *TC = TTP->getTypeConstraint()) {
74  if (TC->getImmediatelyDeclaredConstraint()
75  ->containsUnexpandedParameterPack())
76  ContainsUnexpandedParameterPack = true;
77  }
78  if (TTP->hasTypeConstraint())
79  HasConstrainedParameters = true;
80  } else {
81  llvm_unreachable("unexpected template parameter type");
82  }
83  // FIXME: If a default argument contains an unexpanded parameter pack, the
84  // template parameter list does too.
85  }
86 
87  if (HasRequiresClause) {
88  if (RequiresClause->containsUnexpandedParameterPack())
89  ContainsUnexpandedParameterPack = true;
90  *getTrailingObjects<Expr *>() = RequiresClause;
91  }
92 }
93 
95  if (ContainsUnexpandedParameterPack)
96  return true;
97  if (!HasConstrainedParameters)
98  return false;
99 
100  // An implicit constrained parameter might have had a use of an unexpanded
101  // pack added to it after the template parameter list was created. All
102  // implicit parameters are at the end of the parameter list.
103  for (const NamedDecl *Param : llvm::reverse(asArray())) {
104  if (!Param->isImplicit())
105  break;
106 
107  if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
108  const auto *TC = TTP->getTypeConstraint();
109  if (TC && TC->getImmediatelyDeclaredConstraint()
110  ->containsUnexpandedParameterPack())
111  return true;
112  }
113  }
114 
115  return false;
116 }
117 
120  SourceLocation LAngleLoc,
121  ArrayRef<NamedDecl *> Params,
122  SourceLocation RAngleLoc, Expr *RequiresClause) {
123  void *Mem = C.Allocate(totalSizeToAlloc<NamedDecl *, Expr *>(
124  Params.size(), RequiresClause ? 1u : 0u),
125  alignof(TemplateParameterList));
126  return new (Mem) TemplateParameterList(C, TemplateLoc, LAngleLoc, Params,
127  RAngleLoc, RequiresClause);
128 }
129 
131  unsigned NumRequiredArgs = 0;
132  for (const NamedDecl *P : asArray()) {
133  if (P->isTemplateParameterPack()) {
134  if (Optional<unsigned> Expansions = getExpandedPackSize(P)) {
135  NumRequiredArgs += *Expansions;
136  continue;
137  }
138  break;
139  }
140 
141  if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(P)) {
142  if (TTP->hasDefaultArgument())
143  break;
144  } else if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(P)) {
145  if (NTTP->hasDefaultArgument())
146  break;
147  } else if (cast<TemplateTemplateParmDecl>(P)->hasDefaultArgument())
148  break;
149 
150  ++NumRequiredArgs;
151  }
152 
153  return NumRequiredArgs;
154 }
155 
157  if (size() == 0)
158  return 0;
159 
160  const NamedDecl *FirstParm = getParam(0);
161  if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(FirstParm))
162  return TTP->getDepth();
163  else if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(FirstParm))
164  return NTTP->getDepth();
165  else
166  return cast<TemplateTemplateParmDecl>(FirstParm)->getDepth();
167 }
168 
170  DeclContext *Owner) {
171  bool Invalid = false;
172  for (NamedDecl *P : *Params) {
173  P->setDeclContext(Owner);
174 
175  if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(P))
176  if (AdoptTemplateParameterList(TTP->getTemplateParameters(), Owner))
177  Invalid = true;
178 
179  if (P->isInvalidDecl())
180  Invalid = true;
181  }
182  return Invalid;
183 }
184 
187  if (HasConstrainedParameters)
188  for (const NamedDecl *Param : *this) {
189  if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
190  if (const auto *TC = TTP->getTypeConstraint())
191  AC.push_back(TC->getImmediatelyDeclaredConstraint());
192  } else if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
193  if (const Expr *E = NTTP->getPlaceholderTypeConstraint())
194  AC.push_back(E);
195  }
196  }
197  if (HasRequiresClause)
198  AC.push_back(getRequiresClause());
199 }
200 
202  return HasRequiresClause || HasConstrainedParameters;
203 }
204 
206  const PrintingPolicy &Policy, const TemplateParameterList *TPL,
207  unsigned Idx) {
208  if (!TPL || Idx >= TPL->size() || Policy.AlwaysIncludeTypeForTemplateArgument)
209  return true;
210  const NamedDecl *TemplParam = TPL->getParam(Idx);
211  if (const auto *ParamValueDecl =
212  dyn_cast<NonTypeTemplateParmDecl>(TemplParam))
213  if (ParamValueDecl->getType()->getContainedDeducedType())
214  return true;
215  return false;
216 }
217 
218 namespace clang {
219 
221  return new (C) char[sizeof(void*) * 2];
222 }
223 
224 } // namespace clang
225 
226 //===----------------------------------------------------------------------===//
227 // TemplateDecl Implementation
228 //===----------------------------------------------------------------------===//
229 
232  NamedDecl *Decl)
233  : NamedDecl(DK, DC, L, Name), TemplatedDecl(Decl), TemplateParams(Params) {}
234 
235 void TemplateDecl::anchor() {}
236 
237 void TemplateDecl::
240  if (auto *FD = dyn_cast_or_null<FunctionDecl>(getTemplatedDecl()))
241  if (const Expr *TRC = FD->getTrailingRequiresClause())
242  AC.push_back(TRC);
243 }
244 
247  return true;
248  if (auto *FD = dyn_cast_or_null<FunctionDecl>(getTemplatedDecl()))
249  return FD->getTrailingRequiresClause();
250  return false;
251 }
252 
254  switch (getKind()) {
255  case TemplateDecl::TypeAliasTemplate:
256  case TemplateDecl::BuiltinTemplate:
257  return true;
258  default:
259  return false;
260  };
261 }
262 
263 //===----------------------------------------------------------------------===//
264 // RedeclarableTemplateDecl Implementation
265 //===----------------------------------------------------------------------===//
266 
267 void RedeclarableTemplateDecl::anchor() {}
268 
270  if (Common)
271  return Common;
272 
273  // Walk the previous-declaration chain until we either find a declaration
274  // with a common pointer or we run out of previous declarations.
276  for (const RedeclarableTemplateDecl *Prev = getPreviousDecl(); Prev;
277  Prev = Prev->getPreviousDecl()) {
278  if (Prev->Common) {
279  Common = Prev->Common;
280  break;
281  }
282 
283  PrevDecls.push_back(Prev);
284  }
285 
286  // If we never found a common pointer, allocate one now.
287  if (!Common) {
288  // FIXME: If any of the declarations is from an AST file, we probably
289  // need an update record to add the common data.
290 
292  }
293 
294  // Update any previous declarations we saw with the common pointer.
295  for (const RedeclarableTemplateDecl *Prev : PrevDecls)
296  Prev->Common = Common;
297 
298  return Common;
299 }
300 
302  // Grab the most recent declaration to ensure we've loaded any lazy
303  // redeclarations of this template.
304  CommonBase *CommonBasePtr = getMostRecentDecl()->getCommonPtr();
305  if (CommonBasePtr->LazySpecializations) {
306  ASTContext &Context = getASTContext();
307  uint32_t *Specs = CommonBasePtr->LazySpecializations;
308  CommonBasePtr->LazySpecializations = nullptr;
309  for (uint32_t I = 0, N = *Specs++; I != N; ++I)
310  (void)Context.getExternalSource()->GetExternalDecl(Specs[I]);
311  }
312 }
313 
314 template<class EntryType, typename... ProfileArguments>
317  llvm::FoldingSetVector<EntryType> &Specs, void *&InsertPos,
318  ProfileArguments&&... ProfileArgs) {
319  using SETraits = SpecEntryTraits<EntryType>;
320 
321  llvm::FoldingSetNodeID ID;
322  EntryType::Profile(ID, std::forward<ProfileArguments>(ProfileArgs)...,
323  getASTContext());
324  EntryType *Entry = Specs.FindNodeOrInsertPos(ID, InsertPos);
325  return Entry ? SETraits::getDecl(Entry)->getMostRecentDecl() : nullptr;
326 }
327 
328 template<class Derived, class EntryType>
330  llvm::FoldingSetVector<EntryType> &Specializations, EntryType *Entry,
331  void *InsertPos) {
332  using SETraits = SpecEntryTraits<EntryType>;
333 
334  if (InsertPos) {
335 #ifndef NDEBUG
336  void *CorrectInsertPos;
337  assert(!findSpecializationImpl(Specializations,
338  CorrectInsertPos,
339  SETraits::getTemplateArgs(Entry)) &&
340  InsertPos == CorrectInsertPos &&
341  "given incorrect InsertPos for specialization");
342 #endif
343  Specializations.InsertNode(Entry, InsertPos);
344  } else {
345  EntryType *Existing = Specializations.GetOrInsertNode(Entry);
346  (void)Existing;
347  assert(SETraits::getDecl(Existing)->isCanonicalDecl() &&
348  "non-canonical specialization?");
349  }
350 
352  L->AddedCXXTemplateSpecialization(cast<Derived>(this),
353  SETraits::getDecl(Entry));
354 }
355 
358  auto *CommonPtr = getCommonPtr();
359  if (!CommonPtr->InjectedArgs) {
360  auto &Context = getASTContext();
362  Context.getInjectedTemplateArgs(Params, TemplateArgs);
363  CommonPtr->InjectedArgs =
364  new (Context) TemplateArgument[TemplateArgs.size()];
365  std::copy(TemplateArgs.begin(), TemplateArgs.end(),
366  CommonPtr->InjectedArgs);
367  }
368 
369  return llvm::makeArrayRef(CommonPtr->InjectedArgs, Params->size());
370 }
371 
372 //===----------------------------------------------------------------------===//
373 // FunctionTemplateDecl Implementation
374 //===----------------------------------------------------------------------===//
375 
378  DeclarationName Name,
380  bool Invalid = AdoptTemplateParameterList(Params, cast<DeclContext>(Decl));
381  auto *TD = new (C, DC) FunctionTemplateDecl(C, DC, L, Name, Params, Decl);
382  if (Invalid)
383  TD->setInvalidDecl();
384  return TD;
385 }
386 
388  unsigned ID) {
389  return new (C, ID) FunctionTemplateDecl(C, nullptr, SourceLocation(),
390  DeclarationName(), nullptr, nullptr);
391 }
392 
395  auto *CommonPtr = new (C) Common;
396  C.addDestruction(CommonPtr);
397  return CommonPtr;
398 }
399 
402 }
403 
404 llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> &
407  return getCommonPtr()->Specializations;
408 }
409 
410 FunctionDecl *
412  void *&InsertPos) {
413  return findSpecializationImpl(getSpecializations(), InsertPos, Args);
414 }
415 
417  FunctionTemplateSpecializationInfo *Info, void *InsertPos) {
418  addSpecializationImpl<FunctionTemplateDecl>(getSpecializations(), Info,
419  InsertPos);
420 }
421 
424 
425  // If we haven't created a common pointer yet, then it can just be created
426  // with the usual method.
427  if (!Base::Common)
428  return;
429 
430  Common *ThisCommon = static_cast<Common *>(Base::Common);
431  Common *PrevCommon = nullptr;
433  for (; Prev; Prev = Prev->getPreviousDecl()) {
434  if (Prev->Base::Common) {
435  PrevCommon = static_cast<Common *>(Prev->Base::Common);
436  break;
437  }
438  PreviousDecls.push_back(Prev);
439  }
440 
441  // If the previous redecl chain hasn't created a common pointer yet, then just
442  // use this common pointer.
443  if (!PrevCommon) {
444  for (auto *D : PreviousDecls)
445  D->Base::Common = ThisCommon;
446  return;
447  }
448 
449  // Ensure we don't leak any important state.
450  assert(ThisCommon->Specializations.size() == 0 &&
451  "Can't merge incompatible declarations!");
452 
453  Base::Common = PrevCommon;
454 }
455 
456 //===----------------------------------------------------------------------===//
457 // ClassTemplateDecl Implementation
458 //===----------------------------------------------------------------------===//
459 
461  SourceLocation L,
462  DeclarationName Name,
463  TemplateParameterList *Params,
464  NamedDecl *Decl) {
465  bool Invalid = AdoptTemplateParameterList(Params, cast<DeclContext>(Decl));
466  auto *TD = new (C, DC) ClassTemplateDecl(C, DC, L, Name, Params, Decl);
467  if (Invalid)
468  TD->setInvalidDecl();
469  return TD;
470 }
471 
473  unsigned ID) {
474  return new (C, ID) ClassTemplateDecl(C, nullptr, SourceLocation(),
475  DeclarationName(), nullptr, nullptr);
476 }
477 
480 }
481 
482 llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
485  return getCommonPtr()->Specializations;
486 }
487 
488 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
492 }
493 
496  auto *CommonPtr = new (C) Common;
497  C.addDestruction(CommonPtr);
498  return CommonPtr;
499 }
500 
503  void *&InsertPos) {
504  return findSpecializationImpl(getSpecializations(), InsertPos, Args);
505 }
506 
508  void *InsertPos) {
509  addSpecializationImpl<ClassTemplateDecl>(getSpecializations(), D, InsertPos);
510 }
511 
515  TemplateParameterList *TPL, void *&InsertPos) {
516  return findSpecializationImpl(getPartialSpecializations(), InsertPos, Args,
517  TPL);
518 }
519 
521  llvm::FoldingSetNodeID &ID, const TemplateParameterList *TPL) {
522  const Expr *RC = TPL->getRequiresClause();
523  ID.AddBoolean(RC != nullptr);
524  if (RC)
525  RC->Profile(ID, C, /*Canonical=*/true);
526  ID.AddInteger(TPL->size());
527  for (NamedDecl *D : *TPL) {
528  if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) {
529  ID.AddInteger(0);
530  ID.AddBoolean(NTTP->isParameterPack());
531  NTTP->getType().getCanonicalType().Profile(ID);
532  ID.AddBoolean(NTTP->hasPlaceholderTypeConstraint());
533  if (const Expr *E = NTTP->getPlaceholderTypeConstraint())
534  E->Profile(ID, C, /*Canonical=*/true);
535  continue;
536  }
537  if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(D)) {
538  ID.AddInteger(1);
539  ID.AddBoolean(TTP->isParameterPack());
540  ID.AddBoolean(TTP->hasTypeConstraint());
541  if (const TypeConstraint *TC = TTP->getTypeConstraint())
542  TC->getImmediatelyDeclaredConstraint()->Profile(ID, C,
543  /*Canonical=*/true);
544  continue;
545  }
546  const auto *TTP = cast<TemplateTemplateParmDecl>(D);
547  ID.AddInteger(2);
548  ID.AddBoolean(TTP->isParameterPack());
549  ProfileTemplateParameterList(C, ID, TTP->getTemplateParameters());
550  }
551 }
552 
553 void
556  ASTContext &Context) {
557  ID.AddInteger(TemplateArgs.size());
558  for (const TemplateArgument &TemplateArg : TemplateArgs)
559  TemplateArg.Profile(ID, Context);
560  ProfileTemplateParameterList(Context, ID, TPL);
561 }
562 
565  void *InsertPos) {
566  if (InsertPos)
567  getPartialSpecializations().InsertNode(D, InsertPos);
568  else {
570  = getPartialSpecializations().GetOrInsertNode(D);
571  (void)Existing;
572  assert(Existing->isCanonicalDecl() && "Non-canonical specialization?");
573  }
574 
576  L->AddedCXXTemplateSpecialization(this, D);
577 }
578 
581  llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &PartialSpecs
583  PS.clear();
584  PS.reserve(PartialSpecs.size());
585  for (ClassTemplatePartialSpecializationDecl &P : PartialSpecs)
586  PS.push_back(P.getMostRecentDecl());
587 }
588 
591  ASTContext &Context = getASTContext();
594  if (Context.hasSameType(P.getInjectedSpecializationType(), T))
595  return P.getMostRecentDecl();
596  }
597 
598  return nullptr;
599 }
600 
604  Decl *DCanon = D->getCanonicalDecl();
606  if (P.getInstantiatedFromMember()->getCanonicalDecl() == DCanon)
607  return P.getMostRecentDecl();
608  }
609 
610  return nullptr;
611 }
612 
613 QualType
615  Common *CommonPtr = getCommonPtr();
616  if (!CommonPtr->InjectedClassNameType.isNull())
617  return CommonPtr->InjectedClassNameType;
618 
619  // C++0x [temp.dep.type]p2:
620  // The template argument list of a primary template is a template argument
621  // list in which the nth template argument has the value of the nth template
622  // parameter of the class template. If the nth template parameter is a
623  // template parameter pack (14.5.3), the nth template argument is a pack
624  // expansion (14.5.3) whose pattern is the name of the template parameter
625  // pack.
626  ASTContext &Context = getASTContext();
629  Context.getInjectedTemplateArgs(Params, TemplateArgs);
630  CommonPtr->InjectedClassNameType
632  TemplateArgs);
633  return CommonPtr->InjectedClassNameType;
634 }
635 
636 //===----------------------------------------------------------------------===//
637 // TemplateTypeParm Allocation/Deallocation Method Implementations
638 //===----------------------------------------------------------------------===//
639 
642  SourceLocation KeyLoc, SourceLocation NameLoc,
643  unsigned D, unsigned P, IdentifierInfo *Id,
644  bool Typename, bool ParameterPack,
645  bool HasTypeConstraint,
646  Optional<unsigned> NumExpanded) {
647  auto *TTPDecl =
648  new (C, DC,
649  additionalSizeToAlloc<TypeConstraint>(HasTypeConstraint ? 1 : 0))
650  TemplateTypeParmDecl(DC, KeyLoc, NameLoc, Id, Typename,
651  HasTypeConstraint, NumExpanded);
652  QualType TTPType = C.getTemplateTypeParmType(D, P, ParameterPack, TTPDecl);
653  TTPDecl->setTypeForDecl(TTPType.getTypePtr());
654  return TTPDecl;
655 }
656 
659  return new (C, ID)
660  TemplateTypeParmDecl(nullptr, SourceLocation(), SourceLocation(), nullptr,
661  false, false, std::nullopt);
662 }
663 
666  bool HasTypeConstraint) {
667  return new (C, ID,
668  additionalSizeToAlloc<TypeConstraint>(HasTypeConstraint ? 1 : 0))
669  TemplateTypeParmDecl(nullptr, SourceLocation(), SourceLocation(), nullptr,
670  false, HasTypeConstraint, std::nullopt);
671 }
672 
674  return hasDefaultArgument()
676  : SourceLocation();
677 }
678 
681  return SourceRange(getBeginLoc(),
682  getDefaultArgumentInfo()->getTypeLoc().getEndLoc());
683  // TypeDecl::getSourceRange returns a range containing name location, which is
684  // wrong for unnamed template parameters. e.g:
685  // it will return <[[typename>]] instead of <[[typename]]>
686  else if (getDeclName().isEmpty())
687  return SourceRange(getBeginLoc());
688  return TypeDecl::getSourceRange();
689 }
690 
693 }
694 
697 }
698 
701 }
702 
704  DeclarationNameInfo NameInfo, NamedDecl *FoundDecl, ConceptDecl *CD,
705  const ASTTemplateArgumentListInfo *ArgsAsWritten,
706  Expr *ImmediatelyDeclaredConstraint) {
707  assert(HasTypeConstraint &&
708  "HasTypeConstraint=true must be passed at construction in order to "
709  "call setTypeConstraint");
710  assert(!TypeConstraintInitialized &&
711  "TypeConstraint was already initialized!");
712  new (getTrailingObjects<TypeConstraint>()) TypeConstraint(NNS, NameInfo,
713  FoundDecl, CD, ArgsAsWritten, ImmediatelyDeclaredConstraint);
714  TypeConstraintInitialized = true;
715 }
716 
717 //===----------------------------------------------------------------------===//
718 // NonTypeTemplateParmDecl Method Implementations
719 //===----------------------------------------------------------------------===//
720 
721 NonTypeTemplateParmDecl::NonTypeTemplateParmDecl(
722  DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D,
723  unsigned P, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo,
724  ArrayRef<QualType> ExpandedTypes, ArrayRef<TypeSourceInfo *> ExpandedTInfos)
725  : DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc),
726  TemplateParmPosition(D, P), ParameterPack(true),
727  ExpandedParameterPack(true), NumExpandedTypes(ExpandedTypes.size()) {
728  if (!ExpandedTypes.empty() && !ExpandedTInfos.empty()) {
729  auto TypesAndInfos =
730  getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
731  for (unsigned I = 0; I != NumExpandedTypes; ++I) {
732  new (&TypesAndInfos[I].first) QualType(ExpandedTypes[I]);
733  TypesAndInfos[I].second = ExpandedTInfos[I];
734  }
735  }
736 }
737 
740  SourceLocation StartLoc, SourceLocation IdLoc,
741  unsigned D, unsigned P, IdentifierInfo *Id,
742  QualType T, bool ParameterPack,
743  TypeSourceInfo *TInfo) {
744  AutoType *AT =
745  C.getLangOpts().CPlusPlus20 ? T->getContainedAutoType() : nullptr;
746  return new (C, DC,
747  additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>,
748  Expr *>(0,
749  AT && AT->isConstrained() ? 1 : 0))
750  NonTypeTemplateParmDecl(DC, StartLoc, IdLoc, D, P, Id, T, ParameterPack,
751  TInfo);
752 }
753 
755  const ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
756  SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id,
757  QualType T, TypeSourceInfo *TInfo, ArrayRef<QualType> ExpandedTypes,
758  ArrayRef<TypeSourceInfo *> ExpandedTInfos) {
759  AutoType *AT = TInfo->getType()->getContainedAutoType();
760  return new (C, DC,
761  additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>,
762  Expr *>(
763  ExpandedTypes.size(), AT && AT->isConstrained() ? 1 : 0))
764  NonTypeTemplateParmDecl(DC, StartLoc, IdLoc, D, P, Id, T, TInfo,
765  ExpandedTypes, ExpandedTInfos);
766 }
767 
770  bool HasTypeConstraint) {
771  return new (C, ID, additionalSizeToAlloc<std::pair<QualType,
772  TypeSourceInfo *>,
773  Expr *>(0,
774  HasTypeConstraint ? 1 : 0))
776  0, 0, nullptr, QualType(), false, nullptr);
777 }
778 
781  unsigned NumExpandedTypes,
782  bool HasTypeConstraint) {
783  auto *NTTP =
784  new (C, ID,
785  additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>, Expr *>(
786  NumExpandedTypes, HasTypeConstraint ? 1 : 0))
788  0, 0, nullptr, QualType(), nullptr,
789  std::nullopt, std::nullopt);
790  NTTP->NumExpandedTypes = NumExpandedTypes;
791  return NTTP;
792 }
793 
796  return SourceRange(getOuterLocStart(),
797  getDefaultArgument()->getSourceRange().getEnd());
799 }
800 
802  return hasDefaultArgument()
804  : SourceLocation();
805 }
806 
807 //===----------------------------------------------------------------------===//
808 // TemplateTemplateParmDecl Method Implementations
809 //===----------------------------------------------------------------------===//
810 
811 void TemplateTemplateParmDecl::anchor() {}
812 
813 TemplateTemplateParmDecl::TemplateTemplateParmDecl(
814  DeclContext *DC, SourceLocation L, unsigned D, unsigned P,
816  ArrayRef<TemplateParameterList *> Expansions)
817  : TemplateDecl(TemplateTemplateParm, DC, L, Id, Params),
818  TemplateParmPosition(D, P), ParameterPack(true),
819  ExpandedParameterPack(true), NumExpandedParams(Expansions.size()) {
820  if (!Expansions.empty())
821  std::uninitialized_copy(Expansions.begin(), Expansions.end(),
822  getTrailingObjects<TemplateParameterList *>());
823 }
824 
827  SourceLocation L, unsigned D, unsigned P,
828  bool ParameterPack, IdentifierInfo *Id,
829  TemplateParameterList *Params) {
830  return new (C, DC) TemplateTemplateParmDecl(DC, L, D, P, ParameterPack, Id,
831  Params);
832 }
833 
836  SourceLocation L, unsigned D, unsigned P,
838  TemplateParameterList *Params,
840  return new (C, DC,
841  additionalSizeToAlloc<TemplateParameterList *>(Expansions.size()))
842  TemplateTemplateParmDecl(DC, L, D, P, Id, Params, Expansions);
843 }
844 
847  return new (C, ID) TemplateTemplateParmDecl(nullptr, SourceLocation(), 0, 0,
848  false, nullptr, nullptr);
849 }
850 
853  unsigned NumExpansions) {
854  auto *TTP =
855  new (C, ID, additionalSizeToAlloc<TemplateParameterList *>(NumExpansions))
856  TemplateTemplateParmDecl(nullptr, SourceLocation(), 0, 0, nullptr,
857  nullptr, std::nullopt);
858  TTP->NumExpandedParams = NumExpansions;
859  return TTP;
860 }
861 
864  : SourceLocation();
865 }
866 
868  const ASTContext &C, const TemplateArgumentLoc &DefArg) {
869  if (DefArg.getArgument().isNull())
870  DefaultArgument.set(nullptr);
871  else
872  DefaultArgument.set(new (C) TemplateArgumentLoc(DefArg));
873 }
874 
875 //===----------------------------------------------------------------------===//
876 // TemplateArgumentList Implementation
877 //===----------------------------------------------------------------------===//
878 TemplateArgumentList::TemplateArgumentList(ArrayRef<TemplateArgument> Args)
879  : Arguments(getTrailingObjects<TemplateArgument>()),
880  NumArguments(Args.size()) {
881  std::uninitialized_copy(Args.begin(), Args.end(),
882  getTrailingObjects<TemplateArgument>());
883 }
884 
888  void *Mem = Context.Allocate(totalSizeToAlloc<TemplateArgument>(Args.size()));
889  return new (Mem) TemplateArgumentList(Args);
890 }
891 
893  ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template,
894  TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs,
895  const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI,
896  MemberSpecializationInfo *MSInfo) {
897  const ASTTemplateArgumentListInfo *ArgsAsWritten = nullptr;
898  if (TemplateArgsAsWritten)
899  ArgsAsWritten = ASTTemplateArgumentListInfo::Create(C,
900  *TemplateArgsAsWritten);
901 
902  void *Mem =
903  C.Allocate(totalSizeToAlloc<MemberSpecializationInfo *>(MSInfo ? 1 : 0));
904  return new (Mem) FunctionTemplateSpecializationInfo(
905  FD, Template, TSK, TemplateArgs, ArgsAsWritten, POI, MSInfo);
906 }
907 
908 //===----------------------------------------------------------------------===//
909 // ClassTemplateSpecializationDecl Implementation
910 //===----------------------------------------------------------------------===//
911 
914  DeclContext *DC, SourceLocation StartLoc,
915  SourceLocation IdLoc,
916  ClassTemplateDecl *SpecializedTemplate,
919  : CXXRecordDecl(DK, TK, Context, DC, StartLoc, IdLoc,
920  SpecializedTemplate->getIdentifier(), PrevDecl),
921  SpecializedTemplate(SpecializedTemplate),
922  TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args)),
923  SpecializationKind(TSK_Undeclared) {
924 }
925 
927  Kind DK)
928  : CXXRecordDecl(DK, TTK_Struct, C, nullptr, SourceLocation(),
929  SourceLocation(), nullptr, nullptr),
930  SpecializationKind(TSK_Undeclared) {}
931 
934  DeclContext *DC,
935  SourceLocation StartLoc,
936  SourceLocation IdLoc,
937  ClassTemplateDecl *SpecializedTemplate,
940  auto *Result =
941  new (Context, DC) ClassTemplateSpecializationDecl(
942  Context, ClassTemplateSpecialization, TK, DC, StartLoc, IdLoc,
943  SpecializedTemplate, Args, PrevDecl);
944  Result->setMayHaveOutOfDateDef(false);
945 
946  // If the template decl is incomplete, copy the external lexical storage from
947  // the base template. This allows instantiations of incomplete types to
948  // complete using the external AST if the template's declaration came from an
949  // external AST.
950  if (!SpecializedTemplate->getTemplatedDecl()->isCompleteDefinition())
951  Result->setHasExternalLexicalStorage(
952  SpecializedTemplate->getTemplatedDecl()->hasExternalLexicalStorage());
953 
954  Context.getTypeDeclType(Result, PrevDecl);
955  return Result;
956 }
957 
960  unsigned ID) {
961  auto *Result =
962  new (C, ID) ClassTemplateSpecializationDecl(C, ClassTemplateSpecialization);
963  Result->setMayHaveOutOfDateDef(false);
964  return Result;
965 }
966 
968  raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const {
969  NamedDecl::getNameForDiagnostic(OS, Policy, Qualified);
970 
971  const auto *PS = dyn_cast<ClassTemplatePartialSpecializationDecl>(this);
972  if (const ASTTemplateArgumentListInfo *ArgsAsWritten =
973  PS ? PS->getTemplateArgsAsWritten() : nullptr) {
975  OS, ArgsAsWritten->arguments(), Policy,
976  getSpecializedTemplate()->getTemplateParameters());
977  } else {
978  const TemplateArgumentList &TemplateArgs = getTemplateArgs();
980  OS, TemplateArgs.asArray(), Policy,
981  getSpecializedTemplate()->getTemplateParameters());
982  }
983 }
984 
987  if (const auto *PartialSpec =
988  SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
989  return PartialSpec->PartialSpecialization->getSpecializedTemplate();
990  return SpecializedTemplate.get<ClassTemplateDecl*>();
991 }
992 
995  if (ExplicitInfo) {
997  if (Begin.isValid()) {
998  // Here we have an explicit (partial) specialization or instantiation.
1002  if (getExternLoc().isValid())
1003  Begin = getExternLoc();
1005  if (End.isInvalid())
1007  return SourceRange(Begin, End);
1008  }
1009  // An implicit instantiation of a class template partial specialization
1010  // uses ExplicitInfo to record the TypeAsWritten, but the source
1011  // locations should be retrieved from the instantiation pattern.
1012  using CTPSDecl = ClassTemplatePartialSpecializationDecl;
1013  auto *ctpsd = const_cast<CTPSDecl *>(cast<CTPSDecl>(this));
1014  CTPSDecl *inst_from = ctpsd->getInstantiatedFromMember();
1015  assert(inst_from != nullptr);
1016  return inst_from->getSourceRange();
1017  }
1018  else {
1019  // No explicit info available.
1020  llvm::PointerUnion<ClassTemplateDecl *,
1022  inst_from = getInstantiatedFrom();
1023  if (inst_from.isNull())
1025  if (const auto *ctd = inst_from.dyn_cast<ClassTemplateDecl *>())
1026  return ctd->getSourceRange();
1027  return inst_from.get<ClassTemplatePartialSpecializationDecl *>()
1028  ->getSourceRange();
1029  }
1030 }
1031 
1032 //===----------------------------------------------------------------------===//
1033 // ConceptDecl Implementation
1034 //===----------------------------------------------------------------------===//
1037  TemplateParameterList *Params,
1038  Expr *ConstraintExpr) {
1039  bool Invalid = AdoptTemplateParameterList(Params, DC);
1040  auto *TD = new (C, DC) ConceptDecl(DC, L, Name, Params, ConstraintExpr);
1041  if (Invalid)
1042  TD->setInvalidDecl();
1043  return TD;
1044 }
1045 
1047  unsigned ID) {
1048  ConceptDecl *Result = new (C, ID) ConceptDecl(nullptr, SourceLocation(),
1049  DeclarationName(),
1050  nullptr, nullptr);
1051 
1052  return Result;
1053 }
1054 
1055 //===----------------------------------------------------------------------===//
1056 // ImplicitConceptSpecializationDecl Implementation
1057 //===----------------------------------------------------------------------===//
1058 ImplicitConceptSpecializationDecl::ImplicitConceptSpecializationDecl(
1059  DeclContext *DC, SourceLocation SL,
1060  ArrayRef<TemplateArgument> ConvertedArgs)
1061  : Decl(ImplicitConceptSpecialization, DC, SL),
1062  NumTemplateArgs(ConvertedArgs.size()) {
1063  setTemplateArguments(ConvertedArgs);
1064 }
1065 
1066 ImplicitConceptSpecializationDecl::ImplicitConceptSpecializationDecl(
1067  EmptyShell Empty, unsigned NumTemplateArgs)
1068  : Decl(ImplicitConceptSpecialization, Empty),
1069  NumTemplateArgs(NumTemplateArgs) {}
1070 
1072  const ASTContext &C, DeclContext *DC, SourceLocation SL,
1073  ArrayRef<TemplateArgument> ConvertedArgs) {
1074  return new (C, DC,
1075  additionalSizeToAlloc<TemplateArgument>(ConvertedArgs.size()))
1076  ImplicitConceptSpecializationDecl(DC, SL, ConvertedArgs);
1077 }
1078 
1081  const ASTContext &C, unsigned ID, unsigned NumTemplateArgs) {
1082  return new (C, ID, additionalSizeToAlloc<TemplateArgument>(NumTemplateArgs))
1083  ImplicitConceptSpecializationDecl(EmptyShell{}, NumTemplateArgs);
1084 }
1085 
1087  ArrayRef<TemplateArgument> Converted) {
1088  assert(Converted.size() == NumTemplateArgs);
1089  std::uninitialized_copy(Converted.begin(), Converted.end(),
1090  getTrailingObjects<TemplateArgument>());
1091 }
1092 
1093 //===----------------------------------------------------------------------===//
1094 // ClassTemplatePartialSpecializationDecl Implementation
1095 //===----------------------------------------------------------------------===//
1096 void ClassTemplatePartialSpecializationDecl::anchor() {}
1097 
1098 ClassTemplatePartialSpecializationDecl::
1099 ClassTemplatePartialSpecializationDecl(ASTContext &Context, TagKind TK,
1100  DeclContext *DC,
1101  SourceLocation StartLoc,
1102  SourceLocation IdLoc,
1103  TemplateParameterList *Params,
1104  ClassTemplateDecl *SpecializedTemplate,
1106  const ASTTemplateArgumentListInfo *ArgInfos,
1109  ClassTemplatePartialSpecialization,
1110  TK, DC, StartLoc, IdLoc,
1111  SpecializedTemplate, Args, PrevDecl),
1112  TemplateParams(Params), ArgsAsWritten(ArgInfos),
1113  InstantiatedFromMember(nullptr, false) {
1114  if (AdoptTemplateParameterList(Params, this))
1115  setInvalidDecl();
1116 }
1117 
1121  SourceLocation StartLoc, SourceLocation IdLoc,
1122  TemplateParameterList *Params,
1123  ClassTemplateDecl *SpecializedTemplate,
1125  const TemplateArgumentListInfo &ArgInfos,
1126  QualType CanonInjectedType,
1128  const ASTTemplateArgumentListInfo *ASTArgInfos =
1129  ASTTemplateArgumentListInfo::Create(Context, ArgInfos);
1130 
1131  auto *Result = new (Context, DC)
1132  ClassTemplatePartialSpecializationDecl(Context, TK, DC, StartLoc, IdLoc,
1133  Params, SpecializedTemplate, Args,
1134  ASTArgInfos, PrevDecl);
1135  Result->setSpecializationKind(TSK_ExplicitSpecialization);
1136  Result->setMayHaveOutOfDateDef(false);
1137 
1138  Context.getInjectedClassNameType(Result, CanonInjectedType);
1139  return Result;
1140 }
1141 
1144  unsigned ID) {
1145  auto *Result = new (C, ID) ClassTemplatePartialSpecializationDecl(C);
1146  Result->setMayHaveOutOfDateDef(false);
1147  return Result;
1148 }
1149 
1150 //===----------------------------------------------------------------------===//
1151 // FriendTemplateDecl Implementation
1152 //===----------------------------------------------------------------------===//
1153 
1154 void FriendTemplateDecl::anchor() {}
1155 
1158  SourceLocation L,
1160  FriendUnion Friend, SourceLocation FLoc) {
1161  TemplateParameterList **TPL = nullptr;
1162  if (!Params.empty()) {
1163  TPL = new (Context) TemplateParameterList *[Params.size()];
1164  llvm::copy(Params, TPL);
1165  }
1166  return new (Context, DC)
1167  FriendTemplateDecl(DC, L, TPL, Params.size(), Friend, FLoc);
1168 }
1169 
1171  unsigned ID) {
1172  return new (C, ID) FriendTemplateDecl(EmptyShell());
1173 }
1174 
1175 //===----------------------------------------------------------------------===//
1176 // TypeAliasTemplateDecl Implementation
1177 //===----------------------------------------------------------------------===//
1178 
1181  DeclarationName Name,
1182  TemplateParameterList *Params, NamedDecl *Decl) {
1183  bool Invalid = AdoptTemplateParameterList(Params, DC);
1184  auto *TD = new (C, DC) TypeAliasTemplateDecl(C, DC, L, Name, Params, Decl);
1185  if (Invalid)
1186  TD->setInvalidDecl();
1187  return TD;
1188 }
1189 
1191  unsigned ID) {
1192  return new (C, ID) TypeAliasTemplateDecl(C, nullptr, SourceLocation(),
1193  DeclarationName(), nullptr, nullptr);
1194 }
1195 
1198  auto *CommonPtr = new (C) Common;
1199  C.addDestruction(CommonPtr);
1200  return CommonPtr;
1201 }
1202 
1203 //===----------------------------------------------------------------------===//
1204 // ClassScopeFunctionSpecializationDecl Implementation
1205 //===----------------------------------------------------------------------===//
1206 
1207 void ClassScopeFunctionSpecializationDecl::anchor() {}
1208 
1211  unsigned ID) {
1212  return new (C, ID) ClassScopeFunctionSpecializationDecl(
1213  nullptr, SourceLocation(), nullptr, nullptr);
1214 }
1215 
1216 //===----------------------------------------------------------------------===//
1217 // VarTemplateDecl Implementation
1218 //===----------------------------------------------------------------------===//
1219 
1221  VarTemplateDecl *CurD = this;
1222  while (CurD) {
1223  if (CurD->isThisDeclarationADefinition())
1224  return CurD;
1225  CurD = CurD->getPreviousDecl();
1226  }
1227  return nullptr;
1228 }
1229 
1232  TemplateParameterList *Params,
1233  VarDecl *Decl) {
1234  bool Invalid = AdoptTemplateParameterList(Params, DC);
1235  auto *TD = new (C, DC) VarTemplateDecl(C, DC, L, Name, Params, Decl);
1236  if (Invalid)
1237  TD->setInvalidDecl();
1238  return TD;
1239 }
1240 
1242  unsigned ID) {
1243  return new (C, ID) VarTemplateDecl(C, nullptr, SourceLocation(),
1244  DeclarationName(), nullptr, nullptr);
1245 }
1246 
1249 }
1250 
1251 llvm::FoldingSetVector<VarTemplateSpecializationDecl> &
1254  return getCommonPtr()->Specializations;
1255 }
1256 
1257 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &
1261 }
1262 
1265  auto *CommonPtr = new (C) Common;
1266  C.addDestruction(CommonPtr);
1267  return CommonPtr;
1268 }
1269 
1272  void *&InsertPos) {
1273  return findSpecializationImpl(getSpecializations(), InsertPos, Args);
1274 }
1275 
1277  void *InsertPos) {
1278  addSpecializationImpl<VarTemplateDecl>(getSpecializations(), D, InsertPos);
1279 }
1280 
1283  TemplateParameterList *TPL, void *&InsertPos) {
1284  return findSpecializationImpl(getPartialSpecializations(), InsertPos, Args,
1285  TPL);
1286 }
1287 
1288 void
1291  ASTContext &Context) {
1292  ID.AddInteger(TemplateArgs.size());
1293  for (const TemplateArgument &TemplateArg : TemplateArgs)
1294  TemplateArg.Profile(ID, Context);
1295  ProfileTemplateParameterList(Context, ID, TPL);
1296 }
1297 
1299  VarTemplatePartialSpecializationDecl *D, void *InsertPos) {
1300  if (InsertPos)
1301  getPartialSpecializations().InsertNode(D, InsertPos);
1302  else {
1304  getPartialSpecializations().GetOrInsertNode(D);
1305  (void)Existing;
1306  assert(Existing->isCanonicalDecl() && "Non-canonical specialization?");
1307  }
1308 
1310  L->AddedCXXTemplateSpecialization(this, D);
1311 }
1312 
1315  llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &PartialSpecs =
1317  PS.clear();
1318  PS.reserve(PartialSpecs.size());
1319  for (VarTemplatePartialSpecializationDecl &P : PartialSpecs)
1320  PS.push_back(P.getMostRecentDecl());
1321 }
1322 
1326  Decl *DCanon = D->getCanonicalDecl();
1328  if (P.getInstantiatedFromMember()->getCanonicalDecl() == DCanon)
1329  return P.getMostRecentDecl();
1330  }
1331 
1332  return nullptr;
1333 }
1334 
1335 //===----------------------------------------------------------------------===//
1336 // VarTemplateSpecializationDecl Implementation
1337 //===----------------------------------------------------------------------===//
1338 
1340  Kind DK, ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
1341  SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T,
1343  : VarDecl(DK, Context, DC, StartLoc, IdLoc,
1344  SpecializedTemplate->getIdentifier(), T, TInfo, S),
1345  SpecializedTemplate(SpecializedTemplate),
1346  TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args)),
1347  SpecializationKind(TSK_Undeclared), IsCompleteDefinition(false) {}
1348 
1350  ASTContext &C)
1351  : VarDecl(DK, C, nullptr, SourceLocation(), SourceLocation(), nullptr,
1352  QualType(), nullptr, SC_None),
1353  SpecializationKind(TSK_Undeclared), IsCompleteDefinition(false) {}
1354 
1356  ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
1357  SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T,
1359  return new (Context, DC) VarTemplateSpecializationDecl(
1360  VarTemplateSpecialization, Context, DC, StartLoc, IdLoc,
1361  SpecializedTemplate, T, TInfo, S, Args);
1362 }
1363 
1366  return new (C, ID)
1367  VarTemplateSpecializationDecl(VarTemplateSpecialization, C);
1368 }
1369 
1371  raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const {
1372  NamedDecl::getNameForDiagnostic(OS, Policy, Qualified);
1373 
1374  const auto *PS = dyn_cast<VarTemplatePartialSpecializationDecl>(this);
1375  if (const ASTTemplateArgumentListInfo *ArgsAsWritten =
1376  PS ? PS->getTemplateArgsAsWritten() : nullptr) {
1378  OS, ArgsAsWritten->arguments(), Policy,
1379  getSpecializedTemplate()->getTemplateParameters());
1380  } else {
1381  const TemplateArgumentList &TemplateArgs = getTemplateArgs();
1383  OS, TemplateArgs.asArray(), Policy,
1384  getSpecializedTemplate()->getTemplateParameters());
1385  }
1386 }
1387 
1389  if (const auto *PartialSpec =
1390  SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
1391  return PartialSpec->PartialSpecialization->getSpecializedTemplate();
1392  return SpecializedTemplate.get<VarTemplateDecl *>();
1393 }
1394 
1396  const TemplateArgumentListInfo &ArgsInfo) {
1397  TemplateArgsInfo =
1399 }
1400 
1402  const ASTTemplateArgumentListInfo *ArgsInfo) {
1403  TemplateArgsInfo =
1405 }
1406 
1407 //===----------------------------------------------------------------------===//
1408 // VarTemplatePartialSpecializationDecl Implementation
1409 //===----------------------------------------------------------------------===//
1410 
1411 void VarTemplatePartialSpecializationDecl::anchor() {}
1412 
1413 VarTemplatePartialSpecializationDecl::VarTemplatePartialSpecializationDecl(
1414  ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
1415  SourceLocation IdLoc, TemplateParameterList *Params,
1416  VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo,
1418  const ASTTemplateArgumentListInfo *ArgInfos)
1419  : VarTemplateSpecializationDecl(VarTemplatePartialSpecialization, Context,
1420  DC, StartLoc, IdLoc, SpecializedTemplate, T,
1421  TInfo, S, Args),
1422  TemplateParams(Params), ArgsAsWritten(ArgInfos),
1423  InstantiatedFromMember(nullptr, false) {
1424  if (AdoptTemplateParameterList(Params, DC))
1425  setInvalidDecl();
1426 }
1427 
1430  ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
1431  SourceLocation IdLoc, TemplateParameterList *Params,
1432  VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo,
1434  const TemplateArgumentListInfo &ArgInfos) {
1435  const ASTTemplateArgumentListInfo *ASTArgInfos
1436  = ASTTemplateArgumentListInfo::Create(Context, ArgInfos);
1437 
1438  auto *Result =
1439  new (Context, DC) VarTemplatePartialSpecializationDecl(
1440  Context, DC, StartLoc, IdLoc, Params, SpecializedTemplate, T, TInfo,
1441  S, Args, ASTArgInfos);
1442  Result->setSpecializationKind(TSK_ExplicitSpecialization);
1443  return Result;
1444 }
1445 
1448  unsigned ID) {
1449  return new (C, ID) VarTemplatePartialSpecializationDecl(C);
1450 }
1451 
1452 static TemplateParameterList *
1454  // typename T
1455  auto *T = TemplateTypeParmDecl::Create(
1456  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/1, /*Position=*/0,
1457  /*Id=*/nullptr, /*Typename=*/true, /*ParameterPack=*/false,
1458  /*HasTypeConstraint=*/false);
1459  T->setImplicit(true);
1460 
1461  // T ...Ints
1462  TypeSourceInfo *TI =
1463  C.getTrivialTypeSourceInfo(QualType(T->getTypeForDecl(), 0));
1465  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/1,
1466  /*Id=*/nullptr, TI->getType(), /*ParameterPack=*/true, TI);
1467  N->setImplicit(true);
1468 
1469  // <typename T, T ...Ints>
1470  NamedDecl *P[2] = {T, N};
1471  auto *TPL = TemplateParameterList::Create(
1472  C, SourceLocation(), SourceLocation(), P, SourceLocation(), nullptr);
1473 
1474  // template <typename T, ...Ints> class IntSeq
1475  auto *TemplateTemplateParm = TemplateTemplateParmDecl::Create(
1476  C, DC, SourceLocation(), /*Depth=*/0, /*Position=*/0,
1477  /*ParameterPack=*/false, /*Id=*/nullptr, TPL);
1478  TemplateTemplateParm->setImplicit(true);
1479 
1480  // typename T
1481  auto *TemplateTypeParm = TemplateTypeParmDecl::Create(
1482  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/1,
1483  /*Id=*/nullptr, /*Typename=*/true, /*ParameterPack=*/false,
1484  /*HasTypeConstraint=*/false);
1485  TemplateTypeParm->setImplicit(true);
1486 
1487  // T N
1488  TypeSourceInfo *TInfo = C.getTrivialTypeSourceInfo(
1489  QualType(TemplateTypeParm->getTypeForDecl(), 0));
1490  auto *NonTypeTemplateParm = NonTypeTemplateParmDecl::Create(
1491  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/2,
1492  /*Id=*/nullptr, TInfo->getType(), /*ParameterPack=*/false, TInfo);
1493  NamedDecl *Params[] = {TemplateTemplateParm, TemplateTypeParm,
1494  NonTypeTemplateParm};
1495 
1496  // template <template <typename T, T ...Ints> class IntSeq, typename T, T N>
1498  Params, SourceLocation(), nullptr);
1499 }
1500 
1501 static TemplateParameterList *
1503  // std::size_t Index
1504  TypeSourceInfo *TInfo = C.getTrivialTypeSourceInfo(C.getSizeType());
1505  auto *Index = NonTypeTemplateParmDecl::Create(
1506  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/0,
1507  /*Id=*/nullptr, TInfo->getType(), /*ParameterPack=*/false, TInfo);
1508 
1509  // typename ...T
1510  auto *Ts = TemplateTypeParmDecl::Create(
1511  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/1,
1512  /*Id=*/nullptr, /*Typename=*/true, /*ParameterPack=*/true,
1513  /*HasTypeConstraint=*/false);
1514  Ts->setImplicit(true);
1515 
1516  // template <std::size_t Index, typename ...T>
1517  NamedDecl *Params[] = {Index, Ts};
1519  llvm::makeArrayRef(Params),
1520  SourceLocation(), nullptr);
1521 }
1522 
1524  const ASTContext &C, DeclContext *DC, BuiltinTemplateKind BTK) {
1525  switch (BTK) {
1526  case BTK__make_integer_seq:
1527  return createMakeIntegerSeqParameterList(C, DC);
1529  return createTypePackElementParameterList(C, DC);
1530  }
1531 
1532  llvm_unreachable("unhandled BuiltinTemplateKind!");
1533 }
1534 
1535 void BuiltinTemplateDecl::anchor() {}
1536 
1537 BuiltinTemplateDecl::BuiltinTemplateDecl(const ASTContext &C, DeclContext *DC,
1538  DeclarationName Name,
1539  BuiltinTemplateKind BTK)
1540  : TemplateDecl(BuiltinTemplate, DC, SourceLocation(), Name,
1542  BTK(BTK) {}
1543 
1544 void TypeConstraint::print(llvm::raw_ostream &OS, PrintingPolicy Policy) const {
1545  if (NestedNameSpec)
1548  if (hasExplicitTemplateArgs()) {
1549  OS << "<";
1550  // FIXME: Find corresponding parameter for argument
1551  for (auto &ArgLoc : ArgsAsWritten->arguments())
1552  ArgLoc.getArgument().print(Policy, OS, /*IncludeType*/ false);
1553  OS << ">";
1554  }
1555 }
1556 
1557 TemplateParamObjectDecl *TemplateParamObjectDecl::Create(const ASTContext &C,
1558  QualType T,
1559  const APValue &V) {
1560  DeclContext *DC = C.getTranslationUnitDecl();
1561  auto *TPOD = new (C, DC) TemplateParamObjectDecl(DC, T, V);
1562  C.addDestruction(&TPOD->Value);
1563  return TPOD;
1564 }
1565 
1567 TemplateParamObjectDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
1568  auto *TPOD = new (C, ID) TemplateParamObjectDecl(nullptr, QualType(), APValue());
1569  C.addDestruction(&TPOD->Value);
1570  return TPOD;
1571 }
1572 
1573 void TemplateParamObjectDecl::printName(llvm::raw_ostream &OS,
1574  const PrintingPolicy &Policy) const {
1575  OS << "<template param ";
1576  printAsExpr(OS, Policy);
1577  OS << ">";
1578 }
1579 
1580 void TemplateParamObjectDecl::printAsExpr(llvm::raw_ostream &OS) const {
1581  printAsExpr(OS, getASTContext().getPrintingPolicy());
1582 }
1583 
1584 void TemplateParamObjectDecl::printAsExpr(llvm::raw_ostream &OS,
1585  const PrintingPolicy &Policy) const {
1587  printAsInit(OS, Policy);
1588 }
1589 
1590 void TemplateParamObjectDecl::printAsInit(llvm::raw_ostream &OS) const {
1591  printAsInit(OS, getASTContext().getPrintingPolicy());
1592 }
1593 
1594 void TemplateParamObjectDecl::printAsInit(llvm::raw_ostream &OS,
1595  const PrintingPolicy &Policy) const {
1597 }
1598 
1600  switch (D->getKind()) {
1601  case Decl::Kind::ClassTemplate:
1602  return cast<ClassTemplateDecl>(D)->getTemplateParameters();
1603  case Decl::Kind::ClassTemplateSpecialization: {
1604  const auto *CTSD = cast<ClassTemplateSpecializationDecl>(D);
1605  auto P = CTSD->getSpecializedTemplateOrPartial();
1606  if (const auto *CTPSD =
1608  return CTPSD->getTemplateParameters();
1609  return cast<ClassTemplateDecl *>(P)->getTemplateParameters();
1610  }
1611  case Decl::Kind::ClassTemplatePartialSpecialization:
1612  return cast<ClassTemplatePartialSpecializationDecl>(D)
1613  ->getTemplateParameters();
1614  case Decl::Kind::TypeAliasTemplate:
1615  return cast<TypeAliasTemplateDecl>(D)->getTemplateParameters();
1616  case Decl::Kind::BuiltinTemplate:
1617  return cast<BuiltinTemplateDecl>(D)->getTemplateParameters();
1618  case Decl::Kind::CXXDeductionGuide:
1619  case Decl::Kind::CXXConversion:
1620  case Decl::Kind::CXXConstructor:
1621  case Decl::Kind::CXXDestructor:
1622  case Decl::Kind::CXXMethod:
1623  case Decl::Kind::Function:
1624  return cast<FunctionDecl>(D)
1625  ->getTemplateSpecializationInfo()
1626  ->getTemplate()
1627  ->getTemplateParameters();
1628  case Decl::Kind::FunctionTemplate:
1629  return cast<FunctionTemplateDecl>(D)->getTemplateParameters();
1630  case Decl::Kind::VarTemplate:
1631  return cast<VarTemplateDecl>(D)->getTemplateParameters();
1632  case Decl::Kind::VarTemplateSpecialization: {
1633  const auto *VTSD = cast<VarTemplateSpecializationDecl>(D);
1634  auto P = VTSD->getSpecializedTemplateOrPartial();
1635  if (const auto *VTPSD =
1637  return VTPSD->getTemplateParameters();
1638  return cast<VarTemplateDecl *>(P)->getTemplateParameters();
1639  }
1640  case Decl::Kind::VarTemplatePartialSpecialization:
1641  return cast<VarTemplatePartialSpecializationDecl>(D)
1642  ->getTemplateParameters();
1643  case Decl::Kind::TemplateTemplateParm:
1644  return cast<TemplateTemplateParmDecl>(D)->getTemplateParameters();
1645  case Decl::Kind::Concept:
1646  return cast<ConceptDecl>(D)->getTemplateParameters();
1647  default:
1648  llvm_unreachable("Unhandled templated declaration kind");
1649  }
1650 }
clang::TypeDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.h:3262
clang::TemplateParameterList::getRequiresClause
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
Definition: DeclTemplate.h:175
clang::TemplateDecl::getTemplatedDecl
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Definition: DeclTemplate.h:440
clang::allocateDefaultArgStorageChain
void * allocateDefaultArgStorageChain(const ASTContext &C)
Definition: DeclTemplate.cpp:220
Builtins.h
clang::FunctionTemplateDecl::LoadLazySpecializations
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
Definition: DeclTemplate.cpp:400
clang::FunctionTemplateDecl::mergePrevDecl
void mergePrevDecl(FunctionTemplateDecl *Prev)
Merge Prev with our RedeclarableTemplateDecl::Common.
Definition: DeclTemplate.cpp:422
clang::Decl::getASTContext
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:428
clang::TemplateParameterList::Create
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Definition: DeclTemplate.cpp:119
clang::ASTContext::getTypeDeclType
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Definition: ASTContext.h:1556
clang::VarTemplateDecl::findSpecialization
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
Definition: DeclTemplate.cpp:1271
clang::ClassTemplateDecl::Common::PartialSpecializations
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > PartialSpecializations
The class template partial specializations for this class template.
Definition: DeclTemplate.h:2282
clang::RedeclarableTemplateDecl::CommonBase
Definition: DeclTemplate.h:832
clang::FriendTemplateDecl
Declaration of a friend template.
Definition: DeclTemplate.h:2467
clang::RedeclarableTemplateDecl::newCommon
virtual CommonBase * newCommon(ASTContext &C) const =0
clang::TypeSourceInfo::getType
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6604
clang::TemplateTemplateParmDecl::hasDefaultArgument
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Definition: DeclTemplate.h:1742
clang::VarTemplateDecl::Common::Specializations
llvm::FoldingSetVector< VarTemplateSpecializationDecl > Specializations
The variable template specializations for this variable template, including explicit specializations ...
Definition: DeclTemplate.h:3110
clang::TemplateTypeParmDecl::defaultArgumentWasInherited
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
Definition: DeclTemplate.h:1289
clang::DeclContext::hasExternalLexicalStorage
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
Definition: DeclBase.h:2493
clang::TemplateTypeParmDecl::getIndex
unsigned getIndex() const
Retrieve the index of the template parameter.
Definition: DeclTemplate.cpp:695
clang::VarTemplatePartialSpecializationDecl::CreateDeserialized
static VarTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:1447
clang::MemberSpecializationInfo
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:630
clang::ClassTemplatePartialSpecializationDecl::Create
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)
Definition: DeclTemplate.cpp:1120
clang::Decl::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclBase.h:428
clang::TypeAliasTemplateDecl::CreateDeserialized
static TypeAliasTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty alias template node.
Definition: DeclTemplate.cpp:1190
clang::AutoType::isConstrained
bool isConstrained() const
Definition: Type.h:5265
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:210
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1389
clang::VarDecl::getCanonicalDecl
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: Decl.cpp:2183
clang::VarTemplateDecl::getPreviousDecl
VarTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this variable template, or nullptr if no such declaration exists...
Definition: DeclTemplate.h:3187
clang::TemplateDecl::hasAssociatedConstraints
bool hasAssociatedConstraints() const
Definition: DeclTemplate.cpp:245
clang::Decl::getASTMutationListener
ASTMutationListener * getASTMutationListener() const
Definition: DeclBase.cpp:438
clang::TemplateTypeParmDecl::CreateDeserialized
static TemplateTypeParmDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:658
llvm::SmallVector
Definition: LLVM.h:38
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::ASTContext::getTemplateSpecializationType
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
Definition: ASTContext.cpp:4986
clang::TTK_Struct
@ TTK_Struct
The "struct" keyword.
Definition: Type.h:5535
clang::FunctionTemplateDecl::findSpecialization
FunctionDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
Definition: DeclTemplate.cpp:411
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::SourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:219
clang::ClassTemplateSpecializationDecl::getSpecializedTemplate
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
Definition: DeclTemplate.cpp:986
clang::VarTemplateDecl::AddPartialSpecialization
void AddPartialSpecialization(VarTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
Definition: DeclTemplate.cpp:1298
clang::ClassTemplateSpecializationDecl::getExternLoc
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
Definition: DeclTemplate.h:2053
clang::ClassTemplateSpecializationDecl::Create
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
Definition: DeclTemplate.cpp:933
clang::Stmt::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:324
clang::TSK_Undeclared
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
Definition: Specifiers.h:179
clang::ClassTemplateDecl::Common::InjectedClassNameType
QualType InjectedClassNameType
The injected-class-name type for this class template.
Definition: DeclTemplate.h:2285
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:737
clang::TypeDecl::getTypeForDecl
const Type * getTypeForDecl() const
Definition: Decl.h:3257
clang::NonTypeTemplateParmDecl
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Definition: DeclTemplate.h:1407
clang::TemplateDecl::getAssociatedConstraints
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
Get the total constraint-expression associated with this template, including constraint-expressions d...
Definition: DeclTemplate.cpp:238
clang::RedeclarableTemplateDecl::SpecEntryTraits
Definition: DeclTemplate.h:782
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:56
clang::ClassScopeFunctionSpecializationDecl
Declaration of a function specialization at template class scope.
Definition: DeclTemplate.h:2627
clang::TemplateTemplateParmDecl::setDefaultArgument
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Definition: DeclTemplate.cpp:867
clang::ClassTemplateSpecializationDecl::getSpecializationKind
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
Definition: DeclTemplate.h:1924
clang::VarTemplateDecl::getCommonPtr
Common * getCommonPtr() const
Definition: DeclTemplate.h:3136
DeclCXX.h
clang::NonTypeTemplateParmDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.cpp:794
clang::VarTemplateSpecializationDecl::getNameForDiagnostic
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
Appends a human-readable name for this declaration into the given stream.
Definition: DeclTemplate.cpp:1370
llvm::Optional< unsigned >
clang::TypeLoc::getEndLoc
SourceLocation getEndLoc() const
Get the end source location.
Definition: TypeLoc.cpp:234
clang::TemplateTypeParmDecl::Create
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, Optional< unsigned > NumExpanded=std::nullopt)
Definition: DeclTemplate.cpp:641
clang::NonTypeTemplateParmDecl::hasDefaultArgument
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Definition: DeclTemplate.h:1486
clang::VarTemplateSpecializationDecl::getTemplateArgs
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
Definition: DeclTemplate.h:2778
clang::TemplateArgument::isNull
bool isNull() const
Determine whether this template argument has no value.
Definition: TemplateBase.h:249
clang::VarTemplateDecl::findPartialSpecInstantiatedFromMember
VarTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(VarTemplatePartialSpecializationDecl *D)
Find a variable template partial specialization which was instantiated from the given member partial ...
Definition: DeclTemplate.cpp:1324
clang::ClassTemplateSpecializationDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.cpp:994
clang::printTemplateArgumentList
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy, const TemplateParameterList *TPL=nullptr)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
Definition: TypePrinter.cpp:2152
clang::DeclaratorDecl::getOuterLocStart
SourceLocation getOuterLocStart() const
Return start of source range taking into account any outer template declarations.
Definition: Decl.cpp:1975
clang::ClassTemplatePartialSpecializationDecl
Definition: DeclTemplate.h:2098
clang::PrintingPolicy
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
clang::Expr::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
Definition: Expr.h:232
clang::RedeclarableTemplateDecl
Declaration of a redeclarable template.
Definition: DeclTemplate.h:763
print
void print(llvm::raw_ostream &OS, const Pointer &P, ASTContext &Ctx, QualType Ty)
Definition: InterpFrame.cpp:97
clang::FunctionTemplateDecl::Create
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
Definition: DeclTemplate.cpp:377
clang::NamedDecl::getNameForDiagnostic
virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const
Appends a human-readable name for this declaration into the given stream.
Definition: Decl.cpp:1769
clang::VarTemplateSpecializationDecl
Represents a variable template specialization, which refers to a variable template with a given set o...
Definition: DeclTemplate.h:2687
TemplateName.h
createTypePackElementParameterList
static TemplateParameterList * createTypePackElementParameterList(const ASTContext &C, DeclContext *DC)
Definition: DeclTemplate.cpp:1502
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:144
End
SourceLocation End
Definition: USRLocFinder.cpp:167
clang::ClassTemplateDecl::Common
Data that is common to all of the declarations of a given class template.
Definition: DeclTemplate.h:2274
clang::ClassTemplateDecl::CreateDeserialized
static ClassTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty class template node.
Definition: DeclTemplate.cpp:472
clang::ASTTemplateArgumentListInfo::arguments
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:645
clang::TemplateParamObjectDecl::printAsInit
void printAsInit(llvm::raw_ostream &OS) const
Print this object as an initializer suitable for a variable of the object's type.
Definition: DeclTemplate.cpp:1590
clang::DeclaratorContext::TemplateArg
@ TemplateArg
clang::TemplateTypeParmDecl::getDefaultArgumentInfo
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
Definition: DeclTemplate.h:1280
clang::TemplateTypeParmDecl::setTypeConstraint
void setTypeConstraint(NestedNameSpecifierLoc NNS, DeclarationNameInfo NameInfo, NamedDecl *FoundDecl, ConceptDecl *CD, const ASTTemplateArgumentListInfo *ArgsAsWritten, Expr *ImmediatelyDeclaredConstraint)
Definition: DeclTemplate.cpp:703
clang::TemplateTypeParmDecl::hasDefaultArgument
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Definition: DeclTemplate.h:1272
createBuiltinTemplateParameterList
static TemplateParameterList * createBuiltinTemplateParameterList(const ASTContext &C, DeclContext *DC, BuiltinTemplateKind BTK)
Definition: DeclTemplate.cpp:1523
clang::VarTemplateSpecializationDecl::setTemplateArgsInfo
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
Definition: DeclTemplate.cpp:1395
clang::TemplateParameterList::getAssociatedConstraints
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
All associated constraints derived from this template parameter list, including the requires clause a...
Definition: DeclTemplate.cpp:186
clang::FriendTemplateDecl::Create
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList * > Params, FriendUnion Friend, SourceLocation FriendLoc)
Definition: DeclTemplate.cpp:1157
clang::TypeLoc::getBeginLoc
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:191
clang::ClassTemplateDecl::getPartialSpecializations
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
Definition: DeclTemplate.cpp:489
clang::TemplateTypeParmDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.cpp:679
clang::ASTContext::Allocate
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:707
clang::TemplateArgumentLoc::getLocation
SourceLocation getLocation() const
Definition: TemplateBase.h:497
clang::FunctionTemplateDecl
Declaration of a template function.
Definition: DeclTemplate.h:1006
llvm::MutableArrayRef
Definition: LLVM.h:35
AdoptTemplateParameterList
static bool AdoptTemplateParameterList(TemplateParameterList *Params, DeclContext *Owner)
Definition: DeclTemplate.cpp:169
TemplateBase.h
clang::ClassTemplatePartialSpecializationDecl::getInstantiatedFromMember
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
Definition: DeclTemplate.h:2198
clang::TSK_ExplicitInstantiationDeclaration
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
Definition: Specifiers.h:190
V
#define V(N, I)
Definition: ASTContext.h:3208
clang::ASTContext::getExternalSource
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
Definition: ASTContext.h:1167
clang::TemplateDecl::TemplateDecl
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.cpp:230
clang::NonTypeTemplateParmDecl::defaultArgumentWasInherited
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
Definition: DeclTemplate.h:1496
clang::Decl::Kind
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:86
clang::VarTemplateDecl::VarTemplateDecl
VarTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:3129
clang::TemplateArgumentList::CreateCopy
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
Definition: DeclTemplate.cpp:886
clang::VarTemplateDecl::Create
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
Definition: DeclTemplate.cpp:1230
clang::ClassTemplateSpecializationDecl::getTemplateArgs
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
Definition: DeclTemplate.h:1914
clang::TemplateParameterList::getParam
NamedDecl * getParam(unsigned Idx)
Definition: DeclTemplate.h:139
DeclTemplate.h
clang::ClassTemplateDecl::ClassTemplateDecl
ClassTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:2299
clang::TemplateArgumentListInfo
A convenient class for passing around template argument information.
Definition: TemplateBase.h:565
ProfileTemplateParameterList
static void ProfileTemplateParameterList(ASTContext &C, llvm::FoldingSetNodeID &ID, const TemplateParameterList *TPL)
Definition: DeclTemplate.cpp:520
clang::TagTypeKind
TagTypeKind
The kind of a tag type.
Definition: Type.h:5533
clang::ClassTemplateDecl::newCommon
CommonBase * newCommon(ASTContext &C) const override
Definition: DeclTemplate.cpp:495
clang::Decl::getKind
Kind getKind() const
Definition: DeclBase.h:435
Id
int Id
Definition: ASTDiff.cpp:189
clang::VarTemplateDecl::getPartialSpecializations
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
Definition: DeclTemplate.cpp:1258
clang::ConceptDecl
Declaration of a C++20 concept.
Definition: DeclTemplate.h:3259
clang::DeclaratorDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.cpp:2015
clang::SourceRange::getEnd
SourceLocation getEnd() const
Definition: SourceLocation.h:220
clang::NonTypeTemplateParmDecl::CreateDeserialized
static NonTypeTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID, bool HasTypeConstraint)
Definition: DeclTemplate.cpp:769
clang::TemplateDecl::TemplateParams
TemplateParameterList * TemplateParams
Definition: DeclTemplate.h:459
clang::FunctionTemplateDecl::getCommonPtr
Common * getCommonPtr() const
Definition: DeclTemplate.h:1028
clang::ConceptReference::ConceptName
DeclarationNameInfo ConceptName
The concept name used.
Definition: ASTConcept.h:111
clang::RedeclarableTemplateDecl::RedeclarableTemplateDecl
RedeclarableTemplateDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:872
clang::FunctionTemplateDecl::Common
Data that is common to all of the declarations of a given function template.
Definition: DeclTemplate.h:1012
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:182
clang::TemplateParameterList::TemplateParameterList
TemplateParameterList(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Definition: DeclTemplate.cpp:48
clang::FriendTemplateDecl::FriendUnion
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
Definition: DeclTemplate.h:2471
getIdentifier
static StringRef getIdentifier(const Token &Tok)
Definition: ParsePragma.cpp:1518
clang::ClassTemplateSpecializationDecl::CreateDeserialized
static ClassTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:959
clang::ClassTemplateDecl::LoadLazySpecializations
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
Definition: DeclTemplate.cpp:478
clang::VarTemplateDecl::getDefinition
VarTemplateDecl * getDefinition()
Definition: DeclTemplate.cpp:1220
clang::ImplicitConceptSpecializationDecl::setTemplateArguments
void setTemplateArguments(ArrayRef< TemplateArgument > Converted)
Definition: DeclTemplate.cpp:1086
clang::VarTemplateDecl::Common::PartialSpecializations
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > PartialSpecializations
The variable template partial specializations for this variable template.
Definition: DeclTemplate.h:3115
clang::TemplateParameterList::hasAssociatedConstraints
bool hasAssociatedConstraints() const
Definition: DeclTemplate.cpp:201
clang::VarTemplateDecl::LoadLazySpecializations
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
Definition: DeclTemplate.cpp:1247
clang::TemplateArgument
Represents a template argument.
Definition: TemplateBase.h:61
clang::ASTMutationListener
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Definition: ASTMutationListener.h:46
clang::RISCV::Policy
Policy
Definition: RISCVVIntrinsicUtils.h:96
clang::ClassTemplateDecl::findPartialSpecInstantiatedFromMember
ClassTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *D)
Find a class template partial specialization which was instantiated from the given member partial spe...
Definition: DeclTemplate.cpp:602
clang::AutoType
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Definition: Type.h:5246
clang::TemplateArgumentLoc
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:459
Type.h
Expr.h
clang::ConceptDecl::Create
static ConceptDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, Expr *ConstraintExpr)
Definition: DeclTemplate.cpp:1035
clang::TemplateTemplateParmDecl
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Definition: DeclTemplate.h:1624
ASTContext.h
clang::TypeDecl::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Decl.h:3260
clang::FunctionTemplateDecl::newCommon
CommonBase * newCommon(ASTContext &C) const override
Definition: DeclTemplate.cpp:394
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:906
clang::TemplateArgumentLoc::getArgument
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:508
clang::ConceptReference::hasExplicitTemplateArgs
bool hasExplicitTemplateArgs() const
Whether or not template arguments were explicitly specified in the concept reference (they might not ...
Definition: ASTConcept.h:164
clang::NonTypeTemplateParmDecl::Create
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
Definition: DeclTemplate.cpp:739
clang::TemplateParameterList
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:70
clang::TSK_ExplicitInstantiationDefinition
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
Definition: Specifiers.h:194
clang::TemplateTemplateParmDecl::Create
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params)
Definition: DeclTemplate.cpp:826
clang::getExpandedPackSize
Optional< unsigned > getExpandedPackSize(const NamedDecl *Param)
Check whether the template parameter is a pack expansion, and if so, determine the number of paramete...
Definition: DeclTemplate.h:3437
clang::FunctionTemplateSpecializationInfo::Create
static FunctionTemplateSpecializationInfo * Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template, TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI, MemberSpecializationInfo *MSInfo)
Definition: DeclTemplate.cpp:892
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:243
clang::Redeclarable< RedeclarableTemplateDecl >::getPreviousDecl
RedeclarableTemplateDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Definition: Redeclarable.h:204
clang::FriendTemplateDecl::CreateDeserialized
static FriendTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:1170
clang::Stmt::Profile
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
Definition: StmtProfile.cpp:2369
Base
clang::TagDecl::isCompleteDefinition
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3528
clang::ImplicitConceptSpecializationDecl::Create
static ImplicitConceptSpecializationDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation SL, ArrayRef< TemplateArgument > ConvertedArgs)
Definition: DeclTemplate.cpp:1071
clang::DefaultArgStorage::set
void set(ArgType Arg)
Set the default argument.
Definition: DeclTemplate.h:369
clang::VarTemplateSpecializationDecl::Create
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
Definition: DeclTemplate.cpp:1355
clang::TemplateTypeParmDecl
Declaration of a template type parameter.
Definition: DeclTemplate.h:1205
clang::TemplateParamObjectDecl
A template parameter object.
Definition: DeclTemplate.h:3349
clang::ConceptReference::ArgsAsWritten
const ASTTemplateArgumentListInfo * ArgsAsWritten
The template argument list source info used to specialize the concept.
Definition: ASTConcept.h:124
ExternalASTSource.h
clang::ClassTemplateDecl::findSpecialization
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
Definition: DeclTemplate.cpp:502
clang::TemplateDecl::getTemplateParameters
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:427
clang::QualType::getUnqualifiedType
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition: Type.h:6715
clang::ClassTemplateDecl::AddSpecialization
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
Definition: DeclTemplate.cpp:507
clang::TemplateArgumentList::asArray
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Definition: DeclTemplate.h:291
clang::ClassTemplateSpecializationDecl::getTypeAsWritten
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
Definition: DeclTemplate.h:2048
clang::TemplateTypeParmType
Definition: Type.h:5002
clang::TemplateParamObjectDecl::printAsExpr
void printAsExpr(llvm::raw_ostream &OS) const
Print this object as an equivalent expression.
Definition: DeclTemplate.cpp:1580
clang::RedeclarableTemplateDecl::loadLazySpecializationsImpl
void loadLazySpecializationsImpl() const
Definition: DeclTemplate.cpp:301
clang::VarTemplateDecl::getSpecializations
llvm::FoldingSetVector< VarTemplateSpecializationDecl > & getSpecializations() const
Retrieve the set of specializations of this variable template.
Definition: DeclTemplate.cpp:1252
clang::VarTemplateDecl::Common
Data that is common to all of the declarations of a given variable template.
Definition: DeclTemplate.h:3107
clang::Type::castAs
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:7453
clang::ConceptDecl::ConstraintExpr
Expr * ConstraintExpr
Definition: DeclTemplate.h:3261
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
SourceLocation.h
P
StringRef P
Definition: ASTMatchersInternal.cpp:564
clang::DeclarationNameInfo::printName
void printName(raw_ostream &OS, PrintingPolicy Policy) const
printName - Print the human-readable name to a stream.
Definition: DeclarationName.cpp:472
clang::ConceptReference::NestedNameSpec
NestedNameSpecifierLoc NestedNameSpec
Definition: ASTConcept.h:104
clang::TemplateSpecializationKind
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition: Specifiers.h:176
clang::NestedNameSpecifier::print
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
Definition: NestedNameSpecifier.cpp:252
clang::Type::getContainedAutoType
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
Definition: Type.h:2409
clang::FunctionTemplateSpecializationInfo
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Definition: DeclTemplate.h:478
clang::TagDecl::getBraceRange
SourceRange getBraceRange() const
Definition: Decl.h:3504
clang::NonTypeTemplateParmDecl::getDefaultArgument
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
Definition: DeclTemplate.h:1489
false
#define false
Definition: stdbool.h:22
clang::APValue::printPretty
void printPretty(raw_ostream &OS, const ASTContext &Ctx, QualType Ty) const
Definition: APValue.cpp:691
clang::FunctionTemplateDecl::addSpecialization
void addSpecialization(FunctionTemplateSpecializationInfo *Info, void *InsertPos)
Add a specialization of this function template.
Definition: DeclTemplate.cpp:416
clang::ClassTemplateDecl
Declaration of a class template.
Definition: DeclTemplate.h:2270
clang::ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl
ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
Definition: DeclTemplate.cpp:913
clang::VarTemplateDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary variable pattern.
Definition: DeclTemplate.h:3154
clang::ClassTemplateDecl::findPartialSpecialization
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
Definition: DeclTemplate.cpp:513
clang::TemplateName
Represents a C++ template name within the type system.
Definition: TemplateName.h:201
clang::ImplicitConceptSpecializationDecl
Definition: DeclTemplate.h:3306
clang::VarTemplateSpecializationDecl::CreateDeserialized
static VarTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:1365
clang::RedeclarableTemplateDecl::CommonBase::LazySpecializations
uint32_t * LazySpecializations
If non-null, points to an array of specializations (including partial specializations) known only by ...
Definition: DeclTemplate.h:848
clang::TemplateDecl
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:408
clang::VarTemplatePartialSpecializationDecl
Definition: DeclTemplate.h:2949
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:802
Begin
SourceLocation Begin
Definition: USRLocFinder.cpp:165
llvm::ArrayRef
Definition: LLVM.h:34
clang::RedeclarableTemplateDecl::getCommonPtr
CommonBase * getCommonPtr() const
Retrieves the "common" pointer shared by all (re-)declarations of the same template.
Definition: DeclTemplate.cpp:269
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
clang::DeclaratorDecl
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:758
clang::ClassTemplatePartialSpecializationDecl::CreateDeserialized
static ClassTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:1143
clang::VarTemplateDecl::AddSpecialization
void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
Definition: DeclTemplate.cpp:1276
ASTMutationListener.h
clang::TypeAliasTemplateDecl::Create
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
Definition: DeclTemplate.cpp:1180
LLVM.h
clang::ClassTemplateDecl::getTemplatedDecl
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
Definition: DeclTemplate.h:2318
clang::TSK_ExplicitSpecialization
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
Definition: Specifiers.h:186
clang::VarTemplatePartialSpecializationDecl::Create
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)
Definition: DeclTemplate.cpp:1429
clang::TemplateTypeParmDecl::getDefaultArgumentLoc
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
Definition: DeclTemplate.cpp:673
clang::TemplateArgumentList
A template argument list.
Definition: DeclTemplate.h:238
clang::Redeclarable< RedeclarableTemplateDecl >::getMostRecentDecl
RedeclarableTemplateDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Definition: Redeclarable.h:226
clang::TemplateParameterList::size
unsigned size() const
Definition: DeclTemplate.h:130
clang::ASTContext::getInjectedTemplateArgs
void getInjectedTemplateArgs(const TemplateParameterList *Params, SmallVectorImpl< TemplateArgument > &Args)
Get a template argument list with one argument per template parameter in a template parameter list,...
Definition: ASTContext.cpp:5257
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:85
clang::ClassScopeFunctionSpecializationDecl::CreateDeserialized
static ClassScopeFunctionSpecializationDecl * CreateDeserialized(ASTContext &Context, unsigned ID)
Definition: DeclTemplate.cpp:1210
clang::TemplateParameterList::asArray
ArrayRef< NamedDecl * > asArray()
Definition: DeclTemplate.h:132
clang::ConceptDecl::ConceptDecl
ConceptDecl(DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, Expr *ConstraintExpr)
Definition: DeclTemplate.h:3263
clang::ASTContext::getInjectedClassNameType
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const
getInjectedClassNameType - Return the unique reference to the injected class name type for the specif...
Definition: ASTContext.cpp:4652
clang::ClassTemplatePartialSpecializationDecl::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: DeclTemplate.h:2253
clang::RedeclarableTemplateDecl::addSpecializationImpl
void addSpecializationImpl(llvm::FoldingSetVector< EntryType > &Specs, EntryType *Entry, void *InsertPos)
Definition: DeclTemplate.cpp:329
clang::TemplateParameterList::getDepth
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
Definition: DeclTemplate.cpp:156
clang::TemplateTypeParmDecl::isParameterPack
bool isParameterPack() const
Returns whether this is a parameter pack.
Definition: DeclTemplate.cpp:699
DeclarationName.h
clang::VarTemplatePartialSpecializationDecl::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: DeclTemplate.h:3086
clang::TemplateParamObjectDecl::printName
void printName(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const override
Print this template parameter object in a human-readable format.
Definition: DeclTemplate.cpp:1573
clang::RedeclarableTemplateDecl::Common
CommonBase * Common
Pointer to the common data shared by all declarations of this template.
Definition: DeclTemplate.h:862
clang::ClassTemplateSpecializationDecl::getNameForDiagnostic
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
Appends a human-readable name for this declaration into the given stream.
Definition: DeclTemplate.cpp:967
clang::FunctionTemplateDecl::getPreviousDecl
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
Definition: DeclTemplate.h:1078
clang::Builtin::ID
ID
Definition: Builtins.h:52
clang::SourceLocation::isInvalid
bool isInvalid() const
Definition: SourceLocation.h:111
clang::ClassTemplateSpecializationDecl::getInstantiatedFrom
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this class template specialization is an instantiation of a template (rather than an explicit spec...
Definition: DeclTemplate.h:1978
clang::TemplateTemplateParmDecl::getDefaultArgument
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
Definition: DeclTemplate.h:1745
clang::FunctionTemplateDecl::FunctionTemplateDecl
FunctionTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:1020
clang::ClassTemplateDecl::Create
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a class template node.
Definition: DeclTemplate.cpp:460
clang
Definition: CalledOnceCheck.h:17
clang::TemplateTemplateParmDecl::getDefaultArgumentLoc
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
Definition: DeclTemplate.cpp:862
clang::FunctionTemplateDecl::getSpecializations
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > & getSpecializations() const
Retrieve the set of function template specializations of this function template.
Definition: DeclTemplate.cpp:405
clang::TemplateDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.h:452
clang::CXXRecordDecl::getCanonicalDecl
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:502
clang::ClassTemplateDecl::Common::Specializations
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > Specializations
The class template specializations for this class template, including explicit specializations and in...
Definition: DeclTemplate.h:2277
clang::RedeclarableTemplateDecl::findSpecializationImpl
SpecEntryTraits< EntryType >::DeclType * findSpecializationImpl(llvm::FoldingSetVector< EntryType > &Specs, void *&InsertPos, ProfileArguments &&...ProfileArgs)
Definition: DeclTemplate.cpp:316
createMakeIntegerSeqParameterList
static TemplateParameterList * createMakeIntegerSeqParameterList(const ASTContext &C, DeclContext *DC)
Definition: DeclTemplate.cpp:1453
clang::NestedNameSpecifierLoc::getNestedNameSpecifier
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Definition: NestedNameSpecifier.h:274
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:110
clang::VarTemplateDecl::newCommon
CommonBase * newCommon(ASTContext &C) const override
Definition: DeclTemplate.cpp:1264
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6593
clang::BTK__make_integer_seq
@ BTK__make_integer_seq
This names the __make_integer_seq BuiltinTemplateDecl.
Definition: Builtins.h:292
clang::TemplateParmPosition
Defines the position of a template parameter within a template parameter list.
Definition: DeclTemplate.h:1158
clang::NamedDecl::getDeclName
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:313
clang::TemplateParameterList::begin
iterator begin()
Definition: DeclTemplate.h:125
clang::ClassTemplateDecl::getCommonPtr
Common * getCommonPtr() const
Definition: DeclTemplate.h:2306
clang::getReplacedTemplateParameterList
TemplateParameterList * getReplacedTemplateParameterList(Decl *D)
Internal helper used by Subst* nodes to retrieve the parameter list for their AssociatedDecl.
Definition: DeclTemplate.cpp:1599
clang::TemplateParameterList::shouldIncludeTypeForArgument
static bool shouldIncludeTypeForArgument(const PrintingPolicy &Policy, const TemplateParameterList *TPL, unsigned Idx)
Definition: DeclTemplate.cpp:205
clang::ClassTemplateSpecializationDecl::getTemplateKeywordLoc
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
Definition: DeclTemplate.h:2072
clang::ASTTemplateArgumentListInfo::Create
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
Definition: TemplateBase.cpp:603
clang::ClassTemplateDecl::getSpecializations
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > & getSpecializations() const
Retrieve the set of specializations of this class template.
Definition: DeclTemplate.cpp:483
clang::RedeclarableTemplateDecl::SpecEntryTraits::DeclType
EntryType DeclType
Definition: DeclTemplate.h:783
clang::VarTemplateSpecializationDecl::getSpecializedTemplate
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
Definition: DeclTemplate.cpp:1388
clang::FunctionTemplateDecl::Common::Specializations
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > Specializations
The function template specializations for this function template, including explicit specializations ...
Definition: DeclTemplate.h:1015
clang::ImplicitConceptSpecializationDecl::CreateDeserialized
static ImplicitConceptSpecializationDecl * CreateDeserialized(const ASTContext &C, unsigned ID, unsigned NumTemplateArgs)
Definition: DeclTemplate.cpp:1080
clang::TypeAliasTemplateDecl
Declaration of an alias template.
Definition: DeclTemplate.h:2543
clang::TemplateParameterList::getMinRequiredArguments
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization.
Definition: DeclTemplate.cpp:130
clang::TemplateTemplateParmDecl::CreateDeserialized
static TemplateTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:846
clang::TypeAliasTemplateDecl::TypeAliasTemplateDecl
TypeAliasTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:2547
clang::QualType::getTypePtr
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:6622
clang::Decl::EmptyShell
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
Definition: DeclBase.h:99
clang::Decl::setInvalidDecl
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
Definition: DeclBase.cpp:132
clang::ClassTemplateDecl::getInjectedClassNameSpecialization
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template.
Definition: DeclTemplate.cpp:614
clang::ExternalASTSource::GetExternalDecl
virtual Decl * GetExternalDecl(uint32_t ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
Definition: ExternalASTSource.cpp:71
clang::QualType::print
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Definition: TypePrinter.cpp:2320
clang::APValue
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition: APValue.h:122
clang::ConceptDecl::CreateDeserialized
static ConceptDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:1046
clang::ASTContext::hasSameType
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Definition: ASTContext.h:2517
clang::ASTTemplateArgumentListInfo
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:614
llvm::SmallVectorImpl
Definition: Randstruct.h:18
clang::TemplateParameterList::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Determine whether this template parameter list contains an unexpanded parameter pack.
Definition: DeclTemplate.cpp:94
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:712
clang::SC_None
@ SC_None
Definition: Specifiers.h:238
true
#define true
Definition: stdbool.h:21
clang::VarTemplateDecl
Declaration of a variable template.
Definition: DeclTemplate.h:3103
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::NonTypeTemplateParmDecl::getDefaultArgumentLoc
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
Definition: DeclTemplate.cpp:801
clang::FunctionTemplateDecl::CreateDeserialized
static FunctionTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty function template node.
Definition: DeclTemplate.cpp:387
clang::TemplateParamObjectDecl::getValue
const APValue & getValue() const
Definition: DeclTemplate.h:3386
clang::TypeAliasTemplateDecl::newCommon
CommonBase * newCommon(ASTContext &C) const override
Definition: DeclTemplate.cpp:1197
clang::DeclarationNameInfo
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Definition: DeclarationName.h:767
clang::ClassTemplateSpecializationDecl
Represents a class template specialization, which refers to a class template with a given set of temp...
Definition: DeclTemplate.h:1826
clang::BTK__type_pack_element
@ BTK__type_pack_element
This names the __type_pack_element BuiltinTemplateDecl.
Definition: Builtins.h:295
clang::TemplateDecl::isTypeAlias
bool isTypeAlias() const
Definition: DeclTemplate.cpp:253
clang::Decl::isCanonicalDecl
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Definition: DeclBase.h:949
clang::BuiltinTemplateKind
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
Definition: Builtins.h:290
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1904
clang::TemplateTypeParmDecl::getDepth
unsigned getDepth() const
Retrieve the depth of the template parameter.
Definition: DeclTemplate.cpp:691
clang::VarTemplateSpecializationDecl::VarTemplateSpecializationDecl
VarTemplateSpecializationDecl(Kind DK, ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
Definition: DeclTemplate.cpp:1339
clang::TypeConstraint
Definition: ASTConcept.h:169
clang::VarTemplateDecl::findPartialSpecialization
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
Definition: DeclTemplate.cpp:1282
clang::ClassTemplateDecl::AddPartialSpecialization
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
Definition: DeclTemplate.cpp:563
TypeLoc.h
clang::TypeSourceInfo::getTypeLoc
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:244
clang::RedeclarableTemplateDecl::getInjectedTemplateArgs
ArrayRef< TemplateArgument > getInjectedTemplateArgs()
Retrieve the "injected" template arguments that correspond to the template parameters of this templat...
Definition: DeclTemplate.cpp:356
clang::VarTemplateDecl::CreateDeserialized
static VarTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty variable template node.
Definition: DeclTemplate.cpp:1241
clang::StorageClass
StorageClass
Storage classes.
Definition: Specifiers.h:236