Coverage Report

Created: 2019-07-24 05:18

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