clang 10.0.0git

DeclarationName.cpp
Go to the documentation of this file.
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 static int compareInt(unsigned A, unsigned B) {
42 return (A < B ? -1 : (A > B ? 1 : 0));
43 }
44
45 int DeclarationName::compare(DeclarationName LHS, DeclarationName RHS) {
46 if (LHS.getNameKind() != RHS.getNameKind())
47 return (LHS.getNameKind() < RHS.getNameKind() ? -1 : 1);
48
49 switch (LHS.getNameKind()) {
50 case DeclarationName::Identifier: {
51 IdentifierInfo *LII = LHS.castAsIdentifierInfo();
52 IdentifierInfo *RII = RHS.castAsIdentifierInfo();
53 if (!LII)
54 return RII ? -1 : 0;
55 if (!RII)
56 return 1;
57
58 return LII->getName().compare(RII->getName());
59 }
60
61 case DeclarationName::ObjCZeroArgSelector:
62 case DeclarationName::ObjCOneArgSelector:
63 case DeclarationName::ObjCMultiArgSelector: {
64 Selector LHSSelector = LHS.getObjCSelector();
65 Selector RHSSelector = RHS.getObjCSelector();
66 // getNumArgs for ZeroArgSelector returns 0, but we still need to compare.
67 if (LHS.getNameKind() == DeclarationName::ObjCZeroArgSelector &&
68 RHS.getNameKind() == DeclarationName::ObjCZeroArgSelector) {
69 return LHSSelector.getAsIdentifierInfo()->getName().compare(
70 RHSSelector.getAsIdentifierInfo()->getName());
71 }
72 unsigned LN = LHSSelector.getNumArgs(), RN = RHSSelector.getNumArgs();
73 for (unsigned I = 0, N = std::min(LN, RN); I != N; ++I) {
74 switch (LHSSelector.getNameForSlot(I).compare(
75 RHSSelector.getNameForSlot(I))) {
76 case -1:
77 return -1;
78 case 1:
79 return 1;
80 default:
81 break;
82 }
83 }
84
85 return compareInt(LN, RN);
86 }
87
88 case DeclarationName::CXXConstructorName:
89 case DeclarationName::CXXDestructorName:
90 case DeclarationName::CXXConversionFunctionName:
91 if (QualTypeOrdering()(LHS.getCXXNameType(), RHS.getCXXNameType()))
92 return -1;
93 if (QualTypeOrdering()(RHS.getCXXNameType(), LHS.getCXXNameType()))
94 return 1;
95 return 0;
96
97 case DeclarationName::CXXDeductionGuideName:
98 // We never want to compare deduction guide names for templates from
99 // different scopes, so just compare the template-name.
100 return compare(LHS.getCXXDeductionGuideTemplate()->getDeclName(),
101 RHS.getCXXDeductionGuideTemplate()->getDeclName());
102
103 case DeclarationName::CXXOperatorName:
104 return compareInt(LHS.getCXXOverloadedOperator(),
105 RHS.getCXXOverloadedOperator());
106
107 case DeclarationName::CXXLiteralOperatorName:
108 return LHS.getCXXLiteralIdentifier()->getName().compare(
109 RHS.getCXXLiteralIdentifier()->getName());
110
111 case DeclarationName::CXXUsingDirective:
112 return 0;
113 }
114
115 llvm_unreachable("Invalid DeclarationName Kind!");
116 }
117
118 static void printCXXConstructorDestructorName(QualType ClassType,
119 raw_ostream &OS,
120 PrintingPolicy Policy) {
121 // We know we're printing C++ here. Ensure we print types properly.
122 Policy.adjustForCPlusPlus();
123
124 if (const RecordType *ClassRec = ClassType->getAs<RecordType>()) {
125 OS << *ClassRec->getDecl();
126 return;
127 }
128 if (Policy.SuppressTemplateArgsInCXXConstructors) {
129 if (auto *InjTy = ClassType->getAs<InjectedClassNameType>()) {
130 OS << *InjTy->getDecl();
131 return;
132 }
133 }
134 ClassType.print(OS, Policy);
135 }
136
137 void DeclarationName::print(raw_ostream &OS,
138 const PrintingPolicy &Policy) const {
139 switch (getNameKind()) {
140 case DeclarationName::Identifier:
141 if (const IdentifierInfo *II = getAsIdentifierInfo())
142 OS << II->getName();
143 return;
144
145 case DeclarationName::ObjCZeroArgSelector:
146 case DeclarationName::ObjCOneArgSelector:
147 case DeclarationName::ObjCMultiArgSelector:
148 getObjCSelector().print(OS);
149 return;
150
151 case DeclarationName::CXXConstructorName:
152 return printCXXConstructorDestructorName(getCXXNameType(), OS, Policy);
153
154 case DeclarationName::CXXDestructorName:
155 OS << '~';
156 return printCXXConstructorDestructorName(getCXXNameType(), OS, Policy);
157
158 case DeclarationName::CXXDeductionGuideName:
159 OS << "<deduction guide for ";
160 getCXXDeductionGuideTemplate()->getDeclName().print(OS, Policy);
161 OS << '>';
162 return;
163
164 case DeclarationName::CXXOperatorName: {
165 const char *OpName = getOperatorSpelling(getCXXOverloadedOperator());
166 assert(OpName && "not an overloaded operator");
167
168 OS << "operator";
169 if (OpName[0] >= 'a' && OpName[0] <= 'z')
170 OS << ' ';
171 OS << OpName;
172 return;
173 }
174
175 case DeclarationName::CXXLiteralOperatorName:
176 OS << "operator\"\"" << getCXXLiteralIdentifier()->getName();
177 return;
178
179 case DeclarationName::CXXConversionFunctionName: {
180 OS << "operator ";
181 QualType Type = getCXXNameType();
182 if (const RecordType *Rec = Type->getAs<RecordType>()) {
183 OS << *Rec->getDecl();
184 return;
185 }
186 // We know we're printing C++ here, ensure we print 'bool' properly.
187 PrintingPolicy CXXPolicy = Policy;
188 CXXPolicy.adjustForCPlusPlus();
189 Type.print(OS, CXXPolicy);
190 return;
191 }
192 case DeclarationName::CXXUsingDirective:
193 OS << "<using-directive>";
194 return;
195 }
196
197 llvm_unreachable("Unexpected declaration name kind");
198 }
199
200 namespace clang {
201
202 raw_ostream &operator<<(raw_ostream &OS, DeclarationName N) {
203 LangOptions LO;
204 N.print(OS, PrintingPolicy(LO));
205 return OS;
206 }
207
208 } // namespace clang
209
210 bool DeclarationName::isDependentName() const {
211 QualType T = getCXXNameType();
212 if (!T.isNull() && T->isDependentType())
213 return true;
214
215 // A class-scope deduction guide in a dependent context has a dependent name.
216 auto *TD = getCXXDeductionGuideTemplate();
217 if (TD && TD->getDeclContext()->isDependentContext())
218 return true;
219
220 return false;
221 }
222
223 std::string DeclarationName::getAsString() const {
224 std::string Result;
225 llvm::raw_string_ostream OS(Result);
226 OS << *this;
227 return OS.str();
228 }
229
230 void *DeclarationName::getFETokenInfoSlow() const {
231 switch (getNameKind()) {
232 case Identifier:
233 llvm_unreachable("case Identifier already handled by getFETokenInfo!");
234 case CXXConstructorName:
235 case CXXDestructorName:
236 case CXXConversionFunctionName:
237 return castAsCXXSpecialNameExtra()->FETokenInfo;
238 case CXXOperatorName:
239 return castAsCXXOperatorIdName()->FETokenInfo;
240 case CXXDeductionGuideName:
241 return castAsCXXDeductionGuideNameExtra()->FETokenInfo;
242 case CXXLiteralOperatorName:
243 return castAsCXXLiteralOperatorIdName()->FETokenInfo;
244 default:
245 llvm_unreachable("DeclarationName has no FETokenInfo!");
246 }
247 }
248
249 void DeclarationName::setFETokenInfoSlow(void *T) {
250 switch (getNameKind()) {
251 case Identifier:
252 llvm_unreachable("case Identifier already handled by setFETokenInfo!");
253 case CXXConstructorName:
254 case CXXDestructorName:
255 case CXXConversionFunctionName:
256 castAsCXXSpecialNameExtra()->FETokenInfo = T;
257 break;
258 case CXXOperatorName:
259 castAsCXXOperatorIdName()->FETokenInfo = T;
260 break;
261 case CXXDeductionGuideName:
262 castAsCXXDeductionGuideNameExtra()->FETokenInfo = T;
263 break;
264 case CXXLiteralOperatorName:
265 castAsCXXLiteralOperatorIdName()->FETokenInfo = T;
266 break;
267 default:
268 llvm_unreachable("DeclarationName has no FETokenInfo!");
269 }
270 }
271
272 LLVM_DUMP_METHOD void DeclarationName::dump() const {
273 llvm::errs() << *this << '\n';
274 }
275
276 DeclarationNameTable::DeclarationNameTable(const ASTContext &C) : Ctx(C) {
277 // Initialize the overloaded operator names.
278 for (unsigned Op = 0; Op < NUM_OVERLOADED_OPERATORS; ++Op)
279 CXXOperatorNames[Op].Kind = static_cast<OverloadedOperatorKind>(Op);
280 }
281
282 DeclarationName
283 DeclarationNameTable::getCXXDeductionGuideName(TemplateDecl *Template) {
284 Template = cast<TemplateDecl>(Template->getCanonicalDecl());
285
286 llvm::FoldingSetNodeID ID;
287 ID.AddPointer(Template);
288
289 void *InsertPos = nullptr;
290 if (auto *Name = CXXDeductionGuideNames.FindNodeOrInsertPos(ID, InsertPos))
291 return DeclarationName(Name);
292
293 auto *Name = new (Ctx) detail::CXXDeductionGuideNameExtra(Template);
294 CXXDeductionGuideNames.InsertNode(Name, InsertPos);
295 return DeclarationName(Name);
296 }
297
298 DeclarationName DeclarationNameTable::getCXXConstructorName(CanQualType Ty) {
299 // The type of constructors is unqualified.
300 Ty = Ty.getUnqualifiedType();
301 // Do we already have this C++ constructor name ?
302 llvm::FoldingSetNodeID ID;
303 ID.AddPointer(Ty.getAsOpaquePtr());
304 void *InsertPos = nullptr;
305 if (auto *Name = CXXConstructorNames.FindNodeOrInsertPos(ID, InsertPos))
306 return {Name, DeclarationName::StoredCXXConstructorName};
307
308 // We have to create it.
309 auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
310 CXXConstructorNames.InsertNode(SpecialName, InsertPos);
311 return {SpecialName, DeclarationName::StoredCXXConstructorName};
312 }
313
314 DeclarationName DeclarationNameTable::getCXXDestructorName(CanQualType Ty) {
315 // The type of destructors is unqualified.
316 Ty = Ty.getUnqualifiedType();
317 // Do we already have this C++ destructor name ?
318 llvm::FoldingSetNodeID ID;
319 ID.AddPointer(Ty.getAsOpaquePtr());
320 void *InsertPos = nullptr;
321 if (auto *Name = CXXDestructorNames.FindNodeOrInsertPos(ID, InsertPos))
322 return {Name, DeclarationName::StoredCXXDestructorName};
323
324 // We have to create it.
325 auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
326 CXXDestructorNames.InsertNode(SpecialName, InsertPos);
327 return {SpecialName, DeclarationName::StoredCXXDestructorName};
328 }
329
330 DeclarationName
331 DeclarationNameTable::getCXXConversionFunctionName(CanQualType Ty) {
332 // Do we already have this C++ conversion function name ?
333 llvm::FoldingSetNodeID ID;
334 ID.AddPointer(Ty.getAsOpaquePtr());
335 void *InsertPos = nullptr;
336 if (auto *Name =
337 CXXConversionFunctionNames.FindNodeOrInsertPos(ID, InsertPos))
338 return {Name, DeclarationName::StoredCXXConversionFunctionName};
339
340 // We have to create it.
341 auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
342 CXXConversionFunctionNames.InsertNode(SpecialName, InsertPos);
343 return {SpecialName, DeclarationName::StoredCXXConversionFunctionName};
344 }
345
346 DeclarationName
347 DeclarationNameTable::getCXXSpecialName(DeclarationName::NameKind Kind,
348 CanQualType Ty) {
349 switch (Kind) {
350 case DeclarationName::CXXConstructorName:
351 return getCXXConstructorName(Ty);
352 case DeclarationName::CXXDestructorName:
353 return getCXXDestructorName(Ty);
354 case DeclarationName::CXXConversionFunctionName:
355 return getCXXConversionFunctionName(Ty);
356 default:
357 llvm_unreachable("Invalid kind in getCXXSpecialName!");
358 }
359 }
360
361 DeclarationName
362 DeclarationNameTable::getCXXLiteralOperatorName(IdentifierInfo *II) {
363 llvm::FoldingSetNodeID ID;
364 ID.AddPointer(II);
365
366 void *InsertPos = nullptr;
367 if (auto *Name = CXXLiteralOperatorNames.FindNodeOrInsertPos(ID, InsertPos))
368 return DeclarationName(Name);
369
370 auto *LiteralName = new (Ctx) detail::CXXLiteralOperatorIdName(II);
371 CXXLiteralOperatorNames.InsertNode(LiteralName, InsertPos);
372 return DeclarationName(LiteralName);
373 }
374
375 DeclarationNameLoc::DeclarationNameLoc(DeclarationName Name) {
376 switch (Name.getNameKind()) {
377 case DeclarationName::Identifier:
378 case DeclarationName::CXXDeductionGuideName:
379 break;
380 case DeclarationName::CXXConstructorName:
381 case DeclarationName::CXXDestructorName:
382 case DeclarationName::CXXConversionFunctionName:
383 NamedType.TInfo = nullptr;
384 break;
385 case DeclarationName::CXXOperatorName:
386 CXXOperatorName.BeginOpNameLoc = SourceLocation().getRawEncoding();
387 CXXOperatorName.EndOpNameLoc = SourceLocation().getRawEncoding();
388 break;
389 case DeclarationName::CXXLiteralOperatorName:
390 CXXLiteralOperatorName.OpNameLoc = SourceLocation().getRawEncoding();
391 break;
392 case DeclarationName::ObjCZeroArgSelector:
393 case DeclarationName::ObjCOneArgSelector:
394 case DeclarationName::ObjCMultiArgSelector:
395 // FIXME: ?
396 break;
397 case DeclarationName::CXXUsingDirective:
398 break;
399 }
400 }
401
402 bool DeclarationNameInfo::containsUnexpandedParameterPack() const {
403 switch (Name.getNameKind()) {
404 case DeclarationName::Identifier:
405 case DeclarationName::ObjCZeroArgSelector:
406 case DeclarationName::ObjCOneArgSelector:
407 case DeclarationName::ObjCMultiArgSelector:
408 case DeclarationName::CXXOperatorName:
409 case DeclarationName::CXXLiteralOperatorName:
410 case DeclarationName::CXXUsingDirective:
411 case DeclarationName::CXXDeductionGuideName:
412 return false;
413
414 case DeclarationName::CXXConstructorName:
415 case DeclarationName::CXXDestructorName:
416 case DeclarationName::CXXConversionFunctionName:
417 if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo)
418 return TInfo->getType()->containsUnexpandedParameterPack();
419
420 return Name.getCXXNameType()->containsUnexpandedParameterPack();
421 }
422 llvm_unreachable("All name kinds handled.");
423 }
424
425 bool DeclarationNameInfo::isInstantiationDependent() const {
426 switch (Name.getNameKind()) {
427 case DeclarationName::Identifier:
428 case DeclarationName::ObjCZeroArgSelector:
429 case DeclarationName::ObjCOneArgSelector:
430 case DeclarationName::ObjCMultiArgSelector:
431 case DeclarationName::CXXOperatorName:
432 case DeclarationName::CXXLiteralOperatorName:
433 case DeclarationName::CXXUsingDirective:
434 case DeclarationName::CXXDeductionGuideName:
435 return false;
436
437 case DeclarationName::CXXConstructorName:
438 case DeclarationName::CXXDestructorName:
439 case DeclarationName::CXXConversionFunctionName:
440 if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo)
441 return TInfo->getType()->isInstantiationDependentType();
442
443 return Name.getCXXNameType()->isInstantiationDependentType();
444 }
445 llvm_unreachable("All name kinds handled.");
446 }
447
448 std::string DeclarationNameInfo::getAsString() const {
449 std::string Result;
450 llvm::raw_string_ostream OS(Result);
451 OS << *this;
452 return OS.str();
453 }
454
455 raw_ostream &clang::operator<<(raw_ostream &OS, DeclarationNameInfo DNInfo) {
456 LangOptions LO;
457 DNInfo.printName(OS, PrintingPolicy(LangOptions()));
458 return OS;
459 }
460
461 void DeclarationNameInfo::printName(raw_ostream &OS, PrintingPolicy Policy) const {
462 switch (Name.getNameKind()) {
463 case DeclarationName::Identifier:
464 case DeclarationName::ObjCZeroArgSelector:
465 case DeclarationName::ObjCOneArgSelector:
466 case DeclarationName::ObjCMultiArgSelector:
467 case DeclarationName::CXXOperatorName:
468 case DeclarationName::CXXLiteralOperatorName:
469 case DeclarationName::CXXUsingDirective:
470 case DeclarationName::CXXDeductionGuideName:
471 Name.print(OS, Policy);
472 return;
473
474 case DeclarationName::CXXConstructorName:
475 case DeclarationName::CXXDestructorName:
476 case DeclarationName::CXXConversionFunctionName:
477 if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo) {
478 if (Name.getNameKind() == DeclarationName::CXXDestructorName)
479 OS << '~';
480 else if (Name.getNameKind() == DeclarationName::CXXConversionFunctionName)
481 OS << "operator ";
482 LangOptions LO;
483 Policy.adjustForCPlusPlus();
484 Policy.SuppressScope = true;
485 OS << TInfo->getType().getAsString(Policy);
486 } else
487 Name.print(OS, Policy);
488 return;
489 }
490 llvm_unreachable("Unexpected declaration name kind");
491 }
492
493 SourceLocation DeclarationNameInfo::getEndLocPrivate() const {
494 switch (Name.getNameKind()) {
495 case DeclarationName::Identifier:
496 case DeclarationName::CXXDeductionGuideName:
497 return NameLoc;
498
499 case DeclarationName::CXXOperatorName: {
500 unsigned raw = LocInfo.CXXOperatorName.EndOpNameLoc;
501 return SourceLocation::getFromRawEncoding(raw);
502 }
503
504 case DeclarationName::CXXLiteralOperatorName: {
505 unsigned raw = LocInfo.CXXLiteralOperatorName.OpNameLoc;
506 return SourceLocation::getFromRawEncoding(raw);
507 }
508
509 case DeclarationName::CXXConstructorName:
510 case DeclarationName::CXXDestructorName:
511 case DeclarationName::CXXConversionFunctionName:
512 if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo)
513 return TInfo->getTypeLoc().getEndLoc();
514 else
515 return NameLoc;
516
517 // DNInfo work in progress: FIXME.
518 case DeclarationName::ObjCZeroArgSelector:
519 case DeclarationName::ObjCOneArgSelector:
520 case DeclarationName::ObjCMultiArgSelector:
521 case DeclarationName::CXXUsingDirective:
522 return NameLoc;
523 }
524 llvm_unreachable("Unexpected declaration name kind");
525 }
clang::Builtin::ID
ID
Definition: Builtins.h:46
ASTContext.h
Defines the clang::ASTContext interface.
clang::Selector
Smart pointer class that efficiently represents Objective-C method names.
Definition: IdentifierTable.h:685
clang::SourceLocation::getRawEncoding
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
Definition: SourceLocation.h:144
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:654
clang::DeclarationName::NameKind
NameKind
The kind of the name stored in this DeclarationName.
Definition: DeclarationName.h:202
clang::DeclarationName::print
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Definition: DeclarationName.cpp:137
clang::DeclarationNameTable::getCXXConstructorName
DeclarationName getCXXConstructorName(CanQualType Ty)
Returns the name of a C++ constructor for the given Type.
Definition: DeclarationName.cpp:298
Type.h
C Language Family Type Representation.
clang::DeclarationNameTable::getCXXConversionFunctionName
DeclarationName getCXXConversionFunctionName(CanQualType Ty)
Returns the name of a C++ conversion function for the given Type.
Definition: DeclarationName.cpp:331
clang::DeclarationName::getObjCSelector
Selector getObjCSelector() const
Get the Objective-C selector stored in this declaration name.
Definition: DeclarationName.h:481
DeclTemplate.h
Defines the C++ template declaration subclasses.
clang::DeclarationName::getCXXOverloadedOperator
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
Definition: DeclarationName.h:462
clang::operator<<
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
Definition: Attr.h:346
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1450
clang::CanQual::getUnqualifiedType
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
Definition: CanonicalType.h:618
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6227
clang::DeclarationNameInfo::isInstantiationDependent
bool isInstantiationDependent() const
Determine whether this name involves a template parameter.
Definition: DeclarationName.cpp:425
clang::DeclarationNameTable::getCXXDeductionGuideName
DeclarationName getCXXDeductionGuideName(TemplateDecl *TD)
Returns the name of a C++ deduction guide for the given template.
Definition: DeclarationName.cpp:283
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>&#39;.
Definition: Type.h:7002
PrettyPrinter.h
clang::DeclarationName::CXXUsingDirective
Definition: DeclarationName.h:215
clang::PrintingPolicy
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:47
clang::DeclarationName::ObjCOneArgSelector
Definition: DeclarationName.h:205
clang::DeclarationName::CXXDeductionGuideName
Definition: DeclarationName.h:210
clang::NamedDecl::getDeclName
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:272
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:57
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:168
clang::SourceLocation::getFromRawEncoding
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
Definition: SourceLocation.h:150
clang::DeclarationName::getNameKind
NameKind getNameKind() const
Determine what kind of name this is.
Definition: DeclarationName.h:384
clang::DeclarationNameLoc::DeclarationNameLoc
DeclarationNameLoc()
Definition: DeclarationName.h:685
clang::DeclarationNameTable::getCXXDestructorName
DeclarationName getCXXDestructorName(CanQualType Ty)
Returns the name of a C++ destructor for the given Type.
Definition: DeclarationName.cpp:314
clang::DeclarationName::ObjCZeroArgSelector
Definition: DeclarationName.h:204
compareInt
static int compareInt(unsigned A, unsigned B)
Definition: DeclarationName.cpp:41
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:53
clang::DeclarationName::CXXLiteralOperatorName
Definition: DeclarationName.h:212
clang::DeclarationName::isDependentName
bool isDependentName() const
Determines whether the name itself is dependent, e.g., because it involves a C++ type that is itself ...
Definition: DeclarationName.cpp:210
LLVM.h
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
clang::QualType::print
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Definition: TypePrinter.cpp:1894
clang::DeclarationNameInfo::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Determine whether this name contains an unexpanded parameter pack.
Definition: DeclarationName.cpp:402
clang::Decl::getCanonicalDecl
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:877
clang::PrintingPolicy::SuppressTemplateArgsInCXXConstructors
unsigned SuppressTemplateArgsInCXXConstructors
When true, suppresses printing template arguments in names of C++ constructors.
Definition: PrettyPrinter.h:165
clang::QualTypeOrdering
Function object that provides a total ordering on QualType values.
Definition: TypeOrdering.h:28
TypeOrdering.h
Allows QualTypes to be sorted and hence used in maps and sets.
clang::DeclarationName::getCXXNameType
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function)...
Definition: DeclarationName.h:439
LangOptions.h
Defines the clang::LangOptions interface.
clang::detail::CXXDeductionGuideNameExtra
Contains extra information for the name of a C++ deduction guide.
Definition: DeclarationName.h:75
printCXXConstructorDestructorName
static void printCXXConstructorDestructorName(QualType ClassType, raw_ostream &OS, PrintingPolicy Policy)
Definition: DeclarationName.cpp:118
clang::DeclarationName::getAsString
std::string getAsString() const
Retrieve the human-readable string for this name.
Definition: DeclarationName.cpp:223
DeclBase.h
OperatorKinds.h
Defines an enumeration for C++ overloaded operators.
clang::Selector::getNameForSlot
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
Definition: IdentifierTable.cpp:452
TypeLoc.h
Defines the clang::TypeLoc interface and its subclasses.
clang::DeclarationName::getAsIdentifierInfo
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn&#39;t...
Definition: DeclarationName.h:410
IdentifierTable.h
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
clang::Selector::print
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
Definition: IdentifierTable.cpp:492
clang::NUM_OVERLOADED_OPERATORS
Definition: OperatorKinds.h:26
clang::Selector::getNumArgs
unsigned getNumArgs() const
Definition: IdentifierTable.cpp:430
clang::ObjCSubstitutionContext::Result
The result type of a method or function.
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:719
Kind
Kind
Definition: ChrootChecker.cpp:29
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::DeclarationName::CXXConstructorName
Definition: DeclarationName.h:206
clang::DeclarationName::Identifier
Definition: DeclarationName.h:203
clang::DeclarationNameTable::DeclarationNameTable
DeclarationNameTable(const ASTContext &C)
Definition: DeclarationName.cpp:276
clang::PrintingPolicy::SuppressScope
unsigned SuppressScope
Suppresses printing of scope specifiers.
Definition: PrettyPrinter.h:115
DeclarationName.h
clang::detail::CXXSpecialNameExtra
CXXSpecialNameExtra records the type associated with one of the "special" kinds of declaration names ...
Definition: DeclarationName.h:53
clang::CanQual< Type >
clang::DeclarationNameTable::getCXXSpecialName
DeclarationName getCXXSpecialName(DeclarationName::NameKind Kind, CanQualType Ty)
Returns a declaration name for special kind of C++ name, e.g., for a constructor, destructor...
Definition: DeclarationName.cpp:347
clang::InjectedClassNameType
The injected class name of a C++ class template or class template partial specialization.
Definition: Type.h:5133
clang::IdentifierInfo::getName
StringRef getName() const
Return the actual identifier string.
Definition: IdentifierTable.h:155
Decl.h
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::DeclarationNameInfo::getAsString
std::string getAsString() const
getAsString - Retrieve the human-readable string for this name.
Definition: DeclarationName.cpp:448
clang::TemplateDecl
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:402
clang::DeclarationName::dump
void dump() const
Definition: DeclarationName.cpp:272
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:145
clang::PrintingPolicy::adjustForCPlusPlus
void adjustForCPlusPlus()
Adjust this printing policy for cases where it&#39;s known that we&#39;re printing C++ code (for instance...
Definition: PrettyPrinter.h:69
clang::DeclarationNameInfo::printName
void printName(raw_ostream &OS, PrintingPolicy Policy) const
printName - Print the human-readable name to a stream.
Definition: DeclarationName.cpp:461
clang::DeclarationName::CXXDestructorName
Definition: DeclarationName.h:207
clang::DeclarationName::CXXConversionFunctionName
Definition: DeclarationName.h:208
clang::DeclarationNameInfo
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Definition: DeclarationName.h:690
clang::DeclarationName::ObjCMultiArgSelector
Definition: DeclarationName.h:217
clang::RecordType
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4495
clang::CanQual::getAsOpaquePtr
void * getAsOpaquePtr() const
Retrieve the internal representation of this canonical type.
Definition: CanonicalType.h:182
clang::DeclarationNameTable::getCXXLiteralOperatorName
DeclarationName getCXXLiteralOperatorName(IdentifierInfo *II)
Get the name of the literal operator function with II as the identifier.
Definition: DeclarationName.cpp:362
DeclCXX.h
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
clang::DeclarationName::getCXXDeductionGuideTemplate
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
Definition: DeclarationName.h:451
SourceLocation.h
Defines the clang::SourceLocation class and associated facilities.
clang::DeclarationName::compare
static int compare(DeclarationName LHS, DeclarationName RHS)
Definition: DeclarationName.cpp:45
clang::AttrSyntax::C
clang::detail::CXXLiteralOperatorIdName
Contains the actual identifier that makes up the name of a C++ literal operator.
Definition: DeclarationName.h:116
min
__DEVICE__ int min(int __a, int __b)
Definition: __clang_cuda_device_functions.h:1639
clang::Type::isDependentType
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2150
clang::DeclarationName::getCXXLiteralIdentifier
IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it...
Definition: DeclarationName.h:472
clang::DeclarationName::CXXOperatorName
Definition: DeclarationName.h:209