Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/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
281
static int compareInt(unsigned A, unsigned B) {
42
281
  return (A < B ? 
-1175
:
(A > B 106
?
1106
:
00
));
43
281
}
44
45
121k
int DeclarationName::compare(DeclarationName LHS, DeclarationName RHS) {
46
121k
  if (LHS.getNameKind() != RHS.getNameKind())
47
7.57k
    return (LHS.getNameKind() < RHS.getNameKind() ? 
-14.97k
:
12.60k
);
48
113k
49
113k
  switch (LHS.getNameKind()) {
50
113k
  case DeclarationName::Identifier: {
51
112k
    IdentifierInfo *LII = LHS.castAsIdentifierInfo();
52
112k
    IdentifierInfo *RII = RHS.castAsIdentifierInfo();
53
112k
    if (!LII)
54
0
      return RII ? -1 : 0;
55
112k
    if (!RII)
56
0
      return 1;
57
112k
58
112k
    return LII->getName().compare(RII->getName());
59
112k
  }
60
112k
61
112k
  case DeclarationName::ObjCZeroArgSelector:
62
413
  case DeclarationName::ObjCOneArgSelector:
63
413
  case DeclarationName::ObjCMultiArgSelector: {
64
413
    Selector LHSSelector = LHS.getObjCSelector();
65
413
    Selector RHSSelector = RHS.getObjCSelector();
66
413
    // getNumArgs for ZeroArgSelector returns 0, but we still need to compare.
67
413
    if (LHS.getNameKind() == DeclarationName::ObjCZeroArgSelector &&
68
413
        
RHS.getNameKind() == DeclarationName::ObjCZeroArgSelector252
) {
69
252
      return LHSSelector.getAsIdentifierInfo()->getName().compare(
70
252
          RHSSelector.getAsIdentifierInfo()->getName());
71
252
    }
72
161
    unsigned LN = LHSSelector.getNumArgs(), RN = RHSSelector.getNumArgs();
73
163
    for (unsigned I = 0, N = std::min(LN, RN); I != N; 
++I2
) {
74
163
      switch (LHSSelector.getNameForSlot(I).compare(
75
163
          RHSSelector.getNameForSlot(I))) {
76
163
      case -1:
77
120
        return -1;
78
163
      case 1:
79
41
        return 1;
80
163
      default:
81
2
        break;
82
163
      }
83
163
    }
84
161
85
161
    
return compareInt(LN, RN)0
;
86
161
  }
87
161
88
161
  case DeclarationName::CXXConstructorName:
89
0
  case DeclarationName::CXXDestructorName:
90
0
  case DeclarationName::CXXConversionFunctionName:
91
0
    if (QualTypeOrdering()(LHS.getCXXNameType(), RHS.getCXXNameType()))
92
0
      return -1;
93
0
    if (QualTypeOrdering()(RHS.getCXXNameType(), LHS.getCXXNameType()))
94
0
      return 1;
95
0
    return 0;
96
0
97
2
  case DeclarationName::CXXDeductionGuideName:
98
2
    // We never want to compare deduction guide names for templates from
99
2
    // different scopes, so just compare the template-name.
100
2
    return compare(LHS.getCXXDeductionGuideTemplate()->getDeclName(),
101
2
                   RHS.getCXXDeductionGuideTemplate()->getDeclName());
102
0
103
281
  case DeclarationName::CXXOperatorName:
104
281
    return compareInt(LHS.getCXXOverloadedOperator(),
105
281
                      RHS.getCXXOverloadedOperator());
106
0
107
0
  case DeclarationName::CXXLiteralOperatorName:
108
0
    return LHS.getCXXLiteralIdentifier()->getName().compare(
109
0
        RHS.getCXXLiteralIdentifier()->getName());
110
0
111
0
  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
29.7k
                                              PrintingPolicy Policy) {
121
29.7k
  // We know we're printing C++ here. Ensure we print types properly.
122
29.7k
  Policy.adjustForCPlusPlus();
123
29.7k
124
29.7k
  if (const RecordType *ClassRec = ClassType->getAs<RecordType>()) {
125
29.3k
    OS << *ClassRec->getDecl();
126
29.3k
    return;
127
29.3k
  }
128
356
  if (Policy.SuppressTemplateArgsInCXXConstructors) {
129
28
    if (auto *InjTy = ClassType->getAs<InjectedClassNameType>()) {
130
28
      OS << *InjTy->getDecl();
131
28
      return;
132
28
    }
133
328
  }
134
328
  ClassType.print(OS, Policy);
135
328
}
136
137
673k
void DeclarationName::print(raw_ostream &OS, const PrintingPolicy &Policy) {
138
673k
  switch (getNameKind()) {
139
673k
  case DeclarationName::Identifier:
140
613k
    if (const IdentifierInfo *II = getAsIdentifierInfo())
141
610k
      OS << II->getName();
142
613k
    return;
143
673k
144
673k
  case DeclarationName::ObjCZeroArgSelector:
145
5.67k
  case DeclarationName::ObjCOneArgSelector:
146
5.67k
  case DeclarationName::ObjCMultiArgSelector:
147
5.67k
    getObjCSelector().print(OS);
148
5.67k
    return;
149
5.67k
150
22.2k
  case DeclarationName::CXXConstructorName:
151
22.2k
    return printCXXConstructorDestructorName(getCXXNameType(), OS, Policy);
152
5.67k
153
7.43k
  case DeclarationName::CXXDestructorName:
154
7.43k
    OS << '~';
155
7.43k
    return printCXXConstructorDestructorName(getCXXNameType(), OS, Policy);
156
5.67k
157
5.67k
  case DeclarationName::CXXDeductionGuideName:
158
20
    OS << "<deduction guide for ";
159
20
    getCXXDeductionGuideTemplate()->getDeclName().print(OS, Policy);
160
20
    OS << '>';
161
20
    return;
162
5.67k
163
24.0k
  case DeclarationName::CXXOperatorName: {
164
24.0k
    const char *OpName = getOperatorSpelling(getCXXOverloadedOperator());
165
24.0k
    assert(OpName && "not an overloaded operator");
166
24.0k
167
24.0k
    OS << "operator";
168
24.0k
    if (OpName[0] >= 'a' && 
OpName[0] <= 'z'1.03k
)
169
1.00k
      OS << ' ';
170
24.0k
    OS << OpName;
171
24.0k
    return;
172
5.67k
  }
173
5.67k
174
5.67k
  case DeclarationName::CXXLiteralOperatorName:
175
97
    OS << "operator\"\"" << getCXXLiteralIdentifier()->getName();
176
97
    return;
177
5.67k
178
5.67k
  case DeclarationName::CXXConversionFunctionName: {
179
654
    OS << "operator ";
180
654
    QualType Type = getCXXNameType();
181
654
    if (const RecordType *Rec = Type->getAs<RecordType>()) {
182
67
      OS << *Rec->getDecl();
183
67
      return;
184
67
    }
185
587
    // We know we're printing C++ here, ensure we print 'bool' properly.
186
587
    PrintingPolicy CXXPolicy = Policy;
187
587
    CXXPolicy.adjustForCPlusPlus();
188
587
    Type.print(OS, CXXPolicy);
189
587
    return;
190
587
  }
191
587
  case DeclarationName::CXXUsingDirective:
192
221
    OS << "<using-directive>";
193
221
    return;
194
0
  }
195
0
196
0
  llvm_unreachable("Unexpected declaration name kind");
197
0
}
198
199
namespace clang {
200
201
662k
raw_ostream &operator<<(raw_ostream &OS, DeclarationName N) {
202
662k
  LangOptions LO;
203
662k
  N.print(OS, PrintingPolicy(LO));
204
662k
  return OS;
205
662k
}
206
207
} // namespace clang
208
209
849k
bool DeclarationName::isDependentName() const {
210
849k
  QualType T = getCXXNameType();
211
849k
  if (!T.isNull() && 
T->isDependentType()520
)
212
4
    return true;
213
849k
214
849k
  // A class-scope deduction guide in a dependent context has a dependent name.
215
849k
  auto *TD = getCXXDeductionGuideTemplate();
216
849k
  if (TD && 
TD->getDeclContext()->isDependentContext()0
)
217
0
    return true;
218
849k
219
849k
  return false;
220
849k
}
221
222
46.9k
std::string DeclarationName::getAsString() const {
223
46.9k
  std::string Result;
224
46.9k
  llvm::raw_string_ostream OS(Result);
225
46.9k
  OS << *this;
226
46.9k
  return OS.str();
227
46.9k
}
228
229
8.16M
void *DeclarationName::getFETokenInfoSlow() const {
230
8.16M
  switch (getNameKind()) {
231
8.16M
  case Identifier:
232
0
    llvm_unreachable("case Identifier already handled by getFETokenInfo!");
233
8.16M
  case CXXConstructorName:
234
2.63M
  case CXXDestructorName:
235
2.63M
  case CXXConversionFunctionName:
236
2.63M
    return castAsCXXSpecialNameExtra()->FETokenInfo;
237
5.51M
  case CXXOperatorName:
238
5.51M
    return castAsCXXOperatorIdName()->FETokenInfo;
239
2.63M
  case CXXDeductionGuideName:
240
1.97k
    return castAsCXXDeductionGuideNameExtra()->FETokenInfo;
241
2.63M
  case CXXLiteralOperatorName:
242
14.0k
    return castAsCXXLiteralOperatorIdName()->FETokenInfo;
243
2.63M
  default:
244
0
    llvm_unreachable("DeclarationName has no FETokenInfo!");
245
8.16M
  }
246
8.16M
}
247
248
742k
void DeclarationName::setFETokenInfoSlow(void *T) {
249
742k
  switch (getNameKind()) {
250
742k
  case Identifier:
251
0
    llvm_unreachable("case Identifier already handled by setFETokenInfo!");
252
742k
  case CXXConstructorName:
253
557k
  case CXXDestructorName:
254
557k
  case CXXConversionFunctionName:
255
557k
    castAsCXXSpecialNameExtra()->FETokenInfo = T;
256
557k
    break;
257
557k
  case CXXOperatorName:
258
181k
    castAsCXXOperatorIdName()->FETokenInfo = T;
259
181k
    break;
260
557k
  case CXXDeductionGuideName:
261
151
    castAsCXXDeductionGuideNameExtra()->FETokenInfo = T;
262
151
    break;
263
557k
  case CXXLiteralOperatorName:
264
2.42k
    castAsCXXLiteralOperatorIdName()->FETokenInfo = T;
265
2.42k
    break;
266
557k
  default:
267
0
    llvm_unreachable("DeclarationName has no FETokenInfo!");
268
742k
  }
269
742k
}
270
271
0
LLVM_DUMP_METHOD void DeclarationName::dump() const {
272
0
  llvm::errs() << *this << '\n';
273
0
}
274
275
41.7k
DeclarationNameTable::DeclarationNameTable(const ASTContext &C) : Ctx(C) {
276
41.7k
  // Initialize the overloaded operator names.
277
1.96M
  for (unsigned Op = 0; Op < NUM_OVERLOADED_OPERATORS; 
++Op1.91M
)
278
1.91M
    CXXOperatorNames[Op].Kind = static_cast<OverloadedOperatorKind>(Op);
279
41.7k
}
280
281
DeclarationName
282
1.32k
DeclarationNameTable::getCXXDeductionGuideName(TemplateDecl *Template) {
283
1.32k
  Template = cast<TemplateDecl>(Template->getCanonicalDecl());
284
1.32k
285
1.32k
  llvm::FoldingSetNodeID ID;
286
1.32k
  ID.AddPointer(Template);
287
1.32k
288
1.32k
  void *InsertPos = nullptr;
289
1.32k
  if (auto *Name = CXXDeductionGuideNames.FindNodeOrInsertPos(ID, InsertPos))
290
1.20k
    return DeclarationName(Name);
291
120
292
120
  auto *Name = new (Ctx) detail::CXXDeductionGuideNameExtra(Template);
293
120
  CXXDeductionGuideNames.InsertNode(Name, InsertPos);
294
120
  return DeclarationName(Name);
295
120
}
296
297
2.76M
DeclarationName DeclarationNameTable::getCXXConstructorName(CanQualType Ty) {
298
2.76M
  // The type of constructors is unqualified.
299
2.76M
  Ty = Ty.getUnqualifiedType();
300
2.76M
  // Do we already have this C++ constructor name ?
301
2.76M
  llvm::FoldingSetNodeID ID;
302
2.76M
  ID.AddPointer(Ty.getAsOpaquePtr());
303
2.76M
  void *InsertPos = nullptr;
304
2.76M
  if (auto *Name = CXXConstructorNames.FindNodeOrInsertPos(ID, InsertPos))
305
2.46M
    return {Name, DeclarationName::StoredCXXConstructorName};
306
298k
307
298k
  // We have to create it.
308
298k
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
309
298k
  CXXConstructorNames.InsertNode(SpecialName, InsertPos);
310
298k
  return {SpecialName, DeclarationName::StoredCXXConstructorName};
311
298k
}
312
313
4.51M
DeclarationName DeclarationNameTable::getCXXDestructorName(CanQualType Ty) {
314
4.51M
  // The type of destructors is unqualified.
315
4.51M
  Ty = Ty.getUnqualifiedType();
316
4.51M
  // Do we already have this C++ destructor name ?
317
4.51M
  llvm::FoldingSetNodeID ID;
318
4.51M
  ID.AddPointer(Ty.getAsOpaquePtr());
319
4.51M
  void *InsertPos = nullptr;
320
4.51M
  if (auto *Name = CXXDestructorNames.FindNodeOrInsertPos(ID, InsertPos))
321
2.54M
    return {Name, DeclarationName::StoredCXXDestructorName};
322
1.97M
323
1.97M
  // We have to create it.
324
1.97M
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
325
1.97M
  CXXDestructorNames.InsertNode(SpecialName, InsertPos);
326
1.97M
  return {SpecialName, DeclarationName::StoredCXXDestructorName};
327
1.97M
}
328
329
DeclarationName
330
63.0k
DeclarationNameTable::getCXXConversionFunctionName(CanQualType Ty) {
331
63.0k
  // Do we already have this C++ conversion function name ?
332
63.0k
  llvm::FoldingSetNodeID ID;
333
63.0k
  ID.AddPointer(Ty.getAsOpaquePtr());
334
63.0k
  void *InsertPos = nullptr;
335
63.0k
  if (auto *Name =
336
49.6k
          CXXConversionFunctionNames.FindNodeOrInsertPos(ID, InsertPos))
337
49.6k
    return {Name, DeclarationName::StoredCXXConversionFunctionName};
338
13.3k
339
13.3k
  // We have to create it.
340
13.3k
  auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
341
13.3k
  CXXConversionFunctionNames.InsertNode(SpecialName, InsertPos);
342
13.3k
  return {SpecialName, DeclarationName::StoredCXXConversionFunctionName};
343
13.3k
}
344
345
DeclarationName
346
DeclarationNameTable::getCXXSpecialName(DeclarationName::NameKind Kind,
347
323k
                                        CanQualType Ty) {
348
323k
  switch (Kind) {
349
323k
  case DeclarationName::CXXConstructorName:
350
280k
    return getCXXConstructorName(Ty);
351
323k
  case DeclarationName::CXXDestructorName:
352
30.0k
    return getCXXDestructorName(Ty);
353
323k
  case DeclarationName::CXXConversionFunctionName:
354
12.3k
    return getCXXConversionFunctionName(Ty);
355
323k
  default:
356
0
    llvm_unreachable("Invalid kind in getCXXSpecialName!");
357
323k
  }
358
323k
}
359
360
DeclarationName
361
7.33k
DeclarationNameTable::getCXXLiteralOperatorName(IdentifierInfo *II) {
362
7.33k
  llvm::FoldingSetNodeID ID;
363
7.33k
  ID.AddPointer(II);
364
7.33k
365
7.33k
  void *InsertPos = nullptr;
366
7.33k
  if (auto *Name = CXXLiteralOperatorNames.FindNodeOrInsertPos(ID, InsertPos))
367
6.43k
    return DeclarationName(Name);
368
901
369
901
  auto *LiteralName = new (Ctx) detail::CXXLiteralOperatorIdName(II);
370
901
  CXXLiteralOperatorNames.InsertNode(LiteralName, InsertPos);
371
901
  return DeclarationName(LiteralName);
372
901
}
373
374
70.2M
DeclarationNameLoc::DeclarationNameLoc(DeclarationName Name) {
375
70.2M
  switch (Name.getNameKind()) {
376
70.2M
  case DeclarationName::Identifier:
377
64.1M
  case DeclarationName::CXXDeductionGuideName:
378
64.1M
    break;
379
64.1M
  case DeclarationName::CXXConstructorName:
380
1.00M
  case DeclarationName::CXXDestructorName:
381
1.00M
  case DeclarationName::CXXConversionFunctionName:
382
1.00M
    NamedType.TInfo = nullptr;
383
1.00M
    break;
384
5.18M
  case DeclarationName::CXXOperatorName:
385
5.18M
    CXXOperatorName.BeginOpNameLoc = SourceLocation().getRawEncoding();
386
5.18M
    CXXOperatorName.EndOpNameLoc = SourceLocation().getRawEncoding();
387
5.18M
    break;
388
1.00M
  case DeclarationName::CXXLiteralOperatorName:
389
499
    CXXLiteralOperatorName.OpNameLoc = SourceLocation().getRawEncoding();
390
499
    break;
391
1.00M
  case DeclarationName::ObjCZeroArgSelector:
392
0
  case DeclarationName::ObjCOneArgSelector:
393
0
  case DeclarationName::ObjCMultiArgSelector:
394
0
    // FIXME: ?
395
0
    break;
396
0
  case DeclarationName::CXXUsingDirective:
397
0
    break;
398
70.2M
  }
399
70.2M
}
400
401
5.39M
bool DeclarationNameInfo::containsUnexpandedParameterPack() const {
402
5.39M
  switch (Name.getNameKind()) {
403
5.39M
  case DeclarationName::Identifier:
404
5.39M
  case DeclarationName::ObjCZeroArgSelector:
405
5.39M
  case DeclarationName::ObjCOneArgSelector:
406
5.39M
  case DeclarationName::ObjCMultiArgSelector:
407
5.39M
  case DeclarationName::CXXOperatorName:
408
5.39M
  case DeclarationName::CXXLiteralOperatorName:
409
5.39M
  case DeclarationName::CXXUsingDirective:
410
5.39M
  case DeclarationName::CXXDeductionGuideName:
411
5.39M
    return false;
412
5.39M
413
5.39M
  case DeclarationName::CXXConstructorName:
414
41
  case DeclarationName::CXXDestructorName:
415
41
  case DeclarationName::CXXConversionFunctionName:
416
41
    if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo)
417
27
      return TInfo->getType()->containsUnexpandedParameterPack();
418
14
419
14
    return Name.getCXXNameType()->containsUnexpandedParameterPack();
420
0
  }
421
0
  llvm_unreachable("All name kinds handled.");
422
0
}
423
424
3.65M
bool DeclarationNameInfo::isInstantiationDependent() const {
425
3.65M
  switch (Name.getNameKind()) {
426
3.65M
  case DeclarationName::Identifier:
427
3.65M
  case DeclarationName::ObjCZeroArgSelector:
428
3.65M
  case DeclarationName::ObjCOneArgSelector:
429
3.65M
  case DeclarationName::ObjCMultiArgSelector:
430
3.65M
  case DeclarationName::CXXOperatorName:
431
3.65M
  case DeclarationName::CXXLiteralOperatorName:
432
3.65M
  case DeclarationName::CXXUsingDirective:
433
3.65M
  case DeclarationName::CXXDeductionGuideName:
434
3.65M
    return false;
435
3.65M
436
3.65M
  case DeclarationName::CXXConstructorName:
437
26
  case DeclarationName::CXXDestructorName:
438
26
  case DeclarationName::CXXConversionFunctionName:
439
26
    if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo)
440
13
      return TInfo->getType()->isInstantiationDependentType();
441
13
442
13
    return Name.getCXXNameType()->isInstantiationDependentType();
443
0
  }
