13#ifndef LLVM_CLANG_AST_NESTEDNAMESPECIFIER_H
14#define LLVM_CLANG_AST_NESTEDNAMESPECIFIER_H
20#include "llvm/ADT/DenseMapInfo.h"
25 if (!isStoredKind()) {
26 switch (getFlagKind()) {
29 case FlagKind::Global:
32 llvm_unreachable(
"unhandled FlagKind");
34 switch (
auto [K, Ptr] = getStored(); K) {
35 case StoredKind::Type:
37 case StoredKind::NamespaceWithGlobal:
38 case StoredKind::NamespaceWithNamespace:
40 case StoredKind::NamespaceOrSuper:
41 switch (
static_cast<const Decl *
>(Ptr)->
getKind()) {
43 case Decl::NamespaceAlias:
46 case Decl::ClassTemplateSpecialization:
47 case Decl::ClassTemplatePartialSpecialization:
50 llvm_unreachable(
"unexpected decl kind");
53 llvm_unreachable(
"unknown StoredKind");
57 : NestedNameSpecifier({StoredKind::Type,
T}) {
58 assert(
getKind() == Kind::Type);
61auto NestedNameSpecifier::MakeNamespacePtrKind(
62 const ASTContext &Ctx,
const NamespaceBaseDecl *Namespace,
63 NestedNameSpecifier Prefix) -> PtrKind {
64 switch (Prefix.getKind()) {
66 return {StoredKind::NamespaceOrSuper, Namespace};
68 return {StoredKind::NamespaceWithGlobal,
Namespace};
70 return {StoredKind::NamespaceWithNamespace,
71 MakeNamespaceAndPrefixStorage(Ctx, Namespace, Prefix)};
72 case Kind::MicrosoftSuper:
74 llvm_unreachable(
"invalid prefix for namespace");
76 llvm_unreachable(
"unhandled kind");
82 NestedNameSpecifier Prefix)
83 : NestedNameSpecifier(MakeNamespacePtrKind(Ctx,
Namespace, Prefix)) {
90 : NestedNameSpecifier({StoredKind::NamespaceOrSuper, RD}) {
91 assert(
getKind() == Kind::MicrosoftSuper);
105 llvm_unreachable(
"Invalid NNS Kind!");
124 getAsType()->getCanonicalTypeInternal().getTypePtr());
126 llvm_unreachable(
"unhandled kind");
134 return TypeLoc(Qualifier.getAsType(), LoadPointer(0));
148 switch (Qualifier.getKind()) {
162 Length +=
sizeof(
void *);
166 llvm_unreachable(
"Expected a non-NULL qualifier");
173 auto [Namespace, Prefix] = Qualifier.getAsNamespaceAndPrefix();
185 for (; Qualifier; Qualifier = Qualifier.getAsNamespaceAndPrefix().Prefix) {
186 Length += getLocalDataLength(Qualifier);
198 switch (
auto Kind = Qualifier.getKind()) {
202 return LoadSourceLocation(0);
210 LoadSourceLocation(Offset),
216 void *TypeData = LoadPointer(0);
217 TypeLoc TL(Qualifier.getAsType(), TypeData);
222 llvm_unreachable(
"Invalid NNS Kind!");
253template <>
struct DenseMapInfo<
clang::NestedNameSpecifier> {
255 return hash_combine(
V.getAsVoidPointer());
259template <>
struct DenseMapInfo<
clang::NestedNameSpecifierLoc> {
260 using FirstInfo = DenseMapInfo<clang::NestedNameSpecifier>;
static Decl::Kind getKind(const Decl *D)
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Represents a C++ struct/union/class.
Decl - This represents one declaration (or definition), e.g.
Represents C++ namespaces and their aliases.
NamespaceDecl * getNamespace()
NamespaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this namespace.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covered by this nested-name-specifier.
A C++ nested-name-specifier augmented with source location information.
NamespaceAndPrefixLoc getAsNamespaceAndPrefix() const
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocalEndLoc() const
Retrieve the location of the end 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.
NestedNameSpecifierLoc()=default
Construct an empty nested-name-specifier.
NamespaceAndPrefixLoc castAsNamespaceAndPrefix() const
For a nested-name-specifier that refers to a namespace, retrieve the namespace and its prefix.
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
TypeLoc getAsTypeLoc() const
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
TypeLoc castAsTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
SourceRange getLocalSourceRange() const
Retrieve the source range covering just the last part of this nested-name-specifier,...
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the 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<int>::".
NestedNameSpecifier getCanonical() const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
CXXRecordDecl * getAsMicrosoftSuper() const
NamespaceAndPrefix getAsNamespaceAndPrefix() const
NestedNameSpecifier()=delete
bool isCanonical() const
Whether this nested name specifier is canonical.
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier, or null.
const Type * getAsType() const
Kind
The kind of specifier that completes this nested name specifier.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
Encodes a location in the source.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Base wrapper for a particular "section" of type source info.
SourceLocation getBeginLoc() const
Get the begin source location.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Top level wrappers for InstallAPI frontend operations.
const FunctionProtoType * T
Diagnostic wrappers for TextAPI types for error reporting.
const NamespaceBaseDecl * Namespace
static bool isEqual(const clang::NestedNameSpecifierLoc &LHS, const clang::NestedNameSpecifierLoc &RHS)
DenseMapInfo< void * > SecondInfo
static unsigned getHashValue(const clang::NestedNameSpecifierLoc &PairVal)
DenseMapInfo< clang::NestedNameSpecifier > FirstInfo
static unsigned getHashValue(const clang::NestedNameSpecifier &V)