Coverage Report

Created: 2020-09-22 08:39

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/AST/DeclarationName.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- DeclarationName.cpp - Declaration names implementation -------------===//
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
// This file implements the DeclarationName and DeclarationNameTable
10
// classes.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#include "clang/AST/DeclarationName.h"
15
#include "clang/AST/ASTContext.h"
16
#include "clang/AST/Decl.h"
17
#include "clang/AST/DeclBase.h"
18
#include "clang/AST/DeclCXX.h"
19
#include "clang/AST/DeclTemplate.h"
20
#include "clang/AST/OpenMPClause.h"
21
#include "clang/AST/PrettyPrinter.h"
22
#include "clang/AST/Type.h"
23
#include "clang/AST/TypeLoc.h"
24
#include "clang/AST/TypeOrdering.h"
25
#include "clang/Basic/IdentifierTable.h"
26
#include "clang/Basic/LLVM.h"
27
#include "clang/Basic/LangOptions.h"
28
#include "clang/Basic/OperatorKinds.h"
29
#include "clang/Basic/SourceLocation.h"
30
#include "llvm/ADT/FoldingSet.h"
31
#include "llvm/Support/Casting.h"
32
#include "llvm/Support/Compiler.h"
33
#include "llvm/Support/ErrorHandling.h"
34
#include "llvm/Support/raw_ostream.h"
35
#include <algorithm>
36
#include <cassert>
37
#include <cstdint>
38
#include <string>
39
40
using namespace clang;
41
42
36.6k
static int compareInt(unsigned A, unsigned B) {
43
22.7k
  return (A < B ? -1 : 
(A > B 13.9k
?
113.8k
:
0176
));
44
36.6k
}
45
46
10.3M
int DeclarationName::compare(DeclarationName LHS, DeclarationName RHS) {
47
10.3M
  if (LHS.getNameKind() != RHS.getNameKind())
48
326k
    return (LHS.getNameKind() < RHS.getNameKind() ? 
-1199k
:
1126k
);
49
50
9.99M
  switch (LHS.getNameKind()) {
51
9.72M
  case DeclarationName::Identifier: {
52
9.72M
    IdentifierInfo *LII = LHS.castAsIdentifierInfo();
53
9.72M
    IdentifierInfo *RII = RHS.castAsIdentifierInfo();
54
9.72M
    if (!LII)
55
0
      return RII ? -1 : 0;
56
9.72M
    if (!RII)
57
0
      return 1;
58
59
9.72M
    return LII->getName().compare(RII->getName());
60
9.72M
  }
61
62
238k
  case DeclarationName::ObjCZeroArgSelector:
63
238k
  case DeclarationName::ObjCOneArgSelector:
64
238k
  case DeclarationName::ObjCMultiArgSelector: {
65
238k
    Selector LHSSelector = LHS.getObjCSelector();
66
238k
    Selector RHSSelector = RHS.getObjCSelector();
67
    // getNumArgs for ZeroArgSelector returns 0, but we still need to compare.
68
238k
    if (LHS.getNameKind() == DeclarationName::ObjCZeroArgSelector &&
69
107k
        RHS.getNameKind() == DeclarationName::ObjCZeroArgSelector) {
70
107k
      return LHSSelector.getAsIdentifierInfo()->getName().compare(
71
107k
          RHSSelector.getAsIdentifierInfo()->getName());
72
107k
    }
73
130k
    unsigned LN = LHSSelector.getNumArgs(), RN = RHSSelector.getNumArgs();
74
141k
    for (unsigned I = 0, N = std::min(LN, RN); I != N; 
++I10.4k
) {
75
140k
      switch (LHSSelector.getNameForSlot(I).compare(
76
140k
          RHSSelector.getNameForSlot(I))) {
77
82.2k
      case -1:
78
82.2k
        return -1;
79
47.6k
      case 1:
80
47.6k
        return 1;
81
10.4k
      default:
82
10.4k
        break;
83
140k
      }
84
140k
    }
85
86
899
    return compareInt(LN, RN);
87
130k
  }
88
89
1.88k
  case DeclarationName::CXXConstructorName:
90
1.88k
  case DeclarationName::CXXDestructorName:
91
1.88k
  case DeclarationName::CXXConversionFunctionName:
92
1.88k
    if (QualTypeOrdering()(LHS.getCXXNameType(), RHS.getCXXNameType()))
93
977
      return -1;
94
905
    if (QualTypeOrdering()(RHS.getCXXNameType(), LHS.getCXXNameType()))
95
769
      return 1;
96
136
    return 0;
97
98
1.10k
  case DeclarationName::CXXDeductionGuideName:
99
    // We never want to compare deduction guide names for templates from
100
    // different scopes, so just compare the template-name.
101
1.10k
    return compare(LHS.getCXXDeductionGuideTemplate()->getDeclName(),
102
1.10k
                   RHS.getCXXDeductionGuideTemplate()->getDeclName());
103
104
35.7k
  case DeclarationName::CXXOperatorName:
105
35.7k
    return compareInt(LHS.getCXXOverloadedOperator(),
106
35.7k
                      RHS.getCXXOverloadedOperator());
107
108
617
  case DeclarationName::CXXLiteralOperatorName:
109
617
    return LHS.getCXXLiteralIdentifier()->getName().compare(
110
617
        RHS.getCXXLiteralIdentifier()->getName());
111
112
0
  case DeclarationName::CXXUsingDirective:
113
0
    return 0;
114
0
  }
115
116
0
  llvm_unreachable("Invalid DeclarationName Kind!");
117
0
}
118
119
static void printCXXConstructorDestructorName(QualType ClassType,
120
                                              raw_ostream &OS,
121
151k
                                              PrintingPolicy Policy) {
122
  // We know we're printing C++ here. Ensure we print types properly.
123
151k
  Policy.adjustForCPlusPlus();
124
125
151k
  if (const RecordType *ClassRec = ClassType->getAs<RecordType>()) {
126
132k
    OS << *ClassRec->getDecl();
127
132k
    return;
128
132k
  }
129
19.0k
  if (Policy.SuppressTemplateArgsInCXXConstructors) {
130
33
    if (auto *InjTy = ClassType->getAs<InjectedClassNameType>()) {
131
33
      OS << *InjTy->getDecl();
132
33
      return;
133
33
    }
134
19.0k
  }
135
19.0k
  ClassType.print(OS, Policy);
136
19.0k
}
137
138
void DeclarationName::print(raw_ostream &OS,
139
2.22M
                            const PrintingPolicy &Policy) const {
140
2.22M
  switch (getNameKind()) {
141
1.88M
  case DeclarationName::Identifier:
142
1.88M
    if (const IdentifierInfo *II = getAsIdentifierInfo()) {
143
1.87M
      StringRef Name = II->getName();
144
      // If this is a mangled OpenMP variant name we strip off the mangling for
145
      // printing. It should not be visible to the user at all.
146
1.87M
      if (II->isMangledOpenMPVariantName()) {
147
348
        std::pair<StringRef, StringRef> NameContextPair =
148
348
            Name.split(getOpenMPVariantManglingSeparatorStr());
149
348
        OS << NameContextPair.first << "["
150
348
           << OMPTraitInfo(NameContextPair.second) << "]";
151
1.87M
      } else {
152
1.87M
        OS << Name;
153
1.87M
      }
154
1.87M
    }
155
1.88M
    return;
156
157
9.61k
  case DeclarationName::ObjCZeroArgSelector:
158
9.61k
  case DeclarationName::ObjCOneArgSelector:
159
9.61k
  case DeclarationName::ObjCMultiArgSelector:
160
9.61k
    getObjCSelector().print(OS);
161
9.61k
    return;
162
163
129k
  case DeclarationName::CXXConstructorName:
164
129k
    return printCXXConstructorDestructorName(getCXXNameType(), OS, Policy);
165
166
21.7k
  case DeclarationName::CXXDestructorName:
167
21.7k
    OS << '~';
168
21.7k
    return printCXXConstructorDestructorName(getCXXNameType(), OS, Policy);
169
170
85
  case DeclarationName::CXXDeductionGuideName:
171
85
    OS << "<deduction guide for ";
172
85
    getCXXDeductionGuideTemplate()->getDeclName().print(OS, Policy);
173
85
    OS << '>';
174
85
    return;
175
176
153k
  case DeclarationName::CXXOperatorName: {
177
153k
    const char *OpName = getOperatorSpelling(getCXXOverloadedOperator());
178
153k
    assert(OpName && "not an overloaded operator");
179
180
153k
    OS << "operator";
181
153k
    if (OpName[0] >= 'a' && 
OpName[0] <= 'z'2.83k
)
182
1.95k
      OS << ' ';
183
153k
    OS << OpName;
184
153k
    return;
185
9.61k
  }
186
187
178
  case DeclarationName::CXXLiteralOperatorName:
188
178
    OS << "operator\"\"" << getCXXLiteralIdentifier()->getName();
189
178
    return;
190
191
5.69k
  case DeclarationName::CXXConversionFunctionName: {
192
5.69k
    OS << "operator ";
193
5.69k
    QualType Type = getCXXNameType();
194
5.69k
    if (const RecordType *Rec = Type->getAs<RecordType>()) {
195
629
      OS << *Rec->getDecl();
196
629
      return;
197
629
    }
198
    // We know we're printing C++ here, ensure we print 'bool' properly.
199
5.06k
    PrintingPolicy CXXPolicy = Policy;
200
5.06k
    CXXPolicy.adjustForCPlusPlus();
201
5.06k
    Type.print(OS, CXXPolicy);
202
5.06k
    return;
203
5.06k
  }
204
12.7k
  case DeclarationName::CXXUsingDirective:
205
12.7k
    OS << "<using-directive>";
206
12.7k
    return;
207
0
  }
208
209
0
  llvm_unreachable("Unexpected declaration name kind");
210
0
}
211
212
namespace clang {
213
214
1.92M
raw_ostream &operator<<(raw_ostream &OS, DeclarationName N) {
215
1.92M
  LangOptions LO;
216
1.92M
  N.print(OS, PrintingPolicy(LO));
217
1.92M
  return OS;
218
1.92M
}
219
220
} // namespace clang
221
222
354k
bool DeclarationName::isDependentName() const {
223
354k
  QualType T = getCXXNameType();
224
354k
  if (!T.isNull() && 
T->isDependentType()496
)
225
8
    return true;
226
227
  // A class-scope deduction guide in a dependent context has a dependent name.
228
354k
  auto *TD = getCXXDeductionGuideTemplate();
229
354k
  if (TD && 
TD->getDeclContext()->isDependentContext()0
)
230
0
    return true;
231
232
354k
  return false;
233
354k
}
234
235
710k
std::string DeclarationName::getAsString() const {
236
710k
  std::string Result;
237
710k
  llvm::raw_string_ostream OS(Result);
238
710k
  OS << *this;
239
710k
  return OS.str();
240
710k
}
241
242
6.61M
void *DeclarationName::getFETokenInfoSlow() const {
243
6.61M
  switch (getNameKind()) {
244
0
  case Identifier:
245
0
    llvm_unreachable("case Identifier already handled by getFETokenInfo!");
246
2.16M
  case CXXConstructorName:
247
2.16M
  case CXXDestructorName:
248
2.16M
  case CXXConversionFunctionName:
249
2.16M
    return castAsCXXSpecialNameExtra()->FETokenInfo;
250
4.43M
  case CXXOperatorName:
251
4.43M
    return castAsCXXOperatorIdName()->FETokenInfo;
252
3.55k
  case CXXDeductionGuideName:
253
3.55k
    return castAsCXXDeductionGuideNameExtra()->FETokenInfo;
254
4.41k
  case CXXLiteralOperatorName:
255
4.41k
    return castAsCXXLiteralOperatorIdName()->FETokenInfo;
256
0
  default:
257
0
    llvm_unreachable("DeclarationName has no FETokenInfo!");
258
6.61M
  }
259
6.61M
}
260
261
509k
void DeclarationName::setFETokenInfoSlow(void *T) {
262
509k
  switch (getNameKind()) {
263
0
  case Identifier:
264
0
    llvm_unreachable("case Identifier already handled by setFETokenInfo!");
265
353k
  case CXXConstructorName:
266
353k
  case CXXDestructorName:
267
353k
  case CXXConversionFunctionName:
268
353k
    castAsCXXSpecialNameExtra()->FETokenInfo = T;
269
353k
    break;
270
155k
  case CXXOperatorName:
271
155k
    castAsCXXOperatorIdName()->FETokenInfo = T;
272
155k
    break;
273
405
  case CXXDeductionGuideName:
274
405
    castAsCXXDeductionGuideNameExtra()->FETokenInfo = T;
275
405
    break;
276
696
  case CXXLiteralOperatorName:
277
696
    castAsCXXLiteralOperatorIdName()->FETokenInfo = T;
278
696
    break;
279
0
  default:
280
0
    llvm_unreachable("DeclarationName has no FETokenInfo!");
281
509k
  }
282
509k
}
283
284
0
LLVM_DUMP_METHOD void DeclarationName::dump() const {
285
0
  llvm::errs() << *this << '\n';
286
0
}
287
288
83.9k
DeclarationNameTable::DeclarationNameTable(const ASTContext &C) : Ctx(C) {
289
  // Initialize the overloaded operator names.
290
3.94M
  for (unsigned Op = 0; Op < NUM_OVERLOADED_OPERATORS; 
++Op3.86M
)
291
3.86M
    CXXOperatorNames[Op].Kind = static_cast<OverloadedOperatorKind>(Op);
292
83.9k
}
293
294
DeclarationName
295
2.77k
DeclarationNameTable::getCXXDeductionGuideName(TemplateDecl *Template) {
296
2.77k
  Template = cast<TemplateDecl>(Template->getCanonicalDecl());
297
298
2.77k
  llvm::FoldingSetNodeID ID;
299
2.77k
  ID.AddPointer(Template);
300
301
2.77k
  void *InsertPos = nullptr;
302
2.77k
  if (auto *Name = CXXDeductionGuideNames.FindNodeOrInsertPos(ID, InsertPos))
303
2.49k
    return DeclarationName(Name);
304
305
278
  auto *Name = new (Ctx) detail::CXXDeductionGuideNameExtra(Template);
306
278
  CXXDeductionGuideNames.InsertNode(Name, InsertPos);
307
278
  return DeclarationName(Name);
308
278
}
309
310
2.18M
DeclarationName DeclarationNameTable::getCXXConstructorName(CanQualType Ty) {
311
  // The type of constructors is unqualified.
312
2.18M
  Ty = Ty.getUnqualifiedType();
313
  // Do we already have this C++ constructor name ?
314
2.18M
  llvm::FoldingSetNodeID ID;
315
2.18M
  ID.AddPointer(Ty.getAsOpaquePtr());
316
2.18M
  void *InsertPos = nullptr;
317
2.18M
  if (auto *Name = CXXConstructorNames.FindNodeOrInsertPos(ID, InsertPos))
318
1.91M
    return {Name, DeclarationName::StoredCXXConstructorName};
319
320
  // We have to create it.
321
275k
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
322
275k
  CXXConstructorNames.InsertNode(SpecialName, InsertPos);
323
275k
  return {SpecialName, DeclarationName::StoredCXXConstructorName};
324
275k
}
325
326
6.34M
DeclarationName DeclarationNameTable::getCXXDestructorName(CanQualType Ty) {
327
  // The type of destructors is unqualified.
328
6.34M
  Ty = Ty.getUnqualifiedType();
329
  // Do we already have this C++ destructor name ?
330
6.34M
  llvm::FoldingSetNodeID ID;
331
6.34M
  ID.AddPointer(Ty.getAsOpaquePtr());
332
6.34M
  void *InsertPos = nullptr;
333
6.34M
  if (auto *Name = CXXDestructorNames.FindNodeOrInsertPos(ID, InsertPos))
334
4.95M
    return {Name, DeclarationName::StoredCXXDestructorName};
335
336
  // We have to create it.
337
1.38M
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
338
1.38M
  CXXDestructorNames.InsertNode(SpecialName, InsertPos);
339
1.38M
  return {SpecialName, DeclarationName::StoredCXXDestructorName};
340
1.38M
}
341
342
DeclarationName
343
66.4k
DeclarationNameTable::getCXXConversionFunctionName(CanQualType Ty) {
344
  // Do we already have this C++ conversion function name ?
345
66.4k
  llvm::FoldingSetNodeID ID;
346
66.4k
  ID.AddPointer(Ty.getAsOpaquePtr());
347
66.4k
  void *InsertPos = nullptr;
348
66.4k
  if (auto *Name =
349
53.7k
          CXXConversionFunctionNames.FindNodeOrInsertPos(ID, InsertPos))
350
53.7k
    return {Name, DeclarationName::StoredCXXConversionFunctionName};
351
352
  // We have to create it.
353
12.7k
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
354
12.7k
  CXXConversionFunctionNames.InsertNode(SpecialName, InsertPos);
355
12.7k
  return {SpecialName, DeclarationName::StoredCXXConversionFunctionName};
356
12.7k
}
357
358
DeclarationName
359
DeclarationNameTable::getCXXSpecialName(DeclarationName::NameKind Kind,
360
235k
                                        CanQualType Ty) {
361
235k
  switch (Kind) {
362
210k
  case DeclarationName::CXXConstructorName:
363
210k
    return getCXXConstructorName(Ty);
364
12.9k
  case DeclarationName::CXXDestructorName:
365
12.9k
    return getCXXDestructorName(Ty);
366
11.3k
  case DeclarationName::CXXConversionFunctionName:
367
11.3k
    return getCXXConversionFunctionName(Ty);
368
0
  default:
369
0
    llvm_unreachable("Invalid kind in getCXXSpecialName!");
370
235k
  }
371
235k
}
372
373
DeclarationName
374
2.35k
DeclarationNameTable::getCXXLiteralOperatorName(IdentifierInfo *II) {
375
2.35k
  llvm::FoldingSetNodeID ID;
376
2.35k
  ID.AddPointer(II);
377
378
2.35k
  void *InsertPos = nullptr;
379
2.35k
  if (auto *Name = CXXLiteralOperatorNames.FindNodeOrInsertPos(ID, InsertPos))
380
1.95k
    return DeclarationName(Name);
381
382
402
  auto *LiteralName = new (Ctx) detail::CXXLiteralOperatorIdName(II);
383
402
  CXXLiteralOperatorNames.InsertNode(LiteralName, InsertPos);
384
402
  return DeclarationName(LiteralName);
385
402
}
386
387
113M
DeclarationNameLoc::DeclarationNameLoc(DeclarationName Name) {
388
113M
  switch (Name.getNameKind()) {
389
109M
  case DeclarationName::Identifier:
390
109M
  case DeclarationName::CXXDeductionGuideName:
391
109M
    break;
392
662k
  case DeclarationName::CXXConstructorName:
393
662k
  case DeclarationName::CXXDestructorName:
394
662k
  case DeclarationName::CXXConversionFunctionName:
395
662k
    NamedType.TInfo = nullptr;
396
662k
    break;
397
4.10M
  case DeclarationName::CXXOperatorName:
398
4.10M
    CXXOperatorName.BeginOpNameLoc = SourceLocation().getRawEncoding();
399
4.10M
    CXXOperatorName.EndOpNameLoc = SourceLocation().getRawEncoding();
400
4.10M
    break;
401
704
  case DeclarationName::CXXLiteralOperatorName:
402
704
    CXXLiteralOperatorName.OpNameLoc = SourceLocation().getRawEncoding();
403
704
    break;
404
0
  case DeclarationName::ObjCZeroArgSelector:
405
0
  case DeclarationName::ObjCOneArgSelector:
406
0
  case DeclarationName::ObjCMultiArgSelector:
407
    // FIXME: ?
408
0
    break;
409
0
  case DeclarationName::CXXUsingDirective:
410
0
    break;
411
113M
  }
412
113M
}
413
414
4.45M
bool DeclarationNameInfo::containsUnexpandedParameterPack() const {
415
4.45M
  switch (Name.getNameKind()) {
416
4.45M
  case DeclarationName::Identifier:
417
4.45M
  case DeclarationName::ObjCZeroArgSelector:
418
4.45M
  case DeclarationName::ObjCOneArgSelector:
419
4.45M
  case DeclarationName::ObjCMultiArgSelector:
420
4.45M
  case DeclarationName::CXXOperatorName:
421
4.45M
  case DeclarationName::CXXLiteralOperatorName:
422
4.45M
  case DeclarationName::CXXUsingDirective:
423
4.45M
  case DeclarationName::CXXDeductionGuideName:
424
4.45M
    return false;
425
426
37
  case DeclarationName::CXXConstructorName:
427
37
  case DeclarationName::CXXDestructorName:
428
37
  case DeclarationName::CXXConversionFunctionName:
429
37
    if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo)
430
23
      return TInfo->getType()->containsUnexpandedParameterPack();
431
432
14
    return Name.getCXXNameType()->containsUnexpandedParameterPack();
433
0
  }
