clang  14.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/SmallVector.h"
32 #include "llvm/Support/Casting.h"
33 #include "llvm/Support/ErrorHandling.h"
34 #include <algorithm>
35 #include <cassert>
36 #include <cstdint>
37 #include <memory>
38 #include <utility>
39 
40 using namespace clang;
41 
42 //===----------------------------------------------------------------------===//
43 // TemplateParameterList Implementation
44 //===----------------------------------------------------------------------===//
45 
46 
48  SourceLocation TemplateLoc,
49  SourceLocation LAngleLoc,
50  ArrayRef<NamedDecl *> Params,
51  SourceLocation RAngleLoc,
52  Expr *RequiresClause)
53  : TemplateLoc(TemplateLoc), LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc),
54  NumParams(Params.size()), ContainsUnexpandedParameterPack(false),
55  HasRequiresClause(RequiresClause != nullptr),
56  HasConstrainedParameters(false) {
57  for (unsigned Idx = 0; Idx < NumParams; ++Idx) {
58  NamedDecl *P = Params[Idx];
59  begin()[Idx] = P;
60 
61  bool IsPack = P->isTemplateParameterPack();
62  if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(P)) {
63  if (!IsPack && NTTP->getType()->containsUnexpandedParameterPack())
64  ContainsUnexpandedParameterPack = true;
65  if (NTTP->hasPlaceholderTypeConstraint())
66  HasConstrainedParameters = true;
67  } else if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(P)) {
68  if (!IsPack &&
69  TTP->getTemplateParameters()->containsUnexpandedParameterPack())
70  ContainsUnexpandedParameterPack = true;
71  } else if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(P)) {
72  if (const TypeConstraint *TC = TTP->getTypeConstraint()) {
73  if (TC->getImmediatelyDeclaredConstraint()
74  ->containsUnexpandedParameterPack())
75  ContainsUnexpandedParameterPack = true;
76  }
77  if (TTP->hasTypeConstraint())
78  HasConstrainedParameters = true;
79  } else {
80  llvm_unreachable("unexpected template parameter type");
81  }
82  // FIXME: If a default argument contains an unexpanded parameter pack, the
83  // template parameter list does too.
84  }
85 
86  if (HasRequiresClause) {
87  if (RequiresClause->containsUnexpandedParameterPack())
88  ContainsUnexpandedParameterPack = true;
89  *getTrailingObjects<Expr *>() = RequiresClause;
90  }
91 }
92 
94  if (ContainsUnexpandedParameterPack)
95  return true;
96  if (!HasConstrainedParameters)
97  return false;
98 
99  // An implicit constrained parameter might have had a use of an unexpanded
100  // pack added to it after the template parameter list was created. All
101  // implicit parameters are at the end of the parameter list.
102  for (const NamedDecl *Param : llvm::reverse(asArray())) {
103  if (!Param->isImplicit())
104  break;
105 
106  if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
107  const auto *TC = TTP->getTypeConstraint();
108  if (TC && TC->getImmediatelyDeclaredConstraint()
109  ->containsUnexpandedParameterPack())
110  return true;
111  }
112  }
113 
114  return false;
115 }
116 
119  SourceLocation LAngleLoc,
120  ArrayRef<NamedDecl *> Params,
121  SourceLocation RAngleLoc, Expr *RequiresClause) {
122  void *Mem = C.Allocate(totalSizeToAlloc<NamedDecl *, Expr *>(
123  Params.size(), RequiresClause ? 1u : 0u),
124  alignof(TemplateParameterList));
125  return new (Mem) TemplateParameterList(C, TemplateLoc, LAngleLoc, Params,
126  RAngleLoc, RequiresClause);
127 }
128 
130  unsigned NumRequiredArgs = 0;
131  for (const NamedDecl *P : asArray()) {
132  if (P->isTemplateParameterPack()) {
133  if (Optional<unsigned> Expansions = getExpandedPackSize(P)) {
134  NumRequiredArgs += *Expansions;
135  continue;
136  }
137  break;
138  }
139 
140  if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(P)) {
141  if (TTP->hasDefaultArgument())
142  break;
143  } else if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(P)) {
144  if (NTTP->hasDefaultArgument())
145  break;
146  } else if (cast<TemplateTemplateParmDecl>(P)->hasDefaultArgument())
147  break;
148 
149  ++NumRequiredArgs;
150  }
151 
152  return NumRequiredArgs;
153 }
154 
156  if (size() == 0)
157  return 0;
158 
159  const NamedDecl *FirstParm = getParam(0);
160  if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(FirstParm))
161  return TTP->getDepth();
162  else if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(FirstParm))
163  return NTTP->getDepth();
164  else
165  return cast<TemplateTemplateParmDecl>(FirstParm)->getDepth();
166 }
167 
169  DeclContext *Owner) {
170  bool Invalid = false;
171  for (NamedDecl *P : *Params) {
172  P->setDeclContext(Owner);
173 
174  if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(P))
175  if (AdoptTemplateParameterList(TTP->getTemplateParameters(), Owner))
176  Invalid = true;
177 
178  if (P->isInvalidDecl())
179  Invalid = true;
180  }
181  return Invalid;
182 }
183 
186  if (HasConstrainedParameters)
187  for (const NamedDecl *Param : *this) {
188  if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
189  if (const auto *TC = TTP->getTypeConstraint())
190  AC.push_back(TC->getImmediatelyDeclaredConstraint());
191  } else if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
192  if (const Expr *E = NTTP->getPlaceholderTypeConstraint())
193  AC.push_back(E);
194  }
195  }
196  if (HasRequiresClause)
197  AC.push_back(getRequiresClause());
198 }
199 
201  return HasRequiresClause || HasConstrainedParameters;
202 }
203 
205  const TemplateParameterList *TPL, unsigned Idx) {
206  if (!TPL || Idx >= TPL->size())
207  return true;
208  const NamedDecl *TemplParam = TPL->getParam(Idx);
209  if (const auto *ParamValueDecl =
210  dyn_cast<NonTypeTemplateParmDecl>(TemplParam))
211  if (ParamValueDecl->getType()->getContainedDeducedType())
212  return true;
213  return false;
214 }
215 
216 namespace clang {
217 
219  return new (C) char[sizeof(void*) * 2];
220 }
221 
222 } // namespace clang
223 
224 //===----------------------------------------------------------------------===//
225 // TemplateDecl Implementation
226 //===----------------------------------------------------------------------===//
227 
230  NamedDecl *Decl)
231  : NamedDecl(DK, DC, L, Name), TemplatedDecl(Decl), TemplateParams(Params) {}
232 
233 void TemplateDecl::anchor() {}
234 
235 void TemplateDecl::
238  if (auto *FD = dyn_cast_or_null<FunctionDecl>(getTemplatedDecl()))
239  if (const Expr *TRC = FD->getTrailingRequiresClause())
240  AC.push_back(TRC);
241 }
242 
245  return true;
246  if (auto *FD = dyn_cast_or_null<FunctionDecl>(getTemplatedDecl()))
247  return FD->getTrailingRequiresClause();
248  return false;
249 }
250 
251 //===----------------------------------------------------------------------===//
252 // RedeclarableTemplateDecl Implementation
253 //===----------------------------------------------------------------------===//
254 
255 void RedeclarableTemplateDecl::anchor() {}
256 
258  if (Common)
259  return Common;
260 
261  // Walk the previous-declaration chain until we either find a declaration
262  // with a common pointer or we run out of previous declarations.
264  for (const RedeclarableTemplateDecl *Prev = getPreviousDecl(); Prev;
265  Prev = Prev->getPreviousDecl()) {
266  if (Prev->Common) {
267  Common = Prev->Common;
268  break;
269  }
270 
271  PrevDecls.push_back(Prev);
272  }
273 
274  // If we never found a common pointer, allocate one now.
275  if (!Common) {
276  // FIXME: If any of the declarations is from an AST file, we probably
277  // need an update record to add the common data.
278 
280  }
281 
282  // Update any previous declarations we saw with the common pointer.
283  for (const RedeclarableTemplateDecl *Prev : PrevDecls)
284  Prev->Common = Common;
285 
286  return Common;
287 }
288 
290  // Grab the most recent declaration to ensure we've loaded any lazy
291  // redeclarations of this template.
292  CommonBase *CommonBasePtr = getMostRecentDecl()->getCommonPtr();
293  if (CommonBasePtr->LazySpecializations) {
294  ASTContext &Context = getASTContext();
295  uint32_t *Specs = CommonBasePtr->LazySpecializations;
296  CommonBasePtr->LazySpecializations = nullptr;
297  for (uint32_t I = 0, N = *Specs++; I != N; ++I)
298  (void)Context.getExternalSource()->GetExternalDecl(Specs[I]);
299  }
300 }
301 
302 template<class EntryType, typename... ProfileArguments>
305  llvm::FoldingSetVector<EntryType> &Specs, void *&InsertPos,
306  ProfileArguments&&... ProfileArgs) {
307  using SETraits = SpecEntryTraits<EntryType>;
308 
309  llvm::FoldingSetNodeID ID;
310  EntryType::Profile(ID, std::forward<ProfileArguments>(ProfileArgs)...,
311  getASTContext());
312  EntryType *Entry = Specs.FindNodeOrInsertPos(ID, InsertPos);
313  return Entry ? SETraits::getDecl(Entry)->getMostRecentDecl() : nullptr;
314 }
315 
316 template<class Derived, class EntryType>
318  llvm::FoldingSetVector<EntryType> &Specializations, EntryType *Entry,
319  void *InsertPos) {
320  using SETraits = SpecEntryTraits<EntryType>;
321 
322  if (InsertPos) {
323 #ifndef NDEBUG
324  void *CorrectInsertPos;
325  assert(!findSpecializationImpl(Specializations,
326  CorrectInsertPos,
327  SETraits::getTemplateArgs(Entry)) &&
328  InsertPos == CorrectInsertPos &&
329  "given incorrect InsertPos for specialization");
330 #endif
331  Specializations.InsertNode(Entry, InsertPos);
332  } else {
333  EntryType *Existing = Specializations.GetOrInsertNode(Entry);
334  (void)Existing;
335  assert(SETraits::getDecl(Existing)->isCanonicalDecl() &&
336  "non-canonical specialization?");
337  }
338 
340  L->AddedCXXTemplateSpecialization(cast<Derived>(this),
341  SETraits::getDecl(Entry));
342 }
343 
344 //===----------------------------------------------------------------------===//
345 // FunctionTemplateDecl Implementation
346 //===----------------------------------------------------------------------===//
347 
350  DeclarationName Name,
352  bool Invalid = AdoptTemplateParameterList(Params, cast<DeclContext>(Decl));
353  auto *TD = new (C, DC) FunctionTemplateDecl(C, DC, L, Name, Params, Decl);
354  if (Invalid)
355  TD->setInvalidDecl();
356  return TD;
357 }
358 
360  unsigned ID) {
361  return new (C, ID) FunctionTemplateDecl(C, nullptr, SourceLocation(),
362  DeclarationName(), nullptr, nullptr);
363 }
364 
367  auto *CommonPtr = new (C) Common;
368  C.addDestruction(CommonPtr);
369  return CommonPtr;
370 }
371 
374 }
375 
376 llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> &
379  return getCommonPtr()->Specializations;
380 }
381 
382 FunctionDecl *
384  void *&InsertPos) {
385  return findSpecializationImpl(getSpecializations(), InsertPos, Args);
386 }
387 
389  FunctionTemplateSpecializationInfo *Info, void *InsertPos) {
390  addSpecializationImpl<FunctionTemplateDecl>(getSpecializations(), Info,
391  InsertPos);
392 }
393 
396  Common *CommonPtr = getCommonPtr();
397  if (!CommonPtr->InjectedArgs) {
398  auto &Context = getASTContext();
400  Context.getInjectedTemplateArgs(Params, TemplateArgs);
401  CommonPtr->InjectedArgs =
402  new (Context) TemplateArgument[TemplateArgs.size()];
403  std::copy(TemplateArgs.begin(), TemplateArgs.end(),
404  CommonPtr->InjectedArgs);
405  }
406 
407  return llvm::makeArrayRef(CommonPtr->InjectedArgs, Params->size());
408 }
409 
412 
413  // If we haven't created a common pointer yet, then it can just be created
414  // with the usual method.
415  if (!Base::Common)
416  return;
417 
418  Common *ThisCommon = static_cast<Common *>(Base::Common);
419  Common *PrevCommon = nullptr;
421  for (; Prev; Prev = Prev->getPreviousDecl()) {
422  if (Prev->Base::Common) {
423  PrevCommon = static_cast<Common *>(Prev->Base::Common);
424  break;
425  }
426  PreviousDecls.push_back(Prev);
427  }
428 
429  // If the previous redecl chain hasn't created a common pointer yet, then just
430  // use this common pointer.
431  if (!PrevCommon) {
432  for (auto *D : PreviousDecls)
433  D->Base::Common = ThisCommon;
434  return;
435  }
436 
437  // Ensure we don't leak any important state.
438  assert(ThisCommon->Specializations.size() == 0 &&
439  "Can't merge incompatible declarations!");
440 
441  Base::Common = PrevCommon;
442 }
443 
444 //===----------------------------------------------------------------------===//
445 // ClassTemplateDecl Implementation
446 //===----------------------------------------------------------------------===//
447 
449  SourceLocation L,
450  DeclarationName Name,
451  TemplateParameterList *Params,
452  NamedDecl *Decl) {
453  bool Invalid = AdoptTemplateParameterList(Params, cast<DeclContext>(Decl));
454  auto *TD = new (C, DC) ClassTemplateDecl(C, DC, L, Name, Params, Decl);
455  if (Invalid)
456  TD->setInvalidDecl();
457  return TD;
458 }
459 
461  unsigned ID) {
462  return new (C, ID) ClassTemplateDecl(C, nullptr, SourceLocation(),
463  DeclarationName(), nullptr, nullptr);
464 }
465 
468 }
469 
470 llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
473  return getCommonPtr()->Specializations;
474 }
475 
476 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
480 }
481 
484  auto *CommonPtr = new (C) Common;
485  C.addDestruction(CommonPtr);
486  return CommonPtr;
487 }
488 
491  void *&InsertPos) {
492  return findSpecializationImpl(getSpecializations(), InsertPos, Args);
493 }
494 
496  void *InsertPos) {
497  addSpecializationImpl<ClassTemplateDecl>(getSpecializations(), D, InsertPos);
498 }
499 
503  TemplateParameterList *TPL, void *&InsertPos) {
504  return findSpecializationImpl(getPartialSpecializations(), InsertPos, Args,
505  TPL);
506 }
507 
509  llvm::FoldingSetNodeID &ID, const TemplateParameterList *TPL) {
510  const Expr *RC = TPL->getRequiresClause();
511  ID.AddBoolean(RC != nullptr);
512  if (RC)
513  RC->Profile(ID, C, /*Canonical=*/true);
514  ID.AddInteger(TPL->size());
515  for (NamedDecl *D : *TPL) {
516  if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) {
517  ID.AddInteger(0);
518  ID.AddBoolean(NTTP->isParameterPack());
519  NTTP->getType().getCanonicalType().Profile(ID);
520  continue;
521  }
522  if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(D)) {
523  ID.AddInteger(1);
524  ID.AddBoolean(TTP->isParameterPack());
525  ID.AddBoolean(TTP->hasTypeConstraint());
526  if (const TypeConstraint *TC = TTP->getTypeConstraint())
527  TC->getImmediatelyDeclaredConstraint()->Profile(ID, C,
528  /*Canonical=*/true);
529  continue;
530  }
531  const auto *TTP = cast<TemplateTemplateParmDecl>(D);
532  ID.AddInteger(2);
533  ID.AddBoolean(TTP->isParameterPack());
534  ProfileTemplateParameterList(C, ID, TTP->getTemplateParameters());
535  }
536 }
537 
538 void
541  ASTContext &Context) {
542  ID.AddInteger(TemplateArgs.size());
543  for (const TemplateArgument &TemplateArg : TemplateArgs)
544  TemplateArg.Profile(ID, Context);
545  ProfileTemplateParameterList(Context, ID, TPL);
546 }
547 
550  void *InsertPos) {
551  if (InsertPos)
552  getPartialSpecializations().InsertNode(D, InsertPos);
553  else {
555  = getPartialSpecializations().GetOrInsertNode(D);
556  (void)Existing;
557  assert(Existing->isCanonicalDecl() && "Non-canonical specialization?");
558  }
559 
561  L->AddedCXXTemplateSpecialization(this, D);
562 }
563 
566  llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &PartialSpecs
568  PS.clear();
569  PS.reserve(PartialSpecs.size());
570  for (ClassTemplatePartialSpecializationDecl &P : PartialSpecs)
571  PS.push_back(P.getMostRecentDecl());
572 }
573 
576  ASTContext &Context = getASTContext();
579  if (Context.hasSameType(P.getInjectedSpecializationType(), T))
580  return P.getMostRecentDecl();
581  }
582 
583  return nullptr;
584 }
585 
589  Decl *DCanon = D->getCanonicalDecl();
591  if (P.getInstantiatedFromMember()->getCanonicalDecl() == DCanon)
592  return P.getMostRecentDecl();
593  }
594 
595  return nullptr;
596 }
597 
598 QualType
600  Common *CommonPtr = getCommonPtr();
601  if (!CommonPtr->InjectedClassNameType.isNull())
602  return CommonPtr->InjectedClassNameType;
603 
604  // C++0x [temp.dep.type]p2:
605  // The template argument list of a primary template is a template argument
606  // list in which the nth template argument has the value of the nth template
607  // parameter of the class template. If the nth template parameter is a
608  // template parameter pack (14.5.3), the nth template argument is a pack
609  // expansion (14.5.3) whose pattern is the name of the template parameter
610  // pack.
611  ASTContext &Context = getASTContext();
614  Context.getInjectedTemplateArgs(Params, TemplateArgs);
615  CommonPtr->InjectedClassNameType
617  TemplateArgs);
618  return CommonPtr->InjectedClassNameType;
619 }
620 
621 //===----------------------------------------------------------------------===//
622 // TemplateTypeParm Allocation/Deallocation Method Implementations
623 //===----------------------------------------------------------------------===//
624 
627  SourceLocation KeyLoc, SourceLocation NameLoc,
628  unsigned D, unsigned P, IdentifierInfo *Id,
629  bool Typename, bool ParameterPack,
630  bool HasTypeConstraint,
631  Optional<unsigned> NumExpanded) {
632  auto *TTPDecl =
633  new (C, DC,
634  additionalSizeToAlloc<TypeConstraint>(HasTypeConstraint ? 1 : 0))
635  TemplateTypeParmDecl(DC, KeyLoc, NameLoc, Id, Typename,
636  HasTypeConstraint, NumExpanded);
637  QualType TTPType = C.getTemplateTypeParmType(D, P, ParameterPack, TTPDecl);
638  TTPDecl->setTypeForDecl(TTPType.getTypePtr());
639  return TTPDecl;
640 }
641 
644  return new (C, ID) TemplateTypeParmDecl(nullptr, SourceLocation(),
645  SourceLocation(), nullptr, false,
646  false, None);
647 }
648 
651  bool HasTypeConstraint) {
652  return new (C, ID,
653  additionalSizeToAlloc<TypeConstraint>(HasTypeConstraint ? 1 : 0))
655  nullptr, false, HasTypeConstraint, None);
656 }
657 
659  return hasDefaultArgument()
661  : SourceLocation();
662 }
663 
666  return SourceRange(getBeginLoc(),
667  getDefaultArgumentInfo()->getTypeLoc().getEndLoc());
668  // TypeDecl::getSourceRange returns a range containing name location, which is
669  // wrong for unnamed template parameters. e.g:
670  // it will return <[[typename>]] instead of <[[typename]]>
671  else if (getDeclName().isEmpty())
672  return SourceRange(getBeginLoc());
673  return TypeDecl::getSourceRange();
674 }
675 
678 }
679 
682 }
683 
686 }
687 
689  DeclarationNameInfo NameInfo, NamedDecl *FoundDecl, ConceptDecl *CD,
690  const ASTTemplateArgumentListInfo *ArgsAsWritten,
691  Expr *ImmediatelyDeclaredConstraint) {
692  assert(HasTypeConstraint &&
693  "HasTypeConstraint=true must be passed at construction in order to "
694  "call setTypeConstraint");
695  assert(!TypeConstraintInitialized &&
696  "TypeConstraint was already initialized!");
697  new (getTrailingObjects<TypeConstraint>()) TypeConstraint(NNS, NameInfo,
698  FoundDecl, CD, ArgsAsWritten, ImmediatelyDeclaredConstraint);
699  TypeConstraintInitialized = true;
700 }
701 
702 //===----------------------------------------------------------------------===//
703 // NonTypeTemplateParmDecl Method Implementations
704 //===----------------------------------------------------------------------===//
705 
706 NonTypeTemplateParmDecl::NonTypeTemplateParmDecl(
707  DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D,
708  unsigned P, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo,
709  ArrayRef<QualType> ExpandedTypes, ArrayRef<TypeSourceInfo *> ExpandedTInfos)
710  : DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc),
711  TemplateParmPosition(D, P), ParameterPack(true),
712  ExpandedParameterPack(true), NumExpandedTypes(ExpandedTypes.size()) {
713  if (!ExpandedTypes.empty() && !ExpandedTInfos.empty()) {
714  auto TypesAndInfos =
715  getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
716  for (unsigned I = 0; I != NumExpandedTypes; ++I) {
717  new (&TypesAndInfos[I].first) QualType(ExpandedTypes[I]);
718  TypesAndInfos[I].second = ExpandedTInfos[I];
719  }
720  }
721 }
722 
725  SourceLocation StartLoc, SourceLocation IdLoc,
726  unsigned D, unsigned P, IdentifierInfo *Id,
727  QualType T, bool ParameterPack,
728  TypeSourceInfo *TInfo) {
729  AutoType *AT =
730  C.getLangOpts().CPlusPlus20 ? T->getContainedAutoType() : nullptr;
731  return new (C, DC,
732  additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>,
733  Expr *>(0,
734  AT && AT->isConstrained() ? 1 : 0))
735  NonTypeTemplateParmDecl(DC, StartLoc, IdLoc, D, P, Id, T, ParameterPack,
736  TInfo);
737 }
738 
740  const ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
741  SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id,
742  QualType T, TypeSourceInfo *TInfo, ArrayRef<QualType> ExpandedTypes,
743  ArrayRef<TypeSourceInfo *> ExpandedTInfos) {
744  AutoType *AT = TInfo->getType()->getContainedAutoType();
745  return new (C, DC,
746  additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>,
747  Expr *>(
748  ExpandedTypes.size(), AT && AT->isConstrained() ? 1 : 0))
749  NonTypeTemplateParmDecl(DC, StartLoc, IdLoc, D, P, Id, T, TInfo,
750  ExpandedTypes, ExpandedTInfos);
751 }
752 
755  bool HasTypeConstraint) {
756  return new (C, ID, additionalSizeToAlloc<std::pair<QualType,
757  TypeSourceInfo *>,
758  Expr *>(0,
759  HasTypeConstraint ? 1 : 0))
761  0, 0, nullptr, QualType(), false, nullptr);
762 }
763 
766  unsigned NumExpandedTypes,
767  bool HasTypeConstraint) {
768  auto *NTTP =
769  new (C, ID, additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>,
770  Expr *>(
771  NumExpandedTypes, HasTypeConstraint ? 1 : 0))
773  0, 0, nullptr, QualType(), nullptr, None,
774  None);
775  NTTP->NumExpandedTypes = NumExpandedTypes;
776  return NTTP;
777 }
778 
781  return SourceRange(getOuterLocStart(),
782  getDefaultArgument()->getSourceRange().getEnd());
784 }
785 
787  return hasDefaultArgument()
789  : SourceLocation();
790 }
791 
792 //===----------------------------------------------------------------------===//
793 // TemplateTemplateParmDecl Method Implementations
794 //===----------------------------------------------------------------------===//
795 
796 void TemplateTemplateParmDecl::anchor() {}
797 
798 TemplateTemplateParmDecl::TemplateTemplateParmDecl(
799  DeclContext *DC, SourceLocation L, unsigned D, unsigned P,
801  ArrayRef<TemplateParameterList *> Expansions)
802  : TemplateDecl(TemplateTemplateParm, DC, L, Id, Params),
803  TemplateParmPosition(D, P), ParameterPack(true),
804  ExpandedParameterPack(true), NumExpandedParams(Expansions.size()) {
805  if (!Expansions.empty())
806  std::uninitialized_copy(Expansions.begin(), Expansions.end(),
807  getTrailingObjects<TemplateParameterList *>());
808 }
809 
812  SourceLocation L, unsigned D, unsigned P,
813  bool ParameterPack, IdentifierInfo *Id,
814  TemplateParameterList *Params) {
815  return new (C, DC) TemplateTemplateParmDecl(DC, L, D, P, ParameterPack, Id,
816  Params);
817 }
818 
821  SourceLocation L, unsigned D, unsigned P,
823  TemplateParameterList *Params,
825  return new (C, DC,
826  additionalSizeToAlloc<TemplateParameterList *>(Expansions.size()))
827  TemplateTemplateParmDecl(DC, L, D, P, Id, Params, Expansions);
828 }
829 
832  return new (C, ID) TemplateTemplateParmDecl(nullptr, SourceLocation(), 0, 0,
833  false, nullptr, nullptr);
834 }
835 
838  unsigned NumExpansions) {
839  auto *TTP =
840  new (C, ID, additionalSizeToAlloc<TemplateParameterList *>(NumExpansions))
841  TemplateTemplateParmDecl(nullptr, SourceLocation(), 0, 0, nullptr,
842  nullptr, None);
843  TTP->NumExpandedParams = NumExpansions;
844  return TTP;
845 }
846 
849  : SourceLocation();
850 }
851 
853  const ASTContext &C, const TemplateArgumentLoc &DefArg) {
854  if (DefArg.getArgument().isNull())
855  DefaultArgument.set(nullptr);
856  else
857  DefaultArgument.set(new (C) TemplateArgumentLoc(DefArg));
858 }
859 
860 //===----------------------------------------------------------------------===//
861 // TemplateArgumentList Implementation
862 //===----------------------------------------------------------------------===//
863 TemplateArgumentList::TemplateArgumentList(ArrayRef<TemplateArgument> Args)
864  : Arguments(getTrailingObjects<TemplateArgument>()),
865  NumArguments(Args.size()) {
866  std::uninitialized_copy(Args.begin(), Args.end(),
867  getTrailingObjects<TemplateArgument>());
868 }
869 
873  void *Mem = Context.Allocate(totalSizeToAlloc<TemplateArgument>(Args.size()));
874  return new (Mem) TemplateArgumentList(Args);
875 }
876 
878  ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template,
879  TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs,
880  const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI,
881  MemberSpecializationInfo *MSInfo) {
882  const ASTTemplateArgumentListInfo *ArgsAsWritten = nullptr;
883  if (TemplateArgsAsWritten)
884  ArgsAsWritten = ASTTemplateArgumentListInfo::Create(C,
885  *TemplateArgsAsWritten);
886 
887  void *Mem =
888  C.Allocate(totalSizeToAlloc<MemberSpecializationInfo *>(MSInfo ? 1 : 0));
889  return new (Mem) FunctionTemplateSpecializationInfo(
890  FD, Template, TSK, TemplateArgs, ArgsAsWritten, POI, MSInfo);
891 }
892 
893 //===----------------------------------------------------------------------===//
894 // ClassTemplateSpecializationDecl Implementation
895 //===----------------------------------------------------------------------===//
896 
899  DeclContext *DC, SourceLocation StartLoc,
900  SourceLocation IdLoc,
901  ClassTemplateDecl *SpecializedTemplate,
904  : CXXRecordDecl(DK, TK, Context, DC, StartLoc, IdLoc,
905  SpecializedTemplate->getIdentifier(), PrevDecl),
906  SpecializedTemplate(SpecializedTemplate),
907  TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args)),
908  SpecializationKind(TSK_Undeclared) {
909 }
910 
912  Kind DK)
913  : CXXRecordDecl(DK, TTK_Struct, C, nullptr, SourceLocation(),
914  SourceLocation(), nullptr, nullptr),
915  SpecializationKind(TSK_Undeclared) {}
916 
919  DeclContext *DC,
920  SourceLocation StartLoc,
921  SourceLocation IdLoc,
922  ClassTemplateDecl *SpecializedTemplate,
925  auto *Result =
926  new (Context, DC) ClassTemplateSpecializationDecl(
927  Context, ClassTemplateSpecialization, TK, DC, StartLoc, IdLoc,
928  SpecializedTemplate, Args, PrevDecl);
929  Result->setMayHaveOutOfDateDef(false);
930 
931  Context.getTypeDeclType(Result, PrevDecl);
932  return Result;
933 }
934 
937  unsigned ID) {
938  auto *Result =
939  new (C, ID) ClassTemplateSpecializationDecl(C, ClassTemplateSpecialization);
940  Result->setMayHaveOutOfDateDef(false);
941  return Result;
942 }
943 
945  raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const {
946  NamedDecl::getNameForDiagnostic(OS, Policy, Qualified);
947 
948  const auto *PS = dyn_cast<ClassTemplatePartialSpecializationDecl>(this);
949  if (const ASTTemplateArgumentListInfo *ArgsAsWritten =
950  PS ? PS->getTemplateArgsAsWritten() : nullptr) {
952  OS, ArgsAsWritten->arguments(), Policy,
953  getSpecializedTemplate()->getTemplateParameters());
954  } else {
955  const TemplateArgumentList &TemplateArgs = getTemplateArgs();
957  OS, TemplateArgs.asArray(), Policy,
958  getSpecializedTemplate()->getTemplateParameters());
959  }
960 }
961 
964  if (const auto *PartialSpec =
965  SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
966  return PartialSpec->PartialSpecialization->getSpecializedTemplate();
967  return SpecializedTemplate.get<ClassTemplateDecl*>();
968 }
969 
972  if (ExplicitInfo) {
974  if (Begin.isValid()) {
975  // Here we have an explicit (partial) specialization or instantiation.
979  if (getExternLoc().isValid())
980  Begin = getExternLoc();
982  if (End.isInvalid())
984  return SourceRange(Begin, End);
985  }
986  // An implicit instantiation of a class template partial specialization
987  // uses ExplicitInfo to record the TypeAsWritten, but the source
988  // locations should be retrieved from the instantiation pattern.
990  auto *ctpsd = const_cast<CTPSDecl *>(cast<CTPSDecl>(this));
991  CTPSDecl *inst_from = ctpsd->getInstantiatedFromMember();
992  assert(inst_from != nullptr);
993  return inst_from->getSourceRange();
994  }
995  else {
996  // No explicit info available.
997  llvm::PointerUnion<ClassTemplateDecl *,
999  inst_from = getInstantiatedFrom();
1000  if (inst_from.isNull())
1002  if (const auto *ctd = inst_from.dyn_cast<ClassTemplateDecl *>())
1003  return ctd->getSourceRange();
1004  return inst_from.get<ClassTemplatePartialSpecializationDecl *>()
1005  ->getSourceRange();
1006  }
1007 }
1008 
1009 //===----------------------------------------------------------------------===//
1010 // ConceptDecl Implementation
1011 //===----------------------------------------------------------------------===//
1014  TemplateParameterList *Params,
1015  Expr *ConstraintExpr) {
1016  bool Invalid = AdoptTemplateParameterList(Params, DC);
1017  auto *TD = new (C, DC) ConceptDecl(DC, L, Name, Params, ConstraintExpr);
1018  if (Invalid)
1019  TD->setInvalidDecl();
1020  return TD;
1021 }
1022 
1024  unsigned ID) {
1025  ConceptDecl *Result = new (C, ID) ConceptDecl(nullptr, SourceLocation(),
1026  DeclarationName(),
1027  nullptr, nullptr);
1028 
1029  return Result;
1030 }
1031 
1032 //===----------------------------------------------------------------------===//
1033 // ClassTemplatePartialSpecializationDecl Implementation
1034 //===----------------------------------------------------------------------===//
1035 void ClassTemplatePartialSpecializationDecl::anchor() {}
1036 
1037 ClassTemplatePartialSpecializationDecl::
1038 ClassTemplatePartialSpecializationDecl(ASTContext &Context, TagKind TK,
1039  DeclContext *DC,
1040  SourceLocation StartLoc,
1041  SourceLocation IdLoc,
1042  TemplateParameterList *Params,
1043  ClassTemplateDecl *SpecializedTemplate,
1044  ArrayRef<TemplateArgument> Args,
1045  const ASTTemplateArgumentListInfo *ArgInfos,
1048  ClassTemplatePartialSpecialization,
1049  TK, DC, StartLoc, IdLoc,
1050  SpecializedTemplate, Args, PrevDecl),
1051  TemplateParams(Params), ArgsAsWritten(ArgInfos),
1052  InstantiatedFromMember(nullptr, false) {
1053  if (AdoptTemplateParameterList(Params, this))
1054  setInvalidDecl();
1055 }
1056 
1060  SourceLocation StartLoc, SourceLocation IdLoc,
1061  TemplateParameterList *Params,
1062  ClassTemplateDecl *SpecializedTemplate,
1064  const TemplateArgumentListInfo &ArgInfos,
1065  QualType CanonInjectedType,
1067  const ASTTemplateArgumentListInfo *ASTArgInfos =
1068  ASTTemplateArgumentListInfo::Create(Context, ArgInfos);
1069 
1070  auto *Result = new (Context, DC)
1071  ClassTemplatePartialSpecializationDecl(Context, TK, DC, StartLoc, IdLoc,
1072  Params, SpecializedTemplate, Args,
1073  ASTArgInfos, PrevDecl);
1074  Result->setSpecializationKind(TSK_ExplicitSpecialization);
1075  Result->setMayHaveOutOfDateDef(false);
1076 
1077  Context.getInjectedClassNameType(Result, CanonInjectedType);
1078  return Result;
1079 }
1080 
1083  unsigned ID) {
1084  auto *Result = new (C, ID) ClassTemplatePartialSpecializationDecl(C);
1085  Result->setMayHaveOutOfDateDef(false);
1086  return Result;
1087 }
1088 
1089 //===----------------------------------------------------------------------===//
1090 // FriendTemplateDecl Implementation
1091 //===----------------------------------------------------------------------===//
1092 
1093 void FriendTemplateDecl::anchor() {}
1094 
1097  SourceLocation L,
1099  FriendUnion Friend, SourceLocation FLoc) {
1100  return new (Context, DC) FriendTemplateDecl(DC, L, Params, Friend, FLoc);
1101 }
1102 
1104  unsigned ID) {
1105  return new (C, ID) FriendTemplateDecl(EmptyShell());
1106 }
1107 
1108 //===----------------------------------------------------------------------===//
1109 // TypeAliasTemplateDecl Implementation
1110 //===----------------------------------------------------------------------===//
1111 
1114  DeclarationName Name,
1115  TemplateParameterList *Params, NamedDecl *Decl) {
1116  bool Invalid = AdoptTemplateParameterList(Params, DC);
1117  auto *TD = new (C, DC) TypeAliasTemplateDecl(C, DC, L, Name, Params, Decl);
1118  if (Invalid)
1119  TD->setInvalidDecl();
1120  return TD;
1121 }
1122 
1124  unsigned ID) {
1125  return new (C, ID) TypeAliasTemplateDecl(C, nullptr, SourceLocation(),
1126  DeclarationName(), nullptr, nullptr);
1127 }
1128 
1131  auto *CommonPtr = new (C) Common;
1132  C.addDestruction(CommonPtr);
1133  return CommonPtr;
1134 }
1135 
1136 //===----------------------------------------------------------------------===//
1137 // ClassScopeFunctionSpecializationDecl Implementation
1138 //===----------------------------------------------------------------------===//
1139 
1140 void ClassScopeFunctionSpecializationDecl::anchor() {}
1141 
1144  unsigned ID) {
1145  return new (C, ID) ClassScopeFunctionSpecializationDecl(
1146  nullptr, SourceLocation(), nullptr, nullptr);
1147 }
1148 
1149 //===----------------------------------------------------------------------===//
1150 // VarTemplateDecl Implementation
1151 //===----------------------------------------------------------------------===//
1152 
1154  VarTemplateDecl *CurD = this;
1155  while (CurD) {
1156  if (CurD->isThisDeclarationADefinition())
1157  return CurD;
1158  CurD = CurD->getPreviousDecl();
1159  }
1160  return nullptr;
1161 }
1162 
1165  TemplateParameterList *Params,
1166  VarDecl *Decl) {
1167  bool Invalid = AdoptTemplateParameterList(Params, DC);
1168  auto *TD = new (C, DC) VarTemplateDecl(C, DC, L, Name, Params, Decl);
1169  if (Invalid)
1170  TD->setInvalidDecl();
1171  return TD;
1172 }
1173 
1175  unsigned ID) {
1176  return new (C, ID) VarTemplateDecl(C, nullptr, SourceLocation(),
1177  DeclarationName(), nullptr, nullptr);
1178 }
1179 
1182 }
1183 
1184 llvm::FoldingSetVector<VarTemplateSpecializationDecl> &
1187  return getCommonPtr()->Specializations;
1188 }
1189 
1190 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &
1194 }
1195 
1198  auto *CommonPtr = new (C) Common;
1199  C.addDestruction(CommonPtr);
1200  return CommonPtr;
1201 }
1202 
1205  void *&InsertPos) {
1206  return findSpecializationImpl(getSpecializations(), InsertPos, Args);
1207 }
1208 
1210  void *InsertPos) {
1211  addSpecializationImpl<VarTemplateDecl>(getSpecializations(), D, InsertPos);
1212 }
1213 
1216  TemplateParameterList *TPL, void *&InsertPos) {
1217  return findSpecializationImpl(getPartialSpecializations(), InsertPos, Args,
1218  TPL);
1219 }
1220 
1221 void
1224  ASTContext &Context) {
1225  ID.AddInteger(TemplateArgs.size());
1226  for (const TemplateArgument &TemplateArg : TemplateArgs)
1227  TemplateArg.Profile(ID, Context);
1228  ProfileTemplateParameterList(Context, ID, TPL);
1229 }
1230 
1232  VarTemplatePartialSpecializationDecl *D, void *InsertPos) {
1233  if (InsertPos)
1234  getPartialSpecializations().InsertNode(D, InsertPos);
1235  else {
1237  getPartialSpecializations().GetOrInsertNode(D);
1238  (void)Existing;
1239  assert(Existing->isCanonicalDecl() && "Non-canonical specialization?");
1240  }
1241 
1243  L->AddedCXXTemplateSpecialization(this, D);
1244 }
1245 
1248  llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &PartialSpecs =
1250  PS.clear();
1251  PS.reserve(PartialSpecs.size());
1252  for (VarTemplatePartialSpecializationDecl &P : PartialSpecs)
1253  PS.push_back(P.getMostRecentDecl());
1254 }
1255 
1259  Decl *DCanon = D->getCanonicalDecl();
1261  if (P.getInstantiatedFromMember()->getCanonicalDecl() == DCanon)
1262  return P.getMostRecentDecl();
1263  }
1264 
1265  return nullptr;
1266 }
1267 
1268 //===----------------------------------------------------------------------===//
1269 // VarTemplateSpecializationDecl Implementation
1270 //===----------------------------------------------------------------------===//
1271 
1273  Kind DK, ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
1274  SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T,
1276  : VarDecl(DK, Context, DC, StartLoc, IdLoc,
1277  SpecializedTemplate->getIdentifier(), T, TInfo, S),
1278  SpecializedTemplate(SpecializedTemplate),
1279  TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args)),
1280  SpecializationKind(TSK_Undeclared), IsCompleteDefinition(false) {}
1281 
1283  ASTContext &C)
1284  : VarDecl(DK, C, nullptr, SourceLocation(), SourceLocation(), nullptr,
1285  QualType(), nullptr, SC_None),
1286  SpecializationKind(TSK_Undeclared), IsCompleteDefinition(false) {}
1287 
1289  ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
1290  SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T,
1292  return new (Context, DC) VarTemplateSpecializationDecl(
1293  VarTemplateSpecialization, Context, DC, StartLoc, IdLoc,
1294  SpecializedTemplate, T, TInfo, S, Args);
1295 }
1296 
1299  return new (C, ID)
1300  VarTemplateSpecializationDecl(VarTemplateSpecialization, C);
1301 }
1302 
1304  raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const {
1305  NamedDecl::getNameForDiagnostic(OS, Policy, Qualified);
1306 
1307  const auto *PS = dyn_cast<VarTemplatePartialSpecializationDecl>(this);
1308  if (const ASTTemplateArgumentListInfo *ArgsAsWritten =
1309  PS ? PS->getTemplateArgsAsWritten() : nullptr) {
1311  OS, ArgsAsWritten->arguments(), Policy,
1312  getSpecializedTemplate()->getTemplateParameters());
1313  } else {
1314  const TemplateArgumentList &TemplateArgs = getTemplateArgs();
1316  OS, TemplateArgs.asArray(), Policy,
1317  getSpecializedTemplate()->getTemplateParameters());
1318  }
1319 }
1320 
1322  if (const auto *PartialSpec =
1323  SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
1324  return PartialSpec->PartialSpecialization->getSpecializedTemplate();
1325  return SpecializedTemplate.get<VarTemplateDecl *>();
1326 }
1327 
1329  const TemplateArgumentListInfo &ArgsInfo) {
1330  TemplateArgsInfo.setLAngleLoc(ArgsInfo.getLAngleLoc());
1331  TemplateArgsInfo.setRAngleLoc(ArgsInfo.getRAngleLoc());
1332  for (const TemplateArgumentLoc &Loc : ArgsInfo.arguments())
1333  TemplateArgsInfo.addArgument(Loc);
1334 }
1335 
1336 //===----------------------------------------------------------------------===//
1337 // VarTemplatePartialSpecializationDecl Implementation
1338 //===----------------------------------------------------------------------===//
1339 
1340 void VarTemplatePartialSpecializationDecl::anchor() {}
1341 
1342 VarTemplatePartialSpecializationDecl::VarTemplatePartialSpecializationDecl(
1343  ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
1344  SourceLocation IdLoc, TemplateParameterList *Params,
1345  VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo,
1346  StorageClass S, ArrayRef<TemplateArgument> Args,
1347  const ASTTemplateArgumentListInfo *ArgInfos)
1348  : VarTemplateSpecializationDecl(VarTemplatePartialSpecialization, Context,
1349  DC, StartLoc, IdLoc, SpecializedTemplate, T,
1350  TInfo, S, Args),
1351  TemplateParams(Params), ArgsAsWritten(ArgInfos),
1352  InstantiatedFromMember(nullptr, false) {
1353  if (AdoptTemplateParameterList(Params, DC))
1354  setInvalidDecl();
1355 }
1356 
1359  ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
1360  SourceLocation IdLoc, TemplateParameterList *Params,
1361  VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo,
1363  const TemplateArgumentListInfo &ArgInfos) {
1364  const ASTTemplateArgumentListInfo *ASTArgInfos
1365  = ASTTemplateArgumentListInfo::Create(Context, ArgInfos);
1366 
1367  auto *Result =
1368  new (Context, DC) VarTemplatePartialSpecializationDecl(
1369  Context, DC, StartLoc, IdLoc, Params, SpecializedTemplate, T, TInfo,
1370  S, Args, ASTArgInfos);
1371  Result->setSpecializationKind(TSK_ExplicitSpecialization);
1372  return Result;
1373 }
1374 
1377  unsigned ID) {
1378  return new (C, ID) VarTemplatePartialSpecializationDecl(C);
1379 }
1380 
1381 static TemplateParameterList *
1383  // typename T
1384  auto *T = TemplateTypeParmDecl::Create(
1385  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/1, /*Position=*/0,
1386  /*Id=*/nullptr, /*Typename=*/true, /*ParameterPack=*/false,
1387  /*HasTypeConstraint=*/false);
1388  T->setImplicit(true);
1389 
1390  // T ...Ints
1391  TypeSourceInfo *TI =
1392  C.getTrivialTypeSourceInfo(QualType(T->getTypeForDecl(), 0));
1394  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/1,
1395  /*Id=*/nullptr, TI->getType(), /*ParameterPack=*/true, TI);
1396  N->setImplicit(true);
1397 
1398  // <typename T, T ...Ints>
1399  NamedDecl *P[2] = {T, N};
1400  auto *TPL = TemplateParameterList::Create(
1401  C, SourceLocation(), SourceLocation(), P, SourceLocation(), nullptr);
1402 
1403  // template <typename T, ...Ints> class IntSeq
1404  auto *TemplateTemplateParm = TemplateTemplateParmDecl::Create(
1405  C, DC, SourceLocation(), /*Depth=*/0, /*Position=*/0,
1406  /*ParameterPack=*/false, /*Id=*/nullptr, TPL);
1407  TemplateTemplateParm->setImplicit(true);
1408 
1409  // typename T
1410  auto *TemplateTypeParm = TemplateTypeParmDecl::Create(
1411  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/1,
1412  /*Id=*/nullptr, /*Typename=*/true, /*ParameterPack=*/false,
1413  /*HasTypeConstraint=*/false);
1414  TemplateTypeParm->setImplicit(true);
1415 
1416  // T N
1417  TypeSourceInfo *TInfo = C.getTrivialTypeSourceInfo(
1418  QualType(TemplateTypeParm->getTypeForDecl(), 0));
1419  auto *NonTypeTemplateParm = NonTypeTemplateParmDecl::Create(
1420  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/2,
1421  /*Id=*/nullptr, TInfo->getType(), /*ParameterPack=*/false, TInfo);
1422  NamedDecl *Params[] = {TemplateTemplateParm, TemplateTypeParm,
1423  NonTypeTemplateParm};
1424 
1425  // template <template <typename T, T ...Ints> class IntSeq, typename T, T N>
1427  Params, SourceLocation(), nullptr);
1428 }
1429 
1430 static TemplateParameterList *
1432  // std::size_t Index
1433  TypeSourceInfo *TInfo = C.getTrivialTypeSourceInfo(C.getSizeType());
1434  auto *Index = NonTypeTemplateParmDecl::Create(
1435  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/0,
1436  /*Id=*/nullptr, TInfo->getType(), /*ParameterPack=*/false, TInfo);
1437 
1438  // typename ...T
1439  auto *Ts = TemplateTypeParmDecl::Create(
1440  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/1,
1441  /*Id=*/nullptr, /*Typename=*/true, /*ParameterPack=*/true,
1442  /*HasTypeConstraint=*/false);
1443  Ts->setImplicit(true);
1444 
1445  // template <std::size_t Index, typename ...T>
1446  NamedDecl *Params[] = {Index, Ts};
1448  llvm::makeArrayRef(Params),
1449  SourceLocation(), nullptr);
1450 }
1451 
1453  const ASTContext &C, DeclContext *DC, BuiltinTemplateKind BTK) {
1454  switch (BTK) {
1455  case BTK__make_integer_seq:
1456  return createMakeIntegerSeqParameterList(C, DC);
1458  return createTypePackElementParameterList(C, DC);
1459  }
1460 
1461  llvm_unreachable("unhandled BuiltinTemplateKind!");
1462 }
1463 
1464 void BuiltinTemplateDecl::anchor() {}
1465 
1466 BuiltinTemplateDecl::BuiltinTemplateDecl(const ASTContext &C, DeclContext *DC,
1467  DeclarationName Name,
1468  BuiltinTemplateKind BTK)
1469  : TemplateDecl(BuiltinTemplate, DC, SourceLocation(), Name,
1471  BTK(BTK) {}
1472 
1473 void TypeConstraint::print(llvm::raw_ostream &OS, PrintingPolicy Policy) const {
1474  if (NestedNameSpec)
1476  ConceptName.printName(OS, Policy);
1477  if (hasExplicitTemplateArgs()) {
1478  OS << "<";
1479  // FIXME: Find corresponding parameter for argument
1480  for (auto &ArgLoc : ArgsAsWritten->arguments())
1481  ArgLoc.getArgument().print(Policy, OS, /*IncludeType*/ false);
1482  OS << ">";
1483  }
1484 }
1485 
1486 TemplateParamObjectDecl *TemplateParamObjectDecl::Create(const ASTContext &C,
1487  QualType T,
1488  const APValue &V) {
1489  DeclContext *DC = C.getTranslationUnitDecl();
1490  auto *TPOD = new (C, DC) TemplateParamObjectDecl(DC, T, V);
1491  C.addDestruction(&TPOD->Value);
1492  return TPOD;
1493 }
1494 
1496 TemplateParamObjectDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
1497  auto *TPOD = new (C, ID) TemplateParamObjectDecl(nullptr, QualType(), APValue());
1498  C.addDestruction(&TPOD->Value);
1499  return TPOD;
1500 }
1501 
1502 void TemplateParamObjectDecl::printName(llvm::raw_ostream &OS) const {
1503  OS << "<template param ";
1504  printAsExpr(OS);
1505  OS << ">";
1506 }
1507 
1508 void TemplateParamObjectDecl::printAsExpr(llvm::raw_ostream &OS) const {
1509  const ASTContext &Ctx = getASTContext();
1511  printAsInit(OS);
1512 }
1513 
1514 void TemplateParamObjectDecl::printAsInit(llvm::raw_ostream &OS) const {
1515  const ASTContext &Ctx = getASTContext();
1516  getValue().printPretty(OS, Ctx, getType());
1517 }
clang::TypeDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.h:3167
clang::TemplateParameterList::shouldIncludeTypeForArgument
static bool shouldIncludeTypeForArgument(const TemplateParameterList *TPL, unsigned Idx)
Definition: DeclTemplate.cpp:204
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:431
clang::allocateDefaultArgStorageChain
void * allocateDefaultArgStorageChain(const ASTContext &C)
Definition: DeclTemplate.cpp:218
Builtins.h
clang::FunctionTemplateDecl::LoadLazySpecializations
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
Definition: DeclTemplate.cpp:372
clang::FunctionTemplateDecl::mergePrevDecl
void mergePrevDecl(FunctionTemplateDecl *Prev)
Merge Prev with our RedeclarableTemplateDecl::Common.
Definition: DeclTemplate.cpp:410
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:118
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:1538
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:1204
clang::ClassTemplateDecl::Common::PartialSpecializations
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > PartialSpecializations
The class template partial specializations for this class template.
Definition: DeclTemplate.h:2259
clang::RedeclarableTemplateDecl::CommonBase
Definition: DeclTemplate.h:821
clang::FriendTemplateDecl
Declaration of a friend template.
Definition: DeclTemplate.h:2444
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:6406
clang::TemplateTemplateParmDecl::hasDefaultArgument
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Definition: DeclTemplate.h:1719
clang::VarTemplateDecl::Common::Specializations
llvm::FoldingSetVector< VarTemplateSpecializationDecl > Specializations
The variable template specializations for this variable template, including explicit specializations ...
Definition: DeclTemplate.h:3086
clang::TemplateTypeParmDecl::defaultArgumentWasInherited
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
Definition: DeclTemplate.h:1266
clang::TemplateTypeParmDecl::getIndex
unsigned getIndex() const
Retrieve the index of the template parameter.
Definition: DeclTemplate.cpp:680
clang::VarTemplatePartialSpecializationDecl::CreateDeserialized
static VarTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:1376
clang::MemberSpecializationInfo
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:619
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:1059
clang::Decl::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclBase.h:426
clang::TypeAliasTemplateDecl::CreateDeserialized
static TypeAliasTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty alias template node.
Definition: DeclTemplate.cpp:1123
clang::AutoType::isConstrained
bool isConstrained() const
Definition: Type.h:5018
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:212
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1347
clang::VarDecl::getCanonicalDecl
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: Decl.cpp:2141
clang::VarTemplateDecl::getPreviousDecl
VarTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this variable template, or nullptr if no such declaration exists...
Definition: DeclTemplate.h:3163
clang::TemplateDecl::hasAssociatedConstraints
bool hasAssociatedConstraints() const
Definition: DeclTemplate.cpp:243
clang::Decl::getASTMutationListener
ASTMutationListener * getASTMutationListener() const
Definition: DeclBase.cpp:424
clang::TemplateTypeParmDecl::CreateDeserialized
static TemplateTypeParmDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:643
llvm::SmallVector
Definition: LLVM.h:38
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
clang::ASTContext::getTemplateSpecializationType
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
Definition: ASTContext.cpp:4779
clang::TTK_Struct
@ TTK_Struct
The "struct" keyword.
Definition: Type.h:5310
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:383
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:249
clang::SourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:221
clang::ClassTemplateSpecializationDecl::getSpecializedTemplate
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
Definition: DeclTemplate.cpp:963
clang::VarTemplateDecl::AddPartialSpecialization
void AddPartialSpecialization(VarTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
Definition: DeclTemplate.cpp:1231
clang::ClassTemplateSpecializationDecl::getExternLoc
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
Definition: DeclTemplate.h:2030
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:918
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:2262
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:673
clang::TypeDecl::getTypeForDecl
const Type * getTypeForDecl() const
Definition: Decl.h:3162
clang::NonTypeTemplateParmDecl
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Definition: DeclTemplate.h:1384
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:236
clang::RedeclarableTemplateDecl::SpecEntryTraits
Definition: DeclTemplate.h:771
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:54
clang::ClassScopeFunctionSpecializationDecl
Declaration of a function specialization at template class scope.
Definition: DeclTemplate.h:2604
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:852
clang::TemplateArgumentListInfo::getRAngleLoc
SourceLocation getRAngleLoc() const
Definition: TemplateBase.h:581
clang::ClassTemplateSpecializationDecl::getSpecializationKind
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
Definition: DeclTemplate.h:1901
clang::VarTemplateDecl::getCommonPtr
Common * getCommonPtr() const
Definition: DeclTemplate.h:3112
DeclCXX.h
clang::NonTypeTemplateParmDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.cpp:779
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:1303
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:1463
clang::VarTemplateSpecializationDecl::getTemplateArgs
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
Definition: DeclTemplate.h:2755
clang::TemplateArgument::isNull
bool isNull() const
Determine whether this template argument has no value.
Definition: TemplateBase.h:248
clang::VarTemplateDecl::findPartialSpecInstantiatedFromMember
VarTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(VarTemplatePartialSpecializationDecl *D)
Find a variable template partial specialization which was instantiated from the given member partial ...
Definition: DeclTemplate.cpp:1257
clang::ClassTemplateSpecializationDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.cpp:971
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:2082
clang::DeclaratorDecl::getOuterLocStart
SourceLocation getOuterLocStart() const
Return start of source range taking into account any outer template declarations.
Definition: Decl.cpp:1932
clang::ClassTemplatePartialSpecializationDecl
Definition: DeclTemplate.h:2075
clang::PrintingPolicy
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:59
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:752
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:349
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:1726
clang::VarTemplateSpecializationDecl
Represents a variable template specialization, which refers to a variable template with a given set o...
Definition: DeclTemplate.h:2664
TemplateName.h
createTypePackElementParameterList
static TemplateParameterList * createTypePackElementParameterList(const ASTContext &C, DeclContext *DC)
Definition: DeclTemplate.cpp:1431
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:145
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:2251
clang::ClassTemplateDecl::CreateDeserialized
static ClassTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty class template node.
Definition: DeclTemplate.cpp:460
clang::ASTTemplateArgumentListInfo::arguments
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:641
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:1514
clang::DeclaratorContext::TemplateArg
@ TemplateArg
clang::TemplateTypeParmDecl::getDefaultArgumentInfo
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
Definition: DeclTemplate.h:1257
clang::TemplateTypeParmDecl::setTypeConstraint
void setTypeConstraint(NestedNameSpecifierLoc NNS, DeclarationNameInfo NameInfo, NamedDecl *FoundDecl, ConceptDecl *CD, const ASTTemplateArgumentListInfo *ArgsAsWritten, Expr *ImmediatelyDeclaredConstraint)
Definition: DeclTemplate.cpp:688
clang::TemplateTypeParmDecl::hasDefaultArgument
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Definition: DeclTemplate.h:1249
createBuiltinTemplateParameterList
static TemplateParameterList * createBuiltinTemplateParameterList(const ASTContext &C, DeclContext *DC, BuiltinTemplateKind BTK)
Definition: DeclTemplate.cpp:1452
clang::VarTemplateSpecializationDecl::setTemplateArgsInfo
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
Definition: DeclTemplate.cpp:1328
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:185
clang::FriendTemplateDecl::Create
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList * > Params, FriendUnion Friend, SourceLocation FriendLoc)
Definition: DeclTemplate.cpp:1096
clang::TemplateArgumentListInfo::getLAngleLoc
SourceLocation getLAngleLoc() const
Definition: TemplateBase.h:580
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:477
clang::TemplateTypeParmDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.cpp:664
clang::ASTContext::Allocate
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:708
clang::TemplateArgumentLoc::getLocation
SourceLocation getLocation() const
Definition: TemplateBase.h:496
clang::FunctionTemplateDecl
Declaration of a template function.
Definition: DeclTemplate.h:978
llvm::MutableArrayRef
Definition: LLVM.h:35
AdoptTemplateParameterList
static bool AdoptTemplateParameterList(TemplateParameterList *Params, DeclContext *Owner)
Definition: DeclTemplate.cpp:168
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:2175
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:3121
clang::ASTContext::getExternalSource
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
Definition: ASTContext.h:1158
clang::TemplateDecl::TemplateDecl
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.cpp:228
clang::NonTypeTemplateParmDecl::defaultArgumentWasInherited
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
Definition: DeclTemplate.h:1473
clang::Decl::Kind
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:92
clang::VarTemplateDecl::VarTemplateDecl
VarTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:3105
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:871
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:1163
clang::ClassTemplateSpecializationDecl::getTemplateArgs
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
Definition: DeclTemplate.h:1891
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:2276
clang::TemplateArgumentListInfo
A convenient class for passing around template argument information.
Definition: TemplateBase.h:564
ProfileTemplateParameterList
static void ProfileTemplateParameterList(ASTContext &C, llvm::FoldingSetNodeID &ID, const TemplateParameterList *TPL)
Definition: DeclTemplate.cpp:508
clang::TagTypeKind
TagTypeKind
The kind of a tag type.
Definition: Type.h:5308
clang::ClassTemplateDecl::newCommon
CommonBase * newCommon(ASTContext &C) const override
Definition: DeclTemplate.cpp:483
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:1191
clang::TemplateArgumentListInfo::addArgument
void addArgument(const TemplateArgumentLoc &Loc)
Definition: TemplateBase.h:604
clang::ConceptDecl
Declaration of a C++2a concept.
Definition: DeclTemplate.h:3235
clang::DeclaratorDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.cpp:1972
clang::SourceRange::getEnd
SourceLocation getEnd() const
Definition: SourceLocation.h:222
clang::NonTypeTemplateParmDecl::CreateDeserialized
static NonTypeTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID, bool HasTypeConstraint)
Definition: DeclTemplate.cpp:754
clang::TemplateDecl::TemplateParams
TemplateParameterList * TemplateParams
Definition: DeclTemplate.h:447
clang::FunctionTemplateDecl::getCommonPtr
Common * getCommonPtr() const
Definition: DeclTemplate.h:1009
clang::ConceptReference::ConceptName
DeclarationNameInfo ConceptName
The concept name used.
Definition: ASTConcept.h:110
clang::RedeclarableTemplateDecl::RedeclarableTemplateDecl
RedeclarableTemplateDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:852
clang::FunctionTemplateDecl::Common
Data that is common to all of the declarations of a given function template.
Definition: DeclTemplate.h:984
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:212
clang::TemplateParameterList::TemplateParameterList
TemplateParameterList(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Definition: DeclTemplate.cpp:47
clang::FriendTemplateDecl::FriendUnion
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
Definition: DeclTemplate.h:2448
getIdentifier
static StringRef getIdentifier(const Token &Tok)
Definition: ParsePragma.cpp:1380
clang::ClassTemplateSpecializationDecl::CreateDeserialized
static ClassTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:936
clang::ClassTemplateDecl::LoadLazySpecializations
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
Definition: DeclTemplate.cpp:466
clang::VarTemplateDecl::getDefinition
VarTemplateDecl * getDefinition()
Definition: DeclTemplate.cpp:1153
clang::VarTemplateDecl::Common::PartialSpecializations
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > PartialSpecializations
The variable template partial specializations for this variable template.
Definition: DeclTemplate.h:3091
clang::TemplateParameterList::hasAssociatedConstraints
bool hasAssociatedConstraints() const
Definition: DeclTemplate.cpp:200
clang::VarTemplateDecl::LoadLazySpecializations
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
Definition: DeclTemplate.cpp:1180
clang::TemplateArgument
Represents a template argument.
Definition: TemplateBase.h:62
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:587
clang::AutoType
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Definition: Type.h:4980
clang::TemplateArgumentLoc
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:458
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:1012
clang::TemplateTemplateParmDecl
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Definition: DeclTemplate.h:1601
clang::TemplateArgumentListInfo::setLAngleLoc
void setLAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:583
ASTContext.h
clang::TypeDecl::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Decl.h:3165
clang::FunctionTemplateDecl::newCommon
CommonBase * newCommon(ASTContext &C) const override
Definition: DeclTemplate.cpp:366
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:876
clang::TemplateArgumentLoc::getArgument
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:507
clang::ConceptReference::hasExplicitTemplateArgs
bool hasExplicitTemplateArgs() const
Whether or not template arguments were explicitly specified in the concept reference (they might not ...
Definition: ASTConcept.h:164
clang::NonTypeTemplateParmDecl::Create
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
Definition: DeclTemplate.cpp:724
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:811
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:3372
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:877
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:1103
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:2287
Base
clang::DefaultArgStorage::set
void set(ArgType Arg)
Set the default argument.
Definition: DeclTemplate.h:368
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:1288
clang::TemplateTypeParmDecl
Declaration of a template type parameter.
Definition: DeclTemplate.h:1178
clang::TemplateParamObjectDecl
A template parameter object.
Definition: DeclTemplate.h:3287
clang::ConceptReference::ArgsAsWritten
const ASTTemplateArgumentListInfo * ArgsAsWritten
The template argument list source info used to specialize the concept.
Definition: ASTConcept.h:123
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:490
clang::TemplateDecl::getTemplateParameters
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:418
clang::QualType::getUnqualifiedType
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition: Type.h:6504
clang::ClassTemplateDecl::AddSpecialization
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
Definition: DeclTemplate.cpp:495
clang::TemplateArgumentList::asArray
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Definition: DeclTemplate.h:290
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:2025
clang::TemplateTypeParmType
Definition: Type.h:4765
clang::TemplateParamObjectDecl::printAsExpr
void printAsExpr(llvm::raw_ostream &OS) const
Print this object as an equivalent expression.
Definition: DeclTemplate.cpp:1508
clang::RedeclarableTemplateDecl::loadLazySpecializationsImpl
void loadLazySpecializationsImpl() const
Definition: DeclTemplate.cpp:289
clang::VarTemplateDecl::getSpecializations
llvm::FoldingSetVector< VarTemplateSpecializationDecl > & getSpecializations() const
Retrieve the set of specializations of this variable template.
Definition: DeclTemplate.cpp:1185
clang::VarTemplateDecl::Common
Data that is common to all of the declarations of a given variable template.
Definition: DeclTemplate.h:3083
clang::Type::castAs
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:7226
clang::ConceptDecl::ConstraintExpr
Expr * ConstraintExpr
Definition: DeclTemplate.h:3237
clang::TemplateArgumentListInfo::arguments
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:592
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:255
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:103
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:2279
clang::FunctionTemplateSpecializationInfo
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Definition: DeclTemplate.h:467
clang::TagDecl::getBraceRange
SourceRange getBraceRange() const
Definition: Decl.h:3409
clang::NonTypeTemplateParmDecl::getDefaultArgument
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
Definition: DeclTemplate.h:1466
false
#define false
Definition: stdbool.h:17
clang::APValue::printPretty
void printPretty(raw_ostream &OS, const ASTContext &Ctx, QualType Ty) const
Definition: APValue.cpp:628
clang::FunctionTemplateDecl::addSpecialization
void addSpecialization(FunctionTemplateSpecializationInfo *Info, void *InsertPos)
Add a specialization of this function template.
Definition: DeclTemplate.cpp:388
clang::ClassTemplateDecl
Declaration of a class template.
Definition: DeclTemplate.h:2247
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:898
clang::VarTemplateDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary variable pattern.
Definition: DeclTemplate.h:3130
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:501
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:1298
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:837
clang::ASTContext::getPrintingPolicy
const clang::PrintingPolicy & getPrintingPolicy() const
Definition: ASTContext.h:687
clang::TemplateDecl
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:399
clang::VarTemplatePartialSpecializationDecl
Definition: DeclTemplate.h:2925
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:738
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:257
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
clang::DeclaratorDecl
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:728
clang::ClassTemplatePartialSpecializationDecl::CreateDeserialized
static ClassTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:1082
clang::VarTemplateDecl::AddSpecialization
void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
Definition: DeclTemplate.cpp:1209
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:1113
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:1358
clang::TemplateTypeParmDecl::getDefaultArgumentLoc
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
Definition: DeclTemplate.cpp:658
clang::TemplateArgumentList
A template argument list.
Definition: DeclTemplate.h:236
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:5059
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:1143
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:3239
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:4533
clang::ClassTemplatePartialSpecializationDecl::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: DeclTemplate.h:2230
clang::RedeclarableTemplateDecl::addSpecializationImpl
void addSpecializationImpl(llvm::FoldingSetVector< EntryType > &Specs, EntryType *Entry, void *InsertPos)
Definition: DeclTemplate.cpp:317
clang::TemplateParameterList::getDepth
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
Definition: DeclTemplate.cpp:155
clang::TemplateTypeParmDecl::isParameterPack
bool isParameterPack() const
Returns whether this is a parameter pack.
Definition: DeclTemplate.cpp:684
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:626
DeclarationName.h
clang::VarTemplatePartialSpecializationDecl::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: DeclTemplate.h:3062
clang::RedeclarableTemplateDecl::Common
CommonBase * Common
Pointer to the common data shared by all declarations of this template.
Definition: DeclTemplate.h:842
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:944
clang::FunctionTemplateDecl::getPreviousDecl
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
Definition: DeclTemplate.h:1059
clang::Builtin::ID
ID
Definition: Builtins.h:48
clang::SourceLocation::isInvalid
bool isInvalid() const
Definition: SourceLocation.h:113
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:1955
clang::TemplateTemplateParmDecl::getDefaultArgument
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
Definition: DeclTemplate.h:1722
clang::FunctionTemplateDecl::FunctionTemplateDecl
FunctionTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:1001
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:448
clang
Definition: CalledOnceCheck.h:17
clang::TemplateArgumentListInfo::setRAngleLoc
void setRAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:584
clang::TemplateTemplateParmDecl::getDefaultArgumentLoc
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
Definition: DeclTemplate.cpp:847
clang::FunctionTemplateDecl::getSpecializations
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > & getSpecializations() const
Retrieve the set of function template specializations of this function template.
Definition: DeclTemplate.cpp:377
clang::TemplateDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.h:440
clang::CXXRecordDecl::getCanonicalDecl
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:494
clang::ClassTemplateDecl::Common::Specializations
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > Specializations
The class template specializations for this class template, including explicit specializations and in...
Definition: DeclTemplate.h:2254
clang::RedeclarableTemplateDecl::findSpecializationImpl
SpecEntryTraits< EntryType >::DeclType * findSpecializationImpl(llvm::FoldingSetVector< EntryType > &Specs, void *&InsertPos, ProfileArguments &&...ProfileArgs)
Definition: DeclTemplate.cpp:304
createMakeIntegerSeqParameterList
static TemplateParameterList * createMakeIntegerSeqParameterList(const ASTContext &C, DeclContext *DC)
Definition: DeclTemplate.cpp:1382
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:112
clang::VarTemplateDecl::newCommon
CommonBase * newCommon(ASTContext &C) const override
Definition: DeclTemplate.cpp:1197
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6395
clang::BTK__make_integer_seq
@ BTK__make_integer_seq
This names the __make_integer_seq BuiltinTemplateDecl.
Definition: Builtins.h:253
clang::TemplateParmPosition
Defines the position of a template parameter within a template parameter list.
Definition: DeclTemplate.h:1148
clang::NamedDecl::getDeclName
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:313
clang::TemplateParameterList::begin
iterator begin()
Definition: DeclTemplate.h:124
clang::ClassTemplateDecl::getCommonPtr
Common * getCommonPtr() const
Definition: DeclTemplate.h:2283
clang::ClassTemplateSpecializationDecl::getTemplateKeywordLoc
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
Definition: DeclTemplate.h:2049
clang::ASTTemplateArgumentListInfo::Create
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
Definition: TemplateBase.cpp:611
clang::ClassTemplateDecl::getSpecializations
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > & getSpecializations() const
Retrieve the set of specializations of this class template.
Definition: DeclTemplate.cpp:471
clang::RedeclarableTemplateDecl::SpecEntryTraits::DeclType
EntryType DeclType
Definition: DeclTemplate.h:772
clang::VarTemplateSpecializationDecl::getSpecializedTemplate
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
Definition: DeclTemplate.cpp:1321
clang::FunctionTemplateDecl::Common::Specializations
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > Specializations
The function template specializations for this function template, including explicit specializations ...
Definition: DeclTemplate.h:987
clang::TypeAliasTemplateDecl
Declaration of an alias template.
Definition: DeclTemplate.h:2520
clang::TemplateParameterList::getMinRequiredArguments
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization.
Definition: DeclTemplate.cpp:129
clang::TemplateTemplateParmDecl::CreateDeserialized
static TemplateTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:831
clang::TypeAliasTemplateDecl::TypeAliasTemplateDecl
TypeAliasTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:2524
clang::QualType::getTypePtr
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:6424
clang::TemplateParamObjectDecl::printName
void printName(llvm::raw_ostream &OS) const override
Print this template parameter object in a human-readable format.
Definition: DeclTemplate.cpp:1502
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:105
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:599
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:2248
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:1023
clang::ASTContext::hasSameType
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Definition: ASTContext.h:2484
clang::ASTTemplateArgumentListInfo
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:613
llvm::SmallVectorImpl
Definition: LLVM.h:39
clang::TemplateParameterList::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Determine whether this template parameter list contains an unexpanded parameter pack.
Definition: DeclTemplate.cpp:93
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:687
clang::SC_None
@ SC_None
Definition: Specifiers.h:235
true
#define true
Definition: stdbool.h:16
clang::VarTemplateDecl
Declaration of a variable template.
Definition: DeclTemplate.h:3079
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:786
clang::FunctionTemplateDecl::CreateDeserialized
static FunctionTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty function template node.
Definition: DeclTemplate.cpp:359
clang::TemplateParamObjectDecl::getValue
const APValue & getValue() const
Definition: DeclTemplate.h:3321
clang::TypeAliasTemplateDecl::newCommon
CommonBase * newCommon(ASTContext &C) const override
Definition: DeclTemplate.cpp:1130
clang::DeclarationNameInfo
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Definition: DeclarationName.h:758
clang::ClassTemplateSpecializationDecl
Represents a class template specialization, which refers to a class template with a given set of temp...
Definition: DeclTemplate.h:1803
clang::BTK__type_pack_element
@ BTK__type_pack_element
This names the __type_pack_element BuiltinTemplateDecl.
Definition: Builtins.h:256
clang::FunctionTemplateDecl::Common::InjectedArgs
TemplateArgument * InjectedArgs
The set of "injected" template arguments used within this function template.
Definition: DeclTemplate.h:996
clang::Decl::isCanonicalDecl
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Definition: DeclBase.h:907
clang::BuiltinTemplateKind
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
Definition: Builtins.h:251
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1856
clang::TemplateTypeParmDecl::getDepth
unsigned getDepth() const
Retrieve the depth of the template parameter.
Definition: DeclTemplate.cpp:676
clang::FunctionTemplateDecl::getInjectedTemplateArgs
ArrayRef< TemplateArgument > getInjectedTemplateArgs()
Retrieve the "injected" template arguments that correspond to the template parameters of this functio...
Definition: DeclTemplate.cpp:394
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:1272
clang::TypeConstraint
Definition: ASTConcept.h:169
clang::VarTemplateDecl::findPartialSpecialization
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
Definition: DeclTemplate.cpp:1215
clang::ClassTemplateDecl::AddPartialSpecialization
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
Definition: DeclTemplate.cpp:548
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:1174
clang::StorageClass
StorageClass
Storage classes.
Definition: Specifiers.h:233