clang 20.0.0git
Public Types | Public Member Functions | Static Public Member Functions | List of all members
clang::NestedNameSpecifier Class Reference

Represents a C++ nested name specifier, such as "\::std::vector<int>::". More...

#include "clang/AST/NestedNameSpecifier.h"

Inheritance diagram for clang::NestedNameSpecifier:
Inheritance graph
[legend]

Public Types

enum  SpecifierKind {
  Identifier , Namespace , NamespaceAlias , TypeSpec ,
  TypeSpecWithTemplate , Global , Super
}
 The kind of specifier that completes this nested name specifier. More...
 

Public Member Functions

NestedNameSpecifieroperator= (const NestedNameSpecifier &)=delete
 
NestedNameSpecifiergetPrefix () const
 Return the prefix of this nested name specifier.
 
SpecifierKind getKind () const
 Determine what kind of nested name specifier is stored.
 
IdentifierInfogetAsIdentifier () const
 Retrieve the identifier stored in this nested name specifier.
 
NamespaceDeclgetAsNamespace () const
 Retrieve the namespace stored in this nested name specifier.
 
NamespaceAliasDeclgetAsNamespaceAlias () const
 Retrieve the namespace alias stored in this nested name specifier.
 
CXXRecordDeclgetAsRecordDecl () const
 Retrieve the record declaration stored in this nested name specifier.
 
const TypegetAsType () const
 Retrieve the type stored in this nested name specifier.
 
NestedNameSpecifierDependence getDependence () const
 
bool isDependent () const
 Whether this nested name specifier refers to a dependent type or not.
 
bool isInstantiationDependent () const
 Whether this nested name specifier involves a template parameter.
 
bool containsUnexpandedParameterPack () const
 Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic templates).
 
bool containsErrors () const
 Whether this nested name specifier contains an error.
 
void print (raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
 Print this nested name specifier to the given output stream.
 
void Profile (llvm::FoldingSetNodeID &ID) const
 
void dump (const LangOptions &LO) const
 Dump the nested name specifier to standard output to aid in debugging.
 
void dump () const
 
void dump (llvm::raw_ostream &OS) const
 
void dump (llvm::raw_ostream &OS, const LangOptions &LO) const
 

Static Public Member Functions

static NestedNameSpecifierCreate (const ASTContext &Context, NestedNameSpecifier *Prefix, const IdentifierInfo *II)
 Builds a specifier combining a prefix and an identifier.
 
static NestedNameSpecifierCreate (const ASTContext &Context, NestedNameSpecifier *Prefix, const NamespaceDecl *NS)
 Builds a nested name specifier that names a namespace.
 
static NestedNameSpecifierCreate (const ASTContext &Context, NestedNameSpecifier *Prefix, const NamespaceAliasDecl *Alias)
 Builds a nested name specifier that names a namespace alias.
 
static NestedNameSpecifierCreate (const ASTContext &Context, NestedNameSpecifier *Prefix, bool Template, const Type *T)
 Builds a nested name specifier that names a type.
 
static NestedNameSpecifierCreate (const ASTContext &Context, const IdentifierInfo *II)
 Builds a specifier that consists of just an identifier.
 
static NestedNameSpecifierGlobalSpecifier (const ASTContext &Context)
 Returns the nested name specifier representing the global scope.
 
static NestedNameSpecifierSuperSpecifier (const ASTContext &Context, CXXRecordDecl *RD)
 Returns the nested name specifier representing the __super scope for the given CXXRecordDecl.
 

Detailed Description

Represents a C++ nested name specifier, such as "\::std::vector<int>::".

C++ nested name specifiers are the prefixes to qualified names. For example, "foo::" in "foo::x" is a nested name specifier. Nested name specifiers are made up of a sequence of specifiers, each of which can be a namespace, type, identifier (for dependent names), decltype specifier, or the global specifier ('::'). The last two specifiers can only appear at the start of a nested-namespace-specifier.

Definition at line 50 of file NestedNameSpecifier.h.

Member Enumeration Documentation

◆ SpecifierKind

The kind of specifier that completes this nested name specifier.

Enumerator
Identifier 

An identifier, stored as an IdentifierInfo*.

Namespace 

A namespace, stored as a NamespaceDecl*.

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*.

Global 

The global specifier '::'. There is no stored value.

Super 

Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.

Definition at line 79 of file NestedNameSpecifier.h.

Member Function Documentation

◆ containsErrors()

bool NestedNameSpecifier::containsErrors ( ) const

Whether this nested name specifier contains an error.

Definition at line 246 of file NestedNameSpecifier.cpp.

References getDependence().

Referenced by clang::Sema::DiagnoseUnknownTypeName().

◆ containsUnexpandedParameterPack()

bool NestedNameSpecifier::containsUnexpandedParameterPack ( ) const

Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic templates).

Definition at line 242 of file NestedNameSpecifier.cpp.

References getDependence().

Referenced by clang::Sema::ActOnUsingDeclaration(), clang::Sema::containsUnexpandedParameterPacks(), and clang::Sema::DiagnoseUnexpandedParameterPack().

◆ Create() [1/5]

