Coverage Report

Created: 2020-02-15 09:57

/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/PrettyPrinter.h"
21
#include "clang/AST/Type.h"
22
#include "clang/AST/TypeLoc.h"
23
#include "clang/AST/TypeOrdering.h"
24
#include "clang/Basic/IdentifierTable.h"
25
#include "clang/Basic/LLVM.h"
26
#include "clang/Basic/LangOptions.h"
27
#include "clang/Basic/OperatorKinds.h"
28
#include "clang/Basic/SourceLocation.h"
29
#include "llvm/ADT/FoldingSet.h"
30
#include "llvm/Support/Casting.h"
31
#include "llvm/Support/Compiler.h"
32
#include "llvm/Support/ErrorHandling.h"
33
#include "llvm/Support/raw_ostream.h"
34
#include <algorithm>
35
#include <cassert>
36
#include <cstdint>
37
#include <string>
38
39
using namespace clang;
40
41
37.2k
static int compareInt(unsigned A, unsigned B) {
42
37.2k
  return (A < B ? 
-123.7k
:
(A > B 13.4k
?
112.4k
:
0970
));
43
37.2k
}
44
45
10.4M
int DeclarationName::compare(DeclarationName LHS, DeclarationName RHS) {
46
10.4M
  if (LHS.getNameKind() != RHS.getNameKind())
47
385k
    return (LHS.getNameKind() < RHS.getNameKind() ? 
-1306k
:
178.6k
);
48
10.0M
49
10.0M
  switch (LHS.getNameKind()) {
50
9.88M
  case DeclarationName::Identifier: {
51
9.88M
    IdentifierInfo *LII = LHS.castAsIdentifierInfo();
52
9.88M
    IdentifierInfo *RII = RHS.castAsIdentifierInfo();
53
9.88M
    if (!LII)
54
0
      return RII ? -1 : 0;
55
9.88M
    if (!RII)
56
0
      return 1;
57
9.88M
58
9.88M
    return LII->getName().compare(RII->getName());
59
9.88M
  }
60
9.88M
61
9.88M
  case DeclarationName::ObjCZeroArgSelector:
62
164k
  case DeclarationName::ObjCOneArgSelector:
63
164k
  case DeclarationName::ObjCMultiArgSelector: {
64
164k
    Selector LHSSelector = LHS.getObjCSelector();
65
164k
    Selector RHSSelector = RHS.getObjCSelector();
66
164k
    // getNumArgs for ZeroArgSelector returns 0, but we still need to compare.
67
164k
    if (LHS.getNameKind() == DeclarationName::ObjCZeroArgSelector &&
68
164k
        
RHS.getNameKind() == DeclarationName::ObjCZeroArgSelector71.3k
) {
69
71.3k
      return LHSSelector.getAsIdentifierInfo()->getName().compare(
70
71.3k
          RHSSelector.getAsIdentifierInfo()->getName());
71
71.3k
    }
72
92.7k
    unsigned LN = LHSSelector.getNumArgs(), RN = RHSSelector.getNumArgs();
73
100k
    for (unsigned I = 0, N = std::min(LN, RN); I != N; 
++I8.12k
) {
74
99.8k
      switch (LHSSelector.getNameForSlot(I).compare(
75
99.8k
          RHSSelector.getNameForSlot(I))) {
76
67.5k
      case -1:
77
67.5k
        return -1;
78
24.1k
      case 1:
79
24.1k
        return 1;
80
8.12k
      default:
81
8.12k
        break;
82
99.8k
      }
83
99.8k
    }
84
92.7k
85
92.7k
    
return compareInt(LN, RN)1.08k
;
86
92.7k
  }
87
92.7k
88
92.7k
  case DeclarationName::CXXConstructorName:
89
3.00k
  case DeclarationName::CXXDestructorName:
90
3.00k
  case DeclarationName::CXXConversionFunctionName:
91
3.00k
    if (QualTypeOrdering()(LHS.getCXXNameType(), RHS.getCXXNameType()))
92
1.46k
      return -1;
93
1.54k
    if (QualTypeOrdering()(RHS.getCXXNameType(), LHS.getCXXNameType()))
94
1.31k
      return 1;
95
227
    return 0;
96
227
97
744
  case DeclarationName::CXXDeductionGuideName:
98
744
    // We never want to compare deduction guide names for templates from
99
744
    // different scopes, so just compare the template-name.
100
744
    return compare(LHS.getCXXDeductionGuideTemplate()->getDeclName(),
101
744
                   RHS.getCXXDeductionGuideTemplate()->getDeclName());
102
227
103
36.1k
  case DeclarationName::CXXOperatorName:
104
36.1k
    return compareInt(LHS.getCXXOverloadedOperator(),
105
36.1k
                      RHS.getCXXOverloadedOperator());
106
227
107
310
  case DeclarationName::CXXLiteralOperatorName:
108
310
    return LHS.getCXXLiteralIdentifier()->getName().compare(
109
310
        RHS.getCXXLiteralIdentifier()->getName());
110
227
111
227
  case DeclarationName::CXXUsingDirective:
112
0
    return 0;
113
0
  }
114
0
115
0
  llvm_unreachable("Invalid DeclarationName Kind!");
116
0
}
117
118
static void printCXXConstructorDestructorName(QualType ClassType,
119
                                              raw_ostream &OS,
120
141k
                                              PrintingPolicy Policy) {
121
141k
  // We know we're printing C++ here. Ensure we print types properly.
122
141k
  Policy.adjustForCPlusPlus();
123
141k
124
141k
  if (const RecordType *ClassRec = ClassType->getAs<RecordType>()) {
125
125k
    OS << *ClassRec->getDecl();
126
125k
    return;
127
125k
  }
128
15.5k
  if (Policy.SuppressTemplateArgsInCXXConstructors) {
129
29
    if (auto *InjTy = ClassType->getAs<InjectedClassNameType>()) {
130
29
      OS << *InjTy->getDecl();
131
29
      return;
132
29
    }
133
15.4k
  }
134
15.4k
  ClassType.print(OS, Policy);
135
15.4k
}
136
137
void DeclarationName::print(raw_ostream &OS,
138
2.01M
                            const PrintingPolicy &Policy) const {
139
2.01M
  switch (getNameKind()) {
140
1.71M
  case DeclarationName::Identifier:
141
1.71M
    if (const IdentifierInfo *II = getAsIdentifierInfo())
142
1.70M
      OS << II->getName();
143
1.71M
    return;
144
0
145
8.89k
  case DeclarationName::ObjCZeroArgSelector:
146
8.89k
  case DeclarationName::ObjCOneArgSelector:
147
8.89k
  case DeclarationName::ObjCMultiArgSelector:
148
8.89k
    getObjCSelector().print(OS);
149
8.89k
    return;
150
8.89k
151
119k
  case DeclarationName::CXXConstructorName:
152
119k
    return printCXXConstructorDestructorName(getCXXNameType(), OS, Policy);
153
8.89k
154
21.7k
  case DeclarationName::CXXDestructorName:
155
21.7k
    OS << '~';
156
21.7k
    return printCXXConstructorDestructorName(getCXXNameType(), OS, Policy);
157
8.89k
158
8.89k
  case DeclarationName::CXXDeductionGuideName:
159
20
    OS << "<deduction guide for ";
160
20
    getCXXDeductionGuideTemplate()->getDeclName().print(OS, Policy);
161
20
    OS << '>';
162
20
    return;
163
8.89k
164
137k
  case DeclarationName::CXXOperatorName: {
165
137k
    const char *OpName = getOperatorSpelling(getCXXOverloadedOperator());
166
137k
    assert(OpName && "not an overloaded operator");
167
137k
168
137k
    OS << "operator";
169
137k
    if (OpName[0] >= 'a' && 
OpName[0] <= 'z'3.25k
)
170
2.23k
      OS << ' ';
171
137k
    OS << OpName;
172
137k
    return;
173
8.89k
  }
174
8.89k
175
8.89k
  case DeclarationName::CXXLiteralOperatorName:
176
151
    OS << "operator\"\"" << getCXXLiteralIdentifier()->getName();
177
151
    return;
178
8.89k
179
8.89k
  case DeclarationName::CXXConversionFunctionName: {
180
5.69k
    OS << "operator ";
181
5.69k
    QualType Type = getCXXNameType();
182
5.69k
    if (const RecordType *Rec = Type->getAs<RecordType>()) {
183
593
      OS << *Rec->getDecl();
184
593
      return;
185
593
    }
186
5.10k
    // We know we're printing C++ here, ensure we print 'bool' properly.
187
5.10k
    PrintingPolicy CXXPolicy = Policy;
188
5.10k
    CXXPolicy.adjustForCPlusPlus();
189
5.10k
    Type.print(OS, CXXPolicy);
190
5.10k
    return;
191
5.10k
  }
192
10.8k
  case DeclarationName::CXXUsingDirective:
193
10.8k
    OS << "<using-directive>";
194
10.8k
    return;
195
0
  }
196
0
197
0
  llvm_unreachable("Unexpected declaration name kind");
198
0
}
199
200
namespace clang {
201
202
1.75M
raw_ostream &operator<<(raw_ostream &OS, DeclarationName N) {
203
1.75M
  LangOptions LO;
204
1.75M
  N.print(OS, PrintingPolicy(LO));
205
1.75M
  return OS;
206
1.75M
}
207
208
} // namespace clang
209
210
330k
bool DeclarationName::isDependentName() const {
211
330k
  QualType T = getCXXNameType();
212
330k
  if (!T.isNull() && 
T->isDependentType()435
)
213
8
    return true;
214
330k
215
330k
  // A class-scope deduction guide in a dependent context has a dependent name.
216
330k
  auto *TD = getCXXDeductionGuideTemplate();
217
330k
  if (TD && 
TD->getDeclContext()->isDependentContext()0
)
218
0
    return true;
219
330k
220
330k
  return false;
221
330k
}
222
223
667k
std::string DeclarationName::getAsString() const {
224
667k
  std::string Result;
225
667k
  llvm::raw_string_ostream OS(Result);
226
667k
  OS << *this;
227
667k
  return OS.str();
228
667k
}
229
230
6.19M
void *DeclarationName::getFETokenInfoSlow() const {
231
6.19M
  switch (getNameKind()) {
232
0
  case Identifier:
233
0
    llvm_unreachable("case Identifier already handled by getFETokenInfo!");
234
2.08M
  case CXXConstructorName:
235
2.08M
  case CXXDestructorName:
236
2.08M
  case CXXConversionFunctionName:
237
2.08M
    return castAsCXXSpecialNameExtra()->FETokenInfo;
238
4.09M
  case CXXOperatorName:
239
4.09M
    return castAsCXXOperatorIdName()->FETokenInfo;
240
2.08M
  case CXXDeductionGuideName:
241
3.40k
    return castAsCXXDeductionGuideNameExtra()->FETokenInfo;
242
2.08M
  case CXXLiteralOperatorName:
243
3.40k
    return castAsCXXLiteralOperatorIdName()->FETokenInfo;
244
2.08M
  default:
245
0
    llvm_unreachable("DeclarationName has no FETokenInfo!");
246
6.19M
  }
247
6.19M
}
248
249
477k
void DeclarationName::setFETokenInfoSlow(void *T) {
250
477k
  switch (getNameKind()) {
251
0
  case Identifier:
252
0
    llvm_unreachable("case Identifier already handled by setFETokenInfo!");
253
334k
  case CXXConstructorName:
254
334k
  case CXXDestructorName:
255
334k
  case CXXConversionFunctionName:
256
334k
    castAsCXXSpecialNameExtra()->FETokenInfo = T;
257
334k
    break;
258
334k
  case CXXOperatorName:
259
142k
    castAsCXXOperatorIdName()->FETokenInfo = T;
260
142k
    break;
261
334k
  case CXXDeductionGuideName:
262
348
    castAsCXXDeductionGuideNameExtra()->FETokenInfo = T;
263
348
    break;
264
334k
  case CXXLiteralOperatorName:
265
450
    castAsCXXLiteralOperatorIdName()->FETokenInfo = T;
266
450
    break;
267
334k
  default:
268
0
    llvm_unreachable("DeclarationName has no FETokenInfo!");
269
477k
  }
270
477k
}
271
272
0
LLVM_DUMP_METHOD void DeclarationName::dump() const {
273
0
  llvm::errs() << *this << '\n';
274
0
}
275
276
61.6k
DeclarationNameTable::DeclarationNameTable(const ASTContext &C) : Ctx(C) {
277
61.6k
  // Initialize the overloaded operator names.
278
2.89M
  for (unsigned Op = 0; Op < NUM_OVERLOADED_OPERATORS; 
++Op2.83M
)
279
2.83M
    CXXOperatorNames[Op].Kind = static_cast<OverloadedOperatorKind>(Op);
280
61.6k
}
281
282
DeclarationName
283
2.53k
DeclarationNameTable::getCXXDeductionGuideName(TemplateDecl *Template) {
284
2.53k
  Template = cast<TemplateDecl>(Template->getCanonicalDecl());
285
2.53k
286
2.53k
  llvm::FoldingSetNodeID ID;
287
2.53k
  ID.AddPointer(Template);
288
2.53k
289
2.53k
  void *InsertPos = nullptr;
290
2.53k
  if (auto *Name = CXXDeductionGuideNames.FindNodeOrInsertPos(ID, InsertPos))
291
2.29k
    return DeclarationName(Name);
292
239
293
239
  auto *Name = new (Ctx) detail::CXXDeductionGuideNameExtra(Template);
294
239
  CXXDeductionGuideNames.InsertNode(Name, InsertPos);
295
239
  return DeclarationName(Name);
296
239
}
297
298
2.07M
DeclarationName DeclarationNameTable::getCXXConstructorName(CanQualType Ty) {
299
2.07M
  // The type of constructors is unqualified.
300
2.07M
  Ty = Ty.getUnqualifiedType();
301
2.07M
  // Do we already have this C++ constructor name ?
302
2.07M
  llvm::FoldingSetNodeID ID;
303
2.07M
  ID.AddPointer(Ty.getAsOpaquePtr());
304
2.07M
  void *InsertPos = nullptr;
305
2.07M
  if (auto *Name = CXXConstructorNames.FindNodeOrInsertPos(ID, InsertPos))
306
1.77M
    return {Name, DeclarationName::StoredCXXConstructorName};
307
299k
308
299k
  // We have to create it.
309
299k
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
310
299k
  CXXConstructorNames.InsertNode(SpecialName, InsertPos);
311
299k
  return {SpecialName, DeclarationName::StoredCXXConstructorName};
312
299k
}
313
314
6.12M
DeclarationName DeclarationNameTable::getCXXDestructorName(CanQualType Ty) {
315
6.12M
  // The type of destructors is unqualified.
316
6.12M
  Ty = Ty.getUnqualifiedType();
317
6.12M
  // Do we already have this C++ destructor name ?
318
6.12M
  llvm::FoldingSetNodeID ID;
319
6.12M
  ID.AddPointer(Ty.getAsOpaquePtr());
320
6.12M
  void *InsertPos = nullptr;
321
6.12M
  if (auto *Name = CXXDestructorNames.FindNodeOrInsertPos(ID, InsertPos))
322
4.75M
    return {Name, DeclarationName::StoredCXXDestructorName};
323
1.37M
324
1.37M
  // We have to create it.
325
1.37M
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
326
1.37M
  CXXDestructorNames.InsertNode(SpecialName, InsertPos);
327
1.37M
  return {SpecialName, DeclarationName::StoredCXXDestructorName};
328
1.37M
}
329
330
DeclarationName
331
64.1k
DeclarationNameTable::getCXXConversionFunctionName(CanQualType Ty) {
332
64.1k
  // Do we already have this C++ conversion function name ?
333
64.1k
  llvm::FoldingSetNodeID ID;
334
64.1k
  ID.AddPointer(Ty.getAsOpaquePtr());
335
64.1k
  void *InsertPos = nullptr;
336
64.1k
  if (auto *Name =
337
51.6k
          CXXConversionFunctionNames.FindNodeOrInsertPos(ID, InsertPos))
338
51.6k
    return {Name, DeclarationName::StoredCXXConversionFunctionName};
339
12.5k
340
12.5k
  // We have to create it.
341
12.5k
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
342
12.5k
  CXXConversionFunctionNames.InsertNode(SpecialName, InsertPos);
343
12.5k
  return {SpecialName, DeclarationName::StoredCXXConversionFunctionName};
344
12.5k
}
345
346
DeclarationName
347
DeclarationNameTable::getCXXSpecialName(DeclarationName::NameKind Kind,
348
223k
                                        CanQualType Ty) {
349
223k
  switch (Kind) {
350
199k
  case DeclarationName::CXXConstructorName:
351
199k
    return getCXXConstructorName(Ty);
352
12.3k
  case DeclarationName::CXXDestructorName:
353
12.3k
    return getCXXDestructorName(Ty);
354
11.5k
  case DeclarationName::CXXConversionFunctionName:
355
11.5k
    return getCXXConversionFunctionName(Ty);
356
0
  default:
357
0
    llvm_unreachable("Invalid kind in getCXXSpecialName!");
358
223k
  }
359
223k
}
360
361
DeclarationName
362
1.59k
DeclarationNameTable::getCXXLiteralOperatorName(IdentifierInfo *II) {
363
1.59k
  llvm::FoldingSetNodeID ID;
364
1.59k
  ID.AddPointer(II);
365
1.59k
366
1.59k
  void *InsertPos = nullptr;
367
1.59k
  if (auto *Name = CXXLiteralOperatorNames.FindNodeOrInsertPos(ID, InsertPos))
368
1.35k
    return DeclarationName(Name);
369
249
370
249
  auto *LiteralName = new (Ctx) detail::CXXLiteralOperatorIdName(II);
371
249
  CXXLiteralOperatorNames.InsertNode(LiteralName, InsertPos);
372
249
  return DeclarationName(LiteralName);
373
249
}
374
375
80.4M
DeclarationNameLoc::DeclarationNameLoc(DeclarationName Name) {
376
80.4M
  switch (Name.getNameKind()) {
377
76.0M
  case DeclarationName::Identifier:
378
76.0M
  case DeclarationName::CXXDeductionGuideName:
379
76.0M
    break;
380
76.0M
  case DeclarationName::CXXConstructorName:
381
619k
  case DeclarationName::CXXDestructorName:
382
619k
  case DeclarationName::CXXConversionFunctionName:
383
619k
    NamedType.TInfo = nullptr;
384
619k
    break;
385
3.73M
  case DeclarationName::CXXOperatorName:
386
3.73M
    CXXOperatorName.BeginOpNameLoc = SourceLocation().getRawEncoding();
387
3.73M
    CXXOperatorName.EndOpNameLoc = SourceLocation().getRawEncoding();
388
3.73M
    break;
389
619k
  case DeclarationName::CXXLiteralOperatorName:
390
525
    CXXLiteralOperatorName.OpNameLoc = SourceLocation().getRawEncoding();
391
525
    break;
392
619k
  case DeclarationName::ObjCZeroArgSelector:
393
0
  case DeclarationName::ObjCOneArgSelector:
394
0
  case DeclarationName::ObjCMultiArgSelector:
395
0
    // FIXME: ?
396
0
    break;
397
0
  case DeclarationName::CXXUsingDirective:
398
0
    break;
399
80.4M
  }
400
80.4M
}
401
402
4.09M
bool DeclarationNameInfo::containsUnexpandedParameterPack() const {
403
4.09M
  switch (Name.getNameKind()) {
404
4.09M
  case DeclarationName::Identifier:
405
4.09M
  case DeclarationName::ObjCZeroArgSelector:
406
4.09M
  case DeclarationName::ObjCOneArgSelector:
407
4.09M
  case DeclarationName::ObjCMultiArgSelector:
408
4.09M
  case DeclarationName::CXXOperatorName:
409
4.09M
  case DeclarationName::CXXLiteralOperatorName:
410
4.09M
  case DeclarationName::CXXUsingDirective:
411
4.09M
  case DeclarationName::CXXDeductionGuideName:
412
4.09M
    return false;
413
4.09M
414
4.09M
  case DeclarationName::CXXConstructorName:
415
41
  case DeclarationName::CXXDestructorName:
416
41
  case DeclarationName::CXXConversionFunctionName:
417
41
    if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo)
418
27
      return TInfo->getType()->containsUnexpandedParameterPack();
419
14
420
14
    return Name.getCXXNameType()->containsUnexpandedParameterPack();
421
0
  }
