Coverage Report

Created: 2022-01-18 06:27

/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
34.6k
static int compareInt(unsigned A, unsigned B) {
43
34.6k
  return (A < B ? 
-121.1k
:
(13.5k
A > B13.5k
?
113.3k
:
0170
));
44
34.6k
}
45
46
9.76M
int DeclarationName::compare(DeclarationName LHS, DeclarationName RHS) {
47
9.76M
  if (LHS.getNameKind() != RHS.getNameKind())
48
283k
    return (LHS.getNameKind() < RHS.getNameKind() ? 
-1173k
:
1109k
);
49
50
9.48M
  switch (LHS.getNameKind()) {
51
9.24M
  case DeclarationName::Identifier: {
52
9.24M
    IdentifierInfo *LII = LHS.castAsIdentifierInfo();
53
9.24M
    IdentifierInfo *RII = RHS.castAsIdentifierInfo();
54
9.24M
    if (!LII)
55
0
      return RII ? -1 : 0;
56
9.24M
    if (!RII)
57
0
      return 1;
58
59
9.24M
    return LII->getName().compare(RII->getName());
60
9.24M
  }
61
62
91.0k
  case DeclarationName::ObjCZeroArgSelector:
63
168k
  case DeclarationName::ObjCOneArgSelector:
64
199k
  case DeclarationName::ObjCMultiArgSelector: {
65
199k
    Selector LHSSelector = LHS.getObjCSelector();
66
199k
    Selector RHSSelector = RHS.getObjCSelector();
67
    // getNumArgs for ZeroArgSelector returns 0, but we still need to compare.
68
199k
    if (LHS.getNameKind() == DeclarationName::ObjCZeroArgSelector &&
69
199k
        
RHS.getNameKind() == DeclarationName::ObjCZeroArgSelector91.0k
) {
70
91.0k
      return LHSSelector.getAsIdentifierInfo()->getName().compare(
71
91.0k
          RHSSelector.getAsIdentifierInfo()->getName());
72
91.0k
    }
73
108k
    unsigned LN = LHSSelector.getNumArgs(), RN = RHSSelector.getNumArgs();
74
117k
    for (unsigned I = 0, N = std::min(LN, RN); I != N; 
++I8.95k
) {
75
116k
      switch (LHSSelector.getNameForSlot(I).compare(
76
116k
          RHSSelector.getNameForSlot(I))) {
77
68.3k
      case -1:
78
68.3k
        return -1;
79
39.4k
      case 1:
80
39.4k
        return 1;
81
8.95k
      default:
82
8.95k
        break;
83
116k
      }
84
116k
    }
85
86
679
    return compareInt(LN, RN);
87
108k
  }
88
89
934
  case DeclarationName::CXXConstructorName:
90
1.67k
  case DeclarationName::CXXDestructorName:
91
1.68k
  case DeclarationName::CXXConversionFunctionName:
92
1.68k
    if (QualTypeOrdering()(LHS.getCXXNameType(), RHS.getCXXNameType()))
93
887
      return -1;
94
793
    if (QualTypeOrdering()(RHS.getCXXNameType(), LHS.getCXXNameType()))
95
676
      return 1;
96
117
    return 0;
97
98
1.29k
  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.29k
    return compare(LHS.getCXXDeductionGuideTemplate()->getDeclName(),
102
1.29k
                   RHS.getCXXDeductionGuideTemplate()->getDeclName());
103
104
34.0k
  case DeclarationName::CXXOperatorName:
105
34.0k
    return compareInt(LHS.getCXXOverloadedOperator(),
106
34.0k
                      RHS.getCXXOverloadedOperator());
107
108
618
  case DeclarationName::CXXLiteralOperatorName:
109
618
    return LHS.getCXXLiteralIdentifier()->getName().compare(
110
618
        RHS.getCXXLiteralIdentifier()->getName());
111
112
0
  case DeclarationName::CXXUsingDirective:
113
0
    return 0;
114
9.48M
  }
115
116
0
  llvm_unreachable("Invalid DeclarationName Kind!");
117
0
}
118
119
static void printCXXConstructorDestructorName(QualType ClassType,
120
                                              raw_ostream &OS,
121
424k
                                              PrintingPolicy Policy) {
122
  // We know we're printing C++ here. Ensure we print types properly.
123
424k
  Policy.adjustForCPlusPlus();
124
125
424k
  if (const RecordType *ClassRec = ClassType->getAs<RecordType>()) {
126
310k
    OS << *ClassRec->getDecl();
127
310k
    return;
128
310k
  }
129
113k
  if (Policy.SuppressTemplateArgsInCXXConstructors) {
130
33
    if (auto *InjTy = ClassType->getAs<InjectedClassNameType>()) {
131
33
      OS << *InjTy->getDecl();
132
33
      return;
133
33
    }
134
33
  }
135
113k
  ClassType.print(OS, Policy);
136
113k
}
137
138
void DeclarationName::print(raw_ostream &OS,
139
5.31M
                            const PrintingPolicy &Policy) const {
140
5.31M
  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
400
        std::pair<StringRef, StringRef> NameContextPair =
148
400
            Name.split(getOpenMPVariantManglingSeparatorStr());
149
400
        OS << NameContextPair.first << "["
150
400
           << 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.64k
  case DeclarationName::ObjCZeroArgSelector:
158
9.03k
  case DeclarationName::ObjCOneArgSelector:
159
9.74k
  case DeclarationName::ObjCMultiArgSelector:
160
9.74k
    getObjCSelector().print(OS);
161
9.74k
    return;
162
163
401k
  case DeclarationName::CXXConstructorName:
164
401k
    return printCXXConstructorDestructorName(getCXXNameType(), OS, Policy);
165
166
22.6k
  case DeclarationName::CXXDestructorName:
167
22.6k
    OS << '~';
168
22.6k
    return printCXXConstructorDestructorName(getCXXNameType(), OS, Policy);
169
170
173
  case DeclarationName::CXXDeductionGuideName:
171
173
    OS << "<deduction guide for ";
172
173
    getCXXDeductionGuideTemplate()->getDeclName().print(OS, Policy);
173
173
    OS << '>';
174
173
    return;
175
176
1.55M
  case DeclarationName::CXXOperatorName: {
177
1.55M
    const char *OpName = getOperatorSpelling(getCXXOverloadedOperator());
178
1.55M
    assert(OpName && "not an overloaded operator");
179
180
0
    OS << "operator";
181
1.55M
    if (OpName[0] >= 'a' && 
OpName[0] <= 'z'17.8k
)
182
16.4k
      OS << ' ';
183
1.55M
    OS << OpName;
184
1.55M
    return;
185
9.03k
  }
186
187
193
  case DeclarationName::CXXLiteralOperatorName:
188
193
    OS << "operator\"\"" << getCXXLiteralIdentifier()->getName();
189
193
    return;
190
191
7.14k
  case DeclarationName::CXXConversionFunctionName: {
192
7.14k
    OS << "operator ";
193
7.14k
    QualType Type = getCXXNameType();
194
7.14k
    if (const RecordType *Rec = Type->getAs<RecordType>()) {
195
731
      OS << *Rec->getDecl();
196
731
      return;
197
731
    }
198
    // We know we're printing C++ here, ensure we print 'bool' properly.
199
6.41k
    PrintingPolicy CXXPolicy = Policy;
200
6.41k
    CXXPolicy.adjustForCPlusPlus();
201
6.41k
    Type.print(OS, CXXPolicy);
202
6.41k
    return;
203
7.14k
  }
204
15.4k
  case DeclarationName::CXXUsingDirective:
205
15.4k
    OS << "<using-directive>";
206
15.4k
    return;
207
5.31M
  }
