Coverage Report

Created: 2021-08-24 07:12

/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
39.1k
static int compareInt(unsigned A, unsigned B) {
43
39.1k
  return (A < B ? 
-123.6k
:
(15.4k
A > B15.4k
?
115.2k
:
0177
));
44
39.1k
}
45
46
9.96M
int DeclarationName::compare(DeclarationName LHS, DeclarationName RHS) {
47
9.96M
  if (LHS.getNameKind() != RHS.getNameKind())
48
290k
    return (LHS.getNameKind() < RHS.getNameKind() ? 
-1177k
:
1112k
);
49
50
9.67M
  switch (LHS.getNameKind()) {
51
9.42M
  case DeclarationName::Identifier: {
52
9.42M
    IdentifierInfo *LII = LHS.castAsIdentifierInfo();
53
9.42M
    IdentifierInfo *RII = RHS.castAsIdentifierInfo();
54
9.42M
    if (!LII)
55
0
      return RII ? -1 : 0;
56
9.42M
    if (!RII)
57
0
      return 1;
58
59
9.42M
    return LII->getName().compare(RII->getName());
60
9.42M
  }
61
62
91.0k
  case DeclarationName::ObjCZeroArgSelector:
63
168k
  case DeclarationName::ObjCOneArgSelector:
64
200k
  case DeclarationName::ObjCMultiArgSelector: {
65
200k
    Selector LHSSelector = LHS.getObjCSelector();
66
200k
    Selector RHSSelector = RHS.getObjCSelector();
67
    // getNumArgs for ZeroArgSelector returns 0, but we still need to compare.
68
200k
    if (LHS.getNameKind() == DeclarationName::ObjCZeroArgSelector &&
69
200k
        
RHS.getNameKind() == DeclarationName::ObjCZeroArgSelector91.0k
) {
70
91.0k
      return LHSSelector.getAsIdentifierInfo()->getName().compare(
71
91.0k
          RHSSelector.getAsIdentifierInfo()->getName());
72
91.0k
    }
73
109k
    unsigned LN = LHSSelector.getNumArgs(), RN = RHSSelector.getNumArgs();
74
118k
    for (unsigned I = 0, N = std::min(LN, RN); I != N; 
++I9.00k
) {
75
117k
      switch (LHSSelector.getNameForSlot(I).compare(
76
117k
          RHSSelector.getNameForSlot(I))) {
77
68.8k
      case -1:
78
68.8k
        return -1;
79
39.9k
      case 1:
80
39.9k
        return 1;
81
9.00k
      default:
82
9.00k
        break;
83
117k
      }
84
117k
    }
85
86
692
    return compareInt(LN, RN);
87
109k
  }
88
89
988
  case DeclarationName::CXXConstructorName:
90
1.83k
  case DeclarationName::CXXDestructorName:
91
1.83k
  case DeclarationName::CXXConversionFunctionName:
92
1.83k
    if (QualTypeOrdering()(LHS.getCXXNameType(), RHS.getCXXNameType()))
93
973
      return -1;
94
866
    if (QualTypeOrdering()(RHS.getCXXNameType(), LHS.getCXXNameType()))
95
732
      return 1;
96
134
    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
38.4k
  case DeclarationName::CXXOperatorName:
105
38.4k
    return compareInt(LHS.getCXXOverloadedOperator(),
106
38.4k
                      RHS.getCXXOverloadedOperator());
107
108
679
  case DeclarationName::CXXLiteralOperatorName:
109
679
    return LHS.getCXXLiteralIdentifier()->getName().compare(
110
679
        RHS.getCXXLiteralIdentifier()->getName());
111
112
0
  case DeclarationName::CXXUsingDirective:
113
0
    return 0;
114
9.67M
  }
115
116
0
  llvm_unreachable("Invalid DeclarationName Kind!");
117
0
}
118
119
static void printCXXConstructorDestructorName(QualType ClassType,
120
                                              raw_ostream &OS,
121
300k
                                              PrintingPolicy Policy) {
122
  // We know we're printing C++ here. Ensure we print types properly.
123
300k
  Policy.adjustForCPlusPlus();
124
125
300k
  if (const RecordType *ClassRec = ClassType->getAs<RecordType>()) {
126
185k
    OS << *ClassRec->getDecl();
127
185k
    return;
128
185k
  }
129
114k
  if (Policy.SuppressTemplateArgsInCXXConstructors) {
130
33
    if (auto *InjTy = ClassType->getAs<InjectedClassNameType>()) {
131
33
      OS << *InjTy->getDecl();
132
33
      return;
133
33
    }
134
33
  }
135
114k
  ClassType.print(OS, Policy);
136
114k
}
137
138
void DeclarationName::print(raw_ostream &OS,
139
4.89M
                            const PrintingPolicy &Policy) const {
140
4.89M
  switch (getNameKind()) {
141
3.30M
  case DeclarationName::Identifier:
142
3.30M
    if (const IdentifierInfo *II = getAsIdentifierInfo()) {
143
3.28M
      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
3.28M
      if (II->isMangledOpenMPVariantName()) {
147
360
        std::pair<StringRef, StringRef> NameContextPair =
148
360
            Name.split(getOpenMPVariantManglingSeparatorStr());
149
360
        OS << NameContextPair.first << "["
150
360
           << OMPTraitInfo(NameContextPair.second) << "]";
151
3.28M
      } else {
152
3.28M
        OS << Name;
153
3.28M
      }
154
3.28M
    }
155
3.30M
    return;
156
157
5.63k
  case DeclarationName::ObjCZeroArgSelector:
158
9.02k
  case DeclarationName::ObjCOneArgSelector:
159
9.73k
  case DeclarationName::ObjCMultiArgSelector:
160
9.73k
    getObjCSelector().print(OS);
161
9.73k
    return;
162
163
276k
  case DeclarationName::CXXConstructorName:
164
276k
    return printCXXConstructorDestructorName(getCXXNameType(), OS, Policy);
165
166
23.6k
  case DeclarationName::CXXDestructorName:
167
23.6k
    OS << '~';
168
23.6k
    return printCXXConstructorDestructorName(getCXXNameType(), OS, Policy);
169
170
117
  case DeclarationName::CXXDeductionGuideName:
171
117
    OS << "<deduction guide for ";
172
117
    getCXXDeductionGuideTemplate()->getDeclName().print(OS, Policy);
173
117
    OS << '>';
174
117
    return;
175
176
1.24M
  case DeclarationName::CXXOperatorName: {
177
1.24M
    const char *OpName = getOperatorSpelling(getCXXOverloadedOperator());
178
1.24M
    assert(OpName && "not an overloaded operator");
179
180
0
    OS << "operator";
181
1.24M
    if (OpName[0] >= 'a' && 
OpName[0] <= 'z'3.65k
)
182
2.34k
      OS << ' ';
183
1.24M
    OS << OpName;
184
1.24M
    return;
185
9.02k
  }
186
187
193
  case DeclarationName::CXXLiteralOperatorName:
188
193
    OS << "operator\"\"" << getCXXLiteralIdentifier()->getName();
189
193
    return;
190
191
6.29k
  case DeclarationName::CXXConversionFunctionName: {
192
6.29k
    OS << "operator ";
193
6.29k
    QualType Type = getCXXNameType();
194
6.29k
    if (const RecordType *Rec = Type->getAs<RecordType>()) {
195
713
      OS << *Rec->getDecl();
196
713
      return;
197
713
    }
198
    // We know we're printing C++ here, ensure we print 'bool' properly.
199
5.58k
    PrintingPolicy CXXPolicy = Policy;
200
5.58k
    CXXPolicy.adjustForCPlusPlus();
201
5.58k
    Type.print(OS, CXXPolicy);
202
5.58k
    return;
203
6.29k
  }
204
26.1k
  case DeclarationName::CXXUsingDirective:
205
26.1k
    OS << "<using-directive>";
206
26.1k
    return;
207
4.89M
  }
208
209
0
  llvm_unreachable("Unexpected declaration name kind");
210
0
}
211
212
namespace clang {
213
214
4.31M
raw_ostream &operator<<(raw_ostream &OS, DeclarationName N) {
215
4.31M
  LangOptions LO;
216
4.31M
  N.print(OS, PrintingPolicy(LO));
217
4.31M
  return OS;
218
4.31M
}
219
220
} // namespace clang
221
222
405k
bool DeclarationName::isDependentName() const {
223
405k
  QualType T = getCXXNameType();
224
405k
  if (!T.isNull() && 
T->isDependentType()617
)
225
14
    return true;
226
227
  // A class-scope deduction guide in a dependent context has a dependent name.
228
405k
  auto *TD = getCXXDeductionGuideTemplate();
229
405k
  if (TD && 
TD->getDeclContext()->isDependentContext()0
)
230
0
    return true;
231
232
405k
  return false;
233
405k
}
234
235
2.36M
std::string DeclarationName::getAsString() const {
236
2.36M
  std::string Result;
237
2.36M
  llvm::raw_string_ostream OS(Result);
238
2.36M
  OS << *this;
239
2.36M
  return OS.str();
240
2.36M
}
241
242
7.11M
void *DeclarationName::getFETokenInfoSlow() const {
243
7.11M
  switch (getNameKind()) {
244
0
  case Identifier:
245
0
    llvm_unreachable("case Identifier already handled by getFETokenInfo!");
246
2.38M
  case CXXConstructorName:
247
2.56M
  case CXXDestructorName:
248
2.61M
  case CXXConversionFunctionName:
249
2.61M
    return castAsCXXSpecialNameExtra()->FETokenInfo;
250
4.48M
  case CXXOperatorName:
251
4.48M
    return castAsCXXOperatorIdName()->FETokenInfo;
252
3.67k
  case CXXDeductionGuideName:
253
3.67k
    return castAsCXXDeductionGuideNameExtra()->FETokenInfo;
254
4.98k
  case CXXLiteralOperatorName:
255
4.98k
    return castAsCXXLiteralOperatorIdName()->FETokenInfo;
256
0
  default:
257
0
    llvm_unreachable("DeclarationName has no FETokenInfo!");
258
7.11M
  }
259
7.11M
}
260
261
545k
void DeclarationName::setFETokenInfoSlow(void *T) {
262
545k
  switch (getNameKind()) {
263
0
  case Identifier:
264
0
    llvm_unreachable("case Identifier already handled by setFETokenInfo!");
265
259k
  case CXXConstructorName:
266
356k
  case CXXDestructorName:
267
381k
  case CXXConversionFunctionName:
268
381k
    castAsCXXSpecialNameExtra()->FETokenInfo = T;
269
381k
    break;
270
163k
  case CXXOperatorName:
271
163k
    castAsCXXOperatorIdName()->FETokenInfo = T;
272
163k
    break;
273
430
  case CXXDeductionGuideName:
274
430
    castAsCXXDeductionGuideNameExtra()->FETokenInfo = T;
275
430
    break;
276
809
  case CXXLiteralOperatorName:
277
809
    castAsCXXLiteralOperatorIdName()->FETokenInfo = T;
278
809
    break;
279
0
  default:
280
0
    llvm_unreachable("DeclarationName has no FETokenInfo!");
281
545k
  }
282
545k
}
283
284
0
LLVM_DUMP_METHOD void DeclarationName::dump() const {
285
0
  llvm::errs() << *this << '\n';
286
0
}
287
288
102k
DeclarationNameTable::DeclarationNameTable(const ASTContext &C) : Ctx(C) {
289
  // Initialize the overloaded operator names.
290
4.81M
  for (unsigned Op = 0; Op < NUM_OVERLOADED_OPERATORS; 
++Op4.71M
)
291
4.71M
    CXXOperatorNames[Op].Kind = static_cast<OverloadedOperatorKind>(Op);
292
102k
}
293
294
DeclarationName
295
3.22k
DeclarationNameTable::getCXXDeductionGuideName(TemplateDecl *Template) {
296
3.22k
  Template = cast<TemplateDecl>(Template->getCanonicalDecl());
297
298
3.22k
  llvm::FoldingSetNodeID ID;
299
3.22k
  ID.AddPointer(Template);
300
301
3.22k
  void *InsertPos = nullptr;
302
3.22k
  if (auto *Name = CXXDeductionGuideNames.FindNodeOrInsertPos(ID, InsertPos))
303
2.88k
    return DeclarationName(Name);
304
305
340
  auto *Name = new (Ctx) detail::CXXDeductionGuideNameExtra(Template);
306
340
  CXXDeductionGuideNames.InsertNode(Name, InsertPos);
307
340
  return DeclarationName(Name);
308
3.22k
}
309
310
2.52M
DeclarationName DeclarationNameTable::getCXXConstructorName(CanQualType Ty) {
311
  // The type of constructors is unqualified.
312
2.52M
  Ty = Ty.getUnqualifiedType();
313
  // Do we already have this C++ constructor name ?
314
2.52M
  llvm::FoldingSetNodeID ID;
315
2.52M
  ID.AddPointer(Ty.getAsOpaquePtr());
316
2.52M
  void *InsertPos = nullptr;
317
2.52M
  if (auto *Name = CXXConstructorNames.FindNodeOrInsertPos(ID, InsertPos))
318
2.20M
    return {Name, DeclarationName::StoredCXXConstructorName};
319
320
  // We have to create it.
321
312k
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
322
312k
  CXXConstructorNames.InsertNode(SpecialName, InsertPos);
323
312k
  return {SpecialName, DeclarationName::StoredCXXConstructorName};
324
2.52M
}
325
326
7.36M
DeclarationName DeclarationNameTable::getCXXDestructorName(CanQualType Ty) {
327
  // The type of destructors is unqualified.
328
7.36M
  Ty = Ty.getUnqualifiedType();
329
  // Do we already have this C++ destructor name ?
330
7.36M
  llvm::FoldingSetNodeID ID;
331
7.36M
  ID.AddPointer(Ty.getAsOpaquePtr());
332
7.36M
  void *InsertPos = nullptr;
333
7.36M
  if (auto *Name = CXXDestructorNames.FindNodeOrInsertPos(ID, InsertPos))
334
5.86M
    return {Name, DeclarationName::StoredCXXDestructorName};
335
336
  // We have to create it.
337
1.49M
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
338
1.49M
  CXXDestructorNames.InsertNode(SpecialName, InsertPos);
339
1.49M
  return {SpecialName, DeclarationName::StoredCXXDestructorName};
340
7.36M
}
341
342
DeclarationName
343
79.2k
DeclarationNameTable::getCXXConversionFunctionName(CanQualType Ty) {
344
  // Do we already have this C++ conversion function name ?
345
79.2k
  llvm::FoldingSetNodeID ID;
346
79.2k
  ID.AddPointer(Ty.getAsOpaquePtr());
347
79.2k
  void *InsertPos = nullptr;
348
79.2k
  if (auto *Name =
349
79.2k
          CXXConversionFunctionNames.FindNodeOrInsertPos(ID, InsertPos))
350
62.6k
    return {Name, DeclarationName::StoredCXXConversionFunctionName};
351
352
  // We have to create it.
353
16.5k
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
354
16.5k
  CXXConversionFunctionNames.InsertNode(SpecialName, InsertPos);
355
16.5k
  return {SpecialName, DeclarationName::StoredCXXConversionFunctionName};
356
79.2k
}
357
358
DeclarationName
359
DeclarationNameTable::getCXXSpecialName(DeclarationName::NameKind Kind,
360
253k
                                        CanQualType Ty) {
361
253k
  switch (Kind) {
362
227k
  case DeclarationName::CXXConstructorName:
363
227k
    return getCXXConstructorName(Ty);
364
13.4k
  case DeclarationName::CXXDestructorName:
365
13.4k
    return getCXXDestructorName(Ty);
366
12.4k
  case DeclarationName::CXXConversionFunctionName:
367
12.4k
    return getCXXConversionFunctionName(Ty);
368
0
  default:
369
0
    llvm_unreachable("Invalid kind in getCXXSpecialName!");
370
253k
  }
371
253k
}
372
373
DeclarationName
374
2.68k
DeclarationNameTable::getCXXLiteralOperatorName(IdentifierInfo *II) {
375
2.68k
  llvm::FoldingSetNodeID ID;
376
2.68k
  ID.AddPointer(II);
377
378
2.68k
  void *InsertPos = nullptr;
379
2.68k
  if (auto *Name = CXXLiteralOperatorNames.FindNodeOrInsertPos(ID, InsertPos))
380
2.24k
    return DeclarationName(Name);
381
382
444
  auto *LiteralName = new (Ctx) detail::CXXLiteralOperatorIdName(II);
383
444
  CXXLiteralOperatorNames.InsertNode(LiteralName, InsertPos);
384
444
  return DeclarationName(LiteralName);
385
2.68k
}
386
387
211M
DeclarationNameLoc::DeclarationNameLoc(DeclarationName Name) {
388
211M
  switch (Name.getNameKind()) {
389
206M
  case DeclarationName::Identifier:
390
206M
  case DeclarationName::CXXDeductionGuideName:
391
206M
    break;
392
588k
  case DeclarationName::CXXConstructorName:
393
781k
  case DeclarationName::CXXDestructorName:
394
783k
  case DeclarationName::CXXConversionFunctionName:
395
783k
    setNamedTypeLoc(nullptr);
396
783k
    break;
397
4.52M
  case DeclarationName::CXXOperatorName:
398
4.52M
    setCXXOperatorNameRange(SourceRange());
399
4.52M
    break;
400
793
  case DeclarationName::CXXLiteralOperatorName:
401
793
    setCXXLiteralOperatorNameLoc(SourceLocation());
402
793
    break;
403
0
  case DeclarationName::ObjCZeroArgSelector:
404
0
  case DeclarationName::ObjCOneArgSelector:
405
0
  case DeclarationName::ObjCMultiArgSelector:
406
    // FIXME: ?
407
0
    break;
408
0
  case DeclarationName::CXXUsingDirective:
409
0
    break;
410
211M
  }
411
211M
}
412
413
5.65M
bool DeclarationNameInfo::containsUnexpandedParameterPack() const {
414
5.65M
  switch (Name.getNameKind()) {
415
4.69M
  case DeclarationName::Identifier:
416
4.69M
  case DeclarationName::ObjCZeroArgSelector:
417
4.69M
  case DeclarationName::ObjCOneArgSelector:
418
4.69M
  case DeclarationName::ObjCMultiArgSelector:
419
5.65M
  case DeclarationName::CXXOperatorName:
420
5.65M
  case DeclarationName::CXXLiteralOperatorName:
421
5.65M
  case DeclarationName::CXXUsingDirective:
422
5.65M
  case DeclarationName::CXXDeductionGuideName:
423
5.65M
    return false;
424
425
14
  case DeclarationName::CXXConstructorName:
426
19
  case DeclarationName::CXXDestructorName:
427
55
  case DeclarationName::CXXConversionFunctionName:
428
55
    if (TypeSourceInfo *TInfo = LocInfo.getNamedTypeInfo())
429
40
      return TInfo->getType()->containsUnexpandedParameterPack();
430
431
15
    return Name.getCXXNameType()->containsUnexpandedParameterPack();
432
5.65M
  }
433
0
  llvm_unreachable("All name kinds handled.");
434
0
}
435
436
5.65M
bool DeclarationNameInfo::isInstantiationDependent() const {
437
5.65M
  switch (Name.getNameKind()) {
438
4.69M
  case DeclarationName::Identifier:
439
4.69M
  case DeclarationName::ObjCZeroArgSelector:
440
4.69M
  case DeclarationName::ObjCOneArgSelector:
441
4.69M
  case DeclarationName::ObjCMultiArgSelector:
442
5.65M
  case DeclarationName::CXXOperatorName:
443
5.65M
  case DeclarationName::CXXLiteralOperatorName:
444
5.65M
  case DeclarationName::CXXUsingDirective:
445
5.65M
  case DeclarationName::CXXDeductionGuideName:
446
5.65M
    return false;
447
448
14
  case DeclarationName::CXXConstructorName:
449
19
  case DeclarationName::CXXDestructorName:
450
54
  case DeclarationName::CXXConversionFunctionName:
451
54
    if (TypeSourceInfo *TInfo = LocInfo.getNamedTypeInfo())
452
39
      return TInfo->getType()->isInstantiationDependentType();
453
454
15
    return Name.getCXXNameType()->isInstantiationDependentType();
455
5.65M
  }
456
0
  llvm_unreachable("All name kinds handled.");
457
0
}
458
459
495k
std::string DeclarationNameInfo::getAsString() const {
460
495k
  std::string Result;
461
495k
  llvm::raw_string_ostream OS(Result);
462
495k
  OS << *this;
463
495k
  return OS.str();
464
495k
}
465
466
565k
raw_ostream &clang::operator<<(raw_ostream &OS, DeclarationNameInfo DNInfo) {
467
565k
  LangOptions LO;
468
565k
  DNInfo.printName(OS, PrintingPolicy(LangOptions()));
469
565k
  return OS;
470
565k
}
471
472
573k
void DeclarationNameInfo::printName(raw_ostream &OS, PrintingPolicy Policy) const {
473
573k
  switch (Name.getNameKind()) {
474
368k
  case DeclarationName::Identifier:
475
368k
  case DeclarationName::ObjCZeroArgSelector:
476
368k
  case DeclarationName::ObjCOneArgSelector:
477
368k
  case DeclarationName::ObjCMultiArgSelector:
478
519k
  case DeclarationName::CXXOperatorName:
479
519k
  case DeclarationName::CXXLiteralOperatorName:
480
519k
  case DeclarationName::CXXUsingDirective:
481
519k
  case DeclarationName::CXXDeductionGuideName:
482
519k
    Name.print(OS, Policy);
483
519k
    return;
484
485
48.6k
  case DeclarationName::CXXConstructorName:
486
51.7k
  case DeclarationName::CXXDestructorName:
487
53.7k
  case DeclarationName::CXXConversionFunctionName:
488
53.7k
    if (TypeSourceInfo *TInfo = LocInfo.getNamedTypeInfo()) {
489
4.94k
      if (Name.getNameKind() == DeclarationName::CXXDestructorName)
490
3.08k
        OS << '~';
491
1.86k
      else if (Name.getNameKind() == DeclarationName::CXXConversionFunctionName)
492
1.86k
        OS << "operator ";
493
4.94k
      LangOptions LO;
494
4.94k
      Policy.adjustForCPlusPlus();
495
4.94k
      Policy.SuppressScope = true;
496
4.94k
      OS << TInfo->getType().getAsString(Policy);
497
4.94k
    } else
498
48.8k
      Name.print(OS, Policy);
499
53.7k
    return;
500
573k
  }
501
0
  llvm_unreachable("Unexpected declaration name kind");
502
0
}
503
504
46.1M
SourceLocation DeclarationNameInfo::getEndLocPrivate() const {
505
46.1M
  switch (Name.getNameKind()) {
506
44.3M
  case DeclarationName::Identifier:
507
44.3M
  case DeclarationName::CXXDeductionGuideName:
508
44.3M
    return NameLoc;
509
510
764k
  case DeclarationName::CXXOperatorName:
511
764k
    return LocInfo.getCXXOperatorNameEndLoc();
512
513
1.13k
  case DeclarationName::CXXLiteralOperatorName:
514
1.13k
    return LocInfo.getCXXLiteralOperatorNameLoc();
515
516
832k
  case DeclarationName::CXXConstructorName:
517
990k
  case DeclarationName::CXXDestructorName:
518
1.03M
  case DeclarationName::CXXConversionFunctionName:
519
1.03M
    if (TypeSourceInfo *TInfo = LocInfo.getNamedTypeInfo())
520
96.0k
      return TInfo->getTypeLoc().getEndLoc();
521
938k
    else
522
938k
      return NameLoc;
523
524
    // DNInfo work in progress: FIXME.
525
0
  case DeclarationName::ObjCZeroArgSelector:
526
0
  case DeclarationName::ObjCOneArgSelector:
527
0
  case DeclarationName::ObjCMultiArgSelector:
528
0
  case DeclarationName::CXXUsingDirective:
529
0
    return NameLoc;
530
46.1M
  }
531
0
  llvm_unreachable("Unexpected declaration name kind");
532
0
}