422
0
  llvm_unreachable("All name kinds handled.");
423
0
}
424
425
3.04M
bool DeclarationNameInfo::isInstantiationDependent() const {
426
3.04M
  switch (Name.getNameKind()) {
427
3.04M
  case DeclarationName::Identifier:
428
3.04M
  case DeclarationName::ObjCZeroArgSelector:
429
3.04M
  case DeclarationName::ObjCOneArgSelector:
430
3.04M
  case DeclarationName::ObjCMultiArgSelector:
431
3.04M
  case DeclarationName::CXXOperatorName:
432
3.04M
  case DeclarationName::CXXLiteralOperatorName:
433
3.04M
  case DeclarationName::CXXUsingDirective:
434
3.04M
  case DeclarationName::CXXDeductionGuideName:
435
3.04M
    return false;
436
3.04M
437
3.04M
  case DeclarationName::CXXConstructorName:
438
26
  case DeclarationName::CXXDestructorName:
439
26
  case DeclarationName::CXXConversionFunctionName:
440
26
    if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo)
441
13
      return TInfo->getType()->isInstantiationDependentType();
442
13
443
13
    return Name.getCXXNameType()->isInstantiationDependentType();
444
0
  }
445
0
  llvm_unreachable("All name kinds handled.");
446
0
}
447
448
186k
std::string DeclarationNameInfo::getAsString() const {
449
186k
  std::string Result;
450
186k
  llvm::raw_string_ostream OS(Result);
451
186k
  OS << *this;
452
186k
  return OS.str();
453
186k
}
454
455
238k
raw_ostream &clang::operator<<(raw_ostream &OS, DeclarationNameInfo DNInfo) {
456
238k
  LangOptions LO;
457
238k
  DNInfo.printName(OS, PrintingPolicy(LangOptions()));
458
238k
  return OS;
459
238k
}
460
461
245k
void DeclarationNameInfo::printName(raw_ostream &OS, PrintingPolicy Policy) const {
462
245k
  switch (Name.getNameKind()) {
463
226k
  case DeclarationName::Identifier:
464
226k
  case DeclarationName::ObjCZeroArgSelector:
465
226k
  case DeclarationName::ObjCOneArgSelector:
466
226k
  case DeclarationName::ObjCMultiArgSelector:
467
226k
  case DeclarationName::CXXOperatorName:
468
226k
  case DeclarationName::CXXLiteralOperatorName:
469
226k
  case DeclarationName::CXXUsingDirective:
470
226k
  case DeclarationName::CXXDeductionGuideName:
471
226k
    Name.print(OS, Policy);
472
226k
    return;
473
226k
474
226k
  case DeclarationName::CXXConstructorName:
475
19.5k
  case DeclarationName::CXXDestructorName:
476
19.5k
  case DeclarationName::CXXConversionFunctionName:
477
19.5k
    if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo) {
478
1.34k
      if (Name.getNameKind() == DeclarationName::CXXDestructorName)
479
969
        OS << '~';
480
377
      else if (Name.getNameKind() == DeclarationName::CXXConversionFunctionName)
481
377
        OS << "operator ";
482
1.34k
      LangOptions LO;
483
1.34k
      Policy.adjustForCPlusPlus();
484
1.34k
      Policy.SuppressScope = true;
485
1.34k
      OS << TInfo->getType().getAsString(Policy);
486
1.34k
    } else
487
18.2k
      Name.print(OS, Policy);
488
19.5k
    return;
489
0
  }