208
209
0
  llvm_unreachable("Unexpected declaration name kind");
210
0
}
211
212
namespace clang {
213
214
4.71M
raw_ostream &operator<<(raw_ostream &OS, DeclarationName N) {
215
4.71M
  LangOptions LO;
216
4.71M
  N.print(OS, PrintingPolicy(LO));
217
4.71M
  return OS;
218
4.71M
}
219
220
} // namespace clang
221
222
413k
bool DeclarationName::isDependentName() const {
223
413k
  QualType T = getCXXNameType();
224
413k
  if (!T.isNull() && 
T->isDependentType()620
)
225
14
    return true;
226
227
  // A class-scope deduction guide in a dependent context has a dependent name.
228
413k
  auto *TD = getCXXDeductionGuideTemplate();
229
413k
  if (TD && 
TD->getDeclContext()->isDependentContext()0
)
230
0
    return true;
231
232
413k
  return false;
233
413k
}
234
235
2.39M
std::string DeclarationName::getAsString() const {
236
2.39M
  std::string Result;
237
2.39M
  llvm::raw_string_ostream OS(Result);
238
2.39M
  OS << *this;
239
2.39M
  return Result;
240
2.39M
}
241
242
7.12M
void *DeclarationName::getFETokenInfoSlow() const {
243
7.12M
  switch (getNameKind()) {
244
0
  case Identifier:
245
0
    llvm_unreachable("case Identifier already handled by getFETokenInfo!");
246
2.44M
  case CXXConstructorName:
247
2.62M
  case CXXDestructorName:
248
2.68M
  case CXXConversionFunctionName:
249
2.68M
    return castAsCXXSpecialNameExtra()->FETokenInfo;
250
4.43M
  case CXXOperatorName:
251
4.43M
    return castAsCXXOperatorIdName()->FETokenInfo;
252
3.73k
  case CXXDeductionGuideName:
253
3.73k
    return castAsCXXDeductionGuideNameExtra()->FETokenInfo;
254
4.97k
  case CXXLiteralOperatorName:
255
4.97k
    return castAsCXXLiteralOperatorIdName()->FETokenInfo;
256
0
  default:
257
0
    llvm_unreachable("DeclarationName has no FETokenInfo!");
258
7.12M
  }
259
7.12M
}
260
261
559k
void DeclarationName::setFETokenInfoSlow(void *T) {
262
559k
  switch (getNameKind()) {
263
0
  case Identifier:
264
0
    llvm_unreachable("case Identifier already handled by setFETokenInfo!");
265
262k
  case CXXConstructorName:
266
359k
  case CXXDestructorName:
267
384k
  case CXXConversionFunctionName:
268
384k
    castAsCXXSpecialNameExtra()->FETokenInfo = T;
269
384k
    break;
270
173k
  case CXXOperatorName:
271
173k
    castAsCXXOperatorIdName()->FETokenInfo = T;
272
173k
    break;
273
452
  case CXXDeductionGuideName:
274
452
    castAsCXXDeductionGuideNameExtra()->FETokenInfo = T;
275
452
    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
559k
  }
282
559k
}
283
284
0
LLVM_DUMP_METHOD void DeclarationName::dump() const {
285
0
  llvm::errs() << *this << '\n';
286
0
}
287
288
93.5k
DeclarationNameTable::DeclarationNameTable(const ASTContext &C) : Ctx(C) {
289
  // Initialize the overloaded operator names.
290
4.39M
  for (unsigned Op = 0; Op < NUM_OVERLOADED_OPERATORS; 
++Op4.30M
)
291
4.30M
    CXXOperatorNames[Op].Kind = static_cast<OverloadedOperatorKind>(Op);
292
93.5k
}
293
294
DeclarationName
295
3.36k
DeclarationNameTable::getCXXDeductionGuideName(TemplateDecl *Template) {
296
3.36k
  Template = cast<TemplateDecl>(Template->getCanonicalDecl());
297
298
3.36k
  llvm::FoldingSetNodeID ID;
299
3.36k
  ID.AddPointer(Template);
300
301
3.36k
  void *InsertPos = nullptr;
302
3.36k
  if (auto *Name = CXXDeductionGuideNames.FindNodeOrInsertPos(ID, InsertPos))
303
3.00k
    return DeclarationName(Name);
304
305
366
  auto *Name = new (Ctx) detail::CXXDeductionGuideNameExtra(Template);
306
366
  CXXDeductionGuideNames.InsertNode(Name, InsertPos);
307
366
  return DeclarationName(Name);
308
3.36k
}
309
310
2.56M
DeclarationName DeclarationNameTable::getCXXConstructorName(CanQualType Ty) {
311
  // The type of constructors is unqualified.
312
2.56M
  Ty = Ty.getUnqualifiedType();
313
  // Do we already have this C++ constructor name ?
314
2.56M
  llvm::FoldingSetNodeID ID;
315
2.56M
  ID.AddPointer(Ty.getAsOpaquePtr());
316
2.56M
  void *InsertPos = nullptr;
317
2.56M
  if (auto *Name = CXXConstructorNames.FindNodeOrInsertPos(ID, InsertPos))
318
2.24M
    return {Name, DeclarationName::StoredCXXConstructorName};
319
320
  // We have to create it.
321
327k
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
322
327k
  CXXConstructorNames.InsertNode(SpecialName, InsertPos);
323
327k
  return {SpecialName, DeclarationName::StoredCXXConstructorName};
324
2.56M
}
325
326
7.48M
DeclarationName DeclarationNameTable::getCXXDestructorName(CanQualType Ty) {
327
  // The type of destructors is unqualified.
328
7.48M
  Ty = Ty.getUnqualifiedType();
329
  // Do we already have this C++ destructor name ?
330
7.48M
  llvm::FoldingSetNodeID ID;
331
7.48M
  ID.AddPointer(Ty.getAsOpaquePtr());
332
7.48M
  void *InsertPos = nullptr;
333
7.48M
  if (auto *Name = CXXDestructorNames.FindNodeOrInsertPos(ID, InsertPos))
334
5.95M
    return {Name, DeclarationName::StoredCXXDestructorName};
335
336
  // We have to create it.
337
1.53M
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
338
1.53M
  CXXDestructorNames.InsertNode(SpecialName, InsertPos);
339
1.53M
  return {SpecialName, DeclarationName::StoredCXXDestructorName};
340
7.48M
}
341
342
DeclarationName
343
80.1k
DeclarationNameTable::getCXXConversionFunctionName(CanQualType Ty) {
344
  // Do we already have this C++ conversion function name ?
345
80.1k
  llvm::FoldingSetNodeID ID;
346
80.1k
  ID.AddPointer(Ty.getAsOpaquePtr());
347
80.1k
  void *InsertPos = nullptr;
348
80.1k
  if (auto *Name =
349
80.1k
          CXXConversionFunctionNames.FindNodeOrInsertPos(ID, InsertPos))
350
63.4k
    return {Name, DeclarationName::StoredCXXConversionFunctionName};
351
352
  // We have to create it.
353
16.7k
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
354
16.7k
  CXXConversionFunctionNames.InsertNode(SpecialName, InsertPos);
355
16.7k
  return {SpecialName, DeclarationName::StoredCXXConversionFunctionName};
356
80.1k
}
357
358
DeclarationName
359
DeclarationNameTable::getCXXSpecialName(DeclarationName::NameKind Kind,
360
248k
                                        CanQualType Ty) {
361
248k
  switch (Kind) {
362
223k
  case DeclarationName::CXXConstructorName:
363
223k
    return getCXXConstructorName(Ty);
364
12.9k
  case DeclarationName::CXXDestructorName:
365
12.9k
    return getCXXDestructorName(Ty);
366
12.5k
  case DeclarationName::CXXConversionFunctionName:
367
12.5k
    return getCXXConversionFunctionName(Ty);
368
0
  default:
369
0
    llvm_unreachable("Invalid kind in getCXXSpecialName!");
370
248k
  }
371
248k
}
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.23k
    return DeclarationName(Name);
