1 //===--- IdentifierTable.h - Hash table for identifier lookup ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the IdentifierInfo, IdentifierTable, and Selector
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
16 #define LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
18 #include "clang/Basic/OperatorKinds.h"
19 #include "clang/Basic/TokenKinds.h"
20 #include "clang/Basic/LLVM.h"
21 #include "llvm/ADT/StringMap.h"
22 #include "llvm/ADT/StringRef.h"
23 #include "llvm/ADT/SmallString.h"
24 #include "llvm/ADT/OwningPtr.h"
25 #include "llvm/Support/PointerLikeTypeTraits.h"
31 template <typename T> struct DenseMapInfo;
37 class IdentifierTable;
39 class MultiKeywordSelector; // private class used by Selector
40 class DeclarationName; // AST class that stores declaration names
42 /// IdentifierLocPair - A simple pair of identifier info and location.
43 typedef std::pair<IdentifierInfo*, SourceLocation> IdentifierLocPair;
46 /// IdentifierInfo - One of these records is kept for each identifier that
47 /// is lexed. This contains information about whether the token was #define'd,
48 /// is a language keyword, or if it is a front-end token of some sort (e.g. a
49 /// variable or function name). The preprocessor keeps this information in a
50 /// set, and all tok::identifier tokens have a pointer to one of these.
51 class IdentifierInfo {
52 // Note: DON'T make TokenID a 'tok::TokenKind'; MSVC will treat it as a
53 // signed char and TokenKinds > 255 won't be handled correctly.
54 unsigned TokenID : 9; // Front-end token ID or tok::identifier.
55 // Objective-C keyword ('protocol' in '@protocol') or builtin (__builtin_inf).
56 // First NUM_OBJC_KEYWORDS values are for Objective-C, the remaining values
58 unsigned ObjCOrBuiltinID :11;
59 bool HasMacro : 1; // True if there is a #define for this.
60 bool IsExtension : 1; // True if identifier is a lang extension.
61 bool IsCXX11CompatKeyword : 1; // True if identifier is a keyword in C++11.
62 bool IsPoisoned : 1; // True if identifier is poisoned.
63 bool IsCPPOperatorKeyword : 1; // True if ident is a C++ operator keyword.
64 bool NeedsHandleIdentifier : 1; // See "RecomputeNeedsHandleIdentifier".
65 bool IsFromAST : 1; // True if identfier first appeared in an AST
66 // file and wasn't modified since.
67 bool RevertedTokenID : 1; // True if RevertTokenIDToIdentifier was
69 // 5 bits left in 32-bit word.
70 void *FETokenInfo; // Managed by the language front-end.
71 llvm::StringMapEntry<IdentifierInfo*> *Entry;
73 IdentifierInfo(const IdentifierInfo&); // NONCOPYABLE.
74 void operator=(const IdentifierInfo&); // NONASSIGNABLE.
76 friend class IdentifierTable;
82 /// isStr - Return true if this is the identifier for the specified string.
83 /// This is intended to be used for string literals only: II->isStr("foo").
84 template <std::size_t StrLen>
85 bool isStr(const char (&Str)[StrLen]) const {
86 return getLength() == StrLen-1 && !memcmp(getNameStart(), Str, StrLen-1);
89 /// getNameStart - Return the beginning of the actual string for this
90 /// identifier. The returned string is properly null terminated.
92 const char *getNameStart() const {
93 if (Entry) return Entry->getKeyData();
94 // FIXME: This is gross. It would be best not to embed specific details
95 // of the PTH file format here.
96 // The 'this' pointer really points to a
97 // std::pair<IdentifierInfo, const char*>, where internal pointer
98 // points to the external string data.
99 typedef std::pair<IdentifierInfo, const char*> actualtype;
100 return ((const actualtype*) this)->second;
103 /// getLength - Efficiently return the length of this identifier info.
105 unsigned getLength() const {
106 if (Entry) return Entry->getKeyLength();
107 // FIXME: This is gross. It would be best not to embed specific details
108 // of the PTH file format here.
109 // The 'this' pointer really points to a
110 // std::pair<IdentifierInfo, const char*>, where internal pointer
111 // points to the external string data.
112 typedef std::pair<IdentifierInfo, const char*> actualtype;
113 const char* p = ((const actualtype*) this)->second - 2;
114 return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1;
117 /// getName - Return the actual identifier string.
118 StringRef getName() const {
119 return StringRef(getNameStart(), getLength());
122 /// hasMacroDefinition - Return true if this identifier is #defined to some
124 bool hasMacroDefinition() const {
127 void setHasMacroDefinition(bool Val) {
128 if (HasMacro == Val) return;
132 NeedsHandleIdentifier = 1;
134 RecomputeNeedsHandleIdentifier();
138 /// getTokenID - If this is a source-language token (e.g. 'for'), this API
139 /// can be used to cause the lexer to map identifiers to source-language
141 tok::TokenKind getTokenID() const { return (tok::TokenKind)TokenID; }
143 /// \brief True if RevertTokenIDToIdentifier() was called.
144 bool hasRevertedTokenIDToIdentifier() const { return RevertedTokenID; }
146 /// \brief Revert TokenID to tok::identifier; used for GNU libstdc++ 4.2
149 /// TokenID is normally read-only but there are 2 instances where we revert it
150 /// to tok::identifier for libstdc++ 4.2. Keep track of when this happens
151 /// using this method so we can inform serialization about it.
152 void RevertTokenIDToIdentifier() {
153 assert(TokenID != tok::identifier && "Already at tok::identifier");
154 TokenID = tok::identifier;
155 RevertedTokenID = true;
158 /// getPPKeywordID - Return the preprocessor keyword ID for this identifier.
159 /// For example, "define" will return tok::pp_define.
160 tok::PPKeywordKind getPPKeywordID() const;
162 /// getObjCKeywordID - Return the Objective-C keyword ID for the this
163 /// identifier. For example, 'class' will return tok::objc_class if ObjC is
165 tok::ObjCKeywordKind getObjCKeywordID() const {
166 if (ObjCOrBuiltinID < tok::NUM_OBJC_KEYWORDS)
167 return tok::ObjCKeywordKind(ObjCOrBuiltinID);
169 return tok::objc_not_keyword;
171 void setObjCKeywordID(tok::ObjCKeywordKind ID) { ObjCOrBuiltinID = ID; }
173 /// getBuiltinID - Return a value indicating whether this is a builtin
174 /// function. 0 is not-built-in. 1 is builtin-for-some-nonprimary-target.
175 /// 2+ are specific builtin functions.
176 unsigned getBuiltinID() const {
177 if (ObjCOrBuiltinID >= tok::NUM_OBJC_KEYWORDS)
178 return ObjCOrBuiltinID - tok::NUM_OBJC_KEYWORDS;
182 void setBuiltinID(unsigned ID) {
183 ObjCOrBuiltinID = ID + tok::NUM_OBJC_KEYWORDS;
184 assert(ObjCOrBuiltinID - unsigned(tok::NUM_OBJC_KEYWORDS) == ID
185 && "ID too large for field!");
188 unsigned getObjCOrBuiltinID() const { return ObjCOrBuiltinID; }
189 void setObjCOrBuiltinID(unsigned ID) { ObjCOrBuiltinID = ID; }
191 /// get/setExtension - Initialize information about whether or not this
192 /// language token is an extension. This controls extension warnings, and is
193 /// only valid if a custom token ID is set.
194 bool isExtensionToken() const { return IsExtension; }
195 void setIsExtensionToken(bool Val) {
198 NeedsHandleIdentifier = 1;
200 RecomputeNeedsHandleIdentifier();
203 /// is/setIsCXX11CompatKeyword - Initialize information about whether or not
204 /// this language token is a keyword in C++11. This controls compatibility
205 /// warnings, and is only true when not parsing C++11. Once a compatibility
206 /// problem has been diagnosed with this keyword, the flag will be cleared.
207 bool isCXX11CompatKeyword() const { return IsCXX11CompatKeyword; }
208 void setIsCXX11CompatKeyword(bool Val) {
209 IsCXX11CompatKeyword = Val;
211 NeedsHandleIdentifier = 1;
213 RecomputeNeedsHandleIdentifier();
216 /// setIsPoisoned - Mark this identifier as poisoned. After poisoning, the
217 /// Preprocessor will emit an error every time this token is used.
218 void setIsPoisoned(bool Value = true) {
221 NeedsHandleIdentifier = 1;
223 RecomputeNeedsHandleIdentifier();
227 /// isPoisoned - Return true if this token has been poisoned.
228 bool isPoisoned() const { return IsPoisoned; }
230 /// isCPlusPlusOperatorKeyword/setIsCPlusPlusOperatorKeyword controls whether
231 /// this identifier is a C++ alternate representation of an operator.
232 void setIsCPlusPlusOperatorKeyword(bool Val = true) {
233 IsCPPOperatorKeyword = Val;
235 NeedsHandleIdentifier = 1;
237 RecomputeNeedsHandleIdentifier();
239 bool isCPlusPlusOperatorKeyword() const { return IsCPPOperatorKeyword; }
241 /// getFETokenInfo/setFETokenInfo - The language front-end is allowed to
242 /// associate arbitrary metadata with this token.
244 T *getFETokenInfo() const { return static_cast<T*>(FETokenInfo); }
245 void setFETokenInfo(void *T) { FETokenInfo = T; }
247 /// isHandleIdentifierCase - Return true if the Preprocessor::HandleIdentifier
248 /// must be called on a token of this identifier. If this returns false, we
249 /// know that HandleIdentifier will not affect the token.
250 bool isHandleIdentifierCase() const { return NeedsHandleIdentifier; }
252 /// isFromAST - Return true if the identifier in its current state was loaded
253 /// from an AST file.
254 bool isFromAST() const { return IsFromAST; }
256 void setIsFromAST(bool FromAST = true) { IsFromAST = FromAST; }
259 /// RecomputeNeedsHandleIdentifier - The Preprocessor::HandleIdentifier does
260 /// several special (but rare) things to identifiers of various sorts. For
261 /// example, it changes the "for" keyword token from tok::identifier to
264 /// This method is very tied to the definition of HandleIdentifier. Any
265 /// change to it should be reflected here.
266 void RecomputeNeedsHandleIdentifier() {
267 NeedsHandleIdentifier =
268 (isPoisoned() | hasMacroDefinition() | isCPlusPlusOperatorKeyword() |
269 isExtensionToken() | isCXX11CompatKeyword() ||
270 (getTokenID() == tok::kw___import_module__));
274 /// \brief an RAII object for [un]poisoning an identifier
275 /// within a certain scope. II is allowed to be null, in
276 /// which case, objects of this type have no effect.
277 class PoisonIdentifierRAIIObject {
278 IdentifierInfo *const II;
281 PoisonIdentifierRAIIObject(IdentifierInfo *II, bool NewValue)
282 : II(II), OldValue(II ? II->isPoisoned() : false) {
284 II->setIsPoisoned(NewValue);
287 ~PoisonIdentifierRAIIObject() {
289 II->setIsPoisoned(OldValue);
293 /// \brief An iterator that walks over all of the known identifiers
294 /// in the lookup table.
296 /// Since this iterator uses an abstract interface via virtual
297 /// functions, it uses an object-oriented interface rather than the
298 /// more standard C++ STL iterator interface. In this OO-style
299 /// iteration, the single function \c Next() provides dereference,
300 /// advance, and end-of-sequence checking in a single
301 /// operation. Subclasses of this iterator type will provide the
302 /// actual functionality.
303 class IdentifierIterator {
305 IdentifierIterator(const IdentifierIterator&); // Do not implement
306 IdentifierIterator &operator=(const IdentifierIterator&); // Do not implement
309 IdentifierIterator() { }
312 virtual ~IdentifierIterator();
314 /// \brief Retrieve the next string in the identifier table and
315 /// advances the iterator for the following string.
317 /// \returns The next string in the identifier table. If there is
318 /// no such string, returns an empty \c StringRef.
319 virtual StringRef Next() = 0;
322 /// IdentifierInfoLookup - An abstract class used by IdentifierTable that
323 /// provides an interface for performing lookups from strings
324 /// (const char *) to IdentiferInfo objects.
325 class IdentifierInfoLookup {
327 virtual ~IdentifierInfoLookup();
329 /// get - Return the identifier token info for the specified named identifier.
330 /// Unlike the version in IdentifierTable, this returns a pointer instead
331 /// of a reference. If the pointer is NULL then the IdentifierInfo cannot
333 virtual IdentifierInfo* get(StringRef Name) = 0;
335 /// \brief Retrieve an iterator into the set of all identifiers
336 /// known to this identifier lookup source.
338 /// This routine provides access to all of the identifiers known to
339 /// the identifier lookup, allowing access to the contents of the
340 /// identifiers without introducing the overhead of constructing
341 /// IdentifierInfo objects for each.
343 /// \returns A new iterator into the set of known identifiers. The
344 /// caller is responsible for deleting this iterator.
345 virtual IdentifierIterator *getIdentifiers() const;
348 /// \brief An abstract class used to resolve numerical identifier
349 /// references (meaningful only to some external source) into
350 /// IdentifierInfo pointers.
351 class ExternalIdentifierLookup {
353 virtual ~ExternalIdentifierLookup();
355 /// \brief Return the identifier associated with the given ID number.
357 /// The ID 0 is associated with the NULL identifier.
358 virtual IdentifierInfo *GetIdentifier(unsigned ID) = 0;
361 /// IdentifierTable - This table implements an efficient mapping from strings to
362 /// IdentifierInfo nodes. It has no other purpose, but this is an
363 /// extremely performance-critical piece of the code, as each occurrence of
364 /// every identifier goes through here when lexed.
365 class IdentifierTable {
366 // Shark shows that using MallocAllocator is *much* slower than using this
368 typedef llvm::StringMap<IdentifierInfo*, llvm::BumpPtrAllocator> HashTableTy;
369 HashTableTy HashTable;
371 IdentifierInfoLookup* ExternalLookup;
374 /// IdentifierTable ctor - Create the identifier table, populating it with
375 /// info about the language keywords for the language specified by LangOpts.
376 IdentifierTable(const LangOptions &LangOpts,
377 IdentifierInfoLookup* externalLookup = 0);
379 /// \brief Set the external identifier lookup mechanism.
380 void setExternalIdentifierLookup(IdentifierInfoLookup *IILookup) {
381 ExternalLookup = IILookup;
384 /// \brief Retrieve the external identifier lookup object, if any.
385 IdentifierInfoLookup *getExternalIdentifierLookup() const {
386 return ExternalLookup;
389 llvm::BumpPtrAllocator& getAllocator() {
390 return HashTable.getAllocator();
393 /// get - Return the identifier token info for the specified named identifier.
395 IdentifierInfo &get(StringRef Name) {
396 llvm::StringMapEntry<IdentifierInfo*> &Entry =
397 HashTable.GetOrCreateValue(Name);
399 IdentifierInfo *II = Entry.getValue();
402 // No entry; if we have an external lookup, look there first.
403 if (ExternalLookup) {
404 II = ExternalLookup->get(Name);
406 // Cache in the StringMap for subsequent lookups.
412 // Lookups failed, make a new IdentifierInfo.
413 void *Mem = getAllocator().Allocate<IdentifierInfo>();
414 II = new (Mem) IdentifierInfo();
417 // Make sure getName() knows how to find the IdentifierInfo
424 IdentifierInfo &get(StringRef Name, tok::TokenKind TokenCode) {
425 IdentifierInfo &II = get(Name);
426 II.TokenID = TokenCode;
427 assert(II.TokenID == (unsigned) TokenCode && "TokenCode too large");
431 /// \brief Gets an IdentifierInfo for the given name without consulting
432 /// external sources.
434 /// This is a version of get() meant for external sources that want to
435 /// introduce or modify an identifier. If they called get(), they would
436 /// likely end up in a recursion.
437 IdentifierInfo &getOwn(StringRef Name) {
438 llvm::StringMapEntry<IdentifierInfo*> &Entry =
439 HashTable.GetOrCreateValue(Name);
441 IdentifierInfo *II = Entry.getValue();
444 // Lookups failed, make a new IdentifierInfo.
445 void *Mem = getAllocator().Allocate<IdentifierInfo>();
446 II = new (Mem) IdentifierInfo();
449 // Make sure getName() knows how to find the IdentifierInfo
457 typedef HashTableTy::const_iterator iterator;
458 typedef HashTableTy::const_iterator const_iterator;
460 iterator begin() const { return HashTable.begin(); }
461 iterator end() const { return HashTable.end(); }
462 unsigned size() const { return HashTable.size(); }
464 /// PrintStats - Print some statistics to stderr that indicate how well the
465 /// hashing is doing.
466 void PrintStats() const;
468 void AddKeywords(const LangOptions &LangOpts);
471 /// ObjCMethodFamily - A family of Objective-C methods. These
472 /// families have no inherent meaning in the language, but are
473 /// nonetheless central enough in the existing implementations to
474 /// merit direct AST support. While, in theory, arbitrary methods can
475 /// be considered to form families, we focus here on the methods
476 /// involving allocation and retain-count management, as these are the
477 /// most "core" and the most likely to be useful to diverse clients
478 /// without extra information.
480 /// Both selectors and actual method declarations may be classified
481 /// into families. Method families may impose additional restrictions
482 /// beyond their selector name; for example, a method called '_init'
483 /// that returns void is not considered to be in the 'init' family
484 /// (but would be if it returned 'id'). It is also possible to
485 /// explicitly change or remove a method's family. Therefore the
486 /// method's family should be considered the single source of truth.
487 enum ObjCMethodFamily {
488 /// \brief No particular method family.
491 // Selectors in these families may have arbitrary arity, may be
492 // written with arbitrary leading underscores, and may have
493 // additional CamelCase "words" in their first selector chunk
494 // following the family name.
501 // These families are singletons consisting only of the nullary
502 // selector with the given name.
511 // performSelector families
515 /// Enough bits to store any enumerator in ObjCMethodFamily or
516 /// InvalidObjCMethodFamily.
517 enum { ObjCMethodFamilyBitWidth = 4 };
519 /// An invalid value of ObjCMethodFamily.
520 enum { InvalidObjCMethodFamily = (1 << ObjCMethodFamilyBitWidth) - 1 };
522 /// Selector - This smart pointer class efficiently represents Objective-C
523 /// method names. This class will either point to an IdentifierInfo or a
524 /// MultiKeywordSelector (which is private). This enables us to optimize
525 /// selectors that take no arguments and selectors that take 1 argument, which
526 /// accounts for 78% of all selectors in Cocoa.h.
528 friend class Diagnostic;
530 enum IdentifierInfoFlag {
531 // MultiKeywordSelector = 0.
534 ArgFlags = ZeroArg|OneArg
536 uintptr_t InfoPtr; // a pointer to the MultiKeywordSelector or IdentifierInfo.
538 Selector(IdentifierInfo *II, unsigned nArgs) {
539 InfoPtr = reinterpret_cast<uintptr_t>(II);
540 assert((InfoPtr & ArgFlags) == 0 &&"Insufficiently aligned IdentifierInfo");
541 assert(nArgs < 2 && "nArgs not equal to 0/1");
544 Selector(MultiKeywordSelector *SI) {
545 InfoPtr = reinterpret_cast<uintptr_t>(SI);
546 assert((InfoPtr & ArgFlags) == 0 &&"Insufficiently aligned IdentifierInfo");
549 IdentifierInfo *getAsIdentifierInfo() const {
550 if (getIdentifierInfoFlag())
551 return reinterpret_cast<IdentifierInfo *>(InfoPtr & ~ArgFlags);
554 unsigned getIdentifierInfoFlag() const {
555 return InfoPtr & ArgFlags;
558 static ObjCMethodFamily getMethodFamilyImpl(Selector sel);
561 friend class SelectorTable; // only the SelectorTable can create these
562 friend class DeclarationName; // and the AST's DeclarationName.
564 /// The default ctor should only be used when creating data structures that
565 /// will contain selectors.
566 Selector() : InfoPtr(0) {}
567 Selector(uintptr_t V) : InfoPtr(V) {}
569 /// operator==/!= - Indicate whether the specified selectors are identical.
570 bool operator==(Selector RHS) const {
571 return InfoPtr == RHS.InfoPtr;
573 bool operator!=(Selector RHS) const {
574 return InfoPtr != RHS.InfoPtr;
576 void *getAsOpaquePtr() const {
577 return reinterpret_cast<void*>(InfoPtr);
580 /// \brief Determine whether this is the empty selector.
581 bool isNull() const { return InfoPtr == 0; }
583 // Predicates to identify the selector type.
584 bool isKeywordSelector() const {
585 return getIdentifierInfoFlag() != ZeroArg;
587 bool isUnarySelector() const {
588 return getIdentifierInfoFlag() == ZeroArg;
590 unsigned getNumArgs() const;
593 /// \brief Retrieve the identifier at a given position in the selector.
595 /// Note that the identifier pointer returned may be NULL. Clients that only
596 /// care about the text of the identifier string, and not the specific,
597 /// uniqued identifier pointer, should use \c getNameForSlot(), which returns
598 /// an empty string when the identifier pointer would be NULL.
600 /// \param argIndex The index for which we want to retrieve the identifier.
601 /// This index shall be less than \c getNumArgs() unless this is a keyword
602 /// selector, in which case 0 is the only permissible value.
604 /// \returns the uniqued identifier for this slot, or NULL if this slot has
605 /// no corresponding identifier.
606 IdentifierInfo *getIdentifierInfoForSlot(unsigned argIndex) const;
608 /// \brief Retrieve the name at a given position in the selector.
610 /// \param argIndex The index for which we want to retrieve the name.
611 /// This index shall be less than \c getNumArgs() unless this is a keyword
612 /// selector, in which case 0 is the only permissible value.
614 /// \returns the name for this slot, which may be the empty string if no
615 /// name was supplied.
616 StringRef getNameForSlot(unsigned argIndex) const;
618 /// getAsString - Derive the full selector name (e.g. "foo:bar:") and return
619 /// it as an std::string.
620 std::string getAsString() const;
622 /// getMethodFamily - Derive the conventional family of this method.
623 ObjCMethodFamily getMethodFamily() const {
624 return getMethodFamilyImpl(*this);
627 static Selector getEmptyMarker() {
628 return Selector(uintptr_t(-1));
630 static Selector getTombstoneMarker() {
631 return Selector(uintptr_t(-2));
635 /// SelectorTable - This table allows us to fully hide how we implement
636 /// multi-keyword caching.
637 class SelectorTable {
638 void *Impl; // Actually a SelectorTableImpl
639 SelectorTable(const SelectorTable&); // DISABLED: DO NOT IMPLEMENT
640 void operator=(const SelectorTable&); // DISABLED: DO NOT IMPLEMENT
645 /// getSelector - This can create any sort of selector. NumArgs indicates
646 /// whether this is a no argument selector "foo", a single argument selector
647 /// "foo:" or multi-argument "foo:bar:".
648 Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV);
650 Selector getUnarySelector(IdentifierInfo *ID) {
651 return Selector(ID, 1);
653 Selector getNullarySelector(IdentifierInfo *ID) {
654 return Selector(ID, 0);
657 /// Return the total amount of memory allocated for managing selectors.
658 size_t getTotalMemory() const;
660 /// constructSetterName - Return the setter name for the given
661 /// identifier, i.e. "set" + Name where the initial character of Name
662 /// has been capitalized.
663 static Selector constructSetterName(IdentifierTable &Idents,
664 SelectorTable &SelTable,
665 const IdentifierInfo *Name) {
666 llvm::SmallString<100> SelectorName;
667 SelectorName = "set";
668 SelectorName += Name->getName();
669 SelectorName[3] = toupper(SelectorName[3]);
670 IdentifierInfo *SetterName = &Idents.get(SelectorName);
671 return SelTable.getUnarySelector(SetterName);
675 /// DeclarationNameExtra - Common base of the MultiKeywordSelector,
676 /// CXXSpecialName, and CXXOperatorIdName classes, all of which are
677 /// private classes that describe different kinds of names.
678 class DeclarationNameExtra {
680 /// ExtraKind - The kind of "extra" information stored in the
681 /// DeclarationName. See @c ExtraKindOrNumArgs for an explanation of
682 /// how these enumerator values are used.
686 CXXConversionFunction,
687 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
689 #include "clang/Basic/OperatorKinds.def"
695 /// ExtraKindOrNumArgs - Either the kind of C++ special name or
696 /// operator-id (if the value is one of the CXX* enumerators of
697 /// ExtraKind), in which case the DeclarationNameExtra is also a
698 /// CXXSpecialName, (for CXXConstructor, CXXDestructor, or
699 /// CXXConversionFunction) CXXOperatorIdName, or CXXLiteralOperatorName,
700 /// it may be also name common to C++ using-directives (CXXUsingDirective),
701 /// otherwise it is NUM_EXTRA_KINDS+NumArgs, where NumArgs is the number of
702 /// arguments in the Objective-C selector, in which case the
703 /// DeclarationNameExtra is also a MultiKeywordSelector.
704 unsigned ExtraKindOrNumArgs;
707 } // end namespace clang
710 /// Define DenseMapInfo so that Selectors can be used as keys in DenseMap and
713 struct DenseMapInfo<clang::Selector> {
714 static inline clang::Selector getEmptyKey() {
715 return clang::Selector::getEmptyMarker();
717 static inline clang::Selector getTombstoneKey() {
718 return clang::Selector::getTombstoneMarker();
721 static unsigned getHashValue(clang::Selector S);
723 static bool isEqual(clang::Selector LHS, clang::Selector RHS) {
729 struct isPodLike<clang::Selector> { static const bool value = true; };
732 class PointerLikeTypeTraits<clang::Selector> {
734 static inline const void *getAsVoidPointer(clang::Selector P) {
735 return P.getAsOpaquePtr();
737 static inline clang::Selector getFromVoidPointer(const void *P) {
738 return clang::Selector(reinterpret_cast<uintptr_t>(P));
740 enum { NumLowBitsAvailable = 0 };
743 // Provide PointerLikeTypeTraits for IdentifierInfo pointers, which
744 // are not guaranteed to be 8-byte aligned.
746 class PointerLikeTypeTraits<clang::IdentifierInfo*> {
748 static inline void *getAsVoidPointer(clang::IdentifierInfo* P) {
751 static inline clang::IdentifierInfo *getFromVoidPointer(void *P) {
752 return static_cast<clang::IdentifierInfo*>(P);
754 enum { NumLowBitsAvailable = 1 };
758 class PointerLikeTypeTraits<const clang::IdentifierInfo*> {
760 static inline const void *getAsVoidPointer(const clang::IdentifierInfo* P) {
763 static inline const clang::IdentifierInfo *getFromVoidPointer(const void *P) {
764 return static_cast<const clang::IdentifierInfo*>(P);
766 enum { NumLowBitsAvailable = 1 };
769 } // end namespace llvm