434
0
  llvm_unreachable("All name kinds handled.");
435
0
}
436
437
4.45M
bool DeclarationNameInfo::isInstantiationDependent() const {
438
4.45M
  switch (Name.getNameKind()) {
439
4.45M
  case DeclarationName::Identifier:
440
4.45M
  case DeclarationName::ObjCZeroArgSelector:
441
4.45M
  case DeclarationName::ObjCOneArgSelector:
442
4.45M
  case DeclarationName::ObjCMultiArgSelector:
443
4.45M
  case DeclarationName::CXXOperatorName:
444
4.45M
  case DeclarationName::CXXLiteralOperatorName:
445
4.45M
  case DeclarationName::CXXUsingDirective:
446
4.45M
  case DeclarationName::CXXDeductionGuideName:
447
4.45M
    return false;
448
449
36
  case DeclarationName::CXXConstructorName:
450
36
  case DeclarationName::CXXDestructorName:
451
36
  case DeclarationName::CXXConversionFunctionName:
452
36
    if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo)
453
22
      return TInfo->getType()->isInstantiationDependentType();
454
455
14
    return Name.getCXXNameType()->isInstantiationDependentType();
456
0
  }
457
0
  llvm_unreachable("All name kinds handled.");
458
0
}
459
460
225k
std::string DeclarationNameInfo::getAsString() const {
461
225k
  std::string Result;
462
225k
  llvm::raw_string_ostream OS(Result);
463
225k
  OS << *this;
464
225k
  return OS.str();
465
225k
}
466
467
282k
raw_ostream &clang::operator<<(raw_ostream &OS, DeclarationNameInfo DNInfo) {
468
282k
  LangOptions LO;
469
282k
  DNInfo.printName(OS, PrintingPolicy(LangOptions()));
470
282k
  return OS;
471
282k
}
472
473
289k
void DeclarationNameInfo::printName(raw_ostream &OS, PrintingPolicy Policy) const {
474
289k
  switch (Name.getNameKind()) {
475
267k
  case DeclarationName::Identifier:
476
267k
  case DeclarationName::ObjCZeroArgSelector:
477
267k
  case DeclarationName::ObjCOneArgSelector:
478
267k
  case DeclarationName::ObjCMultiArgSelector:
479
267k
  case DeclarationName::CXXOperatorName:
480
267k
  case DeclarationName::CXXLiteralOperatorName:
481
267k
  case DeclarationName::CXXUsingDirective:
482
267k
  case DeclarationName::CXXDeductionGuideName:
483
267k
    Name.print(OS, Policy);
484
267k
    return;
485
486
21.2k
  case DeclarationName::CXXConstructorName:
487
21.2k
  case DeclarationName::CXXDestructorName:
488
21.2k
  case DeclarationName::CXXConversionFunctionName:
489
21.2k
    if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo) {
490
1.52k
      if (Name.getNameKind() == DeclarationName::CXXDestructorName)
491
1.07k
        OS << '~';
492
448
      else if (Name.getNameKind() == DeclarationName::CXXConversionFunctionName)
493
448
        OS << "operator ";
494
1.52k
      LangOptions LO;
495
1.52k
      Policy.adjustForCPlusPlus();
496
1.52k
      Policy.SuppressScope = true;
497
1.52k
      OS << TInfo->getType().getAsString(Policy);
498
1.52k
    } else
499
19.7k
      Name.print(OS, Policy);
500
21.2k
    return;
501
0
  }
