Coverage Report

Created: 2018-07-20 23:04

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/AST/DeclarationName.h
Line
Count
Source (jump to first uncovered line)
1
//===- DeclarationName.h - Representation of declaration names --*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file declares the DeclarationName and DeclarationNameTable classes.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CLANG_AST_DECLARATIONNAME_H
15
#define LLVM_CLANG_AST_DECLARATIONNAME_H
16
17
#include "clang/Basic/Diagnostic.h"
18
#include "clang/Basic/IdentifierTable.h"
19
#include "clang/Basic/PartialDiagnostic.h"
20
#include "clang/Basic/SourceLocation.h"
21
#include "llvm/ADT/DenseMapInfo.h"
22
#include "llvm/Support/Compiler.h"
23
#include "llvm/Support/type_traits.h"
24
#include <cassert>
25
#include <cstdint>
26
#include <cstring>
27
#include <string>
28
29
namespace clang {
30
31
class ASTContext;
32
template <typename> class CanQual;
33
class CXXDeductionGuideNameExtra;
34
class CXXLiteralOperatorIdName;
35
class CXXOperatorIdName;
36
class CXXSpecialName;
37
class DeclarationNameExtra;
38
class IdentifierInfo;
39
class MultiKeywordSelector;
40
enum OverloadedOperatorKind : int;
41
struct PrintingPolicy;
42
class QualType;
43
class TemplateDecl;
44
class Type;
45
class TypeSourceInfo;
46
class UsingDirectiveDecl;
47
48
using CanQualType = CanQual<Type>;
49
50
/// DeclarationName - The name of a declaration. In the common case,
51
/// this just stores an IdentifierInfo pointer to a normal
52
/// name. However, it also provides encodings for Objective-C
53
/// selectors (optimizing zero- and one-argument selectors, which make
54
/// up 78% percent of all selectors in Cocoa.h) and special C++ names
55
/// for constructors, destructors, and conversion functions.
56
0
class DeclarationName {
Unexecuted instantiation: clang::DeclarationName::operator=(clang::DeclarationName const&)
Unexecuted instantiation: clang::DeclarationName::operator=(clang::DeclarationName&&)
57
public:
58
  /// NameKind - The kind of name this object contains.
59
  enum NameKind {
60
    Identifier,
61
    ObjCZeroArgSelector,
62
    ObjCOneArgSelector,
63
    ObjCMultiArgSelector,
64
    CXXConstructorName,
65
    CXXDestructorName,
66
    CXXConversionFunctionName,
67
    CXXDeductionGuideName,
68
    CXXOperatorName,
69
    CXXLiteralOperatorName,
70
    CXXUsingDirective
71
  };
72
73
  static const unsigned NumNameKinds = CXXUsingDirective + 1;
74
75
private:
76
  friend class DeclarationNameTable;
77
  friend class NamedDecl;
78
79
  /// StoredNameKind - The kind of name that is actually stored in the
80
  /// upper bits of the Ptr field. This is only used internally.
81
  ///
82
  /// Note: The entries here are synchronized with the entries in Selector,
83
  /// for efficient translation between the two.
84
  enum StoredNameKind {
85
    StoredIdentifier = 0,
86
    StoredObjCZeroArgSelector = 0x01,
87
    StoredObjCOneArgSelector = 0x02,
88
    StoredDeclarationNameExtra = 0x03,
89
    PtrMask = 0x03
90
  };
91
92
  /// Ptr - The lowest two bits are used to express what kind of name
93
  /// we're actually storing, using the values of NameKind. Depending
94
  /// on the kind of name this is, the upper bits of Ptr may have one
95
  /// of several different meanings:
96
  ///
97
  ///   StoredIdentifier - The name is a normal identifier, and Ptr is
98
  ///   a normal IdentifierInfo pointer.
99
  ///
100
  ///   StoredObjCZeroArgSelector - The name is an Objective-C
101
  ///   selector with zero arguments, and Ptr is an IdentifierInfo
102
  ///   pointer pointing to the selector name.
103
  ///
104
  ///   StoredObjCOneArgSelector - The name is an Objective-C selector
105
  ///   with one argument, and Ptr is an IdentifierInfo pointer
106
  ///   pointing to the selector name.
107
  ///
108
  ///   StoredDeclarationNameExtra - Ptr is actually a pointer to a
109
  ///   DeclarationNameExtra structure, whose first value will tell us
110
  ///   whether this is an Objective-C selector, C++ operator-id name,
111
  ///   or special C++ name.
112
  uintptr_t Ptr = 0;
113
114
  // Construct a declaration name from the name of a C++ constructor,
115
  // destructor, or conversion function.
116
  DeclarationName(DeclarationNameExtra *Name)
117
11.8M
      : Ptr(reinterpret_cast<uintptr_t>(Name)) {
118
11.8M
    assert((Ptr & PtrMask) == 0 && "Improperly aligned DeclarationNameExtra");
119
11.8M
    Ptr |= StoredDeclarationNameExtra;
120
11.8M
  }
121
122
  /// Construct a declaration name from a raw pointer.
123
398M
  DeclarationName(uintptr_t Ptr) : Ptr(Ptr) {}
124
125
  /// getStoredNameKind - Return the kind of object that is stored in
126
  /// Ptr.
127
1.17G
  StoredNameKind getStoredNameKind() const {
128
1.17G
    return static_cast<StoredNameKind>(Ptr & PtrMask);
129
1.17G
  }
130
131
  /// getExtra - Get the "extra" information associated with this
132
  /// multi-argument selector or C++ special name.
133
194M
  DeclarationNameExtra *getExtra() const {
134
194M
    assert(getStoredNameKind() == StoredDeclarationNameExtra &&
135
194M
           "Declaration name does not store an Extra structure");
136
194M
    return reinterpret_cast<DeclarationNameExtra *>(Ptr & ~PtrMask);
137
194M
  }
138
139
  /// getAsCXXSpecialName - If the stored pointer is actually a
140
  /// CXXSpecialName, returns a pointer to it. Otherwise, returns
141
  /// a NULL pointer.
142
5.30M
  CXXSpecialName *getAsCXXSpecialName() const {
143
5.30M
    NameKind Kind = getNameKind();
144
5.30M
    if (Kind >= CXXConstructorName && 
Kind <= CXXConversionFunctionName4.51M
)
145
4.51M
      return reinterpret_cast<CXXSpecialName *>(getExtra());
146
788k
    return nullptr;
147
788k
  }
148
149
  /// If the stored pointer is actually a CXXDeductionGuideNameExtra, returns a
150
  /// pointer to it. Otherwise, returns a NULL pointer.
151
791k
  CXXDeductionGuideNameExtra *getAsCXXDeductionGuideNameExtra() const {
152
791k
    if (getNameKind() == CXXDeductionGuideName)
153
2.74k
      return reinterpret_cast<CXXDeductionGuideNameExtra *>(getExtra());
154
789k
    return nullptr;
155
789k
  }
156
157
  /// getAsCXXOperatorIdName
158
122M
  CXXOperatorIdName *getAsCXXOperatorIdName() const {
159
122M
    if (getNameKind() == CXXOperatorName)
160
28.6M
      return reinterpret_cast<CXXOperatorIdName *>(getExtra());
161
94.1M
    return nullptr;
162
94.1M
  }
163
164
19.4k
  CXXLiteralOperatorIdName *getAsCXXLiteralOperatorIdName() const {
165
19.4k
    if (getNameKind() == CXXLiteralOperatorName)
166
19.4k
      return reinterpret_cast<CXXLiteralOperatorIdName *>(getExtra());
167
0
    return nullptr;
168
0
  }
169
170
  /// getFETokenInfoAsVoidSlow - Retrieves the front end-specified pointer
171
  /// for this name as a void pointer if it's not an identifier.
172
  void *getFETokenInfoAsVoidSlow() const;
173
174
public:
175
  /// DeclarationName - Used to create an empty selector.
176
98.3M
  DeclarationName() = default;
177
178
  // Construct a declaration name from an IdentifierInfo *.
179
  DeclarationName(const IdentifierInfo *II)
180
158M
      : Ptr(reinterpret_cast<uintptr_t>(II)) {
181
158M
    assert((Ptr & PtrMask) == 0 && "Improperly aligned IdentifierInfo");
182
158M
  }
183
184
  // Construct a declaration name from an Objective-C selector.
185
587k
  DeclarationName(Selector Sel) : Ptr(Sel.InfoPtr) {}
186
187
  /// getUsingDirectiveName - Return name for all using-directives.
188
  static DeclarationName getUsingDirectiveName();
189
190
  // operator bool() - Evaluates true when this declaration name is
191
  // non-empty.
192
200M
  explicit operator bool() const {
193
200M
    return ((Ptr & PtrMask) != 0) ||
194
200M
           
(reinterpret_cast<IdentifierInfo *>(Ptr & ~PtrMask))190M
;
195
200M
  }
196
197
  /// Evaluates true when this declaration name is empty.
198
912k
  bool isEmpty() const {
199
912k
    return !*this;
200
912k
  }
201
202
  /// Predicate functions for querying what type of name this is.
203
635M
  bool isIdentifier() const { return getStoredNameKind() == StoredIdentifier; }
204
627
  bool isObjCZeroArgSelector() const {
205
627
    return getStoredNameKind() == StoredObjCZeroArgSelector;
206
627
  }
207
  bool isObjCOneArgSelector() const {
208
    return getStoredNameKind() == StoredObjCOneArgSelector;
209
  }
210
211
  /// getNameKind - Determine what kind of name this is.
212
  NameKind getNameKind() const;
213
214
  /// Determines whether the name itself is dependent, e.g., because it 
215
  /// involves a C++ type that is itself dependent.
216
  ///
217
  /// Note that this does not capture all of the notions of "dependent name",
218
  /// because an identifier can be a dependent name if it is used as the 
219
  /// callee in a call expression with dependent arguments.
220
  bool isDependentName() const;
221
  
222
  /// getNameAsString - Retrieve the human-readable string for this name.
223
  std::string getAsString() const;
224
225
  /// getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in
226
  /// this declaration name, or NULL if this declaration name isn't a
227
  /// simple identifier.
228
630M
  IdentifierInfo *getAsIdentifierInfo() const {
229
630M
    if (isIdentifier())
230
606M
      return reinterpret_cast<IdentifierInfo *>(Ptr);
231
23.2M
    return nullptr;
232
23.2M
  }
233
234
  /// getAsOpaqueInteger - Get the representation of this declaration
235
  /// name as an opaque integer.
236
219k
  uintptr_t getAsOpaqueInteger() const { return Ptr; }
237
238
  /// getAsOpaquePtr - Get the representation of this declaration name as
239
  /// an opaque pointer.
240
161M
  void *getAsOpaquePtr() const { return reinterpret_cast<void*>(Ptr); }
241
242
  static DeclarationName getFromOpaquePtr(void *P) {
243
    DeclarationName N;
244
    N.Ptr = reinterpret_cast<uintptr_t> (P);
245
    return N;
246
  }
247
248
16.6k
  static DeclarationName getFromOpaqueInteger(uintptr_t P) {
249
16.6k
    DeclarationName N;
250
16.6k
    N.Ptr = P;
251
16.6k
    return N;
252
16.6k
  }
253
254
  /// getCXXNameType - If this name is one of the C++ names (of a
255
  /// constructor, destructor, or conversion function), return the
256
  /// type associated with that name.
257
  QualType getCXXNameType() const;
258
259
  /// If this name is the name of a C++ deduction guide, return the
260
  /// template associated with that name.
261
  TemplateDecl *getCXXDeductionGuideTemplate() const;
262
263
  /// getCXXOverloadedOperator - If this name is the name of an
264
  /// overloadable operator in C++ (e.g., @c operator+), retrieve the
265
  /// kind of overloaded operator.
266
  OverloadedOperatorKind getCXXOverloadedOperator() const;
267
268
  /// getCXXLiteralIdentifier - If this name is the name of a literal
269
  /// operator, retrieve the identifier associated with it.
270
  IdentifierInfo *getCXXLiteralIdentifier() const;
271
272
  /// getObjCSelector - Get the Objective-C selector stored in this
273
  /// declaration name.
274
936k
  Selector getObjCSelector() const {
275
936k
    assert((getNameKind() == ObjCZeroArgSelector ||
276
936k
            getNameKind() == ObjCOneArgSelector ||
277
936k
            getNameKind() == ObjCMultiArgSelector ||
278
936k
            Ptr == 0) && "Not a selector!");
279
936k
    return Selector(Ptr);
280
936k
  }
281
282
  /// getFETokenInfo/setFETokenInfo - The language front-end is
283
  /// allowed to associate arbitrary metadata with some kinds of
284
  /// declaration names, including normal identifiers and C++
285
  /// constructors, destructors, and conversion functions.
286
  template<typename T>
287
168M
  T *getFETokenInfo() const {
288
168M
    if (const IdentifierInfo *Info = getAsIdentifierInfo())
289
161M
      return Info->getFETokenInfo<T>();
290
6.96M
    return static_cast<T*>(getFETokenInfoAsVoidSlow());
291
6.96M
  }
292
293
  void setFETokenInfo(void *T);
294
295
  /// operator== - Determine whether the specified names are identical..
296
966M
  friend bool operator==(DeclarationName LHS, DeclarationName RHS) {
297
966M
    return LHS.Ptr == RHS.Ptr;
298
966M
  }
299
300
  /// operator!= - Determine whether the specified names are different.
301
178k
  friend bool operator!=(DeclarationName LHS, DeclarationName RHS) {
302
178k
    return LHS.Ptr != RHS.Ptr;
303
178k
  }
304
305
174M
  static DeclarationName getEmptyMarker() {
306
174M
    return DeclarationName(uintptr_t(-1));
307
174M
  }
308
309
160M
  static DeclarationName getTombstoneMarker() {
310
160M
    return DeclarationName(uintptr_t(-2));
311
160M
  }
312
313
  static int compare(DeclarationName LHS, DeclarationName RHS);
314
315
  void print(raw_ostream &OS, const PrintingPolicy &Policy);
316
317
  void dump() const;
318
};
319
320
raw_ostream &operator<<(raw_ostream &OS, DeclarationName N);
321
322
/// Ordering on two declaration names. If both names are identifiers,
323
/// this provides a lexicographical ordering.
324
107k
inline bool operator<(DeclarationName LHS, DeclarationName RHS) {
325
107k
  return DeclarationName::compare(LHS, RHS) < 0;
326
107k
}
327
328
/// Ordering on two declaration names. If both names are identifiers,
329
/// this provides a lexicographical ordering.
330
0
inline bool operator>(DeclarationName LHS, DeclarationName RHS) {
331
0
  return DeclarationName::compare(LHS, RHS) > 0;
332
0
}
333
334
/// Ordering on two declaration names. If both names are identifiers,
335
/// this provides a lexicographical ordering.
336
0
inline bool operator<=(DeclarationName LHS, DeclarationName RHS) {
337
0
  return DeclarationName::compare(LHS, RHS) <= 0;
338
0
}
339
340
/// Ordering on two declaration names. If both names are identifiers,
341
/// this provides a lexicographical ordering.
342
0
inline bool operator>=(DeclarationName LHS, DeclarationName RHS) {
343
0
  return DeclarationName::compare(LHS, RHS) >= 0;
344
0
}
345
346
/// DeclarationNameTable - Used to store and retrieve DeclarationName
347
/// instances for the various kinds of declaration names, e.g., normal
348
/// identifiers, C++ constructor names, etc. This class contains
349
/// uniqued versions of each of the C++ special names, which can be
350
/// retrieved using its member functions (e.g.,
351
/// getCXXConstructorName).
352
class DeclarationNameTable {
353
  const ASTContext &Ctx;
354
355
  // Actually a FoldingSet<CXXSpecialName> *
356
  void *CXXSpecialNamesImpl;
357
358
  // Operator names
359
  CXXOperatorIdName *CXXOperatorNames;
360
361
  // Actually a CXXOperatorIdName*
362
  void *CXXLiteralOperatorNames;
363
364
  // FoldingSet<CXXDeductionGuideNameExtra> *
365
  void *CXXDeductionGuideNames;
366
367
public:
368
  DeclarationNameTable(const ASTContext &C);
369
  DeclarationNameTable(const DeclarationNameTable &) = delete;
370
  DeclarationNameTable &operator=(const DeclarationNameTable &) = delete;
371
372
  ~DeclarationNameTable();
373
374
  /// getIdentifier - Create a declaration name that is a simple
375
  /// identifier.
376
8.88k
  DeclarationName getIdentifier(const IdentifierInfo *ID) {
377
8.88k
    return DeclarationName(ID);
378
8.88k
  }
379
380
  /// getCXXConstructorName - Returns the name of a C++ constructor
381
  /// for the given Type.
382
  DeclarationName getCXXConstructorName(CanQualType Ty);
383
384
  /// getCXXDestructorName - Returns the name of a C++ destructor
385
  /// for the given Type.
386
  DeclarationName getCXXDestructorName(CanQualType Ty);
387
388
  /// Returns the name of a C++ deduction guide for the given template.
389
  DeclarationName getCXXDeductionGuideName(TemplateDecl *TD);
390
391
  /// getCXXConversionFunctionName - Returns the name of a C++
392
  /// conversion function for the given Type.
393
  DeclarationName getCXXConversionFunctionName(CanQualType Ty);
394
395
  /// getCXXSpecialName - Returns a declaration name for special kind
396
  /// of C++ name, e.g., for a constructor, destructor, or conversion
397
  /// function.
398
  DeclarationName getCXXSpecialName(DeclarationName::NameKind Kind,
399
                                    CanQualType Ty);
400
401
  /// getCXXOperatorName - Get the name of the overloadable C++
402
  /// operator corresponding to Op.
403
  DeclarationName getCXXOperatorName(OverloadedOperatorKind Op);
404
405
  /// getCXXLiteralOperatorName - Get the name of the literal operator function
406
  /// with II as the identifier.
407
  DeclarationName getCXXLiteralOperatorName(IdentifierInfo *II);
408
};
409
410
/// DeclarationNameLoc - Additional source/type location info
411
/// for a declaration name. Needs a DeclarationName in order
412
/// to be interpreted correctly.
413
0
struct DeclarationNameLoc {
Unexecuted instantiation: clang::DeclarationNameLoc::operator=(clang::DeclarationNameLoc&&)
Unexecuted instantiation: clang::DeclarationNameLoc::operator=(clang::DeclarationNameLoc const&)
414
  // The source location for identifier stored elsewhere.
415
  // struct {} Identifier;
416
417
  // Type info for constructors, destructors and conversion functions.
418
  // Locations (if any) for the tilde (destructor) or operator keyword
419
  // (conversion) are stored elsewhere.
420
  struct NT {
421
    TypeSourceInfo *TInfo;
422
  };
423
424
  // The location (if any) of the operator keyword is stored elsewhere.
425
  struct CXXOpName {
426
    unsigned BeginOpNameLoc;
427
    unsigned EndOpNameLoc;
428
  };
429
430
  // The location (if any) of the operator keyword is stored elsewhere.
431
  struct CXXLitOpName {
432
    unsigned OpNameLoc;
433
  };
434
435
  // struct {} CXXUsingDirective;
436
  // struct {} ObjCZeroArgSelector;
437
  // struct {} ObjCOneArgSelector;
438
  // struct {} ObjCMultiArgSelector;
439
  union {
440
    struct NT NamedType;
441
    struct CXXOpName CXXOperatorName;
442
    struct CXXLitOpName CXXLiteralOperatorName;
443
  };
444
445
  DeclarationNameLoc(DeclarationName Name);
446
447
  // FIXME: this should go away once all DNLocs are properly initialized.
448
58.1M
  DeclarationNameLoc() { memset((void*) this, 0, sizeof(*this)); }
449
};
450
451
/// DeclarationNameInfo - A collector data type for bundling together
452
/// a DeclarationName and the correspnding source/type location info.
453
0
struct DeclarationNameInfo {
Unexecuted instantiation: clang::DeclarationNameInfo::operator=(clang::DeclarationNameInfo const&)
Unexecuted instantiation: clang::DeclarationNameInfo::operator=(clang::DeclarationNameInfo&&)
454
private:
455
  /// Name - The declaration name, also encoding name kind.
456
  DeclarationName Name;
457
458
  /// Loc - The main source location for the declaration name.
459
  SourceLocation NameLoc;
460
461
  /// Info - Further source/type location info for special kinds of names.
462
  DeclarationNameLoc LocInfo;
463
464
public:
465
  // FIXME: remove it.
466
56.4M
  DeclarationNameInfo() = default;
467
468
  DeclarationNameInfo(DeclarationName Name, SourceLocation NameLoc)
469
61.2M
      : Name(Name), NameLoc(NameLoc), LocInfo(Name) {}
470
471
  DeclarationNameInfo(DeclarationName Name, SourceLocation NameLoc,
472
                      DeclarationNameLoc LocInfo)
473
109M
      : Name(Name), NameLoc(NameLoc), LocInfo(LocInfo) {}
474
475
  /// getName - Returns the embedded declaration name.
476
549M
  DeclarationName getName() const { return Name; }
477
478
  /// setName - Sets the embedded declaration name.
479
40.9M
  void setName(DeclarationName N) { Name = N; }
480
481
  /// getLoc - Returns the main location of the declaration name.
482
152M
  SourceLocation getLoc() const { return NameLoc; }
483
484
  /// setLoc - Sets the main location of the declaration name.
485
81.3M
  void setLoc(SourceLocation L) { NameLoc = L; }
486
487
27.9M
  const DeclarationNameLoc &getInfo() const { return LocInfo; }
488
2.17M
  DeclarationNameLoc &getInfo() { return LocInfo; }
489
2.04k
  void setInfo(const DeclarationNameLoc &Info) { LocInfo = Info; }
490
491
  /// getNamedTypeInfo - Returns the source type info associated to
492
  /// the name. Assumes it is a constructor, destructor or conversion.
493
600k
  TypeSourceInfo *getNamedTypeInfo() const {
494
600k
    assert(Name.getNameKind() == DeclarationName::CXXConstructorName ||
495
600k
           Name.getNameKind() == DeclarationName::CXXDestructorName ||
496
600k
           Name.getNameKind() == DeclarationName::CXXConversionFunctionName);
497
600k
    return LocInfo.NamedType.TInfo;
498
600k
  }
499
500
  /// setNamedTypeInfo - Sets the source type info associated to
501
  /// the name. Assumes it is a constructor, destructor or conversion.
502
1.60M
  void setNamedTypeInfo(TypeSourceInfo *TInfo) {
503
1.60M
    assert(Name.getNameKind() == DeclarationName::CXXConstructorName ||
504
1.60M
           Name.getNameKind() == DeclarationName::CXXDestructorName ||
505
1.60M
           Name.getNameKind() == DeclarationName::CXXConversionFunctionName);
506
1.60M
    LocInfo.NamedType.TInfo = TInfo;
507
1.60M
  }
508
509
  /// getCXXOperatorNameRange - Gets the range of the operator name
510
  /// (without the operator keyword). Assumes it is a (non-literal) operator.
511
1.07k
  SourceRange getCXXOperatorNameRange() const {
512
1.07k
    assert(Name.getNameKind() == DeclarationName::CXXOperatorName);
513
1.07k
    return SourceRange(
514
1.07k
     SourceLocation::getFromRawEncoding(LocInfo.CXXOperatorName.BeginOpNameLoc),
515
1.07k
     SourceLocation::getFromRawEncoding(LocInfo.CXXOperatorName.EndOpNameLoc)
516
1.07k
                       );
517
1.07k
  }
518
519
  /// setCXXOperatorNameRange - Sets the range of the operator name
520
  /// (without the operator keyword). Assumes it is a C++ operator.
521
47.0k
  void setCXXOperatorNameRange(SourceRange R) {
522
47.0k
    assert(Name.getNameKind() == DeclarationName::CXXOperatorName);
523
47.0k
    LocInfo.CXXOperatorName.BeginOpNameLoc = R.getBegin().getRawEncoding();
524
47.0k
    LocInfo.CXXOperatorName.EndOpNameLoc = R.getEnd().getRawEncoding();
525
47.0k
  }
526
527
  /// getCXXLiteralOperatorNameLoc - Returns the location of the literal
528
  /// operator name (not the operator keyword).
529
  /// Assumes it is a literal operator.
530
172
  SourceLocation getCXXLiteralOperatorNameLoc() const {
531
172
    assert(Name.getNameKind() == DeclarationName::CXXLiteralOperatorName);
532
172
    return SourceLocation::
533
172
      getFromRawEncoding(LocInfo.CXXLiteralOperatorName.OpNameLoc);
534
172
  }
535
536
  /// setCXXLiteralOperatorNameLoc - Sets the location of the literal
537
  /// operator name (not the operator keyword).
538
  /// Assumes it is a literal operator.
539
6.08k
  void setCXXLiteralOperatorNameLoc(SourceLocation Loc) {
540
6.08k
    assert(Name.getNameKind() == DeclarationName::CXXLiteralOperatorName);
541
6.08k
    LocInfo.CXXLiteralOperatorName.OpNameLoc = Loc.getRawEncoding();
542
6.08k
  }
543
544
  /// Determine whether this name involves a template parameter.
545
  bool isInstantiationDependent() const;
546
  
547
  /// Determine whether this name contains an unexpanded
548
  /// parameter pack.
549
  bool containsUnexpandedParameterPack() const;
550
551
  /// getAsString - Retrieve the human-readable string for this name.
552
  std::string getAsString() const;
553
554
  /// printName - Print the human-readable name to a stream.
555
  void printName(raw_ostream &OS) const;
556
557
  /// getBeginLoc - Retrieve the location of the first token.
558
101M
  SourceLocation getBeginLoc() const { return NameLoc; }
559
560
  /// getEndLoc - Retrieve the location of the last token.
561
  SourceLocation getEndLoc() const;
562
563
  /// getSourceRange - The range of the declaration name.
564
34.7k
  SourceRange getSourceRange() const LLVM_READONLY {
565
34.7k
    return SourceRange(getLocStart(), getLocEnd());
566
34.7k
  }
567
568
101M
  SourceLocation getLocStart() const LLVM_READONLY {
569
101M
    return getBeginLoc();
570
101M
  }
571
572
7.50M
  SourceLocation getLocEnd() const LLVM_READONLY {
573
7.50M
    SourceLocation EndLoc = getEndLoc();
574
7.50M
    return EndLoc.isValid() ? 
EndLoc7.48M
:
getLocStart()17.6k
;
575
7.50M
  }
576
};
577
578
/// Insertion operator for diagnostics.  This allows sending DeclarationName's
579
/// into a diagnostic with <<.
580
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
581
124k
                                           DeclarationName N) {
582
124k
  DB.AddTaggedVal(N.getAsOpaqueInteger(),
583
124k
                  DiagnosticsEngine::ak_declarationname);
584
124k
  return DB;
585
124k
}
586
587
/// Insertion operator for partial diagnostics.  This allows binding
588
/// DeclarationName's into a partial diagnostic with <<.
589
inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
590
95.5k
                                           DeclarationName N) {
591
95.5k
  PD.AddTaggedVal(N.getAsOpaqueInteger(),
592
95.5k
                  DiagnosticsEngine::ak_declarationname);
593
95.5k
  return PD;
594
95.5k
}
595
596
inline raw_ostream &operator<<(raw_ostream &OS,
597
102k
                                     DeclarationNameInfo DNInfo) {
598
102k
  DNInfo.printName(OS);
599
102k
  return OS;
600
102k
}
601
602
} // namespace clang
603
604
namespace llvm {
605
606
/// Define DenseMapInfo so that DeclarationNames can be used as keys
607
/// in DenseMap and DenseSets.
608
template<>
609
struct DenseMapInfo<clang::DeclarationName> {
610
174M
  static inline clang::DeclarationName getEmptyKey() {
611
174M
    return clang::DeclarationName::getEmptyMarker();
612
174M
  }
613
614
160M
  static inline clang::DeclarationName getTombstoneKey() {
615
160M
    return clang::DeclarationName::getTombstoneMarker();
616
160M
  }
617
618
158M
  static unsigned getHashValue(clang::DeclarationName Name) {
619
158M
    return DenseMapInfo<void*>::getHashValue(Name.getAsOpaquePtr());
620
158M
  }
621
622
  static inline bool
623
960M
  isEqual(clang::DeclarationName LHS, clang::DeclarationName RHS) {
624
960M
    return LHS == RHS;
625
960M
  }
626
};
627
628
template <>
629
struct isPodLike<clang::DeclarationName> { static const bool value = true; };
630
631
} // namespace llvm
632
633
#endif // LLVM_CLANG_AST_DECLARATIONNAME_H