clang 24.0.0git
TemplateName.h
Go to the documentation of this file.
1//===- TemplateName.h - C++ Template Name Representation --------*- C++ -*-===//
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 defines the TemplateName interface and subclasses.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_AST_TEMPLATENAME_H
14#define LLVM_CLANG_AST_TEMPLATENAME_H
15
18#include "clang/Basic/LLVM.h"
21#include "llvm/ADT/FoldingSet.h"
22#include "llvm/ADT/PointerIntPair.h"
23#include "llvm/ADT/PointerUnion.h"
24#include "llvm/Support/PointerLikeTypeTraits.h"
25#include "llvm/Support/TrailingObjects.h"
26#include <cassert>
27#include <optional>
28
29namespace clang {
30
31class ASTContext;
32class Decl;
34class Expr;
35class IdentifierInfo;
36class NamedDecl;
43struct PrintingPolicy;
48class TemplateDecl;
50class UsingShadowDecl;
51
52} // namespace clang
53
54namespace llvm {
55
56// Provide PointerLikeTypeTraits for clang::Expr*, this default one requires a
57// full definition of Expr, but this file only sees a forward del because of
58// the dependency.
59template <> struct PointerLikeTypeTraits<clang::Expr *> {
60 static inline void *getAsVoidPointer(clang::Expr *P) { return P; }
61 static inline clang::Expr *getFromVoidPointer(void *P) {
62 return static_cast<clang::Expr *>(P);
63 }
64 static constexpr int NumLowBitsAvailable = 2;
65};
66
67} // namespace llvm
68
69namespace clang {
70
71/// Implementation class used to describe either a set of overloaded
72/// template names or an already-substituted template template parameter pack.
74protected:
83
84 struct BitsTag {
85 LLVM_PREFERRED_TYPE(Kind)
87
88 // The template parameter index.
89 unsigned Index : 14;
90
91 /// The pack index, or the number of stored templates
92 /// or template arguments, depending on which subclass we have.
93 unsigned Data : 15;
94 };
95
96 union {
97 struct BitsTag Bits;
99 };
100
102 Bits.Kind = Kind;
103 Bits.Index = Index;
104 Bits.Data = Data;
105 }
106
107public:
109 return Bits.Kind == Overloaded
110 ? reinterpret_cast<OverloadedTemplateStorage *>(this)
111 : nullptr;
112 }
113
115 return Bits.Kind == Assumed
116 ? reinterpret_cast<AssumedTemplateStorage *>(this)
117 : nullptr;
118 }
119
121 return Bits.Kind == Deduced
122 ? reinterpret_cast<DeducedTemplateStorage *>(this)
123 : nullptr;
124 }
125
131
137
139 return Bits.Kind == PackIndexing
140 ? reinterpret_cast<PackIndexingTemplateStorage *>(this)
141 : nullptr;
142 }
143};
144
145/// A structure for storing the information associated with an
146/// overloaded template name.
147class OverloadedTemplateStorage : public UncommonTemplateNameStorage {
148 friend class ASTContext;
149
150 OverloadedTemplateStorage(unsigned size)
152
154 return reinterpret_cast<NamedDecl **>(this + 1);
155 }
156 NamedDecl * const *getStorage() const {
157 return reinterpret_cast<NamedDecl *const *>(this + 1);
158 }
159
160public:
161 unsigned size() const { return Bits.Data; }
162
163 using iterator = NamedDecl *const *;
164
165 iterator begin() const { return getStorage(); }
166 iterator end() const { return getStorage() + Bits.Data; }
167
169 return llvm::ArrayRef(begin(), end());
170 }
171};
172
173/// A structure for storing an already-substituted template template
174/// parameter pack.
175///
176/// This kind of template names occurs when the parameter pack has been
177/// provided with a template template argument pack in a context where its
178/// enclosing pack expansion could not be fully expanded.
180 public llvm::FoldingSetNode {
181 const TemplateArgument *Arguments;
182 llvm::PointerIntPair<Decl *, 1, bool> AssociatedDeclAndFinal;
183
184public:
186 Decl *AssociatedDecl, unsigned Index,
187 bool Final);
188
189 /// A template-like entity which owns the whole pattern being substituted.
190 /// This will own a set of template parameters.
191 Decl *getAssociatedDecl() const;
192
193 /// Returns the index of the replaced parameter in the associated declaration.
194 /// This should match the result of `getParameterPack()->getIndex()`.
195 unsigned getIndex() const { return Bits.Index; }
196
197 // When true the substitution will be 'Final' (subst node won't be placed).
198 bool getFinal() const;
199
200 /// Retrieve the template template parameter pack being substituted.
201 TemplateTemplateParmDecl *getParameterPack() const;
202
203 /// Retrieve the template template argument pack with which this
204 /// parameter was substituted.
205 TemplateArgument getArgumentPack() const;
206
207 void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context);
208
209 static void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context,
210 const TemplateArgument &ArgPack, Decl *AssociatedDecl,
211 unsigned Index, bool Final);
212};
213
215 // The position in the template parameter list
216 // the first argument corresponds to.
217 unsigned StartPos;
219
220 operator bool() const { return !Args.empty(); }
221};
222
223/// Represents a C++ template name within the type system.
224///
225/// A C++ template name refers to a template within the C++ type
226/// system. In most cases, a template name is simply a reference to a
227/// class template, e.g.
228///
229/// \code
230/// template<typename T> class X { };
231///
232/// X<int> xi;
233/// \endcode
234///
235/// Here, the 'X' in \c X<int> is a template name that refers to the
236/// declaration of the class template X, above. Template names can
237/// also refer to function templates, C++0x template aliases, etc.
238///
239/// Some template names are dependent. For example, consider:
240///
241/// \code
242/// template<typename MetaFun, typename T1, typename T2> struct apply2 {
243/// typedef typename MetaFun::template apply<T1, T2>::type type;
244/// };
245/// \endcode
246///
247/// Here, "apply" is treated as a template name within the typename
248/// specifier in the typedef. "apply" is a nested template, and can
249/// only be understood in the context of a template instantiation,
250/// hence is represented as a dependent template name.
251class TemplateName {
252 // NameDecl is either a TemplateDecl or a UsingShadowDecl depending on the
253 // NameKind.
254 // !! There is no free low bits in 32-bit builds to discriminate more than 4
255 // pointer types in PointerUnion.
256 using StorageType =
257 llvm::PointerUnion<Decl *, UncommonTemplateNameStorage *,
259
260 StorageType Storage;
261
262 explicit TemplateName(void *Ptr);
263
264public:
265 // Kind of name that is actually stored.
266 enum NameKind {
267 /// A single template declaration.
269
270 /// A set of overloaded template declarations.
272
273 /// An unqualified-id that has been assumed to name a function template
274 /// that will be found by ADL.
276
277 /// A qualified template name, where the qualification is kept
278 /// to describe the source code as written.
280
281 /// A dependent template name that has not been resolved to a
282 /// template (or set of templates).
284
285 /// A template template parameter that has been substituted
286 /// for some other template name.
288
289 /// A template template parameter pack that has been substituted for
290 /// a template template argument pack, but has not yet been expanded into
291 /// individual arguments.
293
294 /// A template name that refers to a template declaration found through a
295 /// specific using shadow declaration.
297
298 /// A template name that refers to another TemplateName with deduced default
299 /// arguments.
301
302 /// A pack-index-template-name.
304 };
305
306 TemplateName() = default;
307 explicit TemplateName(TemplateDecl *Template);
308 explicit TemplateName(OverloadedTemplateStorage *Storage);
309 explicit TemplateName(AssumedTemplateStorage *Storage);
310 explicit TemplateName(SubstTemplateTemplateParmStorage *Storage);
311 explicit TemplateName(SubstTemplateTemplateParmPackStorage *Storage);
312 explicit TemplateName(QualifiedTemplateName *Qual);
313 explicit TemplateName(DependentTemplateName *Dep);
314 explicit TemplateName(UsingShadowDecl *Using);
315 explicit TemplateName(DeducedTemplateStorage *Deduced);
316 explicit TemplateName(PackIndexingTemplateStorage *PackIndexing);
317
318 /// Determine whether this template name is NULL.
319 bool isNull() const;
320
321 // Get the kind of name that is actually stored.
322 NameKind getKind() const;
323
324 /// Retrieve the underlying template declaration that
325 /// this template name refers to, if known.
326 ///
327 /// \returns The template declaration that this template name refers
328 /// to, if any. If the template name does not refer to a specific
329 /// declaration because it is a dependent name, or if it refers to a
330 /// set of function templates, returns NULL.
331 TemplateDecl *getAsTemplateDecl(bool IgnoreDeduced = false) const;
332
333 /// Retrieve the template template parameter that this template name refers
334 /// to, if any.
336
337 /// Retrieves the underlying template name that
338 /// this template name refers to, along with the
339 /// deduced default arguments, if any.
340 std::pair<TemplateName, DefaultArguments>
342
343 /// Retrieve the underlying, overloaded function template
344 /// declarations that this template name refers to, if known.
345 ///
346 /// \returns The set of overloaded function templates that this template
347 /// name refers to, if known. If the template name does not refer to a
348 /// specific set of function templates because it is a dependent name or
349 /// refers to a single template, returns NULL.
351
352 /// Retrieve information on a name that has been assumed to be a
353 /// template-name in order to permit a call via ADL.
355
356 /// Retrieve the substituted template template parameter, if
357 /// known.
358 ///
359 /// \returns The storage for the substituted template template parameter,
360 /// if known. Otherwise, returns NULL.
362
363 /// Retrieve the substituted template template parameter pack, if
364 /// known.
365 ///
366 /// \returns The storage for the substituted template template parameter pack,
367 /// if known. Otherwise, returns NULL.
370
371 /// Retrieve the underlying qualified template name
372 /// structure, if any.
374
375 /// Retrieve the underlying dependent template name
376 /// structure, if any.
378
379 // Retrieve the qualifier and template keyword stored in either a underlying
380 // DependentTemplateName or QualifiedTemplateName.
381 std::tuple<NestedNameSpecifier, bool> getQualifierAndTemplateKeyword() const;
382
384 return std::get<0>(getQualifierAndTemplateKeyword());
385 }
386
387 /// Retrieve the using shadow declaration through which the underlying
388 /// template declaration is introduced, if any.
389 UsingShadowDecl *getAsUsingShadowDecl() const;
390
391 /// Retrieve the deduced template info, if any.
392 DeducedTemplateStorage *getAsDeducedTemplateName() const;
393
394 /// Retrieve the pack-index-template-name storage, if any.
395 PackIndexingTemplateStorage *getAsPackIndexingTemplate() const;
396
397 std::optional<TemplateName> desugar(bool IgnoreDeduced) const;
398
399 TemplateName getUnderlying() const;
400
401 TemplateNameDependence getDependence() const;
402
403 /// Determines whether this is a dependent template name.
404 bool isDependent() const;
405
406 /// Determines whether this is a template name that somehow
407 /// depends on a template parameter.
408 bool isInstantiationDependent() const;
409
410 /// Determines whether this template name contains an
411 /// unexpanded parameter pack (for C++0x variadic templates).
412 bool containsUnexpandedParameterPack() const;
413
414 /// Determines whether this template name denotes a concept, or a template
415 /// template parameter denoting one.
416 bool isConceptName() const;
417
418 enum class Qualified { None, AsWritten };
419 /// Print the template name.
420 ///
421 /// \param OS the output stream to which the template name will be
422 /// printed.
423 ///
424 /// \param Qual print the (Qualified::None) simple name,
425 /// (Qualified::AsWritten) any written (possibly partial) qualifier, or
426 /// (Qualified::Fully) the fully qualified name.
427 void print(raw_ostream &OS, const PrintingPolicy &Policy,
428 Qualified Qual = Qualified::AsWritten) const;
429
430 /// Debugging aid that dumps the template name.
431 void dump(raw_ostream &OS, const ASTContext &Context) const;
432
433 /// Debugging aid that dumps the template name to standard
434 /// error.
435 void dump() const;
436
437 void Profile(llvm::FoldingSetNodeID &ID) {
438 ID.AddPointer(Storage.getOpaqueValue());
439 }
440
441 /// Retrieve the template name as a void pointer.
442 void *getAsVoidPointer() const { return Storage.getOpaqueValue(); }
443
444 /// Build a template name from a void pointer.
445 static TemplateName getFromVoidPointer(void *Ptr) {
446 return TemplateName(Ptr);
447 }
448
449 /// Structural equality.
450 bool operator==(TemplateName Other) const { return Storage == Other.Storage; }
451 bool operator!=(TemplateName Other) const { return !operator==(Other); }
452};
453
454/// Insertion operator for diagnostics. This allows sending TemplateName's
455/// into a diagnostic with <<.
456const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
457 TemplateName N);
458
459/// A structure for storing the information associated with a
460/// substituted template template parameter.
461class SubstTemplateTemplateParmStorage
462 : public UncommonTemplateNameStorage, public llvm::FoldingSetNode {
463 friend class ASTContext;
464
465 TemplateName Replacement;
466 Decl *AssociatedDecl;
467
468 SubstTemplateTemplateParmStorage(TemplateName Replacement,
469 Decl *AssociatedDecl, unsigned Index,
470 UnsignedOrNone PackIndex, bool Final)
473 ((PackIndex.toInternalRepresentation()) << 1) | Final),
474 Replacement(Replacement), AssociatedDecl(AssociatedDecl) {
475 assert(AssociatedDecl != nullptr);
476 }
477
478public:
479 /// A template-like entity which owns the whole pattern being substituted.
480 /// This will own a set of template parameters.
481 Decl *getAssociatedDecl() const { return AssociatedDecl; }
482
483 /// Returns the index of the replaced parameter in the associated declaration.
484 /// This should match the result of `getParameter()->getIndex()`.
485 unsigned getIndex() const { return Bits.Index; }
486
487 // This substitution is Final, which means the substitution is fully
488 // sugared: it doesn't need to be resugared later.
489 bool getFinal() const { return Bits.Data & 1; }
490
494
495 TemplateTemplateParmDecl *getParameter() const;
496 TemplateName getReplacement() const { return Replacement; }
497
498 void Profile(llvm::FoldingSetNodeID &ID);
499
500 static void Profile(llvm::FoldingSetNodeID &ID, TemplateName Replacement,
501 Decl *AssociatedDecl, unsigned Index,
502 UnsignedOrNone PackIndex, bool Final);
503};
504
505class DeducedTemplateStorage : public UncommonTemplateNameStorage,
506 public llvm::FoldingSetNode {
507 friend class ASTContext;
508
509 TemplateName Underlying;
510
511 DeducedTemplateStorage(TemplateName Underlying,
512 const DefaultArguments &DefArgs);
513
514public:
515 TemplateName getUnderlying() const { return Underlying; }
516
518 return {/*StartPos=*/Bits.Index,
519 /*Args=*/{reinterpret_cast<const TemplateArgument *>(this + 1),
520 Bits.Data}};
521 }
522
523 void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const;
524
525 static void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
526 TemplateName Underlying, const DefaultArguments &DefArgs);
527};
528
529/// A structure for storing a pack-index-template-name ([temp.names]).
530///
531/// C++29 [temp.names]p1:
532/// pack-index-template-name:
533/// simple-template-name ... [ constant-expression ]
534class PackIndexingTemplateStorage final
536 public llvm::FoldingSetNode,
537 private llvm::TrailingObjects<PackIndexingTemplateStorage, TemplateName> {
538 friend class ASTContext;
539 friend TrailingObjects;
540
541 TemplateName Pattern;
542 llvm::PointerIntPair<Expr *, 1> IndexAndIsFullySubstituted;
543
544 PackIndexingTemplateStorage(TemplateName Pattern, Expr *IndexExpr,
545 bool FullySubstituted,
546 ArrayRef<TemplateName> Expansions);
547
548 // We store the number of expansions in Bits.Data.
549 std::size_t getExpansionCount() const { return Bits.Data; }
550
551public:
552 TemplateName getPattern() const { return Pattern; }
553
554 Expr *getIndexExpr() const { return IndexAndIsFullySubstituted.getPointer(); }
555
556 bool isFullySubstituted() const {
557 return IndexAndIsFullySubstituted.getInt();
558 }
559
561 return getTrailingObjects(getExpansionCount());
562 }
563
564 TemplateTemplateParmDecl *getParameterPack() const;
565
566 UnsignedOrNone getSelectedIndex() const;
567
568 TemplateName getSelectedTemplate() const;
569
570 bool expandsToEmptyPack() const {
571 return isFullySubstituted() && getExpansionCount() == 0;
572 }
573
574 TemplateNameDependence getDependence() const;
575
576 void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const;
577
578 static void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
579 TemplateName Pattern, Expr *IndexExpr,
580 bool FullySubstituted, ArrayRef<TemplateName> Expansions);
581};
582
583inline TemplateName TemplateName::getUnderlying() const {
586 return subst->getReplacement().getUnderlying();
587 return *this;
588}
589
590/// Represents a template name as written in source code.
591///
592/// This kind of template name may refer to a template name that was
593/// preceded by a nested name specifier, e.g., \c std::vector. Here,
594/// the nested name specifier is "std::" and the template name is the
595/// declaration for "vector". It may also have been written with the
596/// 'template' keyword. The QualifiedTemplateName class is only
597/// used to provide "sugar" for template names, so that they can
598/// be differentiated from canonical template names. and has no
599/// semantic meaning. In this manner, it is to TemplateName what
600/// ElaboratedType is to Type, providing extra syntactic sugar
601/// for downstream clients.
602class QualifiedTemplateName : public llvm::FoldingSetNode {
603 friend class ASTContext;
604
605 /// The nested name specifier that qualifies the template name.
606 ///
607 /// The bit is used to indicate whether the "template" keyword was
608 /// present before the template name itself. Note that the
609 /// "template" keyword is always redundant in this case (otherwise,
610 /// the template name would be a dependent name and we would express
611 /// this name with DependentTemplateName).
612 llvm::PointerIntPair<NestedNameSpecifier, 1, bool> Qualifier;
613
614 /// The underlying template name, it is either
615 /// 1) a Template -- a template declaration that this qualified name refers
616 /// to.
617 /// 2) or a UsingTemplate -- a template declaration introduced by a
618 /// using-shadow declaration.
619 TemplateName UnderlyingTemplate;
620
621 QualifiedTemplateName(NestedNameSpecifier NNS, bool TemplateKeyword,
623 : Qualifier(NNS, TemplateKeyword ? 1 : 0), UnderlyingTemplate(Template) {
624 assert(UnderlyingTemplate.getKind() == TemplateName::Template ||
625 UnderlyingTemplate.getKind() == TemplateName::UsingTemplate);
626 }
627
628public:
629 /// Return the nested name specifier that qualifies this name.
630 NestedNameSpecifier getQualifier() const { return Qualifier.getPointer(); }
631
632 /// Whether the template name was prefixed by the "template"
633 /// keyword.
634 bool hasTemplateKeyword() const { return Qualifier.getInt(); }
635
636 /// Return the underlying template name.
637 TemplateName getUnderlyingTemplate() const { return UnderlyingTemplate; }
638
639 void Profile(llvm::FoldingSetNodeID &ID) {
640 Profile(ID, getQualifier(), hasTemplateKeyword(), UnderlyingTemplate);
641 }
642
643 static void Profile(llvm::FoldingSetNodeID &ID, NestedNameSpecifier NNS,
644 bool TemplateKeyword, TemplateName TN) {
645 NNS.Profile(ID);
646 ID.AddBoolean(TemplateKeyword);
647 ID.AddPointer(TN.getAsVoidPointer());
648 }
649};
650
655
656 /// Returns the identifier to which this template name refers.
658 if (getOperator() != OO_None)
659 return nullptr;
660 return reinterpret_cast<const IdentifierInfo *>(PtrOrOp);
661 }
662
663 /// Return the overloaded operator to which this template name refers.
665 uintptr_t OOK = -PtrOrOp;
667 : OO_None;
668 }
669
670 void Profile(llvm::FoldingSetNodeID &ID) const;
671
673 return PtrOrOp == Other.PtrOrOp;
674 };
675
676private:
677 uintptr_t PtrOrOp = 0;
678};
679
680/// Represents a dependent template name that cannot be
681/// resolved prior to template instantiation.
682///
683/// This kind of template name refers to a dependent template name,
684/// including its nested name specifier (if any). For example,
685/// DependentTemplateName can refer to "MetaFun::template apply",
686/// where "MetaFun::" is the nested name specifier and "apply" is the
687/// template name referenced. The "template" keyword is implied.
689 /// The nested name specifier that qualifies the template
690 /// name.
691 ///
692 /// The bit stored in this qualifier describes whether the \c Name field
693 /// was preceeded by a template keyword.
694 llvm::PointerIntPair<NestedNameSpecifier, 1, bool> Qualifier;
695
696 /// The dependent template name.
698
699public:
702 bool HasTemplateKeyword);
703
704 /// Return the nested name specifier that qualifies this name.
705 NestedNameSpecifier getQualifier() const { return Qualifier.getPointer(); }
706
708
709 /// Was this template name was preceeded by the template keyword?
710 bool hasTemplateKeyword() const { return Qualifier.getInt(); }
711
712 TemplateNameDependence getDependence() const;
713
714 void Profile(llvm::FoldingSetNodeID &ID) const {
716 }
717
718 static void Profile(llvm::FoldingSetNodeID &ID, NestedNameSpecifier NNS,
720 bool HasTemplateKeyword) {
721 NNS.Profile(ID);
722 ID.AddBoolean(HasTemplateKeyword);
723 Name.Profile(ID);
724 }
725
726 void print(raw_ostream &OS, const PrintingPolicy &Policy) const;
727};
728
729class DependentTemplateName : public DependentTemplateStorage,
730 public llvm::FoldingSetNode {
731 friend class ASTContext;
733 DependentTemplateName(const DependentTemplateStorage &S)
734 : DependentTemplateStorage(S) {}
735};
736
737} // namespace clang.
738
739namespace llvm {
740
741/// The clang::TemplateName class is effectively a pointer.
742template<>
743struct PointerLikeTypeTraits<clang::TemplateName> {
744 static inline void *getAsVoidPointer(clang::TemplateName TN) {
745 return TN.getAsVoidPointer();
746 }
747
748 static inline clang::TemplateName getFromVoidPointer(void *Ptr) {
750 }
751
752 // No bits are available!
753 static constexpr int NumLowBitsAvailable = 0;
754};
755
756} // namespace llvm.
757
758#endif // LLVM_CLANG_AST_TEMPLATENAME_H
static llvm::GlobalValue::DLLStorageClassTypes getStorage(CodeGenModule &CGM, StringRef Name)
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
static Decl::Kind getKind(const Decl *D)
static void print(llvm::raw_ostream &OS, const T &V, const Context &Ctx, QualType Ty)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines an enumeration for C++ overloaded operators.
Defines clang::OptionalUnsigned.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:223
A structure for storing the information associated with a name that has been assumed to be a template...
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
TemplateName getUnderlying() const
DefaultArguments getDefaultArguments() const
void Profile(llvm::FoldingSetNodeID &ID) const
IdentifierOrOverloadedOperator getName() const
NestedNameSpecifier getQualifier() const
Return the nested name specifier that qualifies this name.
DependentTemplateStorage(NestedNameSpecifier Qualifier, IdentifierOrOverloadedOperator Name, bool HasTemplateKeyword)
static void Profile(llvm::FoldingSetNodeID &ID, NestedNameSpecifier NNS, IdentifierOrOverloadedOperator Name, bool HasTemplateKeyword)
bool hasTemplateKeyword() const
Was this template name was preceeded by the template keyword?
This represents one expression.
Definition Expr.h:113
One of these records is kept for each identifier that is lexed.
This represents a decl that may have a name.
Definition Decl.h:275
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void Profile(llvm::FoldingSetNodeID &ID) const
A structure for storing the information associated with an overloaded template name.
llvm::ArrayRef< NamedDecl * > decls() const
A structure for storing a pack-index-template-name ([temp.names]).
ArrayRef< TemplateName > getExpansions() const
Represents a template name as written in source code.
NestedNameSpecifier getQualifier() const
Return the nested name specifier that qualifies this name.
static void Profile(llvm::FoldingSetNodeID &ID, NestedNameSpecifier NNS, bool TemplateKeyword, TemplateName TN)
void Profile(llvm::FoldingSetNodeID &ID)
TemplateName getUnderlyingTemplate() const
Return the underlying template name.
bool hasTemplateKeyword() const
Whether the template name was prefixed by the "template" keyword.
A structure for storing an already-substituted template template parameter pack.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
SubstTemplateTemplateParmPackStorage(ArrayRef< TemplateArgument > ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final)
A structure for storing the information associated with a substituted template template parameter.
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
Represents a template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
bool isNull() const
Determine whether this template name is NULL.
TemplateName()=default
bool operator==(TemplateName Other) const
Structural equality.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
NestedNameSpecifier getQualifier() const
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to,...
AssumedTemplateStorage * getAsAssumedTemplateName() const
Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...
std::pair< TemplateName, DefaultArguments > getTemplateDeclAndDefaultArgs() const
Retrieves the underlying template name that this template name refers to, along with the deduced defa...
static TemplateName getFromVoidPointer(void *Ptr)
Build a template name from a void pointer.
bool operator!=(TemplateName Other) const
void * getAsVoidPointer() const
Retrieve the template name as a void pointer.
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ OverloadedTemplate
A set of overloaded template declarations.
@ PackIndexingTemplate
A pack-index-template-name.
@ Template
A single template declaration.
@ DependentTemplate
A dependent template name that has not been resolved to a template (or set of templates).
@ SubstTemplateTemplateParm
A template template parameter that has been substituted for some other template name.
@ SubstTemplateTemplateParmPack
A template template parameter pack that has been substituted for a template template argument pack,...
@ DeducedTemplate
A template name that refers to another TemplateName with deduced default arguments.
@ QualifiedTemplate
A qualified template name, where the qualification is kept to describe the source code as written.
@ AssumedTemplate
An unqualified-id that has been assumed to name a function template that will be found by ADL.
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
void Profile(llvm::FoldingSetNodeID &ID)
TemplateTemplateParmDecl * getAsTemplateTemplateParmDecl() const
Retrieve the template template parameter that this template name refers to, if any.
TemplateName getUnderlying() const
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
std::tuple< NestedNameSpecifier, bool > getQualifierAndTemplateKeyword() const
void dump(raw_ostream &OS, const ASTContext &Context) const
Debugging aid that dumps the template name.
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Implementation class used to describe either a set of overloaded template names or an already-substit...
PackIndexingTemplateStorage * getAsPackIndexingTemplate()
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack()
UncommonTemplateNameStorage(Kind Kind, unsigned Index, unsigned Data)
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm()
AssumedTemplateStorage * getAsAssumedTemplateName()
DeducedTemplateStorage * getAsDeducedTemplateName()
OverloadedTemplateStorage * getAsOverloadedStorage()
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3428
Top level wrappers for InstallAPI frontend operations.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
Definition Parser.h:61
OptionalUnsigned< unsigned > UnsignedOrNone
@ Template
We are parsing a template declaration.
Definition Parser.h:81
@ Deduced
The normal deduced case.
Definition TypeBase.h:1818
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
@ PackIndex
Index of a pack indexing expression or specifier.
Definition Sema.h:845
@ Other
Other implicit parameter.
Definition Decl.h:1775
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
ArrayRef< TemplateArgument > Args
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
bool operator==(const IdentifierOrOverloadedOperator &Other) const
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
static constexpr OptionalUnsigned fromInternalRepresentation(underlying_type Rep)
Describes how types, statements, expressions, and declarations should be printed.
unsigned Data
The pack index, or the number of stored templates or template arguments, depending on which subclass ...
static void * getAsVoidPointer(clang::Expr *P)
static clang::Expr * getFromVoidPointer(void *P)
static void * getAsVoidPointer(clang::TemplateName TN)
static clang::TemplateName getFromVoidPointer(void *Ptr)