24 #include "llvm/ADT/FoldingSet.h"
25 #include "llvm/ADT/SmallString.h"
26 #include "llvm/Support/raw_ostream.h"
29 using namespace clang;
49 if (llvm::APSInt::isSameValue(ECD->getInitVal(), Val)) {
50 ECD->printQualifiedName(Out, Policy);
57 Out << (Val.getBoolValue() ?
"true" :
"false");
58 }
else if (T->isCharType()) {
59 const char Ch = Val.getZExtValue();
60 Out << ((Ch ==
'\'') ?
"'\\" :
"'");
61 Out.write_escaped(StringRef(&Ch, 1),
true);
76 Integer.BitWidth = Value.getBitWidth();
77 Integer.IsUnsigned = Value.isUnsigned();
79 unsigned NumWords = Value.getNumWords();
81 void *Mem = Ctx.
Allocate(NumWords *
sizeof(uint64_t));
82 std::memcpy(Mem, Value.getRawData(), NumWords *
sizeof(uint64_t));
83 Integer.pVal =
static_cast<uint64_t *
>(Mem);
85 Integer.VAL = Value.getZExtValue();
103 llvm_unreachable(
"Should not have a NULL template argument");
117 return DC->isDependentContext();
138 llvm_unreachable(
"Invalid TemplateArgument Kind!");
144 llvm_unreachable(
"Should not have a NULL template argument");
157 return DC->isDependentContext();
172 if (
P.isInstantiationDependent())
177 llvm_unreachable(
"Invalid TemplateArgument Kind!");
194 return isa<PackExpansionType>(
getAsType());
197 return isa<PackExpansionExpr>(
getAsExpr());
200 llvm_unreachable(
"Invalid TemplateArgument Kind!");
229 if (
P.containsUnexpandedParameterPack())
268 llvm_unreachable(
"Invalid TemplateArgument Kind!");
294 = dyn_cast_or_null<TemplateTemplateParmDecl>(
297 ID.AddInteger(TTP->getDepth());
298 ID.AddInteger(TTP->getPosition());
299 ID.AddBoolean(TTP->isParameterPack());
301 ID.AddBoolean(
false);
318 ID.AddInteger(
Args.NumArgs);
319 for (
unsigned I = 0;
I !=
Args.NumArgs; ++
I)
320 Args.Args[
I].Profile(ID, Context);
344 if (
Args.NumArgs != Other.
Args.NumArgs)
return false;
345 for (
unsigned I = 0,
E =
Args.NumArgs;
I !=
E; ++
I)
346 if (!
Args.Args[
I].structurallyEquals(Other.
Args.Args[
I]))
351 llvm_unreachable(
"Invalid TemplateArgument Kind!");
362 return cast<PackExpansionExpr>(
getAsExpr())->getPattern();
376 llvm_unreachable(
"Invalid TemplateArgument Kind!");
380 raw_ostream &Out)
const {
400 Out <<
"(anonymous)";
436 P.print(Policy, Out);
469 return TSI->getTypeLoc().getSourceRange();
493 llvm_unreachable(
"Invalid TemplateArgument Kind!");
502 return DB <<
"(null template argument)";
511 return DB <<
"nullptr";
527 llvm::raw_svector_ostream OS(Str);
529 LangOpts.CPlusPlus =
true;
532 return DB << OS.str();
538 llvm::raw_svector_ostream OS(Str);
540 LangOpts.CPlusPlus =
true;
542 Arg.
print(Policy, OS);
543 return DB << OS.str();
547 llvm_unreachable(
"Invalid TemplateArgument Kind!");
558 ASTTemplateArgumentListInfo::ASTTemplateArgumentListInfo(
582 assert(TemplateKWLoc.
isValid());
592 bool &InstantiationDependent,
bool &ContainsUnexpandedParameterPack) {
599 Dependent = Dependent || Info[i].getArgument().isDependent();
600 InstantiationDependent = InstantiationDependent ||
601 Info[i].getArgument().isInstantiationDependent();
602 ContainsUnexpandedParameterPack =
603 ContainsUnexpandedParameterPack ||
604 Info[i].getArgument().containsUnexpandedParameterPack();
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0) const
Defines the clang::ASTContext interface.
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool SuppressNNS=false) const
Print the template name.
static const Decl * getCanonicalDecl(const Decl *D)
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
Expr * getSourceExpression() const
A (possibly-)qualified type.
static void printIntegral(const TemplateArgument &TemplArg, raw_ostream &Out, const PrintingPolicy &Policy)
Print a template integral argument value.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
SourceLocation TemplateKWLoc
The source location of the template keyword; this is used as part of the representation of qualified ...
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
C Language Family Type Representation.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Defines the C++ template declaration subclasses.
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
The base class of the type hierarchy.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
A container of type source information.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
void * getAsOpaquePtr() const
void setRAngleLoc(SourceLocation Loc)
Represents an empty template argument, e.g., one that has not been deduced.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Describes how types, statements, expressions, and declarations should be printed. ...
Defines the clang::Expr interface and subclasses for C++ expressions.
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
static TemplateArgument getEmptyPack()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
TypeSourceInfo * getTypeSourceInfo() const
SourceRange getSourceRange() const LLVM_READONLY
Fetches the full source range of the argument.
SourceLocation getTemplateEllipsisLoc() const
unsigned SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
bool containsUnexpandedParameterPack() const
Whether this template argument contains an unexpanded parameter pack.
A convenient class for passing around template argument information.
NestedNameSpecifierLoc getTemplateQualifierLoc() const
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
Defines the Diagnostic-related interfaces.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
SourceLocation getRAngleLoc() const
SourceLocation getTemplateNameLoc() const
detail::InMemoryDirectory::const_iterator I
void dump() const
Debugging aid that dumps the template argument to standard error.
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
Optional< unsigned > getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce...
A little helper class used to produce diagnostics.
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
constexpr TemplateArgument()
Construct an empty, invalid template argument.
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
bool isInstantiationDependent() const
Determines whether this is a template name that somehow depends on a template parameter.
ArgKind getKind() const
Return the kind of stored template argument.
DeclContext * getDeclContext()
Represents a C++ template name within the type system.
Expr * getSourceNullPtrExpression() const
Defines the clang::TypeLoc interface and its subclasses.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Expr * getSourceIntegralExpression() const
void copyInto(const TemplateArgumentLoc *ArgArray, TemplateArgumentListInfo &List) const
Encodes a location in the source.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
bool isValid() const
Return true if this is a valid SourceLocation object.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
void print(const PrintingPolicy &Policy, raw_ostream &Out) const
Print this template argument to the given output stream.
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const
Used to insert TemplateArguments into FoldingSets.
SourceLocation getLAngleLoc() const
void setLAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
void printQualifiedName(raw_ostream &OS) const
printQualifiedName - Returns human-readable qualified name for declaration, like A::B::i, for i being member of namespace A::B.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
Represents a pack expansion of types.
Represents a template argument.
QualType getAsType() const
Retrieve the type for a type template argument.
void * getAsVoidPointer() const
Retrieve the template name as a void pointer.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool isDependent() const
Determines whether this is a dependent template name.
The template argument is a pack expansion of a template name that was provided for a template templat...
TemplateName getCanonicalTemplateName(TemplateName Name) const
Retrieves the "canonical" template name that refers to a given template.
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
detail::InMemoryDirectory::const_iterator E
Location wrapper for a TemplateArgument.
const T * getAs() const
Member-template getAs<specific type>'.
QualType getIntegralType() const
Retrieve the type of the integral value.
bool structurallyEquals(const TemplateArgument &Other) const
Determines whether two template arguments are superficially the same.
The template argument is a type.
The template argument is actually a parameter pack.
Expr * getSourceDeclExpression() const
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
static const ASTTemplateArgumentListInfo * Create(ASTContext &C, const TemplateArgumentListInfo &List)
The template argument is a template name that was provided for a template template parameter...
void * Allocate(size_t Size, unsigned Align=8) const
void initializeFrom(SourceLocation TemplateKWLoc, const TemplateArgumentListInfo &List, TemplateArgumentLoc *OutArgArray)
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
QualType getParamTypeForDecl() const
void Profile(llvm::FoldingSetNodeID &ID) const
bool MSVCFormatting
Use whitespace and punctuation like MSVC does.
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').