13 #ifndef LLVM_CLANG_AST_DECLARATIONNAME_H 14 #define LLVM_CLANG_AST_DECLARATIONNAME_H 22 #include "llvm/ADT/DenseMapInfo.h" 23 #include "llvm/ADT/FoldingSet.h" 24 #include "llvm/Support/Compiler.h" 25 #include "llvm/Support/type_traits.h" 34 template <
typename>
class CanQual;
35 class DeclarationName;
36 class DeclarationNameTable;
37 class MultiKeywordSelector;
38 struct PrintingPolicy;
41 class UsingDirectiveDecl;
54 :
public llvm::FoldingSetNode {
77 public llvm::FoldingSetNode {
91 FETokenInfo(nullptr) {}
94 void Profile(llvm::FoldingSetNodeID &
ID) { ID.AddPointer(Template); }
111 void *FETokenInfo =
nullptr;
118 public llvm::FoldingSetNode {
131 FETokenInfo(nullptr) {}
134 void Profile(llvm::FoldingSetNodeID &FSID) { FSID.AddPointer(ID); }
175 enum StoredNameKind {
176 StoredIdentifier = 0,
177 StoredObjCZeroArgSelector = Selector::ZeroArg,
178 StoredObjCOneArgSelector = Selector::OneArg,
179 StoredCXXConstructorName = 3,
180 StoredCXXDestructorName = 4,
181 StoredCXXConversionFunctionName = 5,
182 StoredCXXOperatorName = 6,
183 StoredDeclarationNameExtra = Selector::MultiArg,
185 UncommonNameKindOffset = 8
194 "The various classes that DeclarationName::Ptr can point to" 195 " must be at least aligned to 8 bytes!");
204 ObjCZeroArgSelector = StoredObjCZeroArgSelector,
205 ObjCOneArgSelector = StoredObjCOneArgSelector,
206 CXXConstructorName = StoredCXXConstructorName,
207 CXXDestructorName = StoredCXXDestructorName,
208 CXXConversionFunctionName = StoredCXXConversionFunctionName,
209 CXXOperatorName = StoredCXXOperatorName,
210 CXXDeductionGuideName = UncommonNameKindOffset +
212 CXXLiteralOperatorName =
213 UncommonNameKindOffset +
215 CXXUsingDirective = UncommonNameKindOffset +
217 ObjCMultiArgSelector = UncommonNameKindOffset +
256 StoredNameKind getStoredNameKind()
const {
257 return static_cast<StoredNameKind
>(Ptr & PtrMask);
260 void *getPtr()
const {
return reinterpret_cast<void *
>(Ptr & ~PtrMask); }
262 void setPtrAndKind(
const void *
P, StoredNameKind
Kind) {
264 assert((Kind & ~PtrMask) == 0 &&
265 "Invalid StoredNameKind in setPtrAndKind!");
266 assert((PAsInteger & PtrMask) == 0 &&
267 "Improperly aligned pointer in setPtrAndKind!");
268 Ptr = PAsInteger |
Kind;
273 setPtrAndKind(Name, StoredDeclarationNameExtra);
278 StoredNameKind StoredKind) {
279 assert((StoredKind == StoredCXXConstructorName ||
280 StoredKind == StoredCXXDestructorName ||
281 StoredKind == StoredCXXConversionFunctionName) &&
282 "Invalid StoredNameKind when constructing a DeclarationName" 283 " from a CXXSpecialNameExtra!");
284 setPtrAndKind(Name, StoredKind);
289 setPtrAndKind(Name, StoredCXXOperatorName);
294 assert((getStoredNameKind() == StoredIdentifier) &&
295 "DeclarationName does not store an IdentifierInfo!");
302 assert((getStoredNameKind() == StoredDeclarationNameExtra) &&
303 "DeclarationName does not store an Extra structure!");
310 assert((getStoredNameKind() == StoredCXXConstructorName ||
311 getStoredNameKind() == StoredCXXDestructorName ||
312 getStoredNameKind() == StoredCXXConversionFunctionName) &&
313 "DeclarationName does not store a CXXSpecialNameExtra!");
320 assert((getStoredNameKind() == StoredCXXOperatorName) &&
321 "DeclarationName does not store a CXXOperatorIdName!");
328 assert(getNameKind() == CXXDeductionGuideName &&
329 "DeclarationName does not store a CXXDeductionGuideNameExtra!");
336 assert(getNameKind() == CXXLiteralOperatorName &&
337 "DeclarationName does not store a CXXLiteralOperatorIdName!");
343 void *getFETokenInfoSlow()
const;
344 void setFETokenInfoSlow(
void *T);
352 setPtrAndKind(II, StoredIdentifier);
367 explicit operator bool()
const {
368 return getPtr() || (getStoredNameKind() != StoredIdentifier);
375 bool isIdentifier()
const {
return getStoredNameKind() == StoredIdentifier; }
377 return getStoredNameKind() == StoredObjCZeroArgSelector;
380 return getStoredNameKind() == StoredObjCOneArgSelector;
387 StoredNameKind StoredKind = getStoredNameKind();
388 if (StoredKind != StoredDeclarationNameExtra)
389 return static_cast<NameKind>(StoredKind);
393 unsigned ExtraKind = castAsExtra()->getKind();
394 return static_cast<NameKind>(UncommonNameKindOffset + ExtraKind);
403 bool isDependentName()
const;
412 return castAsIdentifierInfo();
440 if (getStoredNameKind() == StoredCXXConstructorName ||
441 getStoredNameKind() == StoredCXXDestructorName ||
442 getStoredNameKind() == StoredCXXConversionFunctionName) {
443 assert(getPtr() &&
"getCXXNameType on a null DeclarationName!");
444 return castAsCXXSpecialNameExtra()->Type;
452 if (getNameKind() == CXXDeductionGuideName) {
454 "getCXXDeductionGuideTemplate on a null DeclarationName!");
455 return castAsCXXDeductionGuideNameExtra()->Template;
463 if (getStoredNameKind() == StoredCXXOperatorName) {
464 assert(getPtr() &&
"getCXXOverloadedOperator on a null DeclarationName!");
465 return castAsCXXOperatorIdName()->Kind;
473 if (getNameKind() == CXXLiteralOperatorName) {
474 assert(getPtr() &&
"getCXXLiteralIdentifier on a null DeclarationName!");
475 return castAsCXXLiteralOperatorIdName()->ID;
482 assert((getNameKind() == ObjCZeroArgSelector ||
483 getNameKind() == ObjCOneArgSelector ||
484 getNameKind() == ObjCMultiArgSelector || !getPtr()) &&
493 assert(getPtr() &&
"getFETokenInfo on an empty DeclarationName!");
494 if (getStoredNameKind() == StoredIdentifier)
495 return castAsIdentifierInfo()->getFETokenInfo();
496 return getFETokenInfoSlow();
500 assert(getPtr() &&
"setFETokenInfo on an empty DeclarationName!");
501 if (getStoredNameKind() == StoredIdentifier)
502 castAsIdentifierInfo()->setFETokenInfo(T);
504 setFETokenInfoSlow(T);
509 return LHS.Ptr == RHS.Ptr;
514 return LHS.Ptr != RHS.Ptr;
574 llvm::FoldingSet<detail::CXXSpecialNameExtra> CXXConstructorNames;
579 llvm::FoldingSet<detail::CXXSpecialNameExtra> CXXDestructorNames;
585 llvm::FoldingSet<detail::CXXSpecialNameExtra> CXXConversionFunctionNames;
596 llvm::FoldingSet<detail::CXXLiteralOperatorIdName> CXXLiteralOperatorNames;
602 llvm::FoldingSet<detail::CXXDeductionGuideNameExtra> CXXDeductionGuideNames;
706 : Name(Name), NameLoc(NameLoc), LocInfo(Name) {}
710 : Name(Name), NameLoc(NameLoc), LocInfo(LocInfo) {}
785 bool isInstantiationDependent()
const;
789 bool containsUnexpandedParameterPack()
const;
807 return EndLoc.
isValid() ? EndLoc : getBeginLoc();
882 #endif // LLVM_CLANG_AST_DECLARATIONNAME_H SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
void setInfo(const DeclarationNameLoc &Info)
Smart pointer class that efficiently represents Objective-C method names.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
A (possibly-)qualified type.
static bool isEqual(clang::DeclarationName LHS, clang::DeclarationName RHS)
NameKind
The kind of the name stored in this DeclarationName.
SourceRange getCXXOperatorNameRange() const
getCXXOperatorNameRange - Gets the range of the operator name (without the operator keyword)...
const DeclarationNameLoc & getInfo() const
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
C Language Family Type Representation.
void AddTaggedVal(intptr_t V, DiagnosticsEngine::ArgumentKind Kind) const
Selector getObjCSelector() const
Get the Objective-C selector stored in this declaration name.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
The base class of the type hierarchy.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
DeclarationName getDeclName() const
Get the name of the template.
SourceLocation getEndLoc() const LLVM_READONLY
A container of type source information.
bool isEmpty() const
Evaluates true when this declaration name is empty.
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
void * getAsOpaquePtr() const
Get the representation of this declaration name as an opaque pointer.
Describes how types, statements, expressions, and declarations should be printed. ...
void print(llvm::raw_ostream &OS, const Pointer &P, ASTContext &Ctx, QualType Ty)
bool operator<=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
void AddTaggedVal(intptr_t V, DiagnosticsEngine::ArgumentKind Kind) const
One of these records is kept for each identifier that is lexed.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
NameKind getNameKind() const
Determine what kind of name this is.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
friend bool operator==(DeclarationName LHS, DeclarationName RHS)
Determine whether the specified names are identical.
static DeclarationName getFromOpaquePtr(void *P)
Get a declaration name from an opaque pointer returned by getAsOpaquePtr.
bool operator>(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
void setCXXOperatorNameRange(SourceRange R)
setCXXOperatorNameRange - Sets the range of the operator name (without the operator keyword)...
uintptr_t getAsOpaqueInteger() const
Get the representation of this declaration name as an opaque integer.
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
DeclarationName(const IdentifierInfo *II)
Construct a declaration name from an IdentifierInfo *.
Defines the Diagnostic-related interfaces.
static clang::DeclarationName getTombstoneKey()
__DEVICE__ void * memset(void *__a, int __b, size_t __c)
static unsigned getHashValue(clang::DeclarationName Name)
void * getAsOpaquePtr() const
A little helper class used to produce diagnostics.
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function)...
llvm::StringRef getAsString(SyncScope S)
static bool compare(const PathDiagnostic &X, const PathDiagnostic &Y)
friend bool operator!=(DeclarationName LHS, DeclarationName RHS)
Determine whether the specified names are different.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Defines an enumeration for C++ overloaded operators.
DeclarationName(Selector Sel)
Construct a declaration name from an Objective-C selector.
static clang::DeclarationName getEmptyKey()
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.
static DeclarationName getFromOpaqueInteger(uintptr_t P)
Get a declaration name from an opaque integer returned by getAsOpaqueInteger.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
SourceLocation getEnd() const
struct CXXOpName CXXOperatorName
DeclarationNameInfo(DeclarationName Name, SourceLocation NameLoc)
bool isObjCOneArgSelector() const
void Profile(llvm::FoldingSetNodeID &FSID)
Encodes a location in the source.
DeclarationName getName() const
getName - Returns the embedded declaration name.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
bool operator>=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
Contains extra information for the name of an overloaded operator in C++, such as "operator+...
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
DeclarationNameInfo(DeclarationName Name, SourceLocation NameLoc, DeclarationNameLoc LocInfo)
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
The name of a declaration.
DeclarationNameLoc & getInfo()
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
DeclarationName()
Construct an empty declaration name.
Not an overloaded operator.
struct CXXLitOpName CXXLiteralOperatorName
void * getFETokenInfo() const
Get and set FETokenInfo.
SourceRange getSourceRange() const LLVM_READONLY
getSourceRange - The range of the declaration name.
static DeclarationName getTombstoneMarker()
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
SourceLocation getCXXLiteralOperatorNameLoc() const
getCXXLiteralOperatorNameLoc - Returns the location of the literal operator name (not the operator ke...
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
Defines the clang::SourceLocation class and associated facilities.
static int compare(DeclarationName LHS, DeclarationName RHS)
A structure for storing the information associated with a name that has been assumed to be a template...
void setFETokenInfo(void *T)
Contains the actual identifier that makes up the name of a C++ literal operator.
static DeclarationName getUsingDirectiveName()
Returns the name for all C++ using-directives.
IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it...
A trivial tuple used to represent a source range.
This represents a decl that may have a name.
Implementation class used to describe either a set of overloaded template names or an already-substit...
static DeclarationName getEmptyMarker()
SourceLocation getBegin() const
bool isObjCZeroArgSelector() const