clang: include/clang/AST/NestedNameSpecifier.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_CLANG_AST_NESTEDNAMESPECIFIER_H
15#define LLVM_CLANG_AST_NESTEDNAMESPECIFIER_H
16
20#include "llvm/ADT/DenseMapInfo.h"
21#include "llvm/ADT/FoldingSet.h"
22#include "llvm/ADT/PointerIntPair.h"
23#include "llvm/Support/Compiler.h"
24#include
25#include
26#include
27
29
30class ASTContext;
31class CXXRecordDecl;
32class IdentifierInfo;
33class LangOptions;
34class NamespaceAliasDecl;
35class NamespaceDecl;
36struct PrintingPolicy;
38class TypeLoc;
39
40
41
42
43
44
45
46
47
48
49
51
52 enum StoredSpecifierKind {
53 StoredIdentifier = 0,
54 StoredDecl = 1,
55 StoredTypeSpec = 2,
56 StoredTypeSpecWithTemplate = 3
57 };
58
59
60
61
62
63
64
65 llvm::PointerIntPair<NestedNameSpecifier *, 2, StoredSpecifierKind> Prefix;
66
67
68
69
70
71
72
73
74 void* Specifier = nullptr;
75
76public:
77
78
80
82
83
85
86
88
89
91
92
93
95
96
98
99
100
103
104private:
105
107
108
109
110 NestedNameSpecifier(const NestedNameSpecifier &Other) = default;
111
112
113
114 static NestedNameSpecifier *FindOrInsert(const ASTContext &Context,
115 const NestedNameSpecifier &Mockup);
116
117public:
119
120
121
122
123
124
128
129
133
134
138
139
142 bool Template, const Type *T);
143
144
145
146
147
148
149
152
153
154
156
157
158
161
162
163
164
165
166
167
168
170
171
173
174
175
177 if (Prefix.getInt() == StoredIdentifier)
179
180 return nullptr;
181 }
182
183
184
186
187
188
190
191
192
194
195
197 if (Prefix.getInt() == StoredTypeSpec ||
198 Prefix.getInt() == StoredTypeSpecWithTemplate)
200
201 return nullptr;
202 }
203
204 NestedNameSpecifierDependence getDependence() const;
205
206
207
209
210
211
213
214
215
217
218
220
221
222
223
224
226 bool ResolveTemplateArguments = false) const;
227
228 void Profile(llvm::FoldingSetNodeID &ID) const {
229 ID.AddPointer(Prefix.getOpaqueValue());
231 }
232
233
234
236 void dump() const;
237 void dump(llvm::raw_ostream &OS) const;
238 void dump(llvm::raw_ostream &OS, const LangOptions &LO) const;
239};
240
241
242
245 void *Data = nullptr;
246
247
248
250
251
252
254
255public:
256
258
259
260
262 : Qualifier(Qualifier), Data(Data) {}
263
264
265
266 explicit operator bool() const { return Qualifier; }
267
268
269
271
272
273
275 return Qualifier;
276 }
277
278
280
281
282
283
284
285
286
288
289
290
291
292
293
294
296
297
298
301 }
302
303
304
307 }
308
309
310
313 }
314
315
316
319 }
320
321
322
323
324
325
326
328 if (!Qualifier)
329 return *this;
330
332 }
333
334
335
337
338
339
341
344 return X.Qualifier == Y.Qualifier && X.Data == Y.Data;
345 }
346
349 return !(X == Y);
350 }
351};
352
353
354
355
357
358
360
361
362
363
364
365
366
367 char *Buffer = nullptr;
368
369
370
371 unsigned BufferSize = 0;
372
373
374
375 unsigned BufferCapacity = 0;
376
377public:
380
383
385 if (BufferCapacity)
386 free(Buffer);
387 }
388
389
391
392
393
394
395
396
397
398
399
400
401
402
405
406
407
408
409
410
411
412
413
414
415
416
419
420
421
422
423
424
425
426
427
428
429
430
433
434
435
436
437
438
439
440
441
442
443
444
445
448
449
450
452
453
454
455
456
457
458
459
460
461
462
463
464
465
468
469
470
471
472
473
474
477
478
479
481
482
485 }
486
487
488
489
490
491
493
494
495
496
497
498
501 }
502
503
504
506 Representation = nullptr;
507 BufferSize = 0;
508 }
509
510
511
512
513
514
515 std::pair<char *, unsigned> getBuffer() const {
516 return std::make_pair(Buffer, BufferSize);
517 }
518};
519
520
521
524 DB.AddTaggedVal(reinterpret_cast<uint64_t>(NNS),
526 return DB;
527}
528
529}
530
531namespace llvm {
532
533template <> struct DenseMapInfo<clang::NestedNameSpecifierLoc> {
534 using FirstInfo = DenseMapInfo<clang::NestedNameSpecifier *>;
536
539 SecondInfo::getEmptyKey());
540 }
541
544 SecondInfo::getTombstoneKey());
545 }
546
548 return hash_combine(
550 SecondInfo::getHashValue(PairVal.getOpaqueData()));
551 }
552
555 return LHS == RHS;
556 }
557};
558}
559
560#endif
Defines the Diagnostic-related interfaces.
Defines the clang::SourceLocation class and associated facilities.
const NestedNameSpecifier * Specifier
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Represents a C++ struct/union/class.
@ ak_nestednamespec
NestedNameSpecifier *.
One of these records is kept for each identifier that is lexed.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Represents a C++ namespace alias.
Represent a C++ namespace.
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
NestedNameSpecifierLocBuilder & operator=(const NestedNameSpecifierLocBuilder &Other)
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
NestedNameSpecifierLocBuilder()=default
void Clear()
Clear out this builder, and prepare it to build another nested-name-specifier with source-location in...
NestedNameSpecifierLoc getTemporary() const
Retrieve a nested-name-specifier with location information based on the information in this builder.
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
std::pair< char *, unsigned > getBuffer() const
Retrieve the underlying buffer.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covered by this nested-name-specifier.
NestedNameSpecifier * getRepresentation() const
Retrieve the representation of the nested-name-specifier.
~NestedNameSpecifierLocBuilder()
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifierLoc(NestedNameSpecifier *Qualifier, void *Data)
Construct a nested-name-specifier with source location information from.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
SourceLocation getLocalEndLoc() const
Retrieve the location of the end of this component of the nested-name-specifier.
friend bool operator==(NestedNameSpecifierLoc X, NestedNameSpecifierLoc Y)
NestedNameSpecifierLoc()=default
Construct an empty nested-name-specifier.
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
SourceRange getLocalSourceRange() const
Retrieve the source range covering just the last part of this nested-name-specifier,...
friend bool operator!=(NestedNameSpecifierLoc X, NestedNameSpecifierLoc Y)
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
bool hasQualifier() const
Evaluates true when this nested-name-specifier location is non-empty.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
unsigned getDataLength() const
Determines the data length for the entire nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector::".
bool containsErrors() const
Whether this nested name specifier contains an error.
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
void Profile(llvm::FoldingSetNodeID &ID) const
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.
bool isInstantiationDependent() const
Whether this nested name specifier involves a template parameter.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
SpecifierKind
The kind of specifier that completes this nested name specifier.
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
@ TypeSpec
A type, stored as a Type*.
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Identifier
An identifier, stored as an IdentifierInfo*.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace, stored as a NamespaceDecl*.
NestedNameSpecifierDependence getDependence() const
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
NestedNameSpecifier & operator=(const NestedNameSpecifier &)=delete
static NestedNameSpecifier * SuperSpecifier(const ASTContext &Context, CXXRecordDecl *RD)
Returns the nested name specifier representing the __super scope for the given CXXRecordDecl.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Encodes a location in the source.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
void AddTaggedVal(uint64_t V, DiagnosticsEngine::ArgumentKind Kind) const
Base wrapper for a particular "section" of type source info.
The base class of the type hierarchy.
@ Extend
Lifetime-extend along this path.
The JSON file list parser is used to communicate input to InstallAPI.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
const FunctionProtoType * T
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.
Wraps an identifier and optional source location for the identifier.
Describes how types, statements, expressions, and declarations should be printed.
static bool isEqual(const clang::NestedNameSpecifierLoc &LHS, const clang::NestedNameSpecifierLoc &RHS)
DenseMapInfo< void * > SecondInfo
static unsigned getHashValue(const clang::NestedNameSpecifierLoc &PairVal)
static clang::NestedNameSpecifierLoc getEmptyKey()
static clang::NestedNameSpecifierLoc getTombstoneKey()
DenseMapInfo< clang::NestedNameSpecifier * > FirstInfo