381
382
447
  auto *LiteralName = new (Ctx) detail::CXXLiteralOperatorIdName(II);
383
447
  CXXLiteralOperatorNames.InsertNode(LiteralName, InsertPos);
384
447
  return DeclarationName(LiteralName);
385
2.68k
}
386
387
175M
DeclarationNameLoc::DeclarationNameLoc(DeclarationName Name) {
388
175M
  switch (Name.getNameKind()) {
389
170M
  case DeclarationName::Identifier:
390
170M
  case DeclarationName::CXXDeductionGuideName:
391
170M
    break;
392
647k
  case DeclarationName::CXXConstructorName:
393
843k
  case DeclarationName::CXXDestructorName:
394
845k
  case DeclarationName::CXXConversionFunctionName:
395
845k
    setNamedTypeLoc(nullptr);
396
845k
    break;
397
4.57M
  case DeclarationName::CXXOperatorName:
398
4.57M
    setCXXOperatorNameRange(SourceRange());
399
4.57M
    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
175M
  }
411
175M
}
412
413
5.71M
bool DeclarationNameInfo::containsUnexpandedParameterPack() const {
414
5.71M
  switch (Name.getNameKind()) {
415
4.76M
  case DeclarationName::Identifier:
416
4.76M
  case DeclarationName::ObjCZeroArgSelector:
417
4.76M
  case DeclarationName::ObjCOneArgSelector:
418
4.76M
  case DeclarationName::ObjCMultiArgSelector:
419
5.71M
  case DeclarationName::CXXOperatorName:
420
5.71M
  case DeclarationName::CXXLiteralOperatorName:
421
5.71M
  case DeclarationName::CXXUsingDirective:
422
5.71M
  case DeclarationName::CXXDeductionGuideName:
423
5.71M
    return false;
424
425
14
  case DeclarationName::CXXConstructorName:
426
19
  case DeclarationName::CXXDestructorName:
427
58
  case DeclarationName::CXXConversionFunctionName:
428
58
    if (TypeSourceInfo *TInfo = LocInfo.getNamedTypeInfo())
429
43
      return TInfo->getType()->containsUnexpandedParameterPack();
430
431
15
    return Name.getCXXNameType()->containsUnexpandedParameterPack();
432
5.71M
  }
433
0
  llvm_unreachable("All name kinds handled.");
434
0
}
435
436
5.71M
bool DeclarationNameInfo::isInstantiationDependent() const {
437
5.71M
  switch (Name.getNameKind()) {
438
4.76M
  case DeclarationName::Identifier:
439
4.76M
  case DeclarationName::ObjCZeroArgSelector:
440
4.76M
  case DeclarationName::ObjCOneArgSelector:
441
4.76M
  case DeclarationName::ObjCMultiArgSelector:
442
5.71M
  case DeclarationName::CXXOperatorName:
443
5.71M
  case DeclarationName::CXXLiteralOperatorName:
444
5.71M
  case DeclarationName::CXXUsingDirective:
445
5.71M
  case DeclarationName::CXXDeductionGuideName:
446
5.71M
    return false;
447
448
14
  case DeclarationName::CXXConstructorName:
449
19
  case DeclarationName::CXXDestructorName:
450
57
  case DeclarationName::CXXConversionFunctionName:
451
57
    if (TypeSourceInfo *TInfo = LocInfo.getNamedTypeInfo())
452
42
      return TInfo->getType()->isInstantiationDependentType();
453
454
15
    return Name.getCXXNameType()->isInstantiationDependentType();
455
5.71M
  }
456
0
  llvm_unreachable("All name kinds handled.");
457
0
}
458
459
520k
std::string DeclarationNameInfo::getAsString() const {
460
520k
  std::string Result;
461
520k
  llvm::raw_string_ostream OS(Result);
462
520k
  OS << *this;
463
520k
  return Result;
464
520k
}
465
466
590k
raw_ostream &clang::operator<<(raw_ostream &OS, DeclarationNameInfo DNInfo) {
467
590k
  LangOptions LO;
468
590k
  DNInfo.printName(OS, PrintingPolicy(LangOptions()));
469
590k
  return OS;
470
590k
}
471
472
598k
void DeclarationNameInfo::printName(raw_ostream &OS, PrintingPolicy Policy) const {
473
598k
  switch (Name.getNameKind()) {
474
377k
  case DeclarationName::Identifier:
475
377k
  case DeclarationName::ObjCZeroArgSelector:
476
377k
  case DeclarationName::ObjCOneArgSelector:
477
377k
  case DeclarationName::ObjCMultiArgSelector:
478
543k
  case DeclarationName::CXXOperatorName:
479
543k
  case DeclarationName::CXXLiteralOperatorName:
480
543k
  case DeclarationName::CXXUsingDirective:
481
543k
  case DeclarationName::CXXDeductionGuideName:
482
543k
    Name.print(OS, Policy);
483
543k
    return;
484
485
50.0k
  case DeclarationName::CXXConstructorName:
486
53.1k
  case DeclarationName::CXXDestructorName:
487
55.2k
  case DeclarationName::CXXConversionFunctionName:
488
55.2k
    if (TypeSourceInfo *TInfo = LocInfo.getNamedTypeInfo()) {
489
5.03k
      if (Name.getNameKind() == DeclarationName::CXXDestructorName)
490
3.09k
        OS << '~';
491
1.93k
      else if (Name.getNameKind() == DeclarationName::CXXConversionFunctionName)
492
1.93k
        OS << "operator ";
493
5.03k
      LangOptions LO;
494
5.03k
      Policy.adjustForCPlusPlus();
495
5.03k
      Policy.SuppressScope = true;
496
5.03k
      OS << TInfo->getType().getAsString(Policy);
497
5.03k
    } else
498
50.2k
      Name.print(OS, Policy);
499
55.2k
    return;
500
598k
  }
501
0
  llvm_unreachable("Unexpected declaration name kind");
502
0
}
503
504
42.5M
SourceLocation DeclarationNameInfo::getEndLocPrivate() const {
505
42.5M
  switch (Name.getNameKind()) {
506
40.7M
  case DeclarationName::Identifier:
507
40.7M
  case DeclarationName::CXXDeductionGuideName:
508
40.7M
    return NameLoc;
509
510
767k
  case DeclarationName::CXXOperatorName:
511
767k
    return LocInfo.getCXXOperatorNameEndLoc();
512
513
1.13k
  case DeclarationName::CXXLiteralOperatorName:
514
1.13k
    return LocInfo.getCXXLiteralOperatorNameLoc();
515
516
876k
  case DeclarationName::CXXConstructorName:
517
1.03M
  case DeclarationName::CXXDestructorName:
518
1.08M
  case DeclarationName::CXXConversionFunctionName:
519
1.08M
    if (TypeSourceInfo *TInfo = LocInfo.getNamedTypeInfo())
520
96.2k
      return TInfo->getTypeLoc().getEndLoc();
521
985k
    else
522
985k
      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
42.5M
  }
531
0
  llvm_unreachable("Unexpected declaration name kind");
532
0
}