clang  14.0.0git
IdentifierTable.h
Go to the documentation of this file.
1 //===- IdentifierTable.h - Hash table for identifier lookup -----*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// \file
10 /// Defines the clang::IdentifierInfo, clang::IdentifierTable, and
11 /// clang::Selector interfaces.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
16 #define LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
17 
18 #include "clang/Basic/LLVM.h"
19 #include "clang/Basic/TokenKinds.h"
20 #include "llvm/ADT/DenseMapInfo.h"
21 #include "llvm/ADT/SmallString.h"
22 #include "llvm/ADT/StringMap.h"
23 #include "llvm/ADT/StringRef.h"
24 #include "llvm/Support/Allocator.h"
25 #include "llvm/Support/PointerLikeTypeTraits.h"
26 #include "llvm/Support/type_traits.h"
27 #include <cassert>
28 #include <cstddef>
29 #include <cstdint>
30 #include <cstring>
31 #include <string>
32 #include <utility>
33 
34 namespace clang {
35 
36 class DeclarationName;
37 class DeclarationNameTable;
38 class IdentifierInfo;
39 class LangOptions;
40 class MultiKeywordSelector;
41 class SourceLocation;
42 
44  NotReserved = 0,
49 };
50 
51 /// A simple pair of identifier info and location.
52 using IdentifierLocPair = std::pair<IdentifierInfo *, SourceLocation>;
53 
54 /// IdentifierInfo and other related classes are aligned to
55 /// 8 bytes so that DeclarationName can use the lower 3 bits
56 /// of a pointer to one of these classes.
58 
59 static constexpr int ObjCOrBuiltinIDBits = 16;
60 
61 /// One of these records is kept for each identifier that
62 /// is lexed. This contains information about whether the token was \#define'd,
63 /// is a language keyword, or if it is a front-end token of some sort (e.g. a
64 /// variable or function name). The preprocessor keeps this information in a
65 /// set, and all tok::identifier tokens have a pointer to one of these.
66 /// It is aligned to 8 bytes because DeclarationName needs the lower 3 bits.
67 class alignas(IdentifierInfoAlignment) IdentifierInfo {
68  friend class IdentifierTable;
69 
70  // Front-end token ID or tok::identifier.
71  unsigned TokenID : 9;
72 
73  // ObjC keyword ('protocol' in '@protocol') or builtin (__builtin_inf).
74  // First NUM_OBJC_KEYWORDS values are for Objective-C,
75  // the remaining values are for builtins.
76  unsigned ObjCOrBuiltinID : ObjCOrBuiltinIDBits;
77 
78  // True if there is a #define for this.
79  unsigned HasMacro : 1;
80 
81  // True if there was a #define for this.
82  unsigned HadMacro : 1;
83 
84  // True if the identifier is a language extension.
85  unsigned IsExtension : 1;
86 
87  // True if the identifier is a keyword in a newer or proposed Standard.
88  unsigned IsFutureCompatKeyword : 1;
89 
90  // True if the identifier is poisoned.
91  unsigned IsPoisoned : 1;
92 
93  // True if the identifier is a C++ operator keyword.
94  unsigned IsCPPOperatorKeyword : 1;
95 
96  // Internal bit set by the member function RecomputeNeedsHandleIdentifier.
97  // See comment about RecomputeNeedsHandleIdentifier for more info.
98  unsigned NeedsHandleIdentifier : 1;
99 
100  // True if the identifier was loaded (at least partially) from an AST file.
101  unsigned IsFromAST : 1;
102 
103  // True if the identifier has changed from the definition
104  // loaded from an AST file.
105  unsigned ChangedAfterLoad : 1;
106 
107  // True if the identifier's frontend information has changed from the
108  // definition loaded from an AST file.
109  unsigned FEChangedAfterLoad : 1;
110 
111  // True if revertTokenIDToIdentifier was called.
112  unsigned RevertedTokenID : 1;
113 
114  // True if there may be additional information about
115  // this identifier stored externally.
116  unsigned OutOfDate : 1;
117 
118  // True if this is the 'import' contextual keyword.
119  unsigned IsModulesImport : 1;
120 
121  // True if this is a mangled OpenMP variant name.
122  unsigned IsMangledOpenMPVariantName : 1;
123 
124  // True if this is a deprecated macro.
125  unsigned IsDeprecatedMacro : 1;
126 
127  // True if this macro is unsafe in headers.
128  unsigned IsRestrictExpansion : 1;
129 
130  // 23 bits left in a 64-bit word.
131 
132  // Managed by the language front-end.
133  void *FETokenInfo = nullptr;
134 
135  llvm::StringMapEntry<IdentifierInfo *> *Entry = nullptr;
136 
138  : TokenID(tok::identifier), ObjCOrBuiltinID(0), HasMacro(false),
139  HadMacro(false), IsExtension(false), IsFutureCompatKeyword(false),
140  IsPoisoned(false), IsCPPOperatorKeyword(false),
141  NeedsHandleIdentifier(false), IsFromAST(false), ChangedAfterLoad(false),
142  FEChangedAfterLoad(false), RevertedTokenID(false), OutOfDate(false),
143  IsModulesImport(false), IsMangledOpenMPVariantName(false),
144  IsDeprecatedMacro(false), IsRestrictExpansion(false) {}
145 
146 public:
147  IdentifierInfo(const IdentifierInfo &) = delete;
148  IdentifierInfo &operator=(const IdentifierInfo &) = delete;
149  IdentifierInfo(IdentifierInfo &&) = delete;
150  IdentifierInfo &operator=(IdentifierInfo &&) = delete;
151 
152  /// Return true if this is the identifier for the specified string.
153  ///
154  /// This is intended to be used for string literals only: II->isStr("foo").
155  template <std::size_t StrLen>
156  bool isStr(const char (&Str)[StrLen]) const {
157  return getLength() == StrLen-1 &&
158  memcmp(getNameStart(), Str, StrLen-1) == 0;
159  }
160 
161  /// Return true if this is the identifier for the specified StringRef.
162  bool isStr(llvm::StringRef Str) const {
163  llvm::StringRef ThisStr(getNameStart(), getLength());
164  return ThisStr == Str;
165  }
166 
167  /// Return the beginning of the actual null-terminated string for this
168  /// identifier.
169  const char *getNameStart() const { return Entry->getKeyData(); }
170 
171  /// Efficiently return the length of this identifier info.
172  unsigned getLength() const { return Entry->getKeyLength(); }
173 
174  /// Return the actual identifier string.
175  StringRef getName() const {
176  return StringRef(getNameStart(), getLength());
177  }
178 
179  /// Return true if this identifier is \#defined to some other value.
180  /// \note The current definition may be in a module and not currently visible.
181  bool hasMacroDefinition() const {
182  return HasMacro;
183  }
184  void setHasMacroDefinition(bool Val) {
185  if (HasMacro == Val) return;
186 
187  HasMacro = Val;
188  if (Val) {
189  NeedsHandleIdentifier = true;
190  HadMacro = true;
191  } else {
192  // Because calling the setters of these calls recomputes, just set them
193  // manually to avoid recomputing a bunch of times.
194  IsDeprecatedMacro = false;
195  IsRestrictExpansion = false;
196  RecomputeNeedsHandleIdentifier();
197  }
198  }
199  /// Returns true if this identifier was \#defined to some value at any
200  /// moment. In this case there should be an entry for the identifier in the
201  /// macro history table in Preprocessor.
202  bool hadMacroDefinition() const {
203  return HadMacro;
204  }
205 
206  bool isDeprecatedMacro() const { return IsDeprecatedMacro; }
207 
208  void setIsDeprecatedMacro(bool Val) {
209  if (IsDeprecatedMacro == Val)
210  return;
211  IsDeprecatedMacro = Val;
212  if (Val)
213  NeedsHandleIdentifier = true;
214  else
215  RecomputeNeedsHandleIdentifier();
216  }
217 
218  bool isRestrictExpansion() const { return IsRestrictExpansion; }
219 
220  void setIsRestrictExpansion(bool Val) {
221  if (IsRestrictExpansion == Val)
222  return;
223  IsRestrictExpansion = Val;
224  if (Val)
225  NeedsHandleIdentifier = true;
226  else
227  RecomputeNeedsHandleIdentifier();
228  }
229 
230  /// If this is a source-language token (e.g. 'for'), this API
231  /// can be used to cause the lexer to map identifiers to source-language
232  /// tokens.
233  tok::TokenKind getTokenID() const { return (tok::TokenKind)TokenID; }
234 
235  /// True if revertTokenIDToIdentifier() was called.
236  bool hasRevertedTokenIDToIdentifier() const { return RevertedTokenID; }
237 
238  /// Revert TokenID to tok::identifier; used for GNU libstdc++ 4.2
239  /// compatibility.
240  ///
241  /// TokenID is normally read-only but there are 2 instances where we revert it
242  /// to tok::identifier for libstdc++ 4.2. Keep track of when this happens
243  /// using this method so we can inform serialization about it.
245  assert(TokenID != tok::identifier && "Already at tok::identifier");
246  TokenID = tok::identifier;
247  RevertedTokenID = true;
248  }
250  assert(TokenID == tok::identifier && "Should be at tok::identifier");
251  TokenID = TK;
252  RevertedTokenID = false;
253  }
254 
255  /// Return the preprocessor keyword ID for this identifier.
256  ///
257  /// For example, "define" will return tok::pp_define.
258  tok::PPKeywordKind getPPKeywordID() const;
259 
260  /// Return the Objective-C keyword ID for the this identifier.
261  ///
262  /// For example, 'class' will return tok::objc_class if ObjC is enabled.
264  if (ObjCOrBuiltinID < tok::NUM_OBJC_KEYWORDS)
265  return tok::ObjCKeywordKind(ObjCOrBuiltinID);
266  else
267  return tok::objc_not_keyword;
268  }
269  void setObjCKeywordID(tok::ObjCKeywordKind ID) { ObjCOrBuiltinID = ID; }
270 
271  /// Return a value indicating whether this is a builtin function.
272  ///
273  /// 0 is not-built-in. 1+ are specific builtin functions.
274  unsigned getBuiltinID() const {
275  if (ObjCOrBuiltinID >= tok::NUM_OBJC_KEYWORDS)
276  return ObjCOrBuiltinID - tok::NUM_OBJC_KEYWORDS;
277  else
278  return 0;
279  }
280  void setBuiltinID(unsigned ID) {
281  ObjCOrBuiltinID = ID + tok::NUM_OBJC_KEYWORDS;
282  assert(ObjCOrBuiltinID - unsigned(tok::NUM_OBJC_KEYWORDS) == ID
283  && "ID too large for field!");
284  }
285 
286  unsigned getObjCOrBuiltinID() const { return ObjCOrBuiltinID; }
287  void setObjCOrBuiltinID(unsigned ID) { ObjCOrBuiltinID = ID; }
288 
289  /// get/setExtension - Initialize information about whether or not this
290  /// language token is an extension. This controls extension warnings, and is
291  /// only valid if a custom token ID is set.
292  bool isExtensionToken() const { return IsExtension; }
293  void setIsExtensionToken(bool Val) {
294  IsExtension = Val;
295  if (Val)
296  NeedsHandleIdentifier = true;
297  else
298  RecomputeNeedsHandleIdentifier();
299  }
300 
301  /// is/setIsFutureCompatKeyword - Initialize information about whether or not
302  /// this language token is a keyword in a newer or proposed Standard. This
303  /// controls compatibility warnings, and is only true when not parsing the
304  /// corresponding Standard. Once a compatibility problem has been diagnosed
305  /// with this keyword, the flag will be cleared.
306  bool isFutureCompatKeyword() const { return IsFutureCompatKeyword; }
307  void setIsFutureCompatKeyword(bool Val) {
308  IsFutureCompatKeyword = Val;
309  if (Val)
310  NeedsHandleIdentifier = true;
311  else
312  RecomputeNeedsHandleIdentifier();
313  }
314 
315  /// setIsPoisoned - Mark this identifier as poisoned. After poisoning, the
316  /// Preprocessor will emit an error every time this token is used.
317  void setIsPoisoned(bool Value = true) {
318  IsPoisoned = Value;
319  if (Value)
320  NeedsHandleIdentifier = true;
321  else
322  RecomputeNeedsHandleIdentifier();
323  }
324 
325  /// Return true if this token has been poisoned.
326  bool isPoisoned() const { return IsPoisoned; }
327 
328  /// isCPlusPlusOperatorKeyword/setIsCPlusPlusOperatorKeyword controls whether
329  /// this identifier is a C++ alternate representation of an operator.
330  void setIsCPlusPlusOperatorKeyword(bool Val = true) {
331  IsCPPOperatorKeyword = Val;
332  }
333  bool isCPlusPlusOperatorKeyword() const { return IsCPPOperatorKeyword; }
334 
335  /// Return true if this token is a keyword in the specified language.
336  bool isKeyword(const LangOptions &LangOpts) const;
337 
338  /// Return true if this token is a C++ keyword in the specified
339  /// language.
340  bool isCPlusPlusKeyword(const LangOptions &LangOpts) const;
341 
342  /// Get and set FETokenInfo. The language front-end is allowed to associate
343  /// arbitrary metadata with this token.
344  void *getFETokenInfo() const { return FETokenInfo; }
345  void setFETokenInfo(void *T) { FETokenInfo = T; }
346 
347  /// Return true if the Preprocessor::HandleIdentifier must be called
348  /// on a token of this identifier.
349  ///
350  /// If this returns false, we know that HandleIdentifier will not affect
351  /// the token.
352  bool isHandleIdentifierCase() const { return NeedsHandleIdentifier; }
353 
354  /// Return true if the identifier in its current state was loaded
355  /// from an AST file.
356  bool isFromAST() const { return IsFromAST; }
357 
358  void setIsFromAST() { IsFromAST = true; }
359 
360  /// Determine whether this identifier has changed since it was loaded
361  /// from an AST file.
363  return ChangedAfterLoad;
364  }
365 
366  /// Note that this identifier has changed since it was loaded from
367  /// an AST file.
369  ChangedAfterLoad = true;
370  }
371 
372  /// Determine whether the frontend token information for this
373  /// identifier has changed since it was loaded from an AST file.
375  return FEChangedAfterLoad;
376  }
377 
378  /// Note that the frontend token information for this identifier has
379  /// changed since it was loaded from an AST file.
381  FEChangedAfterLoad = true;
382  }
383 
384  /// Determine whether the information for this identifier is out of
385  /// date with respect to the external source.
386  bool isOutOfDate() const { return OutOfDate; }
387 
388  /// Set whether the information for this identifier is out of
389  /// date with respect to the external source.
390  void setOutOfDate(bool OOD) {
391  OutOfDate = OOD;
392  if (OOD)
393  NeedsHandleIdentifier = true;
394  else
395  RecomputeNeedsHandleIdentifier();
396  }
397 
398  /// Determine whether this is the contextual keyword \c import.
399  bool isModulesImport() const { return IsModulesImport; }
400 
401  /// Set whether this identifier is the contextual keyword \c import.
402  void setModulesImport(bool I) {
403  IsModulesImport = I;
404  if (I)
405  NeedsHandleIdentifier = true;
406  else
407  RecomputeNeedsHandleIdentifier();
408  }
409 
410  /// Determine whether this is the mangled name of an OpenMP variant.
411  bool isMangledOpenMPVariantName() const { return IsMangledOpenMPVariantName; }
412 
413  /// Set whether this is the mangled name of an OpenMP variant.
414  void setMangledOpenMPVariantName(bool I) { IsMangledOpenMPVariantName = I; }
415 
416  /// Return true if this identifier is an editor placeholder.
417  ///
418  /// Editor placeholders are produced by the code-completion engine and are
419  /// represented as characters between '<#' and '#>' in the source code. An
420  /// example of auto-completed call with a placeholder parameter is shown
421  /// below:
422  /// \code
423  /// function(<#int x#>);
424  /// \endcode
425  bool isEditorPlaceholder() const {
426  return getName().startswith("<#") && getName().endswith("#>");
427  }
428 
429  /// Determine whether \p this is a name reserved for the implementation (C99
430  /// 7.1.3, C++ [lib.global.names]).
431  ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const;
432 
433  /// Provide less than operator for lexicographical sorting.
434  bool operator<(const IdentifierInfo &RHS) const {
435  return getName() < RHS.getName();
436  }
437 
438 private:
439  /// The Preprocessor::HandleIdentifier does several special (but rare)
440  /// things to identifiers of various sorts. For example, it changes the
441  /// \c for keyword token from tok::identifier to tok::for.
442  ///
443  /// This method is very tied to the definition of HandleIdentifier. Any
444  /// change to it should be reflected here.
445  void RecomputeNeedsHandleIdentifier() {
446  NeedsHandleIdentifier = isPoisoned() || hasMacroDefinition() ||
447  isExtensionToken() || isFutureCompatKeyword() ||
448  isOutOfDate() || isModulesImport();
449  }
450 };
451 
452 /// An RAII object for [un]poisoning an identifier within a scope.
453 ///
454 /// \p II is allowed to be null, in which case objects of this type have
455 /// no effect.
457  IdentifierInfo *const II;
458  const bool OldValue;
459 
460 public:
462  : II(II), OldValue(II ? II->isPoisoned() : false) {
463  if(II)
464  II->setIsPoisoned(NewValue);
465  }
466 
468  if(II)
469  II->setIsPoisoned(OldValue);
470  }
471 };
472 
473 /// An iterator that walks over all of the known identifiers
474 /// in the lookup table.
475 ///
476 /// Since this iterator uses an abstract interface via virtual
477 /// functions, it uses an object-oriented interface rather than the
478 /// more standard C++ STL iterator interface. In this OO-style
479 /// iteration, the single function \c Next() provides dereference,
480 /// advance, and end-of-sequence checking in a single
481 /// operation. Subclasses of this iterator type will provide the
482 /// actual functionality.
484 protected:
485  IdentifierIterator() = default;
486 
487 public:
488  IdentifierIterator(const IdentifierIterator &) = delete;
489  IdentifierIterator &operator=(const IdentifierIterator &) = delete;
490 
491  virtual ~IdentifierIterator();
492 
493  /// Retrieve the next string in the identifier table and
494  /// advances the iterator for the following string.
495  ///
496  /// \returns The next string in the identifier table. If there is
497  /// no such string, returns an empty \c StringRef.
498  virtual StringRef Next() = 0;
499 };
500 
501 /// Provides lookups to, and iteration over, IdentiferInfo objects.
503 public:
504  virtual ~IdentifierInfoLookup();
505 
506  /// Return the IdentifierInfo for the specified named identifier.
507  ///
508  /// Unlike the version in IdentifierTable, this returns a pointer instead
509  /// of a reference. If the pointer is null then the IdentifierInfo cannot
510  /// be found.
511  virtual IdentifierInfo* get(StringRef Name) = 0;
512 
513  /// Retrieve an iterator into the set of all identifiers
514  /// known to this identifier lookup source.
515  ///
516  /// This routine provides access to all of the identifiers known to
517  /// the identifier lookup, allowing access to the contents of the
518  /// identifiers without introducing the overhead of constructing
519  /// IdentifierInfo objects for each.
520  ///
521  /// \returns A new iterator into the set of known identifiers. The
522  /// caller is responsible for deleting this iterator.
523  virtual IdentifierIterator *getIdentifiers();
524 };
525 
526 /// Implements an efficient mapping from strings to IdentifierInfo nodes.
527 ///
528 /// This has no other purpose, but this is an extremely performance-critical
529 /// piece of the code, as each occurrence of every identifier goes through
530 /// here when lexed.
532  // Shark shows that using MallocAllocator is *much* slower than using this
533  // BumpPtrAllocator!
534  using HashTableTy = llvm::StringMap<IdentifierInfo *, llvm::BumpPtrAllocator>;
535  HashTableTy HashTable;
536 
537  IdentifierInfoLookup* ExternalLookup;
538 
539 public:
540  /// Create the identifier table.
541  explicit IdentifierTable(IdentifierInfoLookup *ExternalLookup = nullptr);
542 
543  /// Create the identifier table, populating it with info about the
544  /// language keywords for the language specified by \p LangOpts.
545  explicit IdentifierTable(const LangOptions &LangOpts,
546  IdentifierInfoLookup *ExternalLookup = nullptr);
547 
548  /// Set the external identifier lookup mechanism.
550  ExternalLookup = IILookup;
551  }
552 
553  /// Retrieve the external identifier lookup object, if any.
555  return ExternalLookup;
556  }
557 
558  llvm::BumpPtrAllocator& getAllocator() {
559  return HashTable.getAllocator();
560  }
561 
562  /// Return the identifier token info for the specified named
563  /// identifier.
564  IdentifierInfo &get(StringRef Name) {
565  auto &Entry = *HashTable.insert(std::make_pair(Name, nullptr)).first;
566 
567  IdentifierInfo *&II = Entry.second;
568  if (II) return *II;
569 
570  // No entry; if we have an external lookup, look there first.
571  if (ExternalLookup) {
572  II = ExternalLookup->get(Name);
573  if (II)
574  return *II;
575  }
576 
577  // Lookups failed, make a new IdentifierInfo.
578  void *Mem = getAllocator().Allocate<IdentifierInfo>();
579  II = new (Mem) IdentifierInfo();
580 
581  // Make sure getName() knows how to find the IdentifierInfo
582  // contents.
583  II->Entry = &Entry;
584 
585  return *II;
586  }
587 
588  IdentifierInfo &get(StringRef Name, tok::TokenKind TokenCode) {
589  IdentifierInfo &II = get(Name);
590  II.TokenID = TokenCode;
591  assert(II.TokenID == (unsigned) TokenCode && "TokenCode too large");
592  return II;
593  }
594 
595  /// Gets an IdentifierInfo for the given name without consulting
596  /// external sources.
597  ///
598  /// This is a version of get() meant for external sources that want to
599  /// introduce or modify an identifier. If they called get(), they would
600  /// likely end up in a recursion.
601  IdentifierInfo &getOwn(StringRef Name) {
602  auto &Entry = *HashTable.insert(std::make_pair(Name, nullptr)).first;
603 
604  IdentifierInfo *&II = Entry.second;
605  if (II)
606  return *II;
607 
608  // Lookups failed, make a new IdentifierInfo.
609  void *Mem = getAllocator().Allocate<IdentifierInfo>();
610  II = new (Mem) IdentifierInfo();
611 
612  // Make sure getName() knows how to find the IdentifierInfo
613  // contents.
614  II->Entry = &Entry;
615 
616  // If this is the 'import' contextual keyword, mark it as such.
617  if (Name.equals("import"))
618  II->setModulesImport(true);
619 
620  return *II;
621  }
622 
623  using iterator = HashTableTy::const_iterator;
624  using const_iterator = HashTableTy::const_iterator;
625 
626  iterator begin() const { return HashTable.begin(); }
627  iterator end() const { return HashTable.end(); }
628  unsigned size() const { return HashTable.size(); }
629 
630  iterator find(StringRef Name) const { return HashTable.find(Name); }
631 
632  /// Print some statistics to stderr that indicate how well the
633  /// hashing is doing.
634  void PrintStats() const;
635 
636  /// Populate the identifier table with info about the language keywords
637  /// for the language specified by \p LangOpts.
638  void AddKeywords(const LangOptions &LangOpts);
639 };
640 
641 /// A family of Objective-C methods.
642 ///
643 /// These families have no inherent meaning in the language, but are
644 /// nonetheless central enough in the existing implementations to
645 /// merit direct AST support. While, in theory, arbitrary methods can
646 /// be considered to form families, we focus here on the methods
647 /// involving allocation and retain-count management, as these are the
648 /// most "core" and the most likely to be useful to diverse clients
649 /// without extra information.
650 ///
651 /// Both selectors and actual method declarations may be classified
652 /// into families. Method families may impose additional restrictions
653 /// beyond their selector name; for example, a method called '_init'
654 /// that returns void is not considered to be in the 'init' family
655 /// (but would be if it returned 'id'). It is also possible to
656 /// explicitly change or remove a method's family. Therefore the
657 /// method's family should be considered the single source of truth.
659  /// No particular method family.
661 
662  // Selectors in these families may have arbitrary arity, may be
663  // written with arbitrary leading underscores, and may have
664  // additional CamelCase "words" in their first selector chunk
665  // following the family name.
671 
672  // These families are singletons consisting only of the nullary
673  // selector with the given name.
682 
683  // performSelector families
685 };
686 
687 /// Enough bits to store any enumerator in ObjCMethodFamily or
688 /// InvalidObjCMethodFamily.
690 
691 /// An invalid value of ObjCMethodFamily.
693 
694 /// A family of Objective-C methods.
695 ///
696 /// These are family of methods whose result type is initially 'id', but
697 /// but are candidate for the result type to be changed to 'instancetype'.
705 };
706 
711 };
712 
713 /// Smart pointer class that efficiently represents Objective-C method
714 /// names.
715 ///
716 /// This class will either point to an IdentifierInfo or a
717 /// MultiKeywordSelector (which is private). This enables us to optimize
718 /// selectors that take no arguments and selectors that take 1 argument, which
719 /// accounts for 78% of all selectors in Cocoa.h.
720 class Selector {
721  friend class Diagnostic;
722  friend class SelectorTable; // only the SelectorTable can create these
723  friend class DeclarationName; // and the AST's DeclarationName.
724 
725  enum IdentifierInfoFlag {
726  // Empty selector = 0. Note that these enumeration values must
727  // correspond to the enumeration values of DeclarationName::StoredNameKind
728  ZeroArg = 0x01,
729  OneArg = 0x02,
730  MultiArg = 0x07,
731  ArgFlags = 0x07
732  };
733 
734  /// A pointer to the MultiKeywordSelector or IdentifierInfo. We use the low
735  /// three bits of InfoPtr to store an IdentifierInfoFlag. Note that in any
736  /// case IdentifierInfo and MultiKeywordSelector are already aligned to
737  /// 8 bytes even on 32 bits archs because of DeclarationName.
738  uintptr_t InfoPtr = 0;
739 
740  Selector(IdentifierInfo *II, unsigned nArgs) {
741  InfoPtr = reinterpret_cast<uintptr_t>(II);
742  assert((InfoPtr & ArgFlags) == 0 &&"Insufficiently aligned IdentifierInfo");
743  assert(nArgs < 2 && "nArgs not equal to 0/1");
744  InfoPtr |= nArgs+1;
745  }
746 
747  Selector(MultiKeywordSelector *SI) {
748  InfoPtr = reinterpret_cast<uintptr_t>(SI);
749  assert((InfoPtr & ArgFlags) == 0 &&"Insufficiently aligned IdentifierInfo");
750  InfoPtr |= MultiArg;
751  }
752 
753  IdentifierInfo *getAsIdentifierInfo() const {
754  if (getIdentifierInfoFlag() < MultiArg)
755  return reinterpret_cast<IdentifierInfo *>(InfoPtr & ~ArgFlags);
756  return nullptr;
757  }
758 
759  MultiKeywordSelector *getMultiKeywordSelector() const {
760  return reinterpret_cast<MultiKeywordSelector *>(InfoPtr & ~ArgFlags);
761  }
762 
763  unsigned getIdentifierInfoFlag() const {
764  return InfoPtr & ArgFlags;
765  }
766 
767  static ObjCMethodFamily getMethodFamilyImpl(Selector sel);
768 
769  static ObjCStringFormatFamily getStringFormatFamilyImpl(Selector sel);
770 
771 public:
772  /// The default ctor should only be used when creating data structures that
773  /// will contain selectors.
774  Selector() = default;
775  explicit Selector(uintptr_t V) : InfoPtr(V) {}
776 
777  /// operator==/!= - Indicate whether the specified selectors are identical.
778  bool operator==(Selector RHS) const {
779  return InfoPtr == RHS.InfoPtr;
780  }
781  bool operator!=(Selector RHS) const {
782  return InfoPtr != RHS.InfoPtr;
783  }
784 
785  void *getAsOpaquePtr() const {
786  return reinterpret_cast<void*>(InfoPtr);
787  }
788 
789  /// Determine whether this is the empty selector.
790  bool isNull() const { return InfoPtr == 0; }
791 
792  // Predicates to identify the selector type.
793  bool isKeywordSelector() const {
794  return getIdentifierInfoFlag() != ZeroArg;
795  }
796 
797  bool isUnarySelector() const {
798  return getIdentifierInfoFlag() == ZeroArg;
799  }
800 
801  /// If this selector is the specific keyword selector described by Names.
802  bool isKeywordSelector(ArrayRef<StringRef> Names) const;
803 
804  /// If this selector is the specific unary selector described by Name.
805  bool isUnarySelector(StringRef Name) const;
806 
807  unsigned getNumArgs() const;
808 
809  /// Retrieve the identifier at a given position in the selector.
810  ///
811  /// Note that the identifier pointer returned may be NULL. Clients that only
812  /// care about the text of the identifier string, and not the specific,
813  /// uniqued identifier pointer, should use \c getNameForSlot(), which returns
814  /// an empty string when the identifier pointer would be NULL.
815  ///
816  /// \param argIndex The index for which we want to retrieve the identifier.
817  /// This index shall be less than \c getNumArgs() unless this is a keyword
818  /// selector, in which case 0 is the only permissible value.
819  ///
820  /// \returns the uniqued identifier for this slot, or NULL if this slot has
821  /// no corresponding identifier.
822  IdentifierInfo *getIdentifierInfoForSlot(unsigned argIndex) const;
823 
824  /// Retrieve the name at a given position in the selector.
825  ///
826  /// \param argIndex The index for which we want to retrieve the name.
827  /// This index shall be less than \c getNumArgs() unless this is a keyword
828  /// selector, in which case 0 is the only permissible value.
829  ///
830  /// \returns the name for this slot, which may be the empty string if no
831  /// name was supplied.
832  StringRef getNameForSlot(unsigned argIndex) const;
833 
834  /// Derive the full selector name (e.g. "foo:bar:") and return
835  /// it as an std::string.
836  std::string getAsString() const;
837 
838  /// Prints the full selector name (e.g. "foo:bar:").
839  void print(llvm::raw_ostream &OS) const;
840 
841  void dump() const;
842 
843  /// Derive the conventional family of this method.
845  return getMethodFamilyImpl(*this);
846  }
847 
849  return getStringFormatFamilyImpl(*this);
850  }
851 
853  return Selector(uintptr_t(-1));
854  }
855 
857  return Selector(uintptr_t(-2));
858  }
859 
860  static ObjCInstanceTypeFamily getInstTypeMethodFamily(Selector sel);
861 };
862 
863 /// This table allows us to fully hide how we implement
864 /// multi-keyword caching.
866  // Actually a SelectorTableImpl
867  void *Impl;
868 
869 public:
870  SelectorTable();
871  SelectorTable(const SelectorTable &) = delete;
872  SelectorTable &operator=(const SelectorTable &) = delete;
873  ~SelectorTable();
874 
875  /// Can create any sort of selector.
876  ///
877  /// \p NumArgs indicates whether this is a no argument selector "foo", a
878  /// single argument selector "foo:" or multi-argument "foo:bar:".
879  Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV);
880 
882  return Selector(ID, 1);
883  }
884 
886  return Selector(ID, 0);
887  }
888 
889  /// Return the total amount of memory allocated for managing selectors.
890  size_t getTotalMemory() const;
891 
892  /// Return the default setter name for the given identifier.
893  ///
894  /// This is "set" + \p Name where the initial character of \p Name
895  /// has been capitalized.
896  static SmallString<64> constructSetterName(StringRef Name);
897 
898  /// Return the default setter selector for the given identifier.
899  ///
900  /// This is "set" + \p Name where the initial character of \p Name
901  /// has been capitalized.
902  static Selector constructSetterSelector(IdentifierTable &Idents,
903  SelectorTable &SelTable,
904  const IdentifierInfo *Name);
905 
906  /// Return the property name for the given setter selector.
907  static std::string getPropertyNameFromSetterSelector(Selector Sel);
908 };
909 
910 namespace detail {
911 
912 /// DeclarationNameExtra is used as a base of various uncommon special names.
913 /// This class is needed since DeclarationName has not enough space to store
914 /// the kind of every possible names. Therefore the kind of common names is
915 /// stored directly in DeclarationName, and the kind of uncommon names is
916 /// stored in DeclarationNameExtra. It is aligned to 8 bytes because
917 /// DeclarationName needs the lower 3 bits to store the kind of common names.
918 /// DeclarationNameExtra is tightly coupled to DeclarationName and any change
919 /// here is very likely to require changes in DeclarationName(Table).
920 class alignas(IdentifierInfoAlignment) DeclarationNameExtra {
923 
924 protected:
925  /// The kind of "extra" information stored in the DeclarationName. See
926  /// @c ExtraKindOrNumArgs for an explanation of how these enumerator values
927  /// are used. Note that DeclarationName depends on the numerical values
928  /// of the enumerators in this enum. See DeclarationName::StoredNameKind
929  /// for more info.
930  enum ExtraKind {
934  ObjCMultiArgSelector
935  };
936 
937  /// ExtraKindOrNumArgs has one of the following meaning:
938  /// * The kind of an uncommon C++ special name. This DeclarationNameExtra
939  /// is in this case in fact either a CXXDeductionGuideNameExtra or
940  /// a CXXLiteralOperatorIdName.
941  ///
942  /// * It may be also name common to C++ using-directives (CXXUsingDirective),
943  ///
944  /// * Otherwise it is ObjCMultiArgSelector+NumArgs, where NumArgs is
945  /// the number of arguments in the Objective-C selector, in which
946  /// case the DeclarationNameExtra is also a MultiKeywordSelector.
948 
949  DeclarationNameExtra(ExtraKind Kind) : ExtraKindOrNumArgs(Kind) {}
950  DeclarationNameExtra(unsigned NumArgs)
951  : ExtraKindOrNumArgs(ObjCMultiArgSelector + NumArgs) {}
952 
953  /// Return the corresponding ExtraKind.
954  ExtraKind getKind() const {
955  return static_cast<ExtraKind>(ExtraKindOrNumArgs >
956  (unsigned)ObjCMultiArgSelector
957  ? (unsigned)ObjCMultiArgSelector
958  : ExtraKindOrNumArgs);
959  }
960 
961  /// Return the number of arguments in an ObjC selector. Only valid when this
962  /// is indeed an ObjCMultiArgSelector.
963  unsigned getNumArgs() const {
964  assert(ExtraKindOrNumArgs >= (unsigned)ObjCMultiArgSelector &&
965  "getNumArgs called but this is not an ObjC selector!");
966  return ExtraKindOrNumArgs - (unsigned)ObjCMultiArgSelector;
967  }
968 };
969 
970 } // namespace detail
971 
972 } // namespace clang
973 
974 namespace llvm {
975 
976 /// Define DenseMapInfo so that Selectors can be used as keys in DenseMap and
977 /// DenseSets.
978 template <>
979 struct DenseMapInfo<clang::Selector> {
982  }
983 
986  }
987 
988  static unsigned getHashValue(clang::Selector S);
989 
990  static bool isEqual(clang::Selector LHS, clang::Selector RHS) {
991  return LHS == RHS;
992  }
993 };
994 
995 template<>
996 struct PointerLikeTypeTraits<clang::Selector> {
997  static const void *getAsVoidPointer(clang::Selector P) {
998  return P.getAsOpaquePtr();
999  }
1000 
1001  static clang::Selector getFromVoidPointer(const void *P) {
1002  return clang::Selector(reinterpret_cast<uintptr_t>(P));
1003  }
1004 
1005  static constexpr int NumLowBitsAvailable = 0;
1006 };
1007 
1008 // Provide PointerLikeTypeTraits for IdentifierInfo pointers, which
1009 // are not guaranteed to be 8-byte aligned.
1010 template<>
1011 struct PointerLikeTypeTraits<clang::IdentifierInfo*> {
1013  return P;
1014  }
1015 
1017  return static_cast<clang::IdentifierInfo*>(P);
1018  }
1019 
1020  static constexpr int NumLowBitsAvailable = 1;
1021 };
1022 
1023 template<>
1024 struct PointerLikeTypeTraits<const clang::IdentifierInfo*> {
1025  static const void *getAsVoidPointer(const clang::IdentifierInfo* P) {
1026  return P;
1027  }
1028 
1029  static const clang::IdentifierInfo *getFromVoidPointer(const void *P) {
1030  return static_cast<const clang::IdentifierInfo*>(P);
1031  }
1032 
1033  static constexpr int NumLowBitsAvailable = 1;
1034 };
1035 
1036 } // namespace llvm
1037 
1038 #endif // LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
clang::IdentifierInfo::hasMacroDefinition
bool hasMacroDefinition() const
Return true if this identifier is #defined to some other value.
Definition: IdentifierTable.h:181
clang::detail::DeclarationNameExtra::CXXUsingDirective
@ CXXUsingDirective
Definition: IdentifierTable.h:933
llvm
Definition: Dominators.h:30
clang::IdentifierTable::find
iterator find(StringRef Name) const
Definition: IdentifierTable.h:630
clang::OMF_autorelease
@ OMF_autorelease
Definition: IdentifierTable.h:674
clang::IdentifierInfoAlignment
@ IdentifierInfoAlignment
Definition: IdentifierTable.h:57
clang::ReservedIdentifierStatus::StartsWithUnderscoreAtGlobalScope
@ StartsWithUnderscoreAtGlobalScope
clang::IdentifierInfo::setChangedSinceDeserialization
void setChangedSinceDeserialization()
Note that this identifier has changed since it was loaded from an AST file.
Definition: IdentifierTable.h:368
clang::IdentifierInfo::setModulesImport
void setModulesImport(bool I)
Set whether this identifier is the contextual keyword import.
Definition: IdentifierTable.h:402
clang::detail::DeclarationNameExtra::getKind
ExtraKind getKind() const
Return the corresponding ExtraKind.
Definition: IdentifierTable.h:954
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::ObjCMethodFamily
ObjCMethodFamily
A family of Objective-C methods.
Definition: IdentifierTable.h:658
clang::IdentifierInfo::revertIdentifierToTokenID
void revertIdentifierToTokenID(tok::TokenKind TK)
Definition: IdentifierTable.h:249
clang::ReservedIdentifierStatus::NotReserved
@ NotReserved
llvm::DenseMapInfo< clang::Selector >::getTombstoneKey
static clang::Selector getTombstoneKey()
Definition: IdentifierTable.h:984
clang::IdentifierTable::const_iterator
HashTableTy::const_iterator const_iterator
Definition: IdentifierTable.h:624
clang::IdentifierTable::iterator
HashTableTy::const_iterator iterator
Definition: IdentifierTable.h:623
clang::IdentifierTable::get
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
Definition: IdentifierTable.h:564
clang::OMF_None
@ OMF_None
No particular method family.
Definition: IdentifierTable.h:660
clang::OMF_release
@ OMF_release
Definition: IdentifierTable.h:677
clang::ObjCOrBuiltinIDBits
static constexpr int ObjCOrBuiltinIDBits
Definition: IdentifierTable.h:59
clang::IdentifierTable::get
IdentifierInfo & get(StringRef Name, tok::TokenKind TokenCode)
Definition: IdentifierTable.h:588
clang::PoisonIdentifierRAIIObject::~PoisonIdentifierRAIIObject
~PoisonIdentifierRAIIObject()
Definition: IdentifierTable.h:467
clang::IdentifierInfo::setHasMacroDefinition
void setHasMacroDefinition(bool Val)
Definition: IdentifierTable.h:184
clang::ObjCInstanceTypeFamily
ObjCInstanceTypeFamily
A family of Objective-C methods.
Definition: IdentifierTable.h:698
clang::Selector::isUnarySelector
bool isUnarySelector() const
Definition: IdentifierTable.h:797
clang::OMF_finalize
@ OMF_finalize
Definition: IdentifierTable.h:676
clang::OMF_init
@ OMF_init
Definition: IdentifierTable.h:668
llvm::PointerLikeTypeTraits< clang::IdentifierInfo * >::getFromVoidPointer
static clang::IdentifierInfo * getFromVoidPointer(void *P)
Definition: IdentifierTable.h:1016
clang::detail::DeclarationNameExtra::getNumArgs
unsigned getNumArgs() const
Return the number of arguments in an ObjC selector.
Definition: IdentifierTable.h:963
clang::ReservedIdentifierStatus::ContainsDoubleUnderscore
@ ContainsDoubleUnderscore
clang::detail::DeclarationNameExtra::DeclarationNameExtra
DeclarationNameExtra(ExtraKind Kind)
Definition: IdentifierTable.h:949
clang::detail::DeclarationNameExtra::ExtraKindOrNumArgs
unsigned ExtraKindOrNumArgs
ExtraKindOrNumArgs has one of the following meaning:
Definition: IdentifierTable.h:947
clang::IdentifierInfo::isOutOfDate
bool isOutOfDate() const
Determine whether the information for this identifier is out of date with respect to the external sou...
Definition: IdentifierTable.h:386
clang::OMF_retainCount
@ OMF_retainCount
Definition: IdentifierTable.h:679
clang::IdentifierInfo::isFromAST
bool isFromAST() const
Return true if the identifier in its current state was loaded from an AST file.
Definition: IdentifierTable.h:356
print
void print(llvm::raw_ostream &OS, const Pointer &P, ASTContext &Ctx, QualType Ty)
Definition: InterpFrame.cpp:62
clang::IdentifierInfo::getTokenID
tok::TokenKind getTokenID() const
If this is a source-language token (e.g.
Definition: IdentifierTable.h:233
clang::IdentifierInfo::isCPlusPlusOperatorKeyword
bool isCPlusPlusOperatorKeyword() const
Definition: IdentifierTable.h:333
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:145
llvm::DenseMapInfo< clang::Selector >::getEmptyKey
static clang::Selector getEmptyKey()
Definition: IdentifierTable.h:980
clang::SFF_CFString
@ SFF_CFString
Definition: IdentifierTable.h:710
clang::ReservedIdentifierStatus::StartsWithUnderscoreFollowedByCapitalLetter
@ StartsWithUnderscoreFollowedByCapitalLetter
clang::IdentifierInfoLookup::get
virtual IdentifierInfo * get(StringRef Name)=0
Return the IdentifierInfo for the specified named identifier.
clang::IdentifierTable::getOwn
IdentifierInfo & getOwn(StringRef Name)
Gets an IdentifierInfo for the given name without consulting external sources.
Definition: IdentifierTable.h:601
clang::Diagnostic
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
Definition: Diagnostic.h:1532
llvm::DenseMapInfo
Definition: TypeOrdering.h:37
clang::OIT_ReturnsSelf
@ OIT_ReturnsSelf
Definition: IdentifierTable.h:704
TokenKinds.h
clang::OMF_copy
@ OMF_copy
Definition: IdentifierTable.h:667
clang::IdentifierInfo::isStr
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Definition: IdentifierTable.h:156
clang::OIT_Dictionary
@ OIT_Dictionary
Definition: IdentifierTable.h:701
clang::getAsString
llvm::StringRef getAsString(SyncScope S)
Definition: SyncScope.h:50
V
#define V(N, I)
Definition: ASTContext.h:3113
clang::OIT_Array
@ OIT_Array
Definition: IdentifierTable.h:700
clang::OMF_retain
@ OMF_retain
Definition: IdentifierTable.h:678
clang::Selector::getStringFormatFamily
ObjCStringFormatFamily getStringFormatFamily() const
Definition: IdentifierTable.h:848
clang::OMF_dealloc
@ OMF_dealloc
Definition: IdentifierTable.h:675
clang::OIT_Init
@ OIT_Init
Definition: IdentifierTable.h:703
clang::IdentifierInfo::hasChangedSinceDeserialization
bool hasChangedSinceDeserialization() const
Determine whether this identifier has changed since it was loaded from an AST file.
Definition: IdentifierTable.h:362
clang::IdentifierInfo::setIsFutureCompatKeyword
void setIsFutureCompatKeyword(bool Val)
Definition: IdentifierTable.h:307
clang::IdentifierInfo::setIsPoisoned
void setIsPoisoned(bool Value=true)
setIsPoisoned - Mark this identifier as poisoned.
Definition: IdentifierTable.h:317
clang::ReservedIdentifierStatus
ReservedIdentifierStatus
Definition: IdentifierTable.h:43
llvm::PointerLikeTypeTraits< const clang::IdentifierInfo * >::getFromVoidPointer
static const clang::IdentifierInfo * getFromVoidPointer(const void *P)
Definition: IdentifierTable.h:1029
clang::detail::DeclarationNameExtra
DeclarationNameExtra is used as a base of various uncommon special names.
Definition: IdentifierTable.h:920
clang::IdentifierInfo::getLength
unsigned getLength() const
Efficiently return the length of this identifier info.
Definition: IdentifierTable.h:172
clang::detail::DeclarationNameExtra::CXXLiteralOperatorName
@ CXXLiteralOperatorName
Definition: IdentifierTable.h:932
uintptr_t
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Definition: opencl-c-base.h:124
clang::ObjCMethodFamilyBitWidth
@ ObjCMethodFamilyBitWidth
Definition: IdentifierTable.h:689
clang::Selector::operator!=
bool operator!=(Selector RHS) const
Definition: IdentifierTable.h:781
clang::PoisonIdentifierRAIIObject::PoisonIdentifierRAIIObject
PoisonIdentifierRAIIObject(IdentifierInfo *II, bool NewValue)
Definition: IdentifierTable.h:461
llvm::SmallString
Definition: LLVM.h:37
clang::SelectorTable
This table allows us to fully hide how we implement multi-keyword caching.
Definition: IdentifierTable.h:865
clang::IdentifierIterator
An iterator that walks over all of the known identifiers in the lookup table.
Definition: IdentifierTable.h:483
clang::IdentifierInfo::setObjCKeywordID
void setObjCKeywordID(tok::ObjCKeywordKind ID)
Definition: IdentifierTable.h:269
clang::InvalidObjCMethodFamily
@ InvalidObjCMethodFamily
Definition: IdentifierTable.h:692
clang::IdentifierLocPair
std::pair< IdentifierInfo *, SourceLocation > IdentifierLocPair
A simple pair of identifier info and location.
Definition: IdentifierTable.h:52
clang::tok::ObjCKeywordKind
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
Definition: TokenKinds.h:41
clang::SFF_NSString
@ SFF_NSString
Definition: IdentifierTable.h:709
clang::IdentifierInfo::setIsCPlusPlusOperatorKeyword
void setIsCPlusPlusOperatorKeyword(bool Val=true)
isCPlusPlusOperatorKeyword/setIsCPlusPlusOperatorKeyword controls whether this identifier is a C++ al...
Definition: IdentifierTable.h:330
clang::OMF_initialize
@ OMF_initialize
Definition: IdentifierTable.h:681
clang::IdentifierInfo::getObjCKeywordID
tok::ObjCKeywordKind getObjCKeywordID() const
Return the Objective-C keyword ID for the this identifier.
Definition: IdentifierTable.h:263
getName
static std::string getName(const CallEvent &Call)
Definition: ReturnValueChecker.cpp:60
clang::Selector::getMethodFamily
ObjCMethodFamily getMethodFamily() const
Derive the conventional family of this method.
Definition: IdentifierTable.h:844
clang::IdentifierInfo::getBuiltinID
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
Definition: IdentifierTable.h:274
clang::IdentifierInfo::setFETokenInfo
void setFETokenInfo(void *T)
Definition: IdentifierTable.h:345
clang::OMF_self
@ OMF_self
Definition: IdentifierTable.h:680
clang::IdentifierInfo::setIsDeprecatedMacro
void setIsDeprecatedMacro(bool Val)
Definition: IdentifierTable.h:208
clang::IdentifierTable::getAllocator
llvm::BumpPtrAllocator & getAllocator()
Definition: IdentifierTable.h:558
clang::IdentifierInfo::operator<
bool operator<(const IdentifierInfo &RHS) const
Provide less than operator for lexicographical sorting.
Definition: IdentifierTable.h:434
clang::Selector::operator==
bool operator==(Selector RHS) const
operator==/!= - Indicate whether the specified selectors are identical.
Definition: IdentifierTable.h:778
clang::OMF_performSelector
@ OMF_performSelector
Definition: IdentifierTable.h:684
clang::IdentifierInfo::hasFETokenInfoChangedSinceDeserialization
bool hasFETokenInfoChangedSinceDeserialization() const
Determine whether the frontend token information for this identifier has changed since it was loaded ...
Definition: IdentifierTable.h:374
clang::IdentifierTable::getExternalIdentifierLookup
IdentifierInfoLookup * getExternalIdentifierLookup() const
Retrieve the external identifier lookup object, if any.
Definition: IdentifierTable.h:554
clang::tok::TokenKind
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Definition: TokenKinds.h:25
P
StringRef P
Definition: ASTMatchersInternal.cpp:563
clang::IdentifierInfo::isStr
bool isStr(llvm::StringRef Str) const
Return true if this is the identifier for the specified StringRef.
Definition: IdentifierTable.h:162
llvm::PointerLikeTypeTraits< const clang::IdentifierInfo * >::getAsVoidPointer
static const void * getAsVoidPointer(const clang::IdentifierInfo *P)
Definition: IdentifierTable.h:1025
false
#define false
Definition: stdbool.h:17
llvm::DenseMapInfo< clang::Selector >::isEqual
static bool isEqual(clang::Selector LHS, clang::Selector RHS)
Definition: IdentifierTable.h:990
clang::detail::DeclarationNameExtra::CXXDeductionGuideName
@ CXXDeductionGuideName
Definition: IdentifierTable.h:931
clang::IdentifierInfo::isRestrictExpansion
bool isRestrictExpansion() const
Definition: IdentifierTable.h:218
clang::IdentifierInfo::isPoisoned
bool isPoisoned() const
Return true if this token has been poisoned.
Definition: IdentifierTable.h:326
dump
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
Definition: CoverageMappingGen.cpp:1521
clang::IdentifierTable::begin
iterator begin() const
Definition: IdentifierTable.h:626
llvm::ArrayRef
Definition: LLVM.h:34
Value
Value
Definition: UninitializedValues.cpp:102
clang::IdentifierInfo::setFETokenInfoChangedSinceDeserialization
void setFETokenInfoChangedSinceDeserialization()
Note that the frontend token information for this identifier has changed since it was loaded from an ...
Definition: IdentifierTable.h:380
clang::tok::PPKeywordKind
PPKeywordKind
Provides a namespace for preprocessor keywords which start with a '#' at the beginning of the line.
Definition: TokenKinds.h:33
clang::IdentifierInfo::isMangledOpenMPVariantName
bool isMangledOpenMPVariantName() const
Determine whether this is the mangled name of an OpenMP variant.
Definition: IdentifierTable.h:411
LLVM.h
clang::Selector::Selector
Selector(uintptr_t V)
Definition: IdentifierTable.h:775
clang::IdentifierTable::setExternalIdentifierLookup
void setExternalIdentifierLookup(IdentifierInfoLookup *IILookup)
Set the external identifier lookup mechanism.
Definition: IdentifierTable.h:549
clang::detail::DeclarationNameExtra::DeclarationNameExtra
DeclarationNameExtra(unsigned NumArgs)
Definition: IdentifierTable.h:950
clang::IdentifierInfo::setIsRestrictExpansion
void setIsRestrictExpansion(bool Val)
Definition: IdentifierTable.h:220
clang::detail::DeclarationNameExtra::ExtraKind
ExtraKind
The kind of "extra" information stored in the DeclarationName.
Definition: IdentifierTable.h:930
llvm::PointerLikeTypeTraits< clang::Selector >::getFromVoidPointer
static clang::Selector getFromVoidPointer(const void *P)
Definition: IdentifierTable.h:1001
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:67
clang::Selector::getEmptyMarker
static Selector getEmptyMarker()
Definition: IdentifierTable.h:852
clang::IdentifierInfo::isHandleIdentifierCase
bool isHandleIdentifierCase() const
Return true if the Preprocessor::HandleIdentifier must be called on a token of this identifier.
Definition: IdentifierTable.h:352
clang::IdentifierInfo::getObjCOrBuiltinID
unsigned getObjCOrBuiltinID() const
Definition: IdentifierTable.h:286
clang::OMF_new
@ OMF_new
Definition: IdentifierTable.h:670
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:58
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::IdentifierInfo::getNameStart
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
Definition: IdentifierTable.h:169
clang::PoisonIdentifierRAIIObject
An RAII object for [un]poisoning an identifier within a scope.
Definition: IdentifierTable.h:456
clang::SelectorTable::getNullarySelector
Selector getNullarySelector(IdentifierInfo *ID)
Definition: IdentifierTable.h:885
clang::SelectorTable::getUnarySelector
Selector getUnarySelector(IdentifierInfo *ID)
Definition: IdentifierTable.h:881
clang::ObjCStringFormatFamily
ObjCStringFormatFamily
Definition: IdentifierTable.h:707
clang::IdentifierInfo::setMangledOpenMPVariantName
void setMangledOpenMPVariantName(bool I)
Set whether this is the mangled name of an OpenMP variant.
Definition: IdentifierTable.h:414
llvm::PointerLikeTypeTraits< clang::Selector >::getAsVoidPointer
static const void * getAsVoidPointer(clang::Selector P)
Definition: IdentifierTable.h:997
clang::IdentifierInfo::getName
StringRef getName() const
Return the actual identifier string.
Definition: IdentifierTable.h:175
clang::Builtin::ID
ID
Definition: Builtins.h:48
clang::Selector::isNull
bool isNull() const
Determine whether this is the empty selector.
Definition: IdentifierTable.h:790
clang
Definition: CalledOnceCheck.h:17
clang::IdentifierInfo::getFETokenInfo
void * getFETokenInfo() const
Get and set FETokenInfo.
Definition: IdentifierTable.h:344
clang::Selector
Smart pointer class that efficiently represents Objective-C method names.
Definition: IdentifierTable.h:720
clang::IdentifierInfo::hadMacroDefinition
bool hadMacroDefinition() const
Returns true if this identifier was #defined to some value at any moment.
Definition: IdentifierTable.h:202
clang::OMF_alloc
@ OMF_alloc
Definition: IdentifierTable.h:666
clang::IdentifierInfo::setIsFromAST
void setIsFromAST()
Definition: IdentifierTable.h:358
clang::tok::NUM_OBJC_KEYWORDS
@ NUM_OBJC_KEYWORDS
Definition: TokenKinds.h:44
clang::OMF_mutableCopy
@ OMF_mutableCopy
Definition: IdentifierTable.h:669
clang::IdentifierTable
Implements an efficient mapping from strings to IdentifierInfo nodes.
Definition: IdentifierTable.h:531
clang::Selector::isKeywordSelector
bool isKeywordSelector() const
Definition: IdentifierTable.h:793
clang::IdentifierInfo::setBuiltinID
void setBuiltinID(unsigned ID)
Definition: IdentifierTable.h:280
clang::IdentifierInfoLookup
Provides lookups to, and iteration over, IdentiferInfo objects.
Definition: IdentifierTable.h:502
unsigned
llvm::PointerLikeTypeTraits
Definition: DeclGroup.h:139
clang::IdentifierInfo::isModulesImport
bool isModulesImport() const
Determine whether this is the contextual keyword import.
Definition: IdentifierTable.h:399
clang::IdentifierInfo::isExtensionToken
bool isExtensionToken() const
get/setExtension - Initialize information about whether or not this language token is an extension.
Definition: IdentifierTable.h:292
clang::IdentifierInfo::setOutOfDate
void setOutOfDate(bool OOD)
Set whether the information for this identifier is out of date with respect to the external source.
Definition: IdentifierTable.h:390
llvm::PointerLikeTypeTraits< clang::IdentifierInfo * >::getAsVoidPointer
static void * getAsVoidPointer(clang::IdentifierInfo *P)
Definition: IdentifierTable.h:1012
clang::IdentifierInfo::isFutureCompatKeyword
bool isFutureCompatKeyword() const
is/setIsFutureCompatKeyword - Initialize information about whether or not this language token is a ke...
Definition: IdentifierTable.h:306
clang::IdentifierTable::end
iterator end() const
Definition: IdentifierTable.h:627
clang::SFF_None
@ SFF_None
Definition: IdentifierTable.h:708
clang::IdentifierInfo::hasRevertedTokenIDToIdentifier
bool hasRevertedTokenIDToIdentifier() const
True if revertTokenIDToIdentifier() was called.
Definition: IdentifierTable.h:236
clang::IdentifierInfo::revertTokenIDToIdentifier
void revertTokenIDToIdentifier()
Revert TokenID to tok::identifier; used for GNU libstdc++ 4.2 compatibility.
Definition: IdentifierTable.h:244
clang::OIT_Singleton
@ OIT_Singleton
Definition: IdentifierTable.h:702
clang::Selector::getTombstoneMarker
static Selector getTombstoneMarker()
Definition: IdentifierTable.h:856
clang::IdentifierInfo::setObjCOrBuiltinID
void setObjCOrBuiltinID(unsigned ID)
Definition: IdentifierTable.h:287
clang::IdentifierInfo::isEditorPlaceholder
bool isEditorPlaceholder() const
Return true if this identifier is an editor placeholder.
Definition: IdentifierTable.h:425
clang::Selector::getAsOpaquePtr
void * getAsOpaquePtr() const
Definition: IdentifierTable.h:785
clang::DeclarationNameTable
DeclarationNameTable is used to store and retrieve DeclarationName instances for the various kinds of...
Definition: DeclarationName.h:567
clang::IdentifierInfo::isDeprecatedMacro
bool isDeprecatedMacro() const
Definition: IdentifierTable.h:206
clang::OIT_None
@ OIT_None
Definition: IdentifierTable.h:699
clang::ReservedIdentifierStatus::StartsWithDoubleUnderscore
@ StartsWithDoubleUnderscore
clang::IdentifierInfo::setIsExtensionToken
void setIsExtensionToken(bool Val)
Definition: IdentifierTable.h:293
clang::IdentifierTable::size
unsigned size() const
Definition: IdentifierTable.h:628