Coverage Report

Created: 2022-07-16 07:03

/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
38.3k
static int compareInt(unsigned A, unsigned B) {
43
38.3k
  return (A < B ? 
-123.3k
:
(15.0k
A > B15.0k
?
114.8k
:
0177
));
44
38.3k
}
45
46
10.7M
int DeclarationName::compare(DeclarationName LHS, DeclarationName RHS) {
47
10.7M
  if (LHS.getNameKind() != RHS.getNameKind())
48
316k
    return (LHS.getNameKind() < RHS.getNameKind() ? 
-1192k
:
1124k
);
49
50
10.3M
  switch (LHS.getNameKind()) {
51
10.1M
  case DeclarationName::Identifier: {
52
10.1M
    IdentifierInfo *LII = LHS.castAsIdentifierInfo();
53
10.1M
    IdentifierInfo *RII = RHS.castAsIdentifierInfo();
54
10.1M
    if (!LII)
55
0
      return RII ? -1 : 0;
56
10.1M
    if (!RII)
57
0
      return 1;
58
59
10.1M
    return LII->getName().compare(RII->getName());
60
10.1M
  }
61
62
100k
  case DeclarationName::ObjCZeroArgSelector:
63
184k
  case DeclarationName::ObjCOneArgSelector:
64
219k
  case DeclarationName::ObjCMultiArgSelector: {
65
219k
    Selector LHSSelector = LHS.getObjCSelector();
66
219k
    Selector RHSSelector = RHS.getObjCSelector();
67
    // getNumArgs for ZeroArgSelector returns 0, but we still need to compare.
68
219k
    if (LHS.getNameKind() == DeclarationName::ObjCZeroArgSelector &&
69
219k
        
RHS.getNameKind() == DeclarationName::ObjCZeroArgSelector100k
) {
70
100k
      return LHSSelector.getAsIdentifierInfo()->getName().compare(
71
100k
          RHSSelector.getAsIdentifierInfo()->getName());
72
100k
    }
73
119k
    unsigned LN = LHSSelector.getNumArgs(), RN = RHSSelector.getNumArgs();
74
129k
    for (unsigned I = 0, N = std::min(LN, RN); I != N; 
++I9.63k
) {
75
128k
      switch (LHSSelector.getNameForSlot(I).compare(
76
128k
          RHSSelector.getNameForSlot(I))) {
77
75.2k
      case -1:
78
75.2k
        return -1;
79
43.7k
      case 1:
80
43.7k
        return 1;
81
9.63k
      default:
82
9.63k
        break;
83
128k
      }
84
128k
    }
85
86
744
    return compareInt(LN, RN);
87
119k
  }
88
89
999
  case DeclarationName::CXXConstructorName:
90
1.86k
  case DeclarationName::CXXDestructorName:
91
1.86k
  case DeclarationName::CXXConversionFunctionName:
92
1.86k
    if (QualTypeOrdering()(LHS.getCXXNameType(), RHS.getCXXNameType()))
93
943
      return -1;
94
922
    if (QualTypeOrdering()(RHS.getCXXNameType(), LHS.getCXXNameType()))
95
793
      return 1;
96
129
    return 0;
97
98
2.80k
  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
2.80k
    return compare(LHS.getCXXDeductionGuideTemplate()->getDeclName(),
102
2.80k
                   RHS.getCXXDeductionGuideTemplate()->getDeclName());
103
104
37.6k
  case DeclarationName::CXXOperatorName:
105
37.6k
    return compareInt(LHS.getCXXOverloadedOperator(),
106
37.6k
                      RHS.getCXXOverloadedOperator());
107
108
1.15k
  case DeclarationName::CXXLiteralOperatorName:
109
1.15k
    return LHS.getCXXLiteralIdentifier()->getName().compare(
110
1.15k
        RHS.getCXXLiteralIdentifier()->getName());
111
112
0
  case DeclarationName::CXXUsingDirective:
113
0
    return 0;
114
10.3M
  }
115
116
0
  llvm_unreachable("Invalid DeclarationName Kind!");
117
0
}
118
119
static void printCXXConstructorDestructorName(QualType ClassType,
120
                                              raw_ostream &OS,
121
621k
                                              PrintingPolicy Policy) {
122
  // We know we're printing C++ here. Ensure we print types properly.
123
621k
  Policy.adjustForCPlusPlus();
124
125
621k
  if (const RecordType *ClassRec = ClassType->getAs<RecordType>()) {
126
443k
    OS << *ClassRec->getDecl();
127
443k
    return;
128
443k
  }
129
177k
  if (Policy.SuppressTemplateArgsInCXXConstructors) {
130
33
    if (auto *InjTy = ClassType->getAs<InjectedClassNameType>()) {
131
33
      OS << *InjTy->getDecl();
132
33
      return;
133
33
    }
134
33
  }
135
177k
  ClassType.print(OS, Policy);
136
177k
}
137
138
void DeclarationName::print(raw_ostream &OS,
139
7.91M
                            const PrintingPolicy &Policy) const {
140
7.91M
  switch (getNameKind()) {
141
3.87M
  case DeclarationName::Identifier:
142
3.87M
    if (const IdentifierInfo *II = getAsIdentifierInfo()) {
143
3.85M
      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.85M
      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.85M
      } else {
152
3.85M
        OS << Name;
153
3.85M
      }
154
3.85M
    }
155
3.87M
    return;
156
157
5.65k
  case DeclarationName::ObjCZeroArgSelector:
158
9.04k
  case DeclarationName::ObjCOneArgSelector:
159
9.76k
  case DeclarationName::ObjCMultiArgSelector:
160
9.76k
    getObjCSelector().print(OS);
161
9.76k
    return;
162
163
593k
  case DeclarationName::CXXConstructorName:
164
593k
    return printCXXConstructorDestructorName(getCXXNameType(), OS, Policy);
165
166
27.9k
  case DeclarationName::CXXDestructorName:
167
27.9k
    OS << '~';
168
27.9k
    return printCXXConstructorDestructorName(getCXXNameType(), OS, Policy);
169
170
192
  case DeclarationName::CXXDeductionGuideName:
171
192
    OS << "<deduction guide for ";
172
192
    getCXXDeductionGuideTemplate()->getDeclName().print(OS, Policy);
173
192
    OS << '>';
174
192
    return;
175
176
3.38M
  case DeclarationName::CXXOperatorName: {
177
3.38M
    const char *OpName = getOperatorSpelling(getCXXOverloadedOperator());
178
3.38M
    assert(OpName && "not an overloaded operator");
179
180
0
    OS << "operator";
181
3.38M
    if (OpName[0] >= 'a' && 
OpName[0] <= 'z'20.0k
)
182
16.6k
      OS << ' ';
183
3.38M
    OS << OpName;
184
3.38M
    return;
185
9.04k
  }
186
187
249
  case DeclarationName::CXXLiteralOperatorName:
188
249
    OS << "operator\"\"" << getCXXLiteralIdentifier()->getName();
189
249
    return;
190
191
8.10k
  case DeclarationName::CXXConversionFunctionName: {
192
8.10k
    OS << "operator ";
193
8.10k
    QualType Type = getCXXNameType();
194
8.10k
    if (const RecordType *Rec = Type->getAs<RecordType>()) {
195
779
      OS << *Rec->getDecl();
196
779
      return;
197
779
    }
198
    // We know we're printing C++ here, ensure we print 'bool' properly.
199
7.32k
    PrintingPolicy CXXPolicy = Policy;
200
7.32k
    CXXPolicy.adjustForCPlusPlus();
201
7.32k
    Type.print(OS, CXXPolicy);
202
7.32k
    return;
203
8.10k
  }
204
15.9k
  case DeclarationName::CXXUsingDirective:
205
15.9k
    OS << "<using-directive>";
206
15.9k
    return;
207
7.91M
  }