502
0
  llvm_unreachable("Unexpected declaration name kind");
503
0
}
504
505
25.9M
SourceLocation DeclarationNameInfo::getEndLocPrivate() const {
506
25.9M
  switch (Name.getNameKind()) {
507
24.3M
  case DeclarationName::Identifier:
508
24.3M
  case DeclarationName::CXXDeductionGuideName:
509
24.3M
    return NameLoc;
510
511
663k
  case DeclarationName::CXXOperatorName: {
512
663k
    unsigned raw = LocInfo.CXXOperatorName.EndOpNameLoc;
513
663k
    return SourceLocation::getFromRawEncoding(raw);
514
24.3M
  }
515
516
1.00k
  case DeclarationName::CXXLiteralOperatorName: {
517
1.00k
    unsigned raw = LocInfo.CXXLiteralOperatorName.OpNameLoc;
518
1.00k
    return SourceLocation::getFromRawEncoding(raw);
519
24.3M
  }
520
521
889k
  case DeclarationName::CXXConstructorName:
522
889k
  case DeclarationName::CXXDestructorName:
523
889k
  case DeclarationName::CXXConversionFunctionName:
524
889k
    if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo)
525
80.7k
      return TInfo->getTypeLoc().getEndLoc();
526
808k
    else
527
808k
      return NameLoc;
528
529
    // DNInfo work in progress: FIXME.
530
0
  case DeclarationName::ObjCZeroArgSelector:
531
0
  case DeclarationName::ObjCOneArgSelector:
532
0
  case DeclarationName::ObjCMultiArgSelector:
533
0
  case DeclarationName::CXXUsingDirective:
534
0
    return NameLoc;
535
0
  }
536
0
  llvm_unreachable("Unexpected declaration name kind");
537
0
}