490
0
  llvm_unreachable("Unexpected declaration name kind");
491
0
}
492
493
16.8M
SourceLocation DeclarationNameInfo::getEndLocPrivate() const {
494
16.8M
  switch (Name.getNameKind()) {
495
15.4M
  case DeclarationName::Identifier:
496
15.4M
  case DeclarationName::CXXDeductionGuideName:
497
15.4M
    return NameLoc;
498
15.4M
499
15.4M
  case DeclarationName::CXXOperatorName: {
500
575k
    unsigned raw = LocInfo.CXXOperatorName.EndOpNameLoc;
501
575k
    return SourceLocation::getFromRawEncoding(raw);
502
15.4M
  }
503
15.4M
504
15.4M
  case DeclarationName::CXXLiteralOperatorName: {
505
665
    unsigned raw = LocInfo.CXXLiteralOperatorName.OpNameLoc;
506
665
    return SourceLocation::getFromRawEncoding(raw);
507
15.4M
  }
508
15.4M
509
15.4M
  case DeclarationName::CXXConstructorName:
510
841k
  case DeclarationName::CXXDestructorName:
511
841k
  case DeclarationName::CXXConversionFunctionName:
512
841k
    if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo)
513
77.2k
      return TInfo->getTypeLoc().getEndLoc();
514
764k
    else
515
764k
      return NameLoc;
516
0
517
0
    // DNInfo work in progress: FIXME.
518
0
  case DeclarationName::ObjCZeroArgSelector:
519
0
  case DeclarationName::ObjCOneArgSelector:
520
0
  case DeclarationName::ObjCMultiArgSelector:
521
0
  case DeclarationName::CXXUsingDirective:
522
0
    return NameLoc;
523
0
  }
524
0
  llvm_unreachable("Unexpected declaration name kind");
525
0
}