444
0
  llvm_unreachable("All name kinds handled.");
445
0
}
446
447
9.08k
std::string DeclarationNameInfo::getAsString() const {
448
9.08k
  std::string Result;
449
9.08k
  llvm::raw_string_ostream OS(Result);
450
9.08k
  printName(OS);
451
9.08k
  return OS.str();
452
9.08k
}
453
454
41.4k
void DeclarationNameInfo::printName(raw_ostream &OS) const {
455
41.4k
  switch (Name.getNameKind()) {
456
41.4k
  case DeclarationName::Identifier:
457
39.7k
  case DeclarationName::ObjCZeroArgSelector:
458
39.7k
  case DeclarationName::ObjCOneArgSelector:
459
39.7k
  case DeclarationName::ObjCMultiArgSelector:
460
39.7k
  case DeclarationName::CXXOperatorName:
461
39.7k
  case DeclarationName::CXXLiteralOperatorName:
462
39.7k
  case DeclarationName::CXXUsingDirective:
463
39.7k
  case DeclarationName::CXXDeductionGuideName:
464
39.7k
    OS << Name;
465
39.7k
    return;
466
39.7k
467
39.7k
  case DeclarationName::CXXConstructorName:
468
1.66k
  case DeclarationName::CXXDestructorName:
469
1.66k
  case DeclarationName::CXXConversionFunctionName:
470
1.66k
    if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo) {
471
195
      if (Name.getNameKind() == DeclarationName::CXXDestructorName)
472
70
        OS << '~';
473
125
      else if (Name.getNameKind() == DeclarationName::CXXConversionFunctionName)
474
125
        OS << "operator ";
475
195
      LangOptions LO;
476
195
      LO.CPlusPlus = true;
477
195
      LO.Bool = true;
478
195
      PrintingPolicy PP(LO);
479
195
      PP.SuppressScope = true;
480
195
      OS << TInfo->getType().getAsString(PP);
481
195
    } else
482
1.47k
      OS << Name;
483
1.66k
    return;
484
0
  }