NestedNameSpecifier * NestedNameSpecifier::Create ( const ASTContext Context,
const IdentifierInfo II 
)
static

Builds a specifier that consists of just an identifier.

The nested-name-specifier is assumed to be dependent, but has no prefix because the prefix is implied by something outside of the nested name specifier, e.g., in "x->Base::f", the "x" has a dependent type.

Definition at line 115 of file NestedNameSpecifier.cpp.

◆ Create() [2/5]

NestedNameSpecifier * NestedNameSpecifier::Create ( const ASTContext Context,
NestedNameSpecifier Prefix,
bool  Template,
const Type T 
)
static

Builds a nested name specifier that names a type.

Definition at line 104 of file NestedNameSpecifier.cpp.

References clang::T.

◆ Create() [3/5]

NestedNameSpecifier * NestedNameSpecifier::Create ( const ASTContext Context,
NestedNameSpecifier Prefix,
const IdentifierInfo II 
)
static

◆ Create() [4/5]

NestedNameSpecifier * NestedNameSpecifier::Create ( const ASTContext Context,
NestedNameSpecifier Prefix,
const NamespaceAliasDecl Alias 
)
static

Builds a nested name specifier that names a namespace alias.

Definition at line 88 of file NestedNameSpecifier.cpp.

References getAsIdentifier(), and getAsType().

◆ Create() [5/5]

NestedNameSpecifier * NestedNameSpecifier::Create ( const ASTContext Context,
NestedNameSpecifier Prefix,
const NamespaceDecl NS 
)
static

Builds a nested name specifier that names a namespace.

Definition at line 72 of file NestedNameSpecifier.cpp.

References getAsIdentifier(), and getAsType().

◆ dump() [1/4]

LLVM_DUMP_METHOD void NestedNameSpecifier::dump ( ) const

Definition at line 343 of file NestedNameSpecifier.cpp.

References dump().

Referenced by dump().

◆ dump() [2/4]

LLVM_DUMP_METHOD void NestedNameSpecifier::dump ( const LangOptions LO) const

Dump the nested name specifier to standard output to aid in debugging.

Definition at line 339 of file NestedNameSpecifier.cpp.

References dump().

◆ dump() [3/4]

LLVM_DUMP_METHOD void NestedNameSpecifier::dump ( llvm::raw_ostream &  OS) const

Definition at line 345 of file NestedNameSpecifier.cpp.

References dump().

◆ dump() [4/4]

LLVM_DUMP_METHOD void NestedNameSpecifier::dump ( llvm::raw_ostream &  OS,
const LangOptions LO 
) const

Definition at line 350 of file NestedNameSpecifier.cpp.

References print().

◆ getAsIdentifier()

IdentifierInfo * clang::NestedNameSpecifier::getAsIdentifier ( ) const
inline

◆ getAsNamespace()

NamespaceDecl * NestedNameSpecifier::getAsNamespace ( ) const

◆ getAsNamespaceAlias()

NamespaceAliasDecl * NestedNameSpecifier::getAsNamespaceAlias ( ) const

◆ getAsRecordDecl()

CXXRecordDecl * NestedNameSpecifier::getAsRecordDecl ( ) const

◆ getAsType()

const Type * clang::NestedNameSpecifier::getAsType ( ) const
inline

◆ getDependence()

NestedNameSpecifierDependence NestedNameSpecifier::getDependence ( ) const

◆ getKind()

NestedNameSpecifier::SpecifierKind NestedNameSpecifier::getKind ( ) const

◆ getPrefix()

NestedNameSpecifier * clang::NestedNameSpecifier::getPrefix ( ) const
inline

◆ GlobalSpecifier()

NestedNameSpecifier * NestedNameSpecifier::GlobalSpecifier ( const ASTContext Context)
static

◆ isDependent()

bool NestedNameSpecifier::isDependent ( ) const

◆ isInstantiationDependent()

bool NestedNameSpecifier::isInstantiationDependent ( ) const

Whether this nested name specifier involves a template parameter.

Definition at line 238 of file NestedNameSpecifier.cpp.

References getDependence().

◆ operator=()

NestedNameSpecifier & clang::NestedNameSpecifier::operator= ( const NestedNameSpecifier )
delete

◆ print()

void NestedNameSpecifier::print ( raw_ostream &  OS,
const PrintingPolicy Policy,
bool  ResolveTemplateArguments = false 
) const

◆ Profile()

void clang::NestedNameSpecifier::Profile ( llvm::FoldingSetNodeID &  ID) const
inline

Definition at line 228 of file NestedNameSpecifier.h.

References ID, and Specifier.

◆ SuperSpecifier()

NestedNameSpecifier * NestedNameSpecifier::SuperSpecifier ( const ASTContext Context,
CXXRecordDecl RD 
)
static

Returns the nested name specifier representing the __super scope for the given CXXRecordDecl.

Definition at line 134 of file NestedNameSpecifier.cpp.

Referenced by clang::ASTImporter::Import(), clang::NestedNameSpecifierLocBuilder::MakeSuper(), and clang::serialization::DataStreamBasicReader< Impl >::readNestedNameSpecifier().


The documentation for this class was generated from the following files: