Go to the documentation of this file.
14 #ifndef LLVM_CLANG_AST_NESTEDNAMESPECIFIER_H
15 #define LLVM_CLANG_AST_NESTEDNAMESPECIFIER_H
20 #include "llvm/ADT/DenseMapInfo.h"
21 #include "llvm/ADT/FoldingSet.h"
22 #include "llvm/ADT/PointerIntPair.h"
23 #include "llvm/Support/Compiler.h"
34 class NamespaceAliasDecl;
36 struct PrintingPolicy;
52 enum StoredSpecifierKind {
56 StoredTypeSpecWithTemplate = 3
65 llvm::PointerIntPair<NestedNameSpecifier *, 2, StoredSpecifierKind> Prefix;
74 void* Specifier =
nullptr;
110 NestedNameSpecifier(
const NestedNameSpecifier &Other) =
default;
114 static NestedNameSpecifier *FindOrInsert(
const ASTContext &Context,
115 const NestedNameSpecifier &Mockup);
118 NestedNameSpecifier &
operator=(
const NestedNameSpecifier &) =
delete;
125 static NestedNameSpecifier *
Create(
const ASTContext &Context,
126 NestedNameSpecifier *Prefix,
130 static NestedNameSpecifier *
Create(
const ASTContext &Context,
131 NestedNameSpecifier *Prefix,
132 const NamespaceDecl *NS);
135 static NestedNameSpecifier *
Create(
const ASTContext &Context,
136 NestedNameSpecifier *Prefix,
137 NamespaceAliasDecl *Alias);
140 static NestedNameSpecifier *
Create(
const ASTContext &Context,
141 NestedNameSpecifier *Prefix,
142 bool Template,
const Type *T);
150 static NestedNameSpecifier *
Create(
const ASTContext &Context,
155 static NestedNameSpecifier *
GlobalSpecifier(
const ASTContext &Context);
159 static NestedNameSpecifier *
SuperSpecifier(
const ASTContext &Context,
177 if (Prefix.getInt() == StoredIdentifier)
197 if (Prefix.getInt() == StoredTypeSpec ||
198 Prefix.getInt() == StoredTypeSpecWithTemplate)
226 bool ResolveTemplateArguments =
false)
const;
229 ID.AddPointer(Prefix.getOpaqueValue());
237 void dump(llvm::raw_ostream &OS)
const;
245 void *Data =
nullptr;
262 : Qualifier(Qualifier), Data(Data) {}
266 explicit operator bool()
const {
return Qualifier; }
344 return X.Qualifier == Y.Qualifier &&
X.Data == Y.Data;
367 char *Buffer =
nullptr;
371 unsigned BufferSize = 0;
375 unsigned BufferCapacity = 0;
506 Representation =
nullptr;
516 return std::make_pair(Buffer, BufferSize);
533 template <>
struct DenseMapInfo<
clang::NestedNameSpecifierLoc> {
534 using FirstInfo = DenseMapInfo<clang::NestedNameSpecifier *>;
539 SecondInfo::getEmptyKey());
544 SecondInfo::getTombstoneKey());
560 #endif // LLVM_CLANG_AST_NESTEDNAMESPECIFIER_H
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
SourceLocation getLocalEndLoc() const
Retrieve the location of the end of this component of the nested-name-specifier.
@ Identifier
An identifier, stored as an IdentifierInfo*.
YAML serialization mapping.
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
static bool isEqual(const clang::NestedNameSpecifierLoc &LHS, const clang::NestedNameSpecifierLoc &RHS)
friend bool operator!=(NestedNameSpecifierLoc X, NestedNameSpecifierLoc Y)
A trivial tuple used to represent a source range.
Represents a C++ namespace alias.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
Encodes a location in the source.
SourceLocation getBegin() const
bool isInstantiationDependent() const
Whether this nested name specifier involves a template parameter.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Describes how types, statements, expressions, and declarations should be printed.
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
NestedNameSpecifierLoc()=default
Construct an empty nested-name-specifier.
void AddTaggedVal(uint64_t V, DiagnosticsEngine::ArgumentKind Kind) const
The base class of the type hierarchy.
friend bool operator==(NestedNameSpecifierLoc X, NestedNameSpecifierLoc Y)
@ Namespace
A namespace, stored as a NamespaceDecl*.
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
void Clear()
Clear out this builder, and prepare it to build another nested-name-specifier with source-location in...
SourceRange getLocalSourceRange() const
Retrieve the source range covering just the last part of this nested-name-specifier,...
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
void Profile(llvm::FoldingSetNodeID &ID) const
SourceLocation getEnd() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
bool containsErrors() const
Whether this nested name specifier contains an error.
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
NestedNameSpecifierLoc getTemporary() const
Retrieve a nested-name-specifier with location information based on the information in this builder.
@ Global
The global specifier '::'. There is no stored value.
NestedNameSpecifierLocBuilder()=default
NestedNameSpecifier & operator=(const NestedNameSpecifier &)=delete
A C++ nested-name-specifier augmented with source location information.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
Class that aids in the construction of nested-name-specifiers along with source-location information ...
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
NestedNameSpecifierLocBuilder & operator=(const NestedNameSpecifierLocBuilder &Other)
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'type...
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
Represents a C++ struct/union/class.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias 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.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
static clang::NestedNameSpecifierLoc getTombstoneKey()
NestedNameSpecifierDependence getDependence() const
const NestedNameSpecifier * Specifier
static unsigned getHashValue(const clang::NestedNameSpecifierLoc &PairVal)
std::pair< char *, unsigned > getBuffer() const
Retrieve the underlying buffer.
NestedNameSpecifierLoc(NestedNameSpecifier *Qualifier, void *Data)
Construct a nested-name-specifier with source location information from.
Base wrapper for a particular "section" of type source info.
NestedNameSpecifier * getRepresentation() const
Retrieve the representation of the nested-name-specifier.
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
static NestedNameSpecifier * SuperSpecifier(const ASTContext &Context, CXXRecordDecl *RD)
Returns the nested name specifier representing the __super scope for the given CXXRecordDecl.
DenseMapInfo< clang::NestedNameSpecifier * > FirstInfo
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covered by this nested-name-specifier.
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...
unsigned getDataLength() const
Determines the data length for the entire nested-name-specifier.
static clang::NestedNameSpecifierLoc getEmptyKey()
bool hasQualifier() const
Evaluates true when this nested-name-specifier location is empty.
DenseMapInfo< void * > SecondInfo
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
SpecifierKind
The kind of specifier that completes this nested name specifier.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.
@ TypeSpec
A type, stored as a Type*.
~NestedNameSpecifierLocBuilder()
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
Wraps an identifier and optional source location for the identifier.
Represent a C++ namespace.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
@ ak_nestednamespec
NestedNameSpecifier *.