clang  15.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 
253 //===----------------------------------------------------------------------===//
254 // RedeclarableTemplateDecl Implementation
255 //===----------------------------------------------------------------------===//
256 
257 void RedeclarableTemplateDecl::anchor() {}
258 
260  if (Common)
261  return Common;
262 
263  // Walk the previous-declaration chain until we either find a declaration
264  // with a common pointer or we run out of previous declarations.
266  for (const RedeclarableTemplateDecl *Prev = getPreviousDecl(); Prev;
267  Prev = Prev->getPreviousDecl()) {
268  if (Prev->Common) {
269  Common = Prev->Common;
270  break;
271  }
272 
273  PrevDecls.push_back(Prev);
274  }
275 
276  // If we never found a common pointer, allocate one now.
277  if (!Common) {
278  // FIXME: If any of the declarations is from an AST file, we probably
279  // need an update record to add the common data.
280 
282  }
283 
284  // Update any previous declarations we saw with the common pointer.
285  for (const RedeclarableTemplateDecl *Prev : PrevDecls)
286  Prev->Common = Common;
287 
288  return Common;
289 }
290 
292  // Grab the most recent declaration to ensure we've loaded any lazy
293  // redeclarations of this template.
294  CommonBase *CommonBasePtr = getMostRecentDecl()->getCommonPtr();
295  if (CommonBasePtr->LazySpecializations) {
296  ASTContext &Context = getASTContext();
297  uint32_t *Specs = CommonBasePtr->LazySpecializations;
298  CommonBasePtr->LazySpecializations = nullptr;
299  for (uint32_t I = 0, N = *Specs++; I != N; ++I)
300  (void)Context.getExternalSource()->GetExternalDecl(Specs[I]);
301  }
302 }
303 
304 template<class EntryType, typename... ProfileArguments>
307  llvm::FoldingSetVector<EntryType> &Specs, void *&InsertPos,
308  ProfileArguments&&... ProfileArgs) {
309  using SETraits = SpecEntryTraits<EntryType>;
310 
311  llvm::FoldingSetNodeID ID;
312  EntryType::Profile(ID, std::forward<ProfileArguments>(ProfileArgs)...,
313  getASTContext());
314  EntryType *Entry = Specs.FindNodeOrInsertPos(ID, InsertPos);
315  return Entry ? SETraits::getDecl(Entry)->getMostRecentDecl() : nullptr;
316 }
317 
318 template<class Derived, class EntryType>
320  llvm::FoldingSetVector<EntryType> &Specializations, EntryType *Entry,
321  void *InsertPos) {
322  using SETraits = SpecEntryTraits<EntryType>;
323 
324  if (InsertPos) {
325 #ifndef NDEBUG
326  void *CorrectInsertPos;
327  assert(!findSpecializationImpl(Specializations,
328  CorrectInsertPos,
329  SETraits::getTemplateArgs(Entry)) &&
330  InsertPos == CorrectInsertPos &&
331  "given incorrect InsertPos for specialization");
332 #endif
333  Specializations.InsertNode(Entry, InsertPos);
334  } else {
335  EntryType *Existing = Specializations.GetOrInsertNode(Entry);
336  (void)Existing;
337  assert(SETraits::getDecl(Existing)->isCanonicalDecl() &&
338  "non-canonical specialization?");
339  }
340 
342  L->AddedCXXTemplateSpecialization(cast<Derived>(this),
343  SETraits::getDecl(Entry));
344 }
345 
346 //===----------------------------------------------------------------------===//
347 // FunctionTemplateDecl Implementation
348 //===----------------------------------------------------------------------===//
349 
352  DeclarationName Name,
354  bool Invalid = AdoptTemplateParameterList(Params, cast<DeclContext>(Decl));
355  auto *TD = new (C, DC) FunctionTemplateDecl(C, DC, L, Name, Params, Decl);
356  if (Invalid)
357  TD->setInvalidDecl();
358  return TD;
359 }
360 
362  unsigned ID) {
363  return new (C, ID) FunctionTemplateDecl(C, nullptr, SourceLocation(),
364  DeclarationName(), nullptr, nullptr);
365 }
366 
369  auto *CommonPtr = new (C) Common;
370  C.addDestruction(CommonPtr);
371  return CommonPtr;
372 }
373 
376 }
377 
378 llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> &
381  return getCommonPtr()->Specializations;
382 }
383 
384 FunctionDecl *
386  void *&InsertPos) {
387  return findSpecializationImpl(getSpecializations(), InsertPos, Args);
388 }
389 
391  FunctionTemplateSpecializationInfo *Info, void *InsertPos) {
392  addSpecializationImpl<FunctionTemplateDecl>(getSpecializations(), Info,
393  InsertPos);
394 }
395 
398  Common *CommonPtr = getCommonPtr();
399  if (!CommonPtr->InjectedArgs) {
400  auto &Context = getASTContext();
402  Context.getInjectedTemplateArgs(Params, TemplateArgs);
403  CommonPtr->InjectedArgs =
404  new (Context) TemplateArgument[TemplateArgs.size()];
405  std::copy(TemplateArgs.begin(), TemplateArgs.end(),
406  CommonPtr->InjectedArgs);
407  }
408 
409  return llvm::makeArrayRef(CommonPtr->InjectedArgs, Params->size());
410 }
411 
414 
415  // If we haven't created a common pointer yet, then it can just be created
416  // with the usual method.
417  if (!Base::Common)
418  return;
419 
420  Common *ThisCommon = static_cast<Common *>(Base::Common);
421  Common *PrevCommon = nullptr;
423  for (; Prev; Prev = Prev->getPreviousDecl()) {
424  if (Prev->Base::Common) {
425  PrevCommon = static_cast<Common *>(Prev->Base::Common);
426  break;
427  }
428  PreviousDecls.push_back(Prev);
429  }
430 
431  // If the previous redecl chain hasn't created a common pointer yet, then just
432  // use this common pointer.
433  if (!PrevCommon) {
434  for (auto *D : PreviousDecls)
435  D->Base::Common = ThisCommon;
436  return;
437  }
438 
439  // Ensure we don't leak any important state.
440  assert(ThisCommon->Specializations.size() == 0 &&
441  "Can't merge incompatible declarations!");
442 
443  Base::Common = PrevCommon;
444 }
445 
446 //===----------------------------------------------------------------------===//
447 // ClassTemplateDecl Implementation
448 //===----------------------------------------------------------------------===//
449 
451  SourceLocation L,
452  DeclarationName Name,
453  TemplateParameterList *Params,
454  NamedDecl *Decl) {
455  bool Invalid = AdoptTemplateParameterList(Params, cast<DeclContext>(Decl));
456  auto *TD = new (C, DC) ClassTemplateDecl(C, DC, L, Name, Params, Decl);
457  if (Invalid)
458  TD->setInvalidDecl();
459  return TD;
460 }
461 
463  unsigned ID) {
464  return new (C, ID) ClassTemplateDecl(C, nullptr, SourceLocation(),
465  DeclarationName(), nullptr, nullptr);
466 }
467 
470 }
471 
472 llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
475  return getCommonPtr()->Specializations;
476 }
477 
478 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
482 }
483 
486  auto *CommonPtr = new (C) Common;
487  C.addDestruction(CommonPtr);
488  return CommonPtr;
489 }
490 
493  void *&InsertPos) {
494  return findSpecializationImpl(getSpecializations(), InsertPos, Args);
495 }
496 
498  void *InsertPos) {
499  addSpecializationImpl<ClassTemplateDecl>(getSpecializations(), D, InsertPos);
500 }
501 
505  TemplateParameterList *TPL, void *&InsertPos) {
506  return findSpecializationImpl(getPartialSpecializations(), InsertPos, Args,
507  TPL);
508 }
509 
511  llvm::FoldingSetNodeID &ID, const TemplateParameterList *TPL) {
512  const Expr *RC = TPL->getRequiresClause();
513  ID.AddBoolean(RC != nullptr);
514  if (RC)
515  RC->Profile(ID, C, /*Canonical=*/true);
516  ID.AddInteger(TPL->size());
517  for (NamedDecl *D : *TPL) {
518  if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) {
519  ID.AddInteger(0);
520  ID.AddBoolean(NTTP->isParameterPack());
521  NTTP->getType().getCanonicalType().Profile(ID);
522  continue;
523  }
524  if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(D)) {
525  ID.AddInteger(1);
526  ID.AddBoolean(TTP->isParameterPack());
527  ID.AddBoolean(TTP->hasTypeConstraint());
528  if (const TypeConstraint *TC = TTP->getTypeConstraint())
529  TC->getImmediatelyDeclaredConstraint()->Profile(ID, C,
530  /*Canonical=*/true);
531  continue;
532  }
533  const auto *TTP = cast<TemplateTemplateParmDecl>(D);
534  ID.AddInteger(2);
535  ID.AddBoolean(TTP->isParameterPack());
536  ProfileTemplateParameterList(C, ID, TTP->getTemplateParameters());
537  }
538 }
539 
540 void
543  ASTContext &Context) {
544  ID.AddInteger(TemplateArgs.size());
545  for (const TemplateArgument &TemplateArg : TemplateArgs)
546  TemplateArg.Profile(ID, Context);
547  ProfileTemplateParameterList(Context, ID, TPL);
548 }
549 
552  void *InsertPos) {
553  if (InsertPos)
554  getPartialSpecializations().InsertNode(D, InsertPos);
555  else {
557  = getPartialSpecializations().GetOrInsertNode(D);
558  (void)Existing;
559  assert(Existing->isCanonicalDecl() && "Non-canonical specialization?");
560  }
561 
563  L->AddedCXXTemplateSpecialization(this, D);
564 }
565 
568  llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &PartialSpecs
570  PS.clear();
571  PS.reserve(PartialSpecs.size());
572  for (ClassTemplatePartialSpecializationDecl &P : PartialSpecs)
573  PS.push_back(P.getMostRecentDecl());
574 }
575 
578  ASTContext &Context = getASTContext();
581  if (Context.hasSameType(P.getInjectedSpecializationType(), T))
582  return P.getMostRecentDecl();
583  }
584 
585  return nullptr;
586 }
587 
591  Decl *DCanon = D->getCanonicalDecl();
593  if (P.getInstantiatedFromMember()->getCanonicalDecl() == DCanon)
594  return P.getMostRecentDecl();
595  }
596 
597  return nullptr;
598 }
599 
600 QualType
602  Common *CommonPtr = getCommonPtr();
603  if (!CommonPtr->InjectedClassNameType.isNull())
604  return CommonPtr->InjectedClassNameType;
605 
606  // C++0x [temp.dep.type]p2:
607  // The template argument list of a primary template is a template argument
608  // list in which the nth template argument has the value of the nth template
609  // parameter of the class template. If the nth template parameter is a
610  // template parameter pack (14.5.3), the nth template argument is a pack
611  // expansion (14.5.3) whose pattern is the name of the template parameter
612  // pack.
613  ASTContext &Context = getASTContext();
616  Context.getInjectedTemplateArgs(Params, TemplateArgs);
617  CommonPtr->InjectedClassNameType
619  TemplateArgs);
620  return CommonPtr->InjectedClassNameType;
621 }
622 
623 //===----------------------------------------------------------------------===//
624 // TemplateTypeParm Allocation/Deallocation Method Implementations
625 //===----------------------------------------------------------------------===//
626 
629  SourceLocation KeyLoc, SourceLocation NameLoc,
630  unsigned D, unsigned P, IdentifierInfo *Id,
631  bool Typename, bool ParameterPack,
632  bool HasTypeConstraint,
633  Optional<unsigned> NumExpanded) {
634  auto *TTPDecl =
635  new (C, DC,
636  additionalSizeToAlloc<TypeConstraint>(HasTypeConstraint ? 1 : 0))
637  TemplateTypeParmDecl(DC, KeyLoc, NameLoc, Id, Typename,
638  HasTypeConstraint, NumExpanded);
639  QualType TTPType = C.getTemplateTypeParmType(D, P, ParameterPack, TTPDecl);
640  TTPDecl->setTypeForDecl(TTPType.getTypePtr());
641  return TTPDecl;
642 }
643 
646  return new (C, ID) TemplateTypeParmDecl(nullptr, SourceLocation(),
647  SourceLocation(), nullptr, false,
648  false, None);
649 }
650 
653  bool HasTypeConstraint) {
654  return new (C, ID,
655  additionalSizeToAlloc<TypeConstraint>(HasTypeConstraint ? 1 : 0))
657  nullptr, false, HasTypeConstraint, None);
658 }
659 
661  return hasDefaultArgument()
663  : SourceLocation();
664 }
665 
668  return SourceRange(getBeginLoc(),
669  getDefaultArgumentInfo()->getTypeLoc().getEndLoc());
670  // TypeDecl::getSourceRange returns a range containing name location, which is
671  // wrong for unnamed template parameters. e.g:
672  // it will return <[[typename>]] instead of <[[typename]]>
673  else if (getDeclName().isEmpty())
674  return SourceRange(getBeginLoc());
675  return TypeDecl::getSourceRange();
676 }
677 
680 }
681 
684 }
685 
688 }
689 
691  DeclarationNameInfo NameInfo, NamedDecl *FoundDecl, ConceptDecl *CD,
692  const ASTTemplateArgumentListInfo *ArgsAsWritten,
693  Expr *ImmediatelyDeclaredConstraint) {
694  assert(HasTypeConstraint &&
695  "HasTypeConstraint=true must be passed at construction in order to "
696  "call setTypeConstraint");
697  assert(!TypeConstraintInitialized &&
698  "TypeConstraint was already initialized!");
699  new (getTrailingObjects<TypeConstraint>()) TypeConstraint(NNS, NameInfo,
700  FoundDecl, CD, ArgsAsWritten, ImmediatelyDeclaredConstraint);
701  TypeConstraintInitialized = true;
702 }
703 
704 //===----------------------------------------------------------------------===//
705 // NonTypeTemplateParmDecl Method Implementations
706 //===----------------------------------------------------------------------===//
707 
708 NonTypeTemplateParmDecl::NonTypeTemplateParmDecl(
709  DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D,
710  unsigned P, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo,
711  ArrayRef<QualType> ExpandedTypes, ArrayRef<TypeSourceInfo *> ExpandedTInfos)
712  : DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc),
713  TemplateParmPosition(D, P), ParameterPack(true),
714  ExpandedParameterPack(true), NumExpandedTypes(ExpandedTypes.size()) {
715  if (!ExpandedTypes.empty() && !ExpandedTInfos.empty()) {
716  auto TypesAndInfos =
717  getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
718  for (unsigned I = 0; I != NumExpandedTypes; ++I) {
719  new (&TypesAndInfos[I].first) QualType(ExpandedTypes[I]);
720  TypesAndInfos[I].second = ExpandedTInfos[I];
721  }
722  }
723 }
724 
727  SourceLocation StartLoc, SourceLocation IdLoc,
728  unsigned D, unsigned P, IdentifierInfo *Id,
729  QualType T, bool ParameterPack,
730  TypeSourceInfo *TInfo) {
731  AutoType *AT =
732  C.getLangOpts().CPlusPlus20 ? T->getContainedAutoType() : nullptr;
733  return new (C, DC,
734  additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>,
735  Expr *>(0,
736  AT && AT->isConstrained() ? 1 : 0))
737  NonTypeTemplateParmDecl(DC, StartLoc, IdLoc, D, P, Id, T, ParameterPack,
738  TInfo);
739 }
740 
742  const ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
743  SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id,
744  QualType T, TypeSourceInfo *TInfo, ArrayRef<QualType> ExpandedTypes,
745  ArrayRef<TypeSourceInfo *> ExpandedTInfos) {
746  AutoType *AT = TInfo->getType()->getContainedAutoType();
747  return new (C, DC,
748  additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>,
749  Expr *>(
750  ExpandedTypes.size(), AT && AT->isConstrained() ? 1 : 0))
751  NonTypeTemplateParmDecl(DC, StartLoc, IdLoc, D, P, Id, T, TInfo,
752  ExpandedTypes, ExpandedTInfos);
753 }
754 
757  bool HasTypeConstraint) {
758  return new (C, ID, additionalSizeToAlloc<std::pair<QualType,
759  TypeSourceInfo *>,
760  Expr *>(0,
761  HasTypeConstraint ? 1 : 0))
763  0, 0, nullptr, QualType(), false, nullptr);
764 }
765 
768  unsigned NumExpandedTypes,
769  bool HasTypeConstraint) {
770  auto *NTTP =
771  new (C, ID, additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>,
772  Expr *>(
773  NumExpandedTypes, HasTypeConstraint ? 1 : 0))
775  0, 0, nullptr, QualType(), nullptr, None,
776  None);
777  NTTP->NumExpandedTypes = NumExpandedTypes;
778  return NTTP;
779 }
780 
783  return SourceRange(getOuterLocStart(),
784  getDefaultArgument()->getSourceRange().getEnd());
786 }
787 
789  return hasDefaultArgument()
791  : SourceLocation();
792 }
793 
794 //===----------------------------------------------------------------------===//
795 // TemplateTemplateParmDecl Method Implementations
796 //===----------------------------------------------------------------------===//
797 
798 void TemplateTemplateParmDecl::anchor() {}
799 
800 TemplateTemplateParmDecl::TemplateTemplateParmDecl(
801  DeclContext *DC, SourceLocation L, unsigned D, unsigned P,
803  ArrayRef<TemplateParameterList *> Expansions)
804  : TemplateDecl(TemplateTemplateParm, DC, L, Id, Params),
805  TemplateParmPosition(D, P), ParameterPack(true),
806  ExpandedParameterPack(true), NumExpandedParams(Expansions.size()) {
807  if (!Expansions.empty())
808  std::uninitialized_copy(Expansions.begin(), Expansions.end(),
809  getTrailingObjects<TemplateParameterList *>());
810 }
811 
814  SourceLocation L, unsigned D, unsigned P,
815  bool ParameterPack, IdentifierInfo *Id,
816  TemplateParameterList *Params) {
817  return new (C, DC) TemplateTemplateParmDecl(DC, L, D, P, ParameterPack, Id,
818  Params);
819 }
820 
823  SourceLocation L, unsigned D, unsigned P,
825  TemplateParameterList *Params,
827  return new (C, DC,
828  additionalSizeToAlloc<TemplateParameterList *>(Expansions.size()))
829  TemplateTemplateParmDecl(DC, L, D, P, Id, Params, Expansions);
830 }
831 
834  return new (C, ID) TemplateTemplateParmDecl(nullptr, SourceLocation(), 0, 0,
835  false, nullptr, nullptr);
836 }
837 
840  unsigned NumExpansions) {
841  auto *TTP =
842  new (C, ID, additionalSizeToAlloc<TemplateParameterList *>(NumExpansions))
843  TemplateTemplateParmDecl(nullptr, SourceLocation(), 0, 0, nullptr,
844  nullptr, None);
845  TTP->NumExpandedParams = NumExpansions;
846  return TTP;
847 }
848 
851  : SourceLocation();
852 }
853 
855  const ASTContext &C, const TemplateArgumentLoc &DefArg) {
856  if (DefArg.getArgument().isNull())
857  DefaultArgument.set(nullptr);
858  else
859  DefaultArgument.set(new (C) TemplateArgumentLoc(DefArg));
860 }
861 
862 //===----------------------------------------------------------------------===//
863 // TemplateArgumentList Implementation
864 //===----------------------------------------------------------------------===//
865 TemplateArgumentList::TemplateArgumentList(ArrayRef<TemplateArgument> Args)
866  : Arguments(getTrailingObjects<TemplateArgument>()),
867  NumArguments(Args.size()) {
868  std::uninitialized_copy(Args.begin(), Args.end(),
869  getTrailingObjects<TemplateArgument>());
870 }
871 
875  void *Mem = Context.Allocate(totalSizeToAlloc<TemplateArgument>(Args.size()));
876  return new (Mem) TemplateArgumentList(Args);
877 }
878 
880  ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template,
881  TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs,
882  const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI,
883  MemberSpecializationInfo *MSInfo) {
884  const ASTTemplateArgumentListInfo *ArgsAsWritten = nullptr;
885  if (TemplateArgsAsWritten)
886  ArgsAsWritten = ASTTemplateArgumentListInfo::Create(C,
887  *TemplateArgsAsWritten);
888 
889  void *Mem =
890  C.Allocate(totalSizeToAlloc<MemberSpecializationInfo *>(MSInfo ? 1 : 0));
891  return new (Mem) FunctionTemplateSpecializationInfo(
892  FD, Template, TSK, TemplateArgs, ArgsAsWritten, POI, MSInfo);
893 }
894 
895 //===----------------------------------------------------------------------===//
896 // ClassTemplateSpecializationDecl Implementation
897 //===----------------------------------------------------------------------===//
898 
901  DeclContext *DC, SourceLocation StartLoc,
902  SourceLocation IdLoc,
903  ClassTemplateDecl *SpecializedTemplate,
906  : CXXRecordDecl(DK, TK, Context, DC, StartLoc, IdLoc,
907  SpecializedTemplate->getIdentifier(), PrevDecl),
908  SpecializedTemplate(SpecializedTemplate),
909  TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args)),
910  SpecializationKind(TSK_Undeclared) {
911 }
912 
914  Kind DK)
915  : CXXRecordDecl(DK, TTK_Struct, C, nullptr, SourceLocation(),
916  SourceLocation(), nullptr, nullptr),
917  SpecializationKind(TSK_Undeclared) {}
918 
921  DeclContext *DC,
922  SourceLocation StartLoc,
923  SourceLocation IdLoc,
924  ClassTemplateDecl *SpecializedTemplate,
927  auto *Result =
928  new (Context, DC) ClassTemplateSpecializationDecl(
929  Context, ClassTemplateSpecialization, TK, DC, StartLoc, IdLoc,
930  SpecializedTemplate, Args, PrevDecl);
931  Result->setMayHaveOutOfDateDef(false);
932 
933  Context.getTypeDeclType(Result, PrevDecl);
934  return Result;
935 }
936 
939  unsigned ID) {
940  auto *Result =
941  new (C, ID) ClassTemplateSpecializationDecl(C, ClassTemplateSpecialization);
942  Result->setMayHaveOutOfDateDef(false);
943  return Result;
944 }
945 
947  raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const {
949 
950  const auto *PS = dyn_cast<ClassTemplatePartialSpecializationDecl>(this);
951  if (const ASTTemplateArgumentListInfo *ArgsAsWritten =
952  PS ? PS->getTemplateArgsAsWritten() : nullptr) {
954  OS, ArgsAsWritten->arguments(), Policy,
955  getSpecializedTemplate()->getTemplateParameters());
956  } else {
957  const TemplateArgumentList &TemplateArgs = getTemplateArgs();
959  OS, TemplateArgs.asArray(), Policy,
960  getSpecializedTemplate()->getTemplateParameters());
961  }
962 }
963 
966  if (const auto *PartialSpec =
967  SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
968  return PartialSpec->PartialSpecialization->getSpecializedTemplate();
969  return SpecializedTemplate.get<ClassTemplateDecl*>();
970 }
971 
974  if (ExplicitInfo) {
976  if (Begin.isValid()) {
977  // Here we have an explicit (partial) specialization or instantiation.
981  if (getExternLoc().isValid())
982  Begin = getExternLoc();
984  if (End.isInvalid())
986  return SourceRange(Begin, End);
987  }
988  // An implicit instantiation of a class template partial specialization
989  // uses ExplicitInfo to record the TypeAsWritten, but the source
990  // locations should be retrieved from the instantiation pattern.
992  auto *ctpsd = const_cast<CTPSDecl *>(cast<CTPSDecl>(this));
993  CTPSDecl *inst_from = ctpsd->getInstantiatedFromMember();
994  assert(inst_from != nullptr);
995  return inst_from->getSourceRange();
996  }
997  else {
998  // No explicit info available.
999  llvm::PointerUnion<ClassTemplateDecl *,
1001  inst_from = getInstantiatedFrom();
1002  if (inst_from.isNull())
1004  if (const auto *ctd = inst_from.dyn_cast<ClassTemplateDecl *>())
1005  return ctd->getSourceRange();
1006  return inst_from.get<ClassTemplatePartialSpecializationDecl *>()
1007  ->getSourceRange();
1008  }
1009 }
1010 
1011 //===----------------------------------------------------------------------===//
1012 // ConceptDecl Implementation
1013 //===----------------------------------------------------------------------===//
1016  TemplateParameterList *Params,
1017  Expr *ConstraintExpr) {
1018  bool Invalid = AdoptTemplateParameterList(Params, DC);
1019  auto *TD = new (C, DC) ConceptDecl(DC, L, Name, Params, ConstraintExpr);
1020  if (Invalid)
1021  TD->setInvalidDecl();
1022  return TD;
1023 }
1024 
1026  unsigned ID) {
1027  ConceptDecl *Result = new (C, ID) ConceptDecl(nullptr, SourceLocation(),
1028  DeclarationName(),
1029  nullptr, nullptr);
1030 
1031  return Result;
1032 }
1033 
1034 //===----------------------------------------------------------------------===//
1035 // ClassTemplatePartialSpecializationDecl Implementation
1036 //===----------------------------------------------------------------------===//
1037 void ClassTemplatePartialSpecializationDecl::anchor() {}
1038 
1039 ClassTemplatePartialSpecializationDecl::
1040 ClassTemplatePartialSpecializationDecl(ASTContext &Context, TagKind TK,
1041  DeclContext *DC,
1042  SourceLocation StartLoc,
1043  SourceLocation IdLoc,
1044  TemplateParameterList *Params,
1045  ClassTemplateDecl *SpecializedTemplate,
1046  ArrayRef<TemplateArgument> Args,
1047  const ASTTemplateArgumentListInfo *ArgInfos,
1050  ClassTemplatePartialSpecialization,
1051  TK, DC, StartLoc, IdLoc,
1052  SpecializedTemplate, Args, PrevDecl),
1053  TemplateParams(Params), ArgsAsWritten(ArgInfos),
1054  InstantiatedFromMember(nullptr, false) {
1055  if (AdoptTemplateParameterList(Params, this))
1056  setInvalidDecl();
1057 }
1058 
1062  SourceLocation StartLoc, SourceLocation IdLoc,
1063  TemplateParameterList *Params,
1064  ClassTemplateDecl *SpecializedTemplate,
1066  const TemplateArgumentListInfo &ArgInfos,
1067  QualType CanonInjectedType,
1069  const ASTTemplateArgumentListInfo *ASTArgInfos =
1070  ASTTemplateArgumentListInfo::Create(Context, ArgInfos);
1071 
1072  auto *Result = new (Context, DC)
1073  ClassTemplatePartialSpecializationDecl(Context, TK, DC, StartLoc, IdLoc,
1074  Params, SpecializedTemplate, Args,
1075  ASTArgInfos, PrevDecl);
1076  Result->setSpecializationKind(TSK_ExplicitSpecialization);
1077  Result->setMayHaveOutOfDateDef(false);
1078 
1079  Context.getInjectedClassNameType(Result, CanonInjectedType);
1080  return Result;
1081 }
1082 
1085  unsigned ID) {
1086  auto *Result = new (C, ID) ClassTemplatePartialSpecializationDecl(C);
1087  Result->setMayHaveOutOfDateDef(false);
1088  return Result;
1089 }
1090 
1091 //===----------------------------------------------------------------------===//
1092 // FriendTemplateDecl Implementation
1093 //===----------------------------------------------------------------------===//
1094 
1095 void FriendTemplateDecl::anchor() {}
1096 
1099  SourceLocation L,
1101  FriendUnion Friend, SourceLocation FLoc) {
1102  TemplateParameterList **TPL = nullptr;
1103  if (!Params.empty()) {
1104  TPL = new (Context) TemplateParameterList *[Params.size()];
1105  llvm::copy(Params, TPL);
1106  }
1107  return new (Context, DC)
1108  FriendTemplateDecl(DC, L, TPL, Params.size(), Friend, FLoc);
1109 }
1110 
1112  unsigned ID) {
1113  return new (C, ID) FriendTemplateDecl(EmptyShell());
1114 }
1115 
1116 //===----------------------------------------------------------------------===//
1117 // TypeAliasTemplateDecl Implementation
1118 //===----------------------------------------------------------------------===//
1119 
1122  DeclarationName Name,
1123  TemplateParameterList *Params, NamedDecl *Decl) {
1124  bool Invalid = AdoptTemplateParameterList(Params, DC);
1125  auto *TD = new (C, DC) TypeAliasTemplateDecl(C, DC, L, Name, Params, Decl);
1126  if (Invalid)
1127  TD->setInvalidDecl();
1128  return TD;
1129 }
1130 
1132  unsigned ID) {
1133  return new (C, ID) TypeAliasTemplateDecl(C, nullptr, SourceLocation(),
1134  DeclarationName(), nullptr, nullptr);
1135 }
1136 
1139  auto *CommonPtr = new (C) Common;
1140  C.addDestruction(CommonPtr);
1141  return CommonPtr;
1142 }
1143 
1144 //===----------------------------------------------------------------------===//
1145 // ClassScopeFunctionSpecializationDecl Implementation
1146 //===----------------------------------------------------------------------===//
1147 
1148 void ClassScopeFunctionSpecializationDecl::anchor() {}
1149 
1152  unsigned ID) {
1153  return new (C, ID) ClassScopeFunctionSpecializationDecl(
1154  nullptr, SourceLocation(), nullptr, nullptr);
1155 }
1156 
1157 //===----------------------------------------------------------------------===//
1158 // VarTemplateDecl Implementation
1159 //===----------------------------------------------------------------------===//
1160 
1162  VarTemplateDecl *CurD = this;
1163  while (CurD) {
1164  if (CurD->isThisDeclarationADefinition())
1165  return CurD;
1166  CurD = CurD->getPreviousDecl();
1167  }
1168  return nullptr;
1169 }
1170 
1173  TemplateParameterList *Params,
1174  VarDecl *Decl) {
1175  bool Invalid = AdoptTemplateParameterList(Params, DC);
1176  auto *TD = new (C, DC) VarTemplateDecl(C, DC, L, Name, Params, Decl);
1177  if (Invalid)
1178  TD->setInvalidDecl();
1179  return TD;
1180 }
1181 
1183  unsigned ID) {
1184  return new (C, ID) VarTemplateDecl(C, nullptr, SourceLocation(),
1185  DeclarationName(), nullptr, nullptr);
1186 }
1187 
1190 }
1191 
1192 llvm::FoldingSetVector<VarTemplateSpecializationDecl> &
1195  return getCommonPtr()->Specializations;
1196 }
1197 
1198 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &
1202 }
1203 
1206  auto *CommonPtr = new (C) Common;
1207  C.addDestruction(CommonPtr);
1208  return CommonPtr;
1209 }
1210 
1213  void *&InsertPos) {
1214  return findSpecializationImpl(getSpecializations(), InsertPos, Args);
1215 }
1216 
1218  void *InsertPos) {
1219  addSpecializationImpl<VarTemplateDecl>(getSpecializations(), D, InsertPos);
1220 }
1221 
1224  TemplateParameterList *TPL, void *&InsertPos) {
1225  return findSpecializationImpl(getPartialSpecializations(), InsertPos, Args,
1226  TPL);
1227 }
1228 
1229 void
1232  ASTContext &Context) {
1233  ID.AddInteger(TemplateArgs.size());
1234  for (const TemplateArgument &TemplateArg : TemplateArgs)
1235  TemplateArg.Profile(ID, Context);
1236  ProfileTemplateParameterList(Context, ID, TPL);
1237 }
1238 
1240  VarTemplatePartialSpecializationDecl *D, void *InsertPos) {
1241  if (InsertPos)
1242  getPartialSpecializations().InsertNode(D, InsertPos);
1243  else {
1245  getPartialSpecializations().GetOrInsertNode(D);
1246  (void)Existing;
1247  assert(Existing->isCanonicalDecl() && "Non-canonical specialization?");
1248  }
1249 
1251  L->AddedCXXTemplateSpecialization(this, D);
1252 }
1253 
1256  llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &PartialSpecs =
1258  PS.clear();
1259  PS.reserve(PartialSpecs.size());
1260  for (VarTemplatePartialSpecializationDecl &P : PartialSpecs)
1261  PS.push_back(P.getMostRecentDecl());
1262 }
1263 
1267  Decl *DCanon = D->getCanonicalDecl();
1269  if (P.getInstantiatedFromMember()->getCanonicalDecl() == DCanon)
1270  return P.getMostRecentDecl();
1271  }
1272 
1273  return nullptr;
1274 }
1275 
1276 //===----------------------------------------------------------------------===//
1277 // VarTemplateSpecializationDecl Implementation
1278 //===----------------------------------------------------------------------===//
1279 
1281  Kind DK, ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
1282  SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T,
1284  : VarDecl(DK, Context, DC, StartLoc, IdLoc,
1285  SpecializedTemplate->getIdentifier(), T, TInfo, S),
1286  SpecializedTemplate(SpecializedTemplate),
1287  TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args)),
1288  SpecializationKind(TSK_Undeclared), IsCompleteDefinition(false) {}
1289 
1291  ASTContext &C)
1292  : VarDecl(DK, C, nullptr, SourceLocation(), SourceLocation(), nullptr,
1293  QualType(), nullptr, SC_None),
1294  SpecializationKind(TSK_Undeclared), IsCompleteDefinition(false) {}
1295 
1297  ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
1298  SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T,
1300  return new (Context, DC) VarTemplateSpecializationDecl(
1301  VarTemplateSpecialization, Context, DC, StartLoc, IdLoc,
1302  SpecializedTemplate, T, TInfo, S, Args);
1303 }
1304 
1307  return new (C, ID)
1308  VarTemplateSpecializationDecl(VarTemplateSpecialization, C);
1309 }
1310 
1312  raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const {
1314 
1315  const auto *PS = dyn_cast<VarTemplatePartialSpecializationDecl>(this);
1316  if (const ASTTemplateArgumentListInfo *ArgsAsWritten =
1317  PS ? PS->getTemplateArgsAsWritten() : nullptr) {
1319  OS, ArgsAsWritten->arguments(), Policy,
1320  getSpecializedTemplate()->getTemplateParameters());
1321  } else {
1322  const TemplateArgumentList &TemplateArgs = getTemplateArgs();
1324  OS, TemplateArgs.asArray(), Policy,
1325  getSpecializedTemplate()->getTemplateParameters());
1326  }
1327 }
1328 
1330  if (const auto *PartialSpec =
1331  SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
1332  return PartialSpec->PartialSpecialization->getSpecializedTemplate();
1333  return SpecializedTemplate.get<VarTemplateDecl *>();
1334 }
1335 
1337  const TemplateArgumentListInfo &ArgsInfo) {
1338  TemplateArgsInfo.setLAngleLoc(ArgsInfo.getLAngleLoc());
1339  TemplateArgsInfo.setRAngleLoc(ArgsInfo.getRAngleLoc());
1340  for (const TemplateArgumentLoc &Loc : ArgsInfo.arguments())
1341  TemplateArgsInfo.addArgument(Loc);
1342 }
1343 
1344 //===----------------------------------------------------------------------===//
1345 // VarTemplatePartialSpecializationDecl Implementation
1346 //===----------------------------------------------------------------------===//
1347 
1348 void VarTemplatePartialSpecializationDecl::anchor() {}
1349 
1350 VarTemplatePartialSpecializationDecl::VarTemplatePartialSpecializationDecl(
1351  ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
1352  SourceLocation IdLoc, TemplateParameterList *Params,
1353  VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo,
1354  StorageClass S, ArrayRef<TemplateArgument> Args,
1355  const ASTTemplateArgumentListInfo *ArgInfos)
1356  : VarTemplateSpecializationDecl(VarTemplatePartialSpecialization, Context,
1357  DC, StartLoc, IdLoc, SpecializedTemplate, T,
1358  TInfo, S, Args),
1359  TemplateParams(Params), ArgsAsWritten(ArgInfos),
1360  InstantiatedFromMember(nullptr, false) {
1361  if (AdoptTemplateParameterList(Params, DC))
1362  setInvalidDecl();
1363 }
1364 
1367  ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
1368  SourceLocation IdLoc, TemplateParameterList *Params,
1369  VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo,
1371  const TemplateArgumentListInfo &ArgInfos) {
1372  const ASTTemplateArgumentListInfo *ASTArgInfos
1373  = ASTTemplateArgumentListInfo::Create(Context, ArgInfos);
1374 
1375  auto *Result =
1376  new (Context, DC) VarTemplatePartialSpecializationDecl(
1377  Context, DC, StartLoc, IdLoc, Params, SpecializedTemplate, T, TInfo,
1378  S, Args, ASTArgInfos);
1379  Result->setSpecializationKind(TSK_ExplicitSpecialization);
1380  return Result;
1381 }
1382 
1385  unsigned ID) {
1386  return new (C, ID) VarTemplatePartialSpecializationDecl(C);
1387 }
1388 
1389 static TemplateParameterList *
1391  // typename T
1392  auto *T = TemplateTypeParmDecl::Create(
1393  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/1, /*Position=*/0,
1394  /*Id=*/nullptr, /*Typename=*/true, /*ParameterPack=*/false,
1395  /*HasTypeConstraint=*/false);
1396  T->setImplicit(true);
1397 
1398  // T ...Ints
1399  TypeSourceInfo *TI =
1400  C.getTrivialTypeSourceInfo(QualType(T->getTypeForDecl(), 0));
1402  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/1,
1403  /*Id=*/nullptr, TI->getType(), /*ParameterPack=*/true, TI);
1404  N->setImplicit(true);
1405 
1406  // <typename T, T ...Ints>
1407  NamedDecl *P[2] = {T, N};
1408  auto *TPL = TemplateParameterList::Create(
1409  C, SourceLocation(), SourceLocation(), P, SourceLocation(), nullptr);
1410 
1411  // template <typename T, ...Ints> class IntSeq
1412  auto *TemplateTemplateParm = TemplateTemplateParmDecl::Create(
1413  C, DC, SourceLocation(), /*Depth=*/0, /*Position=*/0,
1414  /*ParameterPack=*/false, /*Id=*/nullptr, TPL);
1415  TemplateTemplateParm->setImplicit(true);
1416 
1417  // typename T
1418  auto *TemplateTypeParm = TemplateTypeParmDecl::Create(
1419  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/1,
1420  /*Id=*/nullptr, /*Typename=*/true, /*ParameterPack=*/false,
1421  /*HasTypeConstraint=*/false);
1422  TemplateTypeParm->setImplicit(true);
1423 
1424  // T N
1425  TypeSourceInfo *TInfo = C.getTrivialTypeSourceInfo(
1426  QualType(TemplateTypeParm->getTypeForDecl(), 0));
1427  auto *NonTypeTemplateParm = NonTypeTemplateParmDecl::Create(
1428  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/2,
1429  /*Id=*/nullptr, TInfo->getType(), /*ParameterPack=*/false, TInfo);
1430  NamedDecl *Params[] = {TemplateTemplateParm, TemplateTypeParm,
1431  NonTypeTemplateParm};
1432 
1433  // template <template <typename T, T ...Ints> class IntSeq, typename T, T N>
1435  Params, SourceLocation(), nullptr);
1436 }
1437 
1438 static TemplateParameterList *
1440  // std::size_t Index
1441  TypeSourceInfo *TInfo = C.getTrivialTypeSourceInfo(C.getSizeType());
1442  auto *Index = NonTypeTemplateParmDecl::Create(
1443  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/0,
1444  /*Id=*/nullptr, TInfo->getType(), /*ParameterPack=*/false, TInfo);
1445 
1446  // typename ...T
1447  auto *Ts = TemplateTypeParmDecl::Create(
1448  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/1,
1449  /*Id=*/nullptr, /*Typename=*/true, /*ParameterPack=*/true,
1450  /*HasTypeConstraint=*/false);
1451  Ts->setImplicit(true);
1452 
1453  // template <std::size_t Index, typename ...T>
1454  NamedDecl *Params[] = {Index, Ts};
1456  llvm::makeArrayRef(Params),
1457  SourceLocation(), nullptr);
1458 }
1459 
1461  const ASTContext &C, DeclContext *DC, BuiltinTemplateKind BTK) {
1462  switch (BTK) {
1463  case BTK__make_integer_seq:
1464  return createMakeIntegerSeqParameterList(C, DC);
1466  return createTypePackElementParameterList(C, DC);
1467  }
1468 
1469  llvm_unreachable("unhandled BuiltinTemplateKind!");
1470 }
1471 
1472 void BuiltinTemplateDecl::anchor() {}
1473 
1474 BuiltinTemplateDecl::BuiltinTemplateDecl(const ASTContext &C, DeclContext *DC,
1475  DeclarationName Name,
1476  BuiltinTemplateKind BTK)
1477  : TemplateDecl(BuiltinTemplate, DC, SourceLocation(), Name,
1479  BTK(BTK) {}
1480 
1481 void TypeConstraint::print(llvm::raw_ostream &OS, PrintingPolicy Policy) const {
1482  if (NestedNameSpec)
1484  ConceptName.printName(OS, Policy);
1485  if (hasExplicitTemplateArgs()) {
1486  OS << "<";
1487  // FIXME: Find corresponding parameter for argument
1488  for (auto &ArgLoc : ArgsAsWritten->arguments())
1489  ArgLoc.getArgument().print(Policy, OS, /*IncludeType*/ false);
1490  OS << ">";
1491  }
1492 }
1493 
1494 TemplateParamObjectDecl *TemplateParamObjectDecl::Create(const ASTContext &C,
1495  QualType T,
1496  const APValue &V) {
1497  DeclContext *DC = C.getTranslationUnitDecl();
1498  auto *TPOD = new (C, DC) TemplateParamObjectDecl(DC, T, V);
1499  C.addDestruction(&TPOD->Value);
1500  return TPOD;
1501 }
1502 
1504 TemplateParamObjectDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
1505  auto *TPOD = new (C, ID) TemplateParamObjectDecl(nullptr, QualType(), APValue());
1506  C.addDestruction(&TPOD->Value);
1507  return TPOD;
1508 }
1509 
1510 void TemplateParamObjectDecl::printName(llvm::raw_ostream &OS) const {
1511  OS << "<template param ";
1512  printAsExpr(OS);
1513  OS << ">";
1514 }
1515 
1516 void TemplateParamObjectDecl::printAsExpr(llvm::raw_ostream &OS) const {
1517  printAsExpr(OS, getASTContext().getPrintingPolicy());
1518 }
1519 
1520 void TemplateParamObjectDecl::printAsExpr(llvm::raw_ostream &OS,
1521  const PrintingPolicy &Policy) const {
1522  getType().getUnqualifiedType().print(OS, Policy);
1523  printAsInit(OS, Policy);
1524 }
1525 
1526 void TemplateParamObjectDecl::printAsInit(llvm::raw_ostream &OS) const {
1527  printAsInit(OS, getASTContext().getPrintingPolicy());
1528 }
1529 
1530 void TemplateParamObjectDecl::printAsInit(llvm::raw_ostream &OS,
1531  const PrintingPolicy &Policy) const {
1532  getValue().printPretty(OS, Policy, getType(), &getASTContext());
1533 }
clang::TypeDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.h:3187
clang::TemplateParameterList::getRequiresClause
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
Definition: DeclTemplate.h:174
clang::TemplateDecl::getTemplatedDecl
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Definition: DeclTemplate.h:432
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:374
clang::FunctionTemplateDecl::mergePrevDecl
void mergePrevDecl(FunctionTemplateDecl *Prev)
Merge Prev with our RedeclarableTemplateDecl::Common.
Definition: DeclTemplate.cpp:412
clang::Decl::getASTContext
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:414
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:1569
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:1212
clang::ClassTemplateDecl::Common::PartialSpecializations
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > PartialSpecializations
The class template partial specializations for this class template.
Definition: DeclTemplate.h:2276
clang::RedeclarableTemplateDecl::CommonBase
Definition: DeclTemplate.h:822
clang::FriendTemplateDecl
Declaration of a friend template.
Definition: DeclTemplate.h:2461
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:6482
clang::TemplateTemplateParmDecl::hasDefaultArgument
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Definition: DeclTemplate.h:1736
clang::VarTemplateDecl::Common::Specializations
llvm::FoldingSetVector< VarTemplateSpecializationDecl > Specializations
The variable template specializations for this variable template, including explicit specializations ...
Definition: DeclTemplate.h:3103
clang::TemplateTypeParmDecl::defaultArgumentWasInherited
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
Definition: DeclTemplate.h:1283
clang::TemplateTypeParmDecl::getIndex
unsigned getIndex() const
Retrieve the index of the template parameter.
Definition: DeclTemplate.cpp:682
clang::VarTemplatePartialSpecializationDecl::CreateDeserialized
static VarTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:1384
clang::MemberSpecializationInfo
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:620
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:1061
clang::Decl::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclBase.h:421
clang::TypeAliasTemplateDecl::CreateDeserialized
static TypeAliasTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty alias template node.
Definition: DeclTemplate.cpp:1131
clang::AutoType::isConstrained
bool isConstrained() const
Definition: Type.h:5086
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:1356
clang::VarDecl::getCanonicalDecl
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: Decl.cpp:2162
clang::VarTemplateDecl::getPreviousDecl
VarTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this variable template, or nullptr if no such declaration exists...
Definition: DeclTemplate.h:3180
clang::TemplateDecl::hasAssociatedConstraints
bool hasAssociatedConstraints() const
Definition: DeclTemplate.cpp:245
clang::Decl::getASTMutationListener
ASTMutationListener * getASTMutationListener() const
Definition: DeclBase.cpp:424
clang::TemplateTypeParmDecl::CreateDeserialized
static TemplateTypeParmDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:645
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:4857
clang::TTK_Struct
@ TTK_Struct
The "struct" keyword.
Definition: Type.h:5386
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:385
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:965
clang::VarTemplateDecl::AddPartialSpecialization
void AddPartialSpecialization(VarTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
Definition: DeclTemplate.cpp:1239
clang::ClassTemplateSpecializationDecl::getExternLoc
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
Definition: DeclTemplate.h:2047
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:920
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:176
clang::ClassTemplateDecl::Common::InjectedClassNameType
QualType InjectedClassNameType
The injected-class-name type for this class template.
Definition: DeclTemplate.h:2279
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:675
clang::TypeDecl::getTypeForDecl
const Type * getTypeForDecl() const
Definition: Decl.h:3182
clang::NonTypeTemplateParmDecl
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Definition: DeclTemplate.h:1401
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:772
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:55
clang::ClassScopeFunctionSpecializationDecl
Declaration of a function specialization at template class scope.
Definition: DeclTemplate.h:2621
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:854
clang::TemplateArgumentListInfo::getRAngleLoc
SourceLocation getRAngleLoc() const
Definition: TemplateBase.h:580
clang::ClassTemplateSpecializationDecl::getSpecializationKind
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
Definition: DeclTemplate.h:1918
clang::VarTemplateDecl::getCommonPtr
Common * getCommonPtr() const
Definition: DeclTemplate.h:3129
DeclCXX.h
clang::NonTypeTemplateParmDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.cpp:781
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:1311
llvm::Optional< unsigned >
clang::TypeLoc::getEndLoc
SourceLocation getEndLoc() const
Get the end source location.
Definition: TypeLoc.cpp:228
clang::NonTypeTemplateParmDecl::hasDefaultArgument
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Definition: DeclTemplate.h:1480
clang::VarTemplateSpecializationDecl::getTemplateArgs
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
Definition: DeclTemplate.h:2772
clang::TemplateArgument::isNull
bool isNull() const
Determine whether this template argument has no value.
Definition: TemplateBase.h:247
clang::VarTemplateDecl::findPartialSpecInstantiatedFromMember
VarTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(VarTemplatePartialSpecializationDecl *D)
Find a variable template partial specialization which was instantiated from the given member partial ...
Definition: DeclTemplate.cpp:1265
clang::ClassTemplateSpecializationDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.cpp:973
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:2122
clang::DeclaratorDecl::getOuterLocStart
SourceLocation getOuterLocStart() const
Return start of source range taking into account any outer template declarations.
Definition: Decl.cpp:1954
clang::ClassTemplatePartialSpecializationDecl
Definition: DeclTemplate.h:2092
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:753
print
void print(llvm::raw_ostream &OS, const Pointer &P, ASTContext &Ctx, QualType Ty)
Definition: InterpFrame.cpp:62
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:351
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:1748
clang::VarTemplateSpecializationDecl
Represents a variable template specialization, which refers to a variable template with a given set o...
Definition: DeclTemplate.h:2681
clang::detail::Qualified
std::conditional_t< Const, const T, T > Qualified
Definition: HeaderSearch.h:158
TemplateName.h
createTypePackElementParameterList
static TemplateParameterList * createTypePackElementParameterList(const ASTContext &C, DeclContext *DC)
Definition: DeclTemplate.cpp:1439
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:2268
clang::ClassTemplateDecl::CreateDeserialized
static ClassTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty class template node.
Definition: DeclTemplate.cpp:462
clang::ASTTemplateArgumentListInfo::arguments
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:640
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:1526
clang::DeclaratorContext::TemplateArg
@ TemplateArg
clang::TemplateTypeParmDecl::getDefaultArgumentInfo
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
Definition: DeclTemplate.h:1274
clang::TemplateTypeParmDecl::setTypeConstraint
void setTypeConstraint(NestedNameSpecifierLoc NNS, DeclarationNameInfo NameInfo, NamedDecl *FoundDecl, ConceptDecl *CD, const ASTTemplateArgumentListInfo *ArgsAsWritten, Expr *ImmediatelyDeclaredConstraint)
Definition: DeclTemplate.cpp:690
clang::TemplateTypeParmDecl::hasDefaultArgument
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Definition: DeclTemplate.h:1266
createBuiltinTemplateParameterList
static TemplateParameterList * createBuiltinTemplateParameterList(const ASTContext &C, DeclContext *DC, BuiltinTemplateKind BTK)
Definition: DeclTemplate.cpp:1460
clang::VarTemplateSpecializationDecl::setTemplateArgsInfo
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
Definition: DeclTemplate.cpp:1336
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:1098
clang::TemplateArgumentListInfo::getLAngleLoc
SourceLocation getLAngleLoc() const
Definition: TemplateBase.h:579
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:479
clang::TemplateTypeParmDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.cpp:666
clang::ASTContext::Allocate
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:729
clang::TemplateArgumentLoc::getLocation
SourceLocation getLocation() const
Definition: TemplateBase.h:495
clang::FunctionTemplateDecl
Declaration of a template function.
Definition: DeclTemplate.h:979
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:2192
clang::TSK_ExplicitInstantiationDeclaration
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
Definition: Specifiers.h:187
V
#define V(N, I)
Definition: ASTContext.h:3176
clang::ASTContext::getExternalSource
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
Definition: ASTContext.h:1183
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:1490
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:3122
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:873
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:1171
clang::ClassTemplateSpecializationDecl::getTemplateArgs
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
Definition: DeclTemplate.h:1908
clang::TemplateParameterList::getParam
NamedDecl * getParam(unsigned Idx)
Definition: DeclTemplate.h:138
DeclTemplate.h
clang::ClassTemplateDecl::ClassTemplateDecl
ClassTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:2293
clang::TemplateArgumentListInfo
A convenient class for passing around template argument information.
Definition: TemplateBase.h:563
ProfileTemplateParameterList
static void ProfileTemplateParameterList(ASTContext &C, llvm::FoldingSetNodeID &ID, const TemplateParameterList *TPL)
Definition: DeclTemplate.cpp:510
clang::TagTypeKind
TagTypeKind
The kind of a tag type.
Definition: Type.h:5384
clang::ClassTemplateDecl::newCommon
CommonBase * newCommon(ASTContext &C) const override
Definition: DeclTemplate.cpp:485
Id
int Id
Definition: ASTDiff.cpp:191
clang::VarTemplateDecl::getPartialSpecializations
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
Definition: DeclTemplate.cpp:1199
clang::TemplateArgumentListInfo::addArgument
void addArgument(const TemplateArgumentLoc &Loc)
Definition: TemplateBase.h:603
clang::ConceptDecl
Declaration of a C++2a concept.
Definition: DeclTemplate.h:3252
clang::DeclaratorDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.cpp:1994
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:756
clang::TemplateDecl::TemplateParams
TemplateParameterList * TemplateParams
Definition: DeclTemplate.h:448
clang::FunctionTemplateDecl::getCommonPtr
Common * getCommonPtr() const
Definition: DeclTemplate.h:1010
clang::ConceptReference::ConceptName
DeclarationNameInfo ConceptName
The concept name used.
Definition: ASTConcept.h:109
clang::RedeclarableTemplateDecl::RedeclarableTemplateDecl
RedeclarableTemplateDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:853
clang::FunctionTemplateDecl::Common
Data that is common to all of the declarations of a given function template.
Definition: DeclTemplate.h:985
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:208
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:2465
getIdentifier
static StringRef getIdentifier(const Token &Tok)
Definition: ParsePragma.cpp:1450
clang::ClassTemplateSpecializationDecl::CreateDeserialized
static ClassTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:938
clang::ClassTemplateDecl::LoadLazySpecializations
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
Definition: DeclTemplate.cpp:468
clang::VarTemplateDecl::getDefinition
VarTemplateDecl * getDefinition()
Definition: DeclTemplate.cpp:1161
clang::VarTemplateDecl::Common::PartialSpecializations
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > PartialSpecializations
The variable template partial specializations for this variable template.
Definition: DeclTemplate.h:3108
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:1188
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::ClassTemplateDecl::findPartialSpecInstantiatedFromMember
ClassTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *D)
Find a class template partial specialization which was instantiated from the given member partial spe...
Definition: DeclTemplate.cpp:589
clang::AutoType
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Definition: Type.h:5048
clang::TemplateArgumentLoc
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:457
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:1014
clang::TemplateTemplateParmDecl
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Definition: DeclTemplate.h:1618
clang::TemplateArgumentListInfo::setLAngleLoc
void setLAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:582
ASTContext.h
clang::TypeDecl::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Decl.h:3185
clang::FunctionTemplateDecl::newCommon
CommonBase * newCommon(ASTContext &C) const override
Definition: DeclTemplate.cpp:368
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:874
clang::TemplateArgumentLoc::getArgument
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:506
clang::ConceptReference::hasExplicitTemplateArgs
bool hasExplicitTemplateArgs() const
Whether or not template arguments were explicitly specified in the concept reference (they might not ...
Definition: ASTConcept.h:162
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:726
clang::TemplateParameterList
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:69
clang::TSK_ExplicitInstantiationDefinition
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
Definition: Specifiers.h:191
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:813
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:3391
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:879
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:1111
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:2332
Base
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:1296
clang::TemplateTypeParmDecl
Declaration of a template type parameter.
Definition: DeclTemplate.h:1196
clang::TemplateParamObjectDecl
A template parameter object.
Definition: DeclTemplate.h:3304
clang::ConceptReference::ArgsAsWritten
const ASTTemplateArgumentListInfo * ArgsAsWritten
The template argument list source info used to specialize the concept.
Definition: ASTConcept.h:122
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:492
clang::TemplateDecl::getTemplateParameters
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:419
clang::QualType::getUnqualifiedType
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition: Type.h:6580
clang::ClassTemplateDecl::AddSpecialization
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
Definition: DeclTemplate.cpp:497
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:2042
clang::TemplateTypeParmType
Definition: Type.h:4833
clang::TemplateParamObjectDecl::printAsExpr
void printAsExpr(llvm::raw_ostream &OS) const
Print this object as an equivalent expression.
Definition: DeclTemplate.cpp:1516
clang::RedeclarableTemplateDecl::loadLazySpecializationsImpl
void loadLazySpecializationsImpl() const
Definition: DeclTemplate.cpp:291
clang::VarTemplateDecl::getSpecializations
llvm::FoldingSetVector< VarTemplateSpecializationDecl > & getSpecializations() const
Retrieve the set of specializations of this variable template.
Definition: DeclTemplate.cpp:1193
clang::VarTemplateDecl::Common
Data that is common to all of the declarations of a given variable template.
Definition: DeclTemplate.h:3100
clang::Type::castAs
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:7310
clang::ConceptDecl::ConstraintExpr
Expr * ConstraintExpr
Definition: DeclTemplate.h:3254
clang::TemplateArgumentListInfo::arguments
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:591
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
SourceLocation.h
P
StringRef P
Definition: ASTMatchersInternal.cpp:563
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:102
clang::TemplateSpecializationKind
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition: Specifiers.h:173
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:2290
clang::FunctionTemplateSpecializationInfo
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Definition: DeclTemplate.h:468
clang::TagDecl::getBraceRange
SourceRange getBraceRange() const
Definition: Decl.h:3429
clang::NonTypeTemplateParmDecl::getDefaultArgument
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
Definition: DeclTemplate.h:1483
false
#define false
Definition: stdbool.h:22
clang::APValue::printPretty
void printPretty(raw_ostream &OS, const ASTContext &Ctx, QualType Ty) const
Definition: APValue.cpp:689
clang::FunctionTemplateDecl::addSpecialization
void addSpecialization(FunctionTemplateSpecializationInfo *Info, void *InsertPos)
Add a specialization of this function template.
Definition: DeclTemplate.cpp:390
clang::ClassTemplateDecl
Declaration of a class template.
Definition: DeclTemplate.h:2264
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:900
clang::VarTemplateDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary variable pattern.
Definition: DeclTemplate.h:3147
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:503
clang::TemplateName
Represents a C++ template name within the type system.
Definition: TemplateName.h:192
clang::VarTemplateSpecializationDecl::CreateDeserialized
static VarTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:1306
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:838
clang::TemplateDecl
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:400
clang::VarTemplatePartialSpecializationDecl
Definition: DeclTemplate.h:2942
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:740
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:259
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:726
clang::ClassTemplatePartialSpecializationDecl::CreateDeserialized
static ClassTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:1084
clang::VarTemplateDecl::AddSpecialization
void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
Definition: DeclTemplate.cpp:1217
clang::PrintingPolicy::AlwaysIncludeTypeForTemplateArgument
unsigned AlwaysIncludeTypeForTemplateArgument
Whether to use type suffixes (eg: 1U) on integral non-type template parameters.
Definition: PrettyPrinter.h:283
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:1121
LLVM.h
clang::TSK_ExplicitSpecialization
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
Definition: Specifiers.h:183
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:1366
clang::TemplateTypeParmDecl::getDefaultArgumentLoc
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
Definition: DeclTemplate.cpp:660
clang::TemplateArgumentList
A template argument list.
Definition: DeclTemplate.h:237
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:129
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:5145
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:84
clang::ClassScopeFunctionSpecializationDecl::CreateDeserialized
static ClassScopeFunctionSpecializationDecl * CreateDeserialized(ASTContext &Context, unsigned ID)
Definition: DeclTemplate.cpp:1151
clang::TemplateParameterList::asArray
ArrayRef< NamedDecl * > asArray()
Definition: DeclTemplate.h:131
clang::ConceptDecl::ConceptDecl
ConceptDecl(DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, Expr *ConstraintExpr)
Definition: DeclTemplate.h:3256
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:4556
clang::ClassTemplatePartialSpecializationDecl::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: DeclTemplate.h:2247
clang::RedeclarableTemplateDecl::addSpecializationImpl
void addSpecializationImpl(llvm::FoldingSetVector< EntryType > &Specs, EntryType *Entry, void *InsertPos)
Definition: DeclTemplate.cpp:319
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:686
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=None)
Definition: DeclTemplate.cpp:628
DeclarationName.h
clang::VarTemplatePartialSpecializationDecl::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: DeclTemplate.h:3079
clang::RedeclarableTemplateDecl::Common
CommonBase * Common
Pointer to the common data shared by all declarations of this template.
Definition: DeclTemplate.h:843
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:946
clang::FunctionTemplateDecl::getPreviousDecl
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
Definition: DeclTemplate.h:1060
clang::Builtin::ID
ID
Definition: Builtins.h:51
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:1972
clang::TemplateTemplateParmDecl::getDefaultArgument
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
Definition: DeclTemplate.h:1739
clang::FunctionTemplateDecl::FunctionTemplateDecl
FunctionTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:1002
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:450
clang
Definition: CalledOnceCheck.h:17
clang::TemplateArgumentListInfo::setRAngleLoc
void setRAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:583
clang::TemplateTemplateParmDecl::getDefaultArgumentLoc
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
Definition: DeclTemplate.cpp:849
clang::FunctionTemplateDecl::getSpecializations
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > & getSpecializations() const
Retrieve the set of function template specializations of this function template.
Definition: DeclTemplate.cpp:379
clang::TemplateDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.h:441
clang::CXXRecordDecl::getCanonicalDecl
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:501
clang::ClassTemplateDecl::Common::Specializations
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > Specializations
The class template specializations for this class template, including explicit specializations and in...
Definition: DeclTemplate.h:2271
clang::RedeclarableTemplateDecl::findSpecializationImpl
SpecEntryTraits< EntryType >::DeclType * findSpecializationImpl(llvm::FoldingSetVector< EntryType > &Specs, void *&InsertPos, ProfileArguments &&...ProfileArgs)
Definition: DeclTemplate.cpp:306
createMakeIntegerSeqParameterList
static TemplateParameterList * createMakeIntegerSeqParameterList(const ASTContext &C, DeclContext *DC)
Definition: DeclTemplate.cpp:1390
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:1205
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6471
clang::BTK__make_integer_seq
@ BTK__make_integer_seq
This names the __make_integer_seq BuiltinTemplateDecl.
Definition: Builtins.h:281
clang::TemplateParmPosition
Defines the position of a template parameter within a template parameter list.
Definition: DeclTemplate.h:1149
clang::NamedDecl::getDeclName
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:311
clang::TemplateParameterList::begin
iterator begin()
Definition: DeclTemplate.h:124
clang::ClassTemplateDecl::getCommonPtr
Common * getCommonPtr() const
Definition: DeclTemplate.h:2300
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:2066
clang::ASTTemplateArgumentListInfo::Create
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
Definition: TemplateBase.cpp:613
clang::ClassTemplateDecl::getSpecializations
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > & getSpecializations() const
Retrieve the set of specializations of this class template.
Definition: DeclTemplate.cpp:473
clang::RedeclarableTemplateDecl::SpecEntryTraits::DeclType
EntryType DeclType
Definition: DeclTemplate.h:773
clang::VarTemplateSpecializationDecl::getSpecializedTemplate
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
Definition: DeclTemplate.cpp:1329
clang::FunctionTemplateDecl::Common::Specializations
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > Specializations
The function template specializations for this function template, including explicit specializations ...
Definition: DeclTemplate.h:988
clang::TypeAliasTemplateDecl
Declaration of an alias template.
Definition: DeclTemplate.h:2537
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:833
clang::TypeAliasTemplateDecl::TypeAliasTemplateDecl
TypeAliasTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:2541
clang::QualType::getTypePtr
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:6500
clang::TemplateParamObjectDecl::printName
void printName(llvm::raw_ostream &OS) const override
Print this template parameter object in a human-readable format.
Definition: DeclTemplate.cpp:1510
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:601
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:2288
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:1025
clang::ASTContext::hasSameType
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Definition: ASTContext.h:2524
clang::ASTTemplateArgumentListInfo
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:612
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:685
clang::SC_None
@ SC_None
Definition: Specifiers.h:235
true
#define true
Definition: stdbool.h:21
clang::VarTemplateDecl
Declaration of a variable template.
Definition: DeclTemplate.h:3096
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:788
clang::FunctionTemplateDecl::CreateDeserialized
static FunctionTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty function template node.
Definition: DeclTemplate.cpp:361
clang::TemplateParamObjectDecl::getValue
const APValue & getValue() const
Definition: DeclTemplate.h:3340
clang::TypeAliasTemplateDecl::newCommon
CommonBase * newCommon(ASTContext &C) const override
Definition: DeclTemplate.cpp:1138
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:1820
clang::BTK__type_pack_element
@ BTK__type_pack_element
This names the __type_pack_element BuiltinTemplateDecl.
Definition: Builtins.h:284
clang::FunctionTemplateDecl::Common::InjectedArgs
TemplateArgument * InjectedArgs
The set of "injected" template arguments used within this function template.
Definition: DeclTemplate.h:997
clang::Decl::isCanonicalDecl
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Definition: DeclBase.h:916
clang::BuiltinTemplateKind
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
Definition: Builtins.h:279
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1872
clang::TemplateTypeParmDecl::getDepth
unsigned getDepth() const
Retrieve the depth of the template parameter.
Definition: DeclTemplate.cpp:678
clang::FunctionTemplateDecl::getInjectedTemplateArgs
ArrayRef< TemplateArgument > getInjectedTemplateArgs()
Retrieve the "injected" template arguments that correspond to the template parameters of this functio...
Definition: DeclTemplate.cpp:396
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:1280
clang::TypeConstraint
Definition: ASTConcept.h:167
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:1223
clang::ClassTemplateDecl::AddPartialSpecialization
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
Definition: DeclTemplate.cpp:550
TypeLoc.h
clang::TypeSourceInfo::getTypeLoc
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:244
clang::VarTemplateDecl::CreateDeserialized
static VarTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty variable template node.
Definition: DeclTemplate.cpp:1182
clang::StorageClass
StorageClass
Storage classes.
Definition: Specifiers.h:233