23 using namespace clang;
26 assert(S &&
"Expecting non-null pointer.");
31 assert(II &&
"Expecting non-null pointer.");
54 for (
unsigned i = 0; i < NumArgs; ++i) {
85 assert(NNS &&
"Expecting non-null pointer.");
137 llvm_unreachable(
"Expected valid TemplateArgument");
175 const unsigned size = Bools.size();
176 const unsigned remainder = size % unsigned_bits;
177 const unsigned loops = size / unsigned_bits;
178 auto I = Bools.rbegin();
180 for (
unsigned i = 0; i <
remainder; ++i) {
185 ID.AddInteger(value);
187 for (
unsigned i = 0; i < loops; ++i) {
189 for (
unsigned j = 0; j < unsigned_bits; ++j) {
194 ID.AddInteger(value);
197 assert(
I == Bools.rend());
199 return ID.ComputeHash();
206 llvm::FoldingSetNodeID &
ID;
211 : ID(ID), Hash(Hash) {}
223 Hash.AddIdentifierInfo(II);
245 Inherited::VisitNamedDecl(D);
249 if (!isa<FunctionDecl>(D)) {
252 Inherited::VisitValueDecl(D);
258 const bool HasInit = D->
hasInit();
259 Hash.AddBoolean(HasInit);
263 Inherited::VisitVarDecl(D);
268 Inherited::VisitParmVarDecl(D);
273 Inherited::VisitAccessSpecDecl(D);
280 Inherited::VisitStaticAssertDecl(D);
285 Hash.AddBoolean(IsBitfield);
294 Inherited::VisitFieldDecl(D);
301 Hash.AddBoolean(D->
isPure());
307 Hash.AddSubDecl(Param);
312 Inherited::VisitFunctionDecl(D);
319 Inherited::VisitCXXMethodDecl(D);
325 Inherited::VisitTypedefNameDecl(D);
329 Inherited::VisitTypedefDecl(D);
333 Inherited::VisitTypeAliasDecl(D);
338 Hash.AddBoolean(TSI);
356 case Decl::AccessSpec:
357 case Decl::CXXConstructor:
358 case Decl::CXXDestructor:
359 case Decl::CXXMethod:
362 case Decl::StaticAssert:
363 case Decl::TypeAlias:
371 assert(D &&
"Expecting non-null pointer.");
379 "Expected non-null record to be a definition.");
383 if (isa<ClassTemplateSpecializationDecl>(DC)) {
394 for (
const Decl *SubDecl : Record->
decls()) {
396 Decls.push_back(SubDecl);
400 ID.AddInteger(Decls.size());
401 for (
auto SubDecl : Decls) {
407 assert(D &&
"Expecting non-null pointer.");
408 auto Result = DeclMap.insert(std::make_pair(D, DeclMap.size()));
409 ID.AddInteger(
Result.first->second);
418 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
427 llvm::FoldingSetNodeID &
ID;
432 : ID(ID), Hash(Hash) {}
460 Hash.AddBoolean(NNS);
462 Hash.AddNestedNameSpecifier(NNS);
469 Hash.AddIdentifierInfo(II);
493 VisitAdjustedType(T);
536 VisitFunctionType(T);
542 AddQualType(ParamType);
544 VisitFunctionType(T);
550 VisitQualifiers(UnderlyingType.getQualifiers());
552 dyn_cast<TypedefType>(UnderlyingType.getTypePtr())) {
553 UnderlyingType = Underlying->getDecl()->getUnderlyingType();
555 AddType(UnderlyingType.getTypePtr());
575 VisitTypeWithKeyword(T);
584 Hash.AddTemplateArgument(TA);
586 VisitTypeWithKeyword(T);
592 VisitTypeWithKeyword(T);
598 Hash.AddTemplateArgument(TA);
613 assert(T &&
"Expecting non-null pointer.");
614 auto Result = TypeMap.insert(std::make_pair(T, TypeMap.size()));
615 ID.AddInteger(
Result.first->second);
635 Bools.push_back(Value);
void VisitTypeAliasDecl(const TypeAliasDecl *D)
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
void VisitFunctionNoProtoType(const FunctionNoProtoType *T)
const Type * Ty
The locally-unqualified type.
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
unsigned getDepth() const
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
void AddBoolean(bool value)
bool isBitField() const
Determines whether this field is a bitfield.
This file contains the declaration of the ODRHash class, which calculates a hash based on AST nodes...
Stmt - This represents one statement.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
void AddQualType(QualType T)
FunctionType - C99 6.7.5.3 - Function Declarators.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
unsigned getNumArgs() const
Retrieve the number of template arguments.
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
TypedefDecl - Represents the declaration of a typedef-name via the 'typedef' type specifier...
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
Represents a qualified type name for which the type name is dependent.
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.
QualType getUnderlyingType() const
Decl - This represents one declaration (or definition), e.g.
void VisitCXXMethodDecl(const CXXMethodDecl *D)
void Profile(llvm::FoldingSetNodeID &ID) const
void VisitDependentNameType(const DependentNameType *T)
bool hasDefinition() const
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
const Expr * getInit() const
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
A container of type source information.
unsigned getIndex() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
A template template parameter that has been substituted for some other template name.
Expr * getInClassInitializer() const
getInClassInitializer - Get the C++11 in-class initializer for this member, or null if one has not be...
const llvm::APInt & getSize() const
An identifier, stored as an IdentifierInfo*.
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
void VisitFriendDecl(const FriendDecl *D)
Represents an empty template argument, e.g., one that has not been deduced.
AccessSpecifier getAccess() const
TemplateTypeParmDecl * getDecl() const
A namespace, stored as a NamespaceDecl*.
QualType getOriginalType() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
Qualifiers getIndexTypeQualifiers() const
void AddTemplateArgument(TemplateArgument TA)
ParmVarDecl - Represents a parameter to a function.
unsigned getNumArgs() const
Retrieve the number of template arguments.
void AddIdentifierInfo(const IdentifierInfo *II)
The collection of all-type qualifiers we support.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
void VisitDecayedType(const DecayedType *T)
QualType getPointeeType() const
unsigned getNumParams() const
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
static bool isWhitelistedDecl(const Decl *D, const CXXRecordDecl *Record)
One of these records is kept for each identifier that is lexed.
void VisitVariableArrayType(const VariableArrayType *T)
StringLiteral * getMessage()
void VisitNamedDecl(const NamedDecl *D)
Expr * getSizeExpr() const
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
ArrayRef< QualType > getParamTypes() const
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
QualType getReturnType() const
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
bool isKeywordSelector() const
bool isPure() const
Whether this virtual function is pure, i.e.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
void AddTemplateParameterList(const TemplateParameterList *TPL)
void VisitRecordType(const RecordType *T)
unsigned getAsOpaqueValue() const
Represents an access specifier followed by colon ':'.
void VisitIncompleteArrayType(const IncompleteArrayType *T)
bool isNull() const
Determine whether this is the empty selector.
void Visit(const Decl *D)
A qualified template name, where the qualification is kept to describe the source code as written...
void AddDecl(const Decl *D)
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
QualType getReturnType() const
void VisitDependentSizedArrayType(const DependentSizedArrayType *T)
void VisitTagType(const TagType *T)
#define remainder(__x, __y)
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
TypeClass getTypeClass() const
bool isStaticLocal() const
isStaticLocal - Returns true if a variable with function scope is a static local variable.
void VisitTypedefDecl(const TypedefDecl *D)
detail::InMemoryDirectory::const_iterator I
void VisitFunctionDecl(const FunctionDecl *D)
void AddTemplateName(TemplateName Name)
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
void VisitEnumType(const EnumType *T)
ExtInfo getExtInfo() const
ODRDeclVisitor(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
Represents a prototype with parameter type info, e.g.
ODRTypeVisitor(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
void VisitFunctionType(const FunctionType *T)
void VisitFunctionProtoType(const FunctionProtoType *T)
A dependent template name that has not been resolved to a template (or set of templates).
void Visit(const Type *T)
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isUnarySelector() const
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
Represents an array type in C++ whose size is a value-dependent expression.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
void VisitDependentTemplateSpecializationType(const DependentTemplateSpecializationType *T)
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
StringRef getName() const
Return the actual identifier string.
unsigned getNumArgs() const
bool isDeletedAsWritten() const
bool isEmpty() const
Evaluates true when this declaration name is empty.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Expr * getBitWidth() const
void AddStmt(const Stmt *S)
void AddDeclarationName(DeclarationName Name)
QualType getNamedType() const
Retrieve the type named by the qualified-id.
ArgKind getKind() const
Return the kind of stored template argument.
DeclContext * getDeclContext()
Represents a C++ template name within the type system.
A namespace alias, stored as a NamespaceAliasDecl*.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Qualifiers Quals
The local qualifiers.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
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.
A helper class for Type nodes having an ElaboratedTypeKeyword.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
The result type of a method or function.
A type, stored as a Type*.
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
const IdentifierInfo * getIdentifier() const
A template template parameter pack that has been substituted for a template template argument pack...
void AddDecl(const Decl *D)
void AddType(const Type *T)
void AddNestedNameSpecifier(const NestedNameSpecifier *NNS)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
void VisitArrayType(const ArrayType *T)
void AddType(const Type *T)
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
void AddIdentifierInfo(const IdentifierInfo *II)
Represents a static or instance method of a struct/union/class.
void VisitTypedefNameDecl(const TypedefNameDecl *D)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
ArrayRef< ParmVarDecl * > parameters() const
void VisitStaticAssertDecl(const StaticAssertDecl *D)
void VisitTypedefType(const TypedefType *T)
TypedefNameDecl * getDecl() const
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
void VisitElaboratedType(const ElaboratedType *T)
void AddNestedNameSpecifier(const NestedNameSpecifier *NNS)
Represents a C++11 static_assert declaration.
ArrayRef< TemplateArgument > template_arguments() const
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
QualType getType() const
Return the type wrapped by this type source info.
void AddSubDecl(const Decl *D)
Represents a pointer type decayed from an array or function type.
Expr * getSizeExpr() const
Base class for declarations which introduce a typedef-name.
Represents a template argument.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
QualType getAsType() const
Retrieve the type for a type template argument.
void AddIdentifierInfo(const IdentifierInfo *II)
Selector getObjCSelector() const
getObjCSelector - Get the Objective-C selector stored in this declaration name.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
The template argument is a pack expansion of a template name that was provided for a template templat...
void VisitQualifiers(Qualifiers Quals)
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
bool isParameterPack() const
void AddCXXRecordDecl(const CXXRecordDecl *Record)
void VisitAdjustedType(const AdjustedType *T)
DeclarationName - The name of a declaration.
void VisitValueDecl(const ValueDecl *D)
size_t param_size() const
void VisitVarDecl(const VarDecl *D)
A type that was preceded by the 'template' keyword, stored as a Type*.
void VisitConstantArrayType(const ConstantArrayType *T)
void VisitFieldDecl(const FieldDecl *D)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
void VisitTemplateTypeParmType(const TemplateTypeParmType *T)
void AddQualType(QualType T)
ArrayRef< TemplateArgument > template_arguments() const
The template argument is a type.
NestedNameSpecifier * getQualifier() const
The template argument is actually a parameter pack.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
Represents a C++ struct/union/class.
Represents a template specialization type whose template cannot be resolved, e.g. ...
The template argument is a template name that was provided for a template template parameter...
Represents a C array with an unspecified size.
ArraySizeModifier getSizeModifier() const
ElaboratedTypeKeyword getKeyword() const
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
This class is used for builtin types like 'int'.
QualType getAdjustedType() const
QualType getDecayedType() const
TagDecl * getDecl() const
void AddStmt(const Stmt *S)
void VisitType(const Type *T)
Represents a type template specialization; the template must be a class template, a type alias templa...
void VisitBuiltinType(const BuiltinType *T)
QualType getElementType() const
void VisitTemplateSpecializationType(const TemplateSpecializationType *T)
A set of overloaded template declarations.
void AddQualType(QualType T)
NamedDecl - This represents a decl with a name.
Represents a C array with a specified size that is not an integer-constant-expression.
void VisitTypeWithKeyword(const TypeWithKeyword *T)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A simple visitor class that helps create declaration visitors.
The global specifier '::'. There is no stored value.
Represents the canonical version of C arrays with a specified constant size.
void VisitParmVarDecl(const ParmVarDecl *D)
A single template declaration.
void VisitAccessSpecDecl(const AccessSpecDecl *D)
void ProcessODRHash(llvm::FoldingSetNodeID &ID, ODRHash &Hash) const
Calculate a unique representation for a statement that is stable across compiler invocations.
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).