Coverage Report

Created: 2021-01-23 06:44

/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
23.5k
  return (A < B ? -1 : 
(A > B 14.7k
?
114.5k
:
0189
));
44
38.3k
}
45
46
9.99M
int DeclarationName::compare(DeclarationName LHS, DeclarationName RHS) {
47
9.99M
  if (LHS.getNameKind() != RHS.getNameKind())
48
283k
    return (LHS.getNameKind() < RHS.getNameKind() ? 
-1172k
:
1110k
);
49
50
9.70M
  switch (LHS.getNameKind()) {
51
9.48M
  case DeclarationName::Identifier: {
52
9.48M
    IdentifierInfo *LII = LHS.castAsIdentifierInfo();
53
9.48M
    IdentifierInfo *RII = RHS.castAsIdentifierInfo();
54
9.48M
    if (!LII)
55
0
      return RII ? -1 : 0;
56
9.48M
    if (!RII)
57
0
      return 1;
58
59
9.48M
    return LII->getName().compare(RII->getName());
60
9.48M
  }
61
62
82.3k
  case DeclarationName::ObjCZeroArgSelector:
63
148k
  case DeclarationName::ObjCOneArgSelector:
64
180k
  case DeclarationName::ObjCMultiArgSelector: {
65
180k
    Selector LHSSelector = LHS.getObjCSelector();
66
180k
    Selector RHSSelector = RHS.getObjCSelector();
67
    // getNumArgs for ZeroArgSelector returns 0, but we still need to compare.
68
180k
    if (LHS.getNameKind() == DeclarationName::ObjCZeroArgSelector &&
69
82.3k
        RHS.getNameKind() == DeclarationName::ObjCZeroArgSelector) {
70
82.3k
      return LHSSelector.getAsIdentifierInfo()->getName().compare(
71
82.3k
          RHSSelector.getAsIdentifierInfo()->getName());
72
82.3k
    }
73
97.6k
    unsigned LN = LHSSelector.getNumArgs(), RN = RHSSelector.getNumArgs();
74
105k
    for (unsigned I = 0, N = std::min(LN, RN); I != N; 
++I8.25k
) {
75
105k
      switch (LHSSelector.getNameForSlot(I).compare(
76
105k
          RHSSelector.getNameForSlot(I))) {
77
61.2k
      case -1:
78
61.2k
        return -1;
79
35.6k
      case 1:
80
35.6k
        return 1;
81
8.25k
      default:
82
8.25k
        break;
83
105k
      }
84
105k
    }
85
86
827
    return compareInt(LN, RN);
87
97.6k
  }
88
89
933
  case DeclarationName::CXXConstructorName:
90
1.76k
  case DeclarationName::CXXDestructorName:
91
1.77k
  case DeclarationName::CXXConversionFunctionName:
92
1.77k
    if (QualTypeOrdering()(LHS.getCXXNameType(), RHS.getCXXNameType()))
93
953
      return -1;
94
818
    if (QualTypeOrdering()(RHS.getCXXNameType(), LHS.getCXXNameType()))
95
695
      return 1;
96
123
    return 0;
97
98
1.11k
  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.11k
    return compare(LHS.getCXXDeductionGuideTemplate()->getDeclName(),
102
1.11k
                   RHS.getCXXDeductionGuideTemplate()->getDeclName());
103
104
37.5k
  case DeclarationName::CXXOperatorName:
105
37.5k
    return compareInt(LHS.getCXXOverloadedOperator(),
106
37.5k
                      RHS.getCXXOverloadedOperator());
107
108
625
  case DeclarationName::CXXLiteralOperatorName:
109
625
    return LHS.getCXXLiteralIdentifier()->getName().compare(
110
625
        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
276k
                                              PrintingPolicy Policy) {
122
  // We know we're printing C++ here. Ensure we print types properly.
123
276k
  Policy.adjustForCPlusPlus();
124
125
276k
  if (const RecordType *ClassRec = ClassType->getAs<RecordType>()) {
126
175k
    OS << *ClassRec->getDecl();
127
175k
    return;
128
175k
  }
129
100k
  if (Policy.SuppressTemplateArgsInCXXConstructors) {
130
33
    if (auto *InjTy = ClassType->getAs<InjectedClassNameType>()) {
131
33
      OS << *InjTy->getDecl();
132
33
      return;
133
33
    }
134
100k
  }
135
100k
  ClassType.print(OS, Policy);
136
100k
}
137
138
void DeclarationName::print(raw_ostream &OS,
139
3.86M
                            const PrintingPolicy &Policy) const {
140
3.86M
  switch (getNameKind()) {
141
2.25M
  case DeclarationName::Identifier:
142
2.25M
    if (const IdentifierInfo *II = getAsIdentifierInfo()) {
143
2.24M
      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
2.24M
      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
2.24M
      } else {
152
2.24M
        OS << Name;
153
2.24M
      }
154
2.24M
    }
155
2.25M
    return;
156
157
5.51k
  case DeclarationName::ObjCZeroArgSelector:
158
8.80k
  case DeclarationName::ObjCOneArgSelector:
159
9.51k
  case DeclarationName::ObjCMultiArgSelector:
160
9.51k
    getObjCSelector().print(OS);
161
9.51k
    return;
162
163
252k
  case DeclarationName::CXXConstructorName:
164
252k
    return printCXXConstructorDestructorName(getCXXNameType(), OS, Policy);
165
166
23.2k
  case DeclarationName::CXXDestructorName:
167
23.2k
    OS << '~';
168
23.2k
    return printCXXConstructorDestructorName(getCXXNameType(), OS, Policy);
169
170
107
  case DeclarationName::CXXDeductionGuideName:
171
107
    OS << "<deduction guide for ";
172
107
    getCXXDeductionGuideTemplate()->getDeclName().print(OS, Policy);
173
107
    OS << '>';
174
107
    return;
175
176
1.30M
  case DeclarationName::CXXOperatorName: {
177
1.30M
    const char *OpName = getOperatorSpelling(getCXXOverloadedOperator());
178
1.30M
    assert(OpName && "not an overloaded operator");
179
180
1.30M
    OS << "operator";
181
1.30M
    if (OpName[0] >= 'a' && 
OpName[0] <= 'z'3.50k
)
182
2.28k
      OS << ' ';
183
1.30M
    OS << OpName;
184
1.30M
    return;
185
8.80k
  }
186
187
190
  case DeclarationName::CXXLiteralOperatorName:
188
190
    OS << "operator\"\"" << getCXXLiteralIdentifier()->getName();
189
190
    return;
190
191
6.16k
  case DeclarationName::CXXConversionFunctionName: {
192
6.16k
    OS << "operator ";
193
6.16k
    QualType Type = getCXXNameType();
194
6.16k
    if (const RecordType *Rec = Type->getAs<RecordType>()) {
195
679
      OS << *Rec->getDecl();
196
679
      return;
197
679
    }
198
    // We know we're printing C++ here, ensure we print 'bool' properly.
199
5.48k
    PrintingPolicy CXXPolicy = Policy;
200
5.48k
    CXXPolicy.adjustForCPlusPlus();
201
5.48k
    Type.print(OS, CXXPolicy);
202
5.48k
    return;
203
5.48k
  }
204
14.3k
  case DeclarationName::CXXUsingDirective:
205
14.3k
    OS << "<using-directive>";
206
14.3k
    return;
207
0
  }
208
209
0
  llvm_unreachable("Unexpected declaration name kind");
210
0
}
211
212
namespace clang {
213
214
3.30M
raw_ostream &operator<<(raw_ostream &OS, DeclarationName N) {
215
3.30M
  LangOptions LO;
216
3.30M
  N.print(OS, PrintingPolicy(LO));
217
3.30M
  return OS;
218
3.30M
}
219
220
} // namespace clang
221
222
361k
bool DeclarationName::isDependentName() const {
223
361k
  QualType T = getCXXNameType();
224
361k
  if (!T.isNull() && 
T->isDependentType()508
)
225
8
    return true;
226
227
  // A class-scope deduction guide in a dependent context has a dependent name.
228
361k
  auto *TD = getCXXDeductionGuideTemplate();
229
361k
  if (TD && 
TD->getDeclContext()->isDependentContext()0
)
230
0
    return true;
231
232
361k
  return false;
233
361k
}
234
235
1.93M
std::string DeclarationName::getAsString() const {
236
1.93M
  std::string Result;
237
1.93M
  llvm::raw_string_ostream OS(Result);
238
1.93M
  OS << *this;
239
1.93M
  return OS.str();
240
1.93M
}
241
242
6.81M
void *DeclarationName::getFETokenInfoSlow() const {
243
6.81M
  switch (getNameKind()) {
244
0
  case Identifier:
245
0
    llvm_unreachable("case Identifier already handled by getFETokenInfo!");
246
2.03M
  case CXXConstructorName:
247
2.20M
  case CXXDestructorName:
248
2.25M
  case CXXConversionFunctionName:
249
2.25M
    return castAsCXXSpecialNameExtra()->FETokenInfo;
250
4.55M
  case CXXOperatorName:
251
4.55M
    return castAsCXXOperatorIdName()->FETokenInfo;
252
3.57k
  case CXXDeductionGuideName:
253
3.57k
    return castAsCXXDeductionGuideNameExtra()->FETokenInfo;
254
4.68k
  case CXXLiteralOperatorName:
255
4.68k
    return castAsCXXLiteralOperatorIdName()->FETokenInfo;
256
0
  default:
257
0
    llvm_unreachable("DeclarationName has no FETokenInfo!");
258
6.81M
  }
259
6.81M
}
260
261
531k
void DeclarationName::setFETokenInfoSlow(void *T) {
262
531k
  switch (getNameKind()) {
263
0
  case Identifier:
264
0
    llvm_unreachable("case Identifier already handled by setFETokenInfo!");
265
250k
  case CXXConstructorName:
266
343k
  case CXXDestructorName:
267
368k
  case CXXConversionFunctionName:
268
368k
    castAsCXXSpecialNameExtra()->FETokenInfo = T;
269
368k
    break;
270
161k
  case CXXOperatorName:
271
161k
    castAsCXXOperatorIdName()->FETokenInfo = T;
272
161k
    break;
273
415
  case CXXDeductionGuideName:
274
415
    castAsCXXDeductionGuideNameExtra()->FETokenInfo = T;
275
415
    break;
276
742
  case CXXLiteralOperatorName:
277
742
    castAsCXXLiteralOperatorIdName()->FETokenInfo = T;
278
742
    break;
279
0
  default:
280
0
    llvm_unreachable("DeclarationName has no FETokenInfo!");
281
531k
  }
282
531k
}
283
284
0
LLVM_DUMP_METHOD void DeclarationName::dump() const {
285
0
  llvm::errs() << *this << '\n';
286
0
}
287
288
86.5k
DeclarationNameTable::DeclarationNameTable(const ASTContext &C) : Ctx(C) {
289
  // Initialize the overloaded operator names.
290
4.06M
  for (unsigned Op = 0; Op < NUM_OVERLOADED_OPERATORS; 
++Op3.98M
)
291
3.98M
    CXXOperatorNames[Op].Kind = static_cast<OverloadedOperatorKind>(Op);
292
86.5k
}
293
294
DeclarationName
295
3.10k
DeclarationNameTable::getCXXDeductionGuideName(TemplateDecl *Template) {
296
3.10k
  Template = cast<TemplateDecl>(Template->getCanonicalDecl());
297
298
3.10k
  llvm::FoldingSetNodeID ID;
299
3.10k
  ID.AddPointer(Template);
300
301
3.10k
  void *InsertPos = nullptr;
302
3.10k
  if (auto *Name = CXXDeductionGuideNames.FindNodeOrInsertPos(ID, InsertPos))
303
2.77k
    return DeclarationName(Name);
304
305
331
  auto *Name = new (Ctx) detail::CXXDeductionGuideNameExtra(Template);
306
331
  CXXDeductionGuideNames.InsertNode(Name, InsertPos);
307
331
  return DeclarationName(Name);
308
331
}
309
310
2.40M
DeclarationName DeclarationNameTable::getCXXConstructorName(CanQualType Ty) {
311
  // The type of constructors is unqualified.
312
2.40M
  Ty = Ty.getUnqualifiedType();
313
  // Do we already have this C++ constructor name ?
314
2.40M
  llvm::FoldingSetNodeID ID;
315
2.40M
  ID.AddPointer(Ty.getAsOpaquePtr());
316
2.40M
  void *InsertPos = nullptr;
317
2.40M
  if (auto *Name = CXXConstructorNames.FindNodeOrInsertPos(ID, InsertPos))
318
2.10M
    return {Name, DeclarationName::StoredCXXConstructorName};
319
320
  // We have to create it.
321
299k
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
322
299k
  CXXConstructorNames.InsertNode(SpecialName, InsertPos);
323
299k
  return {SpecialName, DeclarationName::StoredCXXConstructorName};
324
299k
}
325
326
6.76M
DeclarationName DeclarationNameTable::getCXXDestructorName(CanQualType Ty) {
327
  // The type of destructors is unqualified.
328
6.76M
  Ty = Ty.getUnqualifiedType();
329
  // Do we already have this C++ destructor name ?
330
6.76M
  llvm::FoldingSetNodeID ID;
331
6.76M
  ID.AddPointer(Ty.getAsOpaquePtr());
332
6.76M
  void *InsertPos = nullptr;
333
6.76M
  if (auto *Name = CXXDestructorNames.FindNodeOrInsertPos(ID, InsertPos))
334
5.32M
    return {Name, DeclarationName::StoredCXXDestructorName};
335
336
  // We have to create it.
337
1.44M
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
338
1.44M
  CXXDestructorNames.InsertNode(SpecialName, InsertPos);
339
1.44M
  return {SpecialName, DeclarationName::StoredCXXDestructorName};
340
1.44M
}
341
342
DeclarationName
343
77.4k
DeclarationNameTable::getCXXConversionFunctionName(CanQualType Ty) {
344
  // Do we already have this C++ conversion function name ?
345
77.4k
  llvm::FoldingSetNodeID ID;
346
77.4k
  ID.AddPointer(Ty.getAsOpaquePtr());
347
77.4k
  void *InsertPos = nullptr;
348
77.4k
  if (auto *Name =
349
61.5k
          CXXConversionFunctionNames.FindNodeOrInsertPos(ID, InsertPos))
350
61.5k
    return {Name, DeclarationName::StoredCXXConversionFunctionName};
351
352
  // We have to create it.
353
15.8k
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
354
15.8k
  CXXConversionFunctionNames.InsertNode(SpecialName, InsertPos);
355
15.8k
  return {SpecialName, DeclarationName::StoredCXXConversionFunctionName};
356
15.8k
}
357
358
DeclarationName
359
DeclarationNameTable::getCXXSpecialName(DeclarationName::NameKind Kind,
360
239k
                                        CanQualType Ty) {
361
239k
  switch (Kind) {
362
214k
  case DeclarationName::CXXConstructorName:
363
214k
    return getCXXConstructorName(Ty);
364
13.1k
  case DeclarationName::CXXDestructorName:
365
13.1k
    return getCXXDestructorName(Ty);
366
12.0k
  case DeclarationName::CXXConversionFunctionName:
367
12.0k
    return getCXXConversionFunctionName(Ty);
368
0
  default:
369
0
    llvm_unreachable("Invalid kind in getCXXSpecialName!");
370
239k
  }
371
239k
}
372
373
DeclarationName
374
2.50k
DeclarationNameTable::getCXXLiteralOperatorName(IdentifierInfo *II) {
375
2.50k
  llvm::FoldingSetNodeID ID;
376
2.50k
  ID.AddPointer(II);
377
378
2.50k
  void *InsertPos = nullptr;
379
2.50k
  if (auto *Name = CXXLiteralOperatorNames.FindNodeOrInsertPos(ID, InsertPos))
380
2.08k
    return DeclarationName(Name);
381
382
419
  auto *LiteralName = new (Ctx) detail::CXXLiteralOperatorIdName(II);
383
419
  CXXLiteralOperatorNames.InsertNode(LiteralName, InsertPos);
384
419
  return DeclarationName(LiteralName);
385
419
}
386
387
117M
DeclarationNameLoc::DeclarationNameLoc(DeclarationName Name) {
388
117M
  switch (Name.getNameKind()) {
389
112M
  case DeclarationName::Identifier:
390
112M
  case DeclarationName::CXXDeductionGuideName:
391
112M
    break;
392
561k
  case DeclarationName::CXXConstructorName:
393
741k
  case DeclarationName::CXXDestructorName:
394
744k
  case DeclarationName::CXXConversionFunctionName:
395
744k
    NamedType.TInfo = nullptr;
396
744k
    break;
397
4.43M
  case DeclarationName::CXXOperatorName:
398
4.43M
    CXXOperatorName.BeginOpNameLoc = SourceLocation().getRawEncoding();
399
4.43M
    CXXOperatorName.EndOpNameLoc = SourceLocation().getRawEncoding();
400
4.43M
    break;
401
781
  case DeclarationName::CXXLiteralOperatorName:
402
781
    CXXLiteralOperatorName.OpNameLoc = SourceLocation().getRawEncoding();
403
781
    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
117M
  }
412
117M
}
413
414
5.44M
bool DeclarationNameInfo::containsUnexpandedParameterPack() const {
415
5.44M
  switch (Name.getNameKind()) {
416
4.54M
  case DeclarationName::Identifier:
417
4.54M
  case DeclarationName::ObjCZeroArgSelector:
418
4.54M
  case DeclarationName::ObjCOneArgSelector:
419
4.54M
  case DeclarationName::ObjCMultiArgSelector:
420
5.44M
  case DeclarationName::CXXOperatorName:
421
5.44M
  case DeclarationName::CXXLiteralOperatorName:
422
5.44M
  case DeclarationName::CXXUsingDirective:
423
5.44M
  case DeclarationName::CXXDeductionGuideName:
424
5.44M
    return false;
425
426
13
  case DeclarationName::CXXConstructorName:
427
18
  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
5.44M
bool DeclarationNameInfo::isInstantiationDependent() const {
438
5.44M
  switch (Name.getNameKind()) {
439
4.54M
  case DeclarationName::Identifier:
440
4.54M
  case DeclarationName::ObjCZeroArgSelector:
441
4.54M
  case DeclarationName::ObjCOneArgSelector:
442
4.54M
  case DeclarationName::ObjCMultiArgSelector:
443
5.44M
  case DeclarationName::CXXOperatorName:
444
5.44M
  case DeclarationName::CXXLiteralOperatorName:
445
5.44M
  case DeclarationName::CXXUsingDirective:
446
5.44M
  case DeclarationName::CXXDeductionGuideName:
447
5.44M
    return false;
448
449
13
  case DeclarationName::CXXConstructorName:
450
18
  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
476k
std::string DeclarationNameInfo::getAsString() const {
461
476k
  std::string Result;
462
476k
  llvm::raw_string_ostream OS(Result);
463
476k
  OS << *this;
464
476k
  return OS.str();
465
476k
}
466
467
544k
raw_ostream &clang::operator<<(raw_ostream &OS, DeclarationNameInfo DNInfo) {
468
544k
  LangOptions LO;
469
544k
  DNInfo.printName(OS, PrintingPolicy(LangOptions()));
470
544k
  return OS;
471
544k
}
472
473
552k
void DeclarationNameInfo::printName(raw_ostream &OS, PrintingPolicy Policy) const {
474
552k
  switch (Name.getNameKind()) {
475
351k
  case DeclarationName::Identifier:
476
351k
  case DeclarationName::ObjCZeroArgSelector:
477
351k
  case DeclarationName::ObjCOneArgSelector:
478
351k
  case DeclarationName::ObjCMultiArgSelector:
479
499k
  case DeclarationName::CXXOperatorName:
480
499k
  case DeclarationName::CXXLiteralOperatorName:
481
499k
  case DeclarationName::CXXUsingDirective:
482
499k
  case DeclarationName::CXXDeductionGuideName:
483
499k
    Name.print(OS, Policy);
484
499k
    return;
485
486
47.4k
  case DeclarationName::CXXConstructorName:
487
50.5k
  case DeclarationName::CXXDestructorName:
488
52.5k
  case DeclarationName::CXXConversionFunctionName:
489
52.5k
    if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo) {
490
4.83k
      if (Name.getNameKind() == DeclarationName::CXXDestructorName)
491
3.01k
        OS << '~';
492
1.82k
      else if (Name.getNameKind() == DeclarationName::CXXConversionFunctionName)
493
1.82k
        OS << "operator ";
494
4.83k
      LangOptions LO;
495
4.83k
      Policy.adjustForCPlusPlus();
496
4.83k
      Policy.SuppressScope = true;
497
4.83k
      OS << TInfo->getType().getAsString(Policy);
498
4.83k
    } else
499
47.6k
      Name.print(OS, Policy);
500
52.5k
    return;
501
0
  }
502
0
  llvm_unreachable("Unexpected declaration name kind");
503
0
}
504
505
27.2M
SourceLocation DeclarationNameInfo::getEndLocPrivate() const {
506
27.2M
  switch (Name.getNameKind()) {
507
25.4M
  case DeclarationName::Identifier:
508
25.4M
  case DeclarationName::CXXDeductionGuideName:
509
25.4M
    return NameLoc;
510
511
749k
  case DeclarationName::CXXOperatorName: {
512
749k
    unsigned raw = LocInfo.CXXOperatorName.EndOpNameLoc;
513
749k
    return SourceLocation::getFromRawEncoding(raw);
514
25.4M
  }
515
516
1.07k
  case DeclarationName::CXXLiteralOperatorName: {
517
1.07k
    unsigned raw = LocInfo.CXXLiteralOperatorName.OpNameLoc;
518
1.07k
    return SourceLocation::getFromRawEncoding(raw);
519
25.4M
  }
520
521
791k
  case DeclarationName::CXXConstructorName:
522
941k
  case DeclarationName::CXXDestructorName:
523
984k
  case DeclarationName::CXXConversionFunctionName:
524
984k
    if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo)
525
93.4k
      return TInfo->getTypeLoc().getEndLoc();
526
891k
    else
527
891k
      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
}