208
209
0
  llvm_unreachable("Unexpected declaration name kind");
210
0
}
211
212
namespace clang {
213
214
7.09M
raw_ostream &operator<<(raw_ostream &OS, DeclarationName N) {
215
7.09M
  LangOptions LO;
216
7.09M
  N.print(OS, PrintingPolicy(LO));
217
7.09M
  return OS;
218
7.09M
}
219
220
} // namespace clang
221
222
429k
bool DeclarationName::isDependentName() const {
223
429k
  QualType T = getCXXNameType();
224
429k
  if (!T.isNull() && 
T->isDependentType()621
)
225
14
    return true;
226
227
  // A class-scope deduction guide in a dependent context has a dependent name.
228
429k
  auto *TD = getCXXDeductionGuideTemplate();
229
429k
  if (TD && 
TD->getDeclContext()->isDependentContext()0
)
230
0
    return true;
231
232
429k
  return false;
233
429k
}
234
235
4.32M
std::string DeclarationName::getAsString() const {
236
4.32M
  std::string Result;
237
4.32M
  llvm::raw_string_ostream OS(Result);
238
4.32M
  OS << *this;
239
4.32M
  return Result;
240
4.32M
}
241
242
8.95M
void *DeclarationName::getFETokenInfoSlow() const {
243
8.95M
  switch (getNameKind()) {
244
0
  case Identifier:
245
0
    llvm_unreachable("case Identifier already handled by getFETokenInfo!");
246
3.16M
  case CXXConstructorName:
247
3.37M
  case CXXDestructorName:
248
3.43M
  case CXXConversionFunctionName:
249
3.43M
    return castAsCXXSpecialNameExtra()->FETokenInfo;
250
5.50M
  case CXXOperatorName:
251
5.50M
    return castAsCXXOperatorIdName()->FETokenInfo;
252
7.25k
  case CXXDeductionGuideName:
253
7.25k
    return castAsCXXDeductionGuideNameExtra()->FETokenInfo;
254
6.42k
  case CXXLiteralOperatorName:
255
6.42k
    return castAsCXXLiteralOperatorIdName()->FETokenInfo;
256
0
  default:
257
0
    llvm_unreachable("DeclarationName has no FETokenInfo!");
258
8.95M
  }
259
8.95M
}
260
261
631k
void DeclarationName::setFETokenInfoSlow(void *T) {
262
631k
  switch (getNameKind()) {
263
0
  case Identifier:
264
0
    llvm_unreachable("case Identifier already handled by setFETokenInfo!");
265
310k
  case CXXConstructorName:
266
418k
  case CXXDestructorName:
267
446k
  case CXXConversionFunctionName:
268
446k
    castAsCXXSpecialNameExtra()->FETokenInfo = T;
269
446k
    break;
270
182k
  case CXXOperatorName:
271
182k
    castAsCXXOperatorIdName()->FETokenInfo = T;
272
182k
    break;
273
834
  case CXXDeductionGuideName:
274
834
    castAsCXXDeductionGuideNameExtra()->FETokenInfo = T;
275
834
    break;
276
1.16k
  case CXXLiteralOperatorName:
277
1.16k
    castAsCXXLiteralOperatorIdName()->FETokenInfo = T;
278
1.16k
    break;
279
0
  default:
280
0
    llvm_unreachable("DeclarationName has no FETokenInfo!");
281
631k
  }
282
631k
}
283
284
0
LLVM_DUMP_METHOD void DeclarationName::dump() const {
285
0
  llvm::errs() << *this << '\n';
286
0
}
287
288
96.6k
DeclarationNameTable::DeclarationNameTable(const ASTContext &C) : Ctx(C) {
289
  // Initialize the overloaded operator names.
290
4.54M
  for (unsigned Op = 0; Op < NUM_OVERLOADED_OPERATORS; 
++Op4.44M
)
291
4.44M
    CXXOperatorNames[Op].Kind = static_cast<OverloadedOperatorKind>(Op);
292
96.6k
}
293
294
DeclarationName
295
6.11k
DeclarationNameTable::getCXXDeductionGuideName(TemplateDecl *Template) {
296
6.11k
  Template = cast<TemplateDecl>(Template->getCanonicalDecl());
297
298
6.11k
  llvm::FoldingSetNodeID ID;
299
6.11k
  ID.AddPointer(Template);
300
301
6.11k
  void *InsertPos = nullptr;
302
6.11k
  if (auto *Name = CXXDeductionGuideNames.FindNodeOrInsertPos(ID, InsertPos))
303
5.50k
    return DeclarationName(Name);
304
305
608
  auto *Name = new (Ctx) detail::CXXDeductionGuideNameExtra(Template);
306
608
  CXXDeductionGuideNames.InsertNode(Name, InsertPos);
307
608
  return DeclarationName(Name);
308
6.11k
}
309
310
3.26M
DeclarationName DeclarationNameTable::getCXXConstructorName(CanQualType Ty) {
311
  // The type of constructors is unqualified.
312
3.26M
  Ty = Ty.getUnqualifiedType();
313
  // Do we already have this C++ constructor name ?
314
3.26M
  llvm::FoldingSetNodeID ID;
315
3.26M
  ID.AddPointer(Ty.getAsOpaquePtr());
316
3.26M
  void *InsertPos = nullptr;
317
3.26M
  if (auto *Name = CXXConstructorNames.FindNodeOrInsertPos(ID, InsertPos))
318
2.86M
    return {Name, DeclarationName::StoredCXXConstructorName};
319
320
  // We have to create it.
321
401k
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
322
401k
  CXXConstructorNames.InsertNode(SpecialName, InsertPos);
323
401k
  return {SpecialName, DeclarationName::StoredCXXConstructorName};
324
3.26M
}
325
326
8.50M
DeclarationName DeclarationNameTable::getCXXDestructorName(CanQualType Ty) {
327
  // The type of destructors is unqualified.
328
8.50M
  Ty = Ty.getUnqualifiedType();
329
  // Do we already have this C++ destructor name ?
330
8.50M
  llvm::FoldingSetNodeID ID;
331
8.50M
  ID.AddPointer(Ty.getAsOpaquePtr());
332
8.50M
  void *InsertPos = nullptr;
333
8.50M
  if (auto *Name = CXXDestructorNames.FindNodeOrInsertPos(ID, InsertPos))
334
6.66M
    return {Name, DeclarationName::StoredCXXDestructorName};
335
336
  // We have to create it.
337
1.83M
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
338
1.83M
  CXXDestructorNames.InsertNode(SpecialName, InsertPos);
339
1.83M
  return {SpecialName, DeclarationName::StoredCXXDestructorName};
340
8.50M
}
341
342
DeclarationName
343
88.4k
DeclarationNameTable::getCXXConversionFunctionName(CanQualType Ty) {
344
  // Do we already have this C++ conversion function name ?
345
88.4k
  llvm::FoldingSetNodeID ID;
346
88.4k
  ID.AddPointer(Ty.getAsOpaquePtr());
347
88.4k
  void *InsertPos = nullptr;
348
88.4k
  if (auto *Name =
349
88.4k
          CXXConversionFunctionNames.FindNodeOrInsertPos(ID, InsertPos))
350
70.0k
    return {Name, DeclarationName::StoredCXXConversionFunctionName};
351
352
  // We have to create it.
353
18.4k
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
354
18.4k
  CXXConversionFunctionNames.InsertNode(SpecialName, InsertPos);
355
18.4k
  return {SpecialName, DeclarationName::StoredCXXConversionFunctionName};
356
88.4k
}
357
358
DeclarationName
359
DeclarationNameTable::getCXXSpecialName(DeclarationName::NameKind Kind,
360
283k
                                        CanQualType Ty) {
361
283k
  switch (Kind) {
362
257k
  case DeclarationName::CXXConstructorName:
363
257k
    return getCXXConstructorName(Ty);
364
13.3k
  case DeclarationName::CXXDestructorName:
365
13.3k
    return getCXXDestructorName(Ty);
366
13.0k
  case DeclarationName::CXXConversionFunctionName:
367
13.0k
    return getCXXConversionFunctionName(Ty);
368
0
  default:
369
0
    llvm_unreachable("Invalid kind in getCXXSpecialName!");
370
283k
  }
371
283k
}
372
373
DeclarationName
374
3.53k
DeclarationNameTable::getCXXLiteralOperatorName(IdentifierInfo *II) {
375
3.53k
  llvm::FoldingSetNodeID ID;
376
3.53k
  ID.AddPointer(II);
377
378
3.53k
  void *InsertPos = nullptr;
379
3.53k
  if (auto *Name = CXXLiteralOperatorNames.FindNodeOrInsertPos(ID, InsertPos))
380
2.95k
    return DeclarationName(Name);
381
382
573
  auto *LiteralName = new (Ctx) detail::CXXLiteralOperatorIdName(II);
383
573
  CXXLiteralOperatorNames.InsertNode(LiteralName, InsertPos);
384
573
  return DeclarationName(LiteralName);
385
3.53k
}
386
387
175M
DeclarationNameLoc::DeclarationNameLoc(DeclarationName Name) {
388
175M
  switch (Name.getNameKind()) {
389
168M
  case DeclarationName::Identifier:
390
168M
  case DeclarationName::CXXDeductionGuideName:
391
168M
    break;
392
768k
  case DeclarationName::CXXConstructorName:
393
988k
  case DeclarationName::CXXDestructorName:
394
991k
  case DeclarationName::CXXConversionFunctionName:
395
991k
    setNamedTypeLoc(nullptr);
396
991k
    break;
397
6.01M
  case DeclarationName::CXXOperatorName:
398
6.01M
    setCXXOperatorNameRange(SourceRange());
399
6.01M
    break;
400
809
  case DeclarationName::CXXLiteralOperatorName:
401
809
    setCXXLiteralOperatorNameLoc(SourceLocation());
402
809
    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
8.54M
bool DeclarationNameInfo::containsUnexpandedParameterPack() const {
414
8.54M
  switch (Name.getNameKind()) {
415
7.12M
  case DeclarationName::Identifier:
416
7.12M
  case DeclarationName::ObjCZeroArgSelector:
417
7.12M
  case DeclarationName::ObjCOneArgSelector:
418
7.12M
  case DeclarationName::ObjCMultiArgSelector:
419
8.54M
  case DeclarationName::CXXOperatorName:
420
8.54M
  case DeclarationName::CXXLiteralOperatorName:
421
8.54M
  case DeclarationName::CXXUsingDirective:
422
8.54M
  case DeclarationName::CXXDeductionGuideName:
423
8.54M
    return false;
424
425
14
  case DeclarationName::CXXConstructorName:
426
19
  case DeclarationName::CXXDestructorName:
427
59
  case DeclarationName::CXXConversionFunctionName:
428
59
    if (TypeSourceInfo *TInfo = LocInfo.getNamedTypeInfo())
429
44
      return TInfo->getType()->containsUnexpandedParameterPack();
430
431
15
    return Name.getCXXNameType()->containsUnexpandedParameterPack();
432
8.54M
  }
433
0
  llvm_unreachable("All name kinds handled.");
434
0
}
435
436
8.54M
bool DeclarationNameInfo::isInstantiationDependent() const {
437
8.54M
  switch (Name.getNameKind()) {
438
7.12M
  case DeclarationName::Identifier:
439
7.12M
  case DeclarationName::ObjCZeroArgSelector:
440
7.12M
  case DeclarationName::ObjCOneArgSelector:
441
7.12M
  case DeclarationName::ObjCMultiArgSelector:
442
8.54M
  case DeclarationName::CXXOperatorName:
443
8.54M
  case DeclarationName::CXXLiteralOperatorName:
444
8.54M
  case DeclarationName::CXXUsingDirective:
445
8.54M
  case DeclarationName::CXXDeductionGuideName:
446
8.54M
    return false;
447
448
14
  case DeclarationName::CXXConstructorName:
449
19
  case DeclarationName::CXXDestructorName:
450
58
  case DeclarationName::CXXConversionFunctionName:
451
58
    if (TypeSourceInfo *TInfo = LocInfo.getNamedTypeInfo())
452
43
      return TInfo->getType()->isInstantiationDependentType();
453
454
15
    return Name.getCXXNameType()->isInstantiationDependentType();
455
8.54M
  }
456
0
  llvm_unreachable("All name kinds handled.");
457
0
}
458
459
710k
std::string DeclarationNameInfo::getAsString() const {
460
710k
  std::string Result;
461
710k
  llvm::raw_string_ostream OS(Result);
462
710k
  OS << *this;
463
710k
  return Result;
464
710k
}
465
466
720k
raw_ostream &clang::operator<<(raw_ostream &OS, DeclarationNameInfo DNInfo) {
467
720k
  LangOptions LO;
468
720k
  DNInfo.printName(OS, PrintingPolicy(LangOptions()));
469
720k
  return OS;
470
720k
}
471
472
805k
void DeclarationNameInfo::printName(raw_ostream &OS, PrintingPolicy Policy) const {
473
805k
  switch (Name.getNameKind()) {
474
518k
  case DeclarationName::Identifier:
475
518k
  case DeclarationName::ObjCZeroArgSelector:
476
518k
  case DeclarationName::ObjCOneArgSelector:
477
518k
  case DeclarationName::ObjCMultiArgSelector:
478
713k
  case DeclarationName::CXXOperatorName:
479
713k
  case DeclarationName::CXXLiteralOperatorName:
480
713k
  case DeclarationName::CXXUsingDirective:
481
713k
  case DeclarationName::CXXDeductionGuideName:
482
713k
    Name.print(OS, Policy);
483
713k
    return;
484
485
84.5k
  case DeclarationName::CXXConstructorName:
486
89.6k
  case DeclarationName::CXXDestructorName:
487
91.9k
  case DeclarationName::CXXConversionFunctionName:
488
91.9k
    if (TypeSourceInfo *TInfo = LocInfo.getNamedTypeInfo()) {
489
7.15k
      if (Name.getNameKind() == DeclarationName::CXXDestructorName)
490
5.04k
        OS << '~';
491
2.11k
      else if (Name.getNameKind() == DeclarationName::CXXConversionFunctionName)
492
2.11k
        OS << "operator ";
493
7.15k
      LangOptions LO;
494
7.15k
      Policy.adjustForCPlusPlus();
495
7.15k
      Policy.SuppressScope = true;
496
7.15k
      OS << TInfo->getType().getAsString(Policy);
497
7.15k
    } else
498
84.7k
      Name.print(OS, Policy);
499
91.9k
    return;
500
805k
  }
501
0
  llvm_unreachable("Unexpected declaration name kind");
502
0
}
503
504
43.6M
SourceLocation DeclarationNameInfo::getEndLocPrivate() const {
505
43.6M
  switch (Name.getNameKind()) {
506
41.3M
  case DeclarationName::Identifier:
507
41.3M
  case DeclarationName::CXXDeductionGuideName:
508
41.3M
    return NameLoc;
509
510
972k
  case DeclarationName::CXXOperatorName:
511
972k
    return LocInfo.getCXXOperatorNameEndLoc();
512
513
1.45k
  case DeclarationName::CXXLiteralOperatorName:
514
1.45k
    return LocInfo.getCXXLiteralOperatorNameLoc();
515
516
1.09M
  case DeclarationName::CXXConstructorName:
517
1.28M
  case DeclarationName::CXXDestructorName:
518
1.32M
  case DeclarationName::CXXConversionFunctionName:
519
1.32M
    if (TypeSourceInfo *TInfo = LocInfo.getNamedTypeInfo())
520
110k
      return TInfo->getTypeLoc().getEndLoc();
521
1.21M
    else
522
1.21M
      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
43.6M
  }
531
0
  llvm_unreachable("Unexpected declaration name kind");
532
0
}