14 #ifndef LLVM_CLANG_AST_DECLARATIONNAME_H 15 #define LLVM_CLANG_AST_DECLARATIONNAME_H 23 #include "llvm/ADT/DenseMapInfo.h" 24 #include "llvm/ADT/FoldingSet.h" 25 #include "llvm/Support/Compiler.h" 26 #include "llvm/Support/type_traits.h" 35 template <
typename>
class CanQual;
36 class DeclarationName;
37 class DeclarationNameTable;
38 class MultiKeywordSelector;
39 struct PrintingPolicy;
42 class UsingDirectiveDecl;
55 :
public llvm::FoldingSetNode {
78 public llvm::FoldingSetNode {
92 FETokenInfo(nullptr) {}
95 void Profile(llvm::FoldingSetNodeID &
ID) { ID.AddPointer(Template); }
112 void *FETokenInfo =
nullptr;
119 public llvm::FoldingSetNode {
132 FETokenInfo(nullptr) {}
135 void Profile(llvm::FoldingSetNodeID &FSID) { FSID.AddPointer(ID); }
176 enum StoredNameKind {
177 StoredIdentifier = 0,
178 StoredObjCZeroArgSelector = Selector::ZeroArg,
179 StoredObjCOneArgSelector = Selector::OneArg,
180 StoredCXXConstructorName = 3,
181 StoredCXXDestructorName = 4,
182 StoredCXXConversionFunctionName = 5,
183 StoredCXXOperatorName = 6,
184 StoredDeclarationNameExtra = Selector::MultiArg,
186 UncommonNameKindOffset = 8
195 "The various classes that DeclarationName::Ptr can point to" 196 " must be at least aligned to 8 bytes!");
205 ObjCZeroArgSelector = StoredObjCZeroArgSelector,
206 ObjCOneArgSelector = StoredObjCOneArgSelector,
207 CXXConstructorName = StoredCXXConstructorName,
208 CXXDestructorName = StoredCXXDestructorName,
209 CXXConversionFunctionName = StoredCXXConversionFunctionName,
210 CXXOperatorName = StoredCXXOperatorName,
211 CXXDeductionGuideName = UncommonNameKindOffset +
213 CXXLiteralOperatorName =
214 UncommonNameKindOffset +
216 CXXUsingDirective = UncommonNameKindOffset +
218 ObjCMultiArgSelector = UncommonNameKindOffset +
257 StoredNameKind getStoredNameKind()
const {
258 return static_cast<StoredNameKind
>(Ptr & PtrMask);
261 void *getPtr()
const {
return reinterpret_cast<void *
>(Ptr & ~PtrMask); }
263 void setPtrAndKind(
const void *
P, StoredNameKind
Kind) {
265 assert((Kind & ~PtrMask) == 0 &&
266 "Invalid StoredNameKind in setPtrAndKind!");
267 assert((PAsInteger & PtrMask) == 0 &&
268 "Improperly aligned pointer in setPtrAndKind!");
269 Ptr = PAsInteger |
Kind;
274 setPtrAndKind(Name, StoredDeclarationNameExtra);
279 StoredNameKind StoredKind) {
280 assert((StoredKind == StoredCXXConstructorName ||
281 StoredKind == StoredCXXDestructorName ||
282 StoredKind == StoredCXXConversionFunctionName) &&
283 "Invalid StoredNameKind when constructing a DeclarationName" 284 " from a CXXSpecialNameExtra!");
285 setPtrAndKind(Name, StoredKind);
290 setPtrAndKind(Name, StoredCXXOperatorName);
295 assert((getStoredNameKind() == StoredIdentifier) &&
296 "DeclarationName does not store an IdentifierInfo!");
303 assert((getStoredNameKind() == StoredDeclarationNameExtra) &&
304 "DeclarationName does not store an Extra structure!");
311 assert((getStoredNameKind() == StoredCXXConstructorName ||
312 getStoredNameKind() == StoredCXXDestructorName ||
313 getStoredNameKind() == StoredCXXConversionFunctionName) &&
314 "DeclarationName does not store a CXXSpecialNameExtra!");
321 assert((getStoredNameKind() == StoredCXXOperatorName) &&
322 "DeclarationName does not store a CXXOperatorIdName!");
329 assert(getNameKind() == CXXDeductionGuideName &&
330 "DeclarationName does not store a CXXDeductionGuideNameExtra!");
337 assert(getNameKind() == CXXLiteralOperatorName &&
338 "DeclarationName does not store a CXXLiteralOperatorIdName!");
344 void *getFETokenInfoSlow()
const;
345 void setFETokenInfoSlow(
void *T);
353 setPtrAndKind(II, StoredIdentifier);
368 explicit operator bool()
const {
369 return getPtr() || (getStoredNameKind() != StoredIdentifier);
376 bool isIdentifier()
const {
return getStoredNameKind() == StoredIdentifier; }
378 return getStoredNameKind() == StoredObjCZeroArgSelector;
381 return getStoredNameKind() == StoredObjCOneArgSelector;
388 StoredNameKind StoredKind = getStoredNameKind();
389 if (StoredKind != StoredDeclarationNameExtra)
390 return static_cast<NameKind>(StoredKind);
394 unsigned ExtraKind = castAsExtra()->getKind();
395 return static_cast<NameKind>(UncommonNameKindOffset + ExtraKind);
404 bool isDependentName()
const;
413 return castAsIdentifierInfo();
441 if (getStoredNameKind() == StoredCXXConstructorName ||
442 getStoredNameKind() == StoredCXXDestructorName ||
443 getStoredNameKind() == StoredCXXConversionFunctionName) {
444 assert(getPtr() &&
"getCXXNameType on a null DeclarationName!");
445 return castAsCXXSpecialNameExtra()->Type;
453 if (getNameKind() == CXXDeductionGuideName) {
455 "getCXXDeductionGuideTemplate on a null DeclarationName!");
456 return castAsCXXDeductionGuideNameExtra()->Template;
464 if (getStoredNameKind() == StoredCXXOperatorName) {
465 assert(getPtr() &&
"getCXXOverloadedOperator on a null DeclarationName!");
466 return castAsCXXOperatorIdName()->Kind;
474 if (getNameKind() == CXXLiteralOperatorName) {
475 assert(getPtr() &&
"getCXXLiteralIdentifier on a null DeclarationName!");
476 return castAsCXXLiteralOperatorIdName()->ID;
483 assert((getNameKind() == ObjCZeroArgSelector ||
484 getNameKind() == ObjCOneArgSelector ||
485 getNameKind() == ObjCMultiArgSelector || !getPtr()) &&
494 assert(getPtr() &&
"getFETokenInfo on an empty DeclarationName!");
495 if (getStoredNameKind() == StoredIdentifier)
496 return castAsIdentifierInfo()->getFETokenInfo();
497 return getFETokenInfoSlow();
501 assert(getPtr() &&
"setFETokenInfo on an empty DeclarationName!");
502 if (getStoredNameKind() == StoredIdentifier)
503 castAsIdentifierInfo()->setFETokenInfo(T);
505 setFETokenInfoSlow(T);
510 return LHS.Ptr == RHS.Ptr;
515 return LHS.Ptr != RHS.Ptr;
575 llvm::FoldingSet<detail::CXXSpecialNameExtra> CXXConstructorNames;
580 llvm::FoldingSet<detail::CXXSpecialNameExtra> CXXDestructorNames;
586 llvm::FoldingSet<detail::CXXSpecialNameExtra> CXXConversionFunctionNames;
597 llvm::FoldingSet<detail::CXXLiteralOperatorIdName> CXXLiteralOperatorNames;
603 llvm::FoldingSet<detail::CXXDeductionGuideNameExtra> CXXDeductionGuideNames;
707 : Name(Name), NameLoc(NameLoc), LocInfo(Name) {}
711 : Name(Name), NameLoc(NameLoc), LocInfo(LocInfo) {}
786 bool isInstantiationDependent()
const;
790 bool containsUnexpandedParameterPack()
const;
796 void printName(raw_ostream &OS)
const;
808 return EndLoc.
isValid() ? EndLoc : getBeginLoc();
870 #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
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
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.
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. ...
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.
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
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
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+...
void printName(raw_ostream &OS) const
printName - Print the human-readable name to a stream.
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)
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.
static DeclarationName getEmptyMarker()
SourceLocation getBegin() const
bool isObjCZeroArgSelector() const