485
0
  llvm_unreachable("Unexpected declaration name kind");
486
0
}
487
488
19.4M
SourceLocation DeclarationNameInfo::getEndLocPrivate() const {
489
19.4M
  switch (Name.getNameKind()) {
490
19.4M
  case DeclarationName::Identifier:
491
17.3M
  case DeclarationName::CXXDeductionGuideName:
492
17.3M
    return NameLoc;
493
17.3M
494
17.3M
  case DeclarationName::CXXOperatorName: {
495
799k
    unsigned raw = LocInfo.CXXOperatorName.EndOpNameLoc;
496
799k
    return SourceLocation::getFromRawEncoding(raw);
497
17.3M
  }
498
17.3M
499
17.3M
  case DeclarationName::CXXLiteralOperatorName: {
500
2.56k
    unsigned raw = LocInfo.CXXLiteralOperatorName.OpNameLoc;
501
2.56k
    return SourceLocation::getFromRawEncoding(raw);
502
17.3M
  }
503
17.3M
504
17.3M
  case DeclarationName::CXXConstructorName:
505
1.24M
  case DeclarationName::CXXDestructorName:
506
1.24M
  case DeclarationName::CXXConversionFunctionName:
507
1.24M
    if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo)
508
120k
      return TInfo->getTypeLoc().getEndLoc();
509
1.12M
    else
510
1.12M
      return NameLoc;
511
0
512
0
    // DNInfo work in progress: FIXME.
513
0
  case DeclarationName::ObjCZeroArgSelector:
514
0
  case DeclarationName::ObjCOneArgSelector:
515
0
  case DeclarationName::ObjCMultiArgSelector:
516
0
  case DeclarationName::CXXUsingDirective:
517
0
    return NameLoc;
518
0
  }
519
0
  llvm_unreachable("Unexpected declaration name kind");
520
0
}