clang 24.0.0git
clang::NestedNameSpecifier Class Reference

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

#include "clang/AST/NestedNameSpecifierBase.h"

Public Types

enum class  Kind {
  Null , Global , Type , Namespace ,
  MicrosoftSuper
}
 The kind of specifier that completes this nested name specifier. More...

Public Member Functions

 NestedNameSpecifier ()=delete
Kind getKind () const
 NestedNameSpecifier (std::nullopt_t)
 NestedNameSpecifier (const Type *T)
 NestedNameSpecifier (const ASTContext &Ctx, const NamespaceBaseDecl *Namespace, NestedNameSpecifier Prefix)
 Builds a nested name specifier that names a namespace.
 NestedNameSpecifier (CXXRecordDecl *RD)
 Builds a nested name specifier that names a class through microsoft's __super specifier.
 operator bool () const
void * getAsVoidPointer () const
const Type * getAsType () const
NamespaceAndPrefix getAsNamespaceAndPrefix () const
CXXRecordDecl * getAsMicrosoftSuper () const
CXXRecordDecl * getAsRecordDecl () const
 Retrieve the record declaration stored in this nested name specifier, or null.
NestedNameSpecifier getCanonical () const
 Retrieves the "canonical" nested name specifier for a given nested name specifier.
bool isCanonical () const
 Whether this nested name specifier is canonical.
bool isFullyQualified () const
 Whether this nested name specifier starts with a '::'.
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, bool PrintFinalScopeResOp=true) const
 Print this nested name specifier to the given output stream.
void Profile (llvm::FoldingSetNodeID &ID) const
void dump (llvm::raw_ostream *OS=nullptr, const LangOptions *LO=nullptr) const
 Dump the nested name specifier to aid in debugging.
void dump (const LangOptions &LO) const
void dump (llvm::raw_ostream &OS) const
void dump (llvm::raw_ostream &OS, const LangOptions &LO) const

Static Public Member Functions

static constexpr NestedNameSpecifier getGlobal ()
static NestedNameSpecifier getFromVoidPointer (const void *Ptr)

Static Public Attributes

static constexpr auto NumLowBitsAvailable = FlagOffset

Friends

bool operator== (NestedNameSpecifier LHS, NestedNameSpecifier RHS)
bool operator!= (NestedNameSpecifier LHS, NestedNameSpecifier RHS)

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, decltype specifier, or the global specifier ('::'). The last two specifiers can only appear at the start of a nested-namespace-specifier.

Definition at line 51 of file NestedNameSpecifierBase.h.

Member Enumeration Documentation

◆ Kind

The kind of specifier that completes this nested name specifier.

Enumerator
Null 

Empty.

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

MicrosoftSuper 

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

Definition at line 111 of file NestedNameSpecifierBase.h.

Constructor & Destructor Documentation

◆ NestedNameSpecifier() [1/5]

clang::NestedNameSpecifier::NestedNameSpecifier ( )
delete

◆ NestedNameSpecifier() [2/5]

clang::NestedNameSpecifier::NestedNameSpecifier ( std::nullopt_t )
inline

Definition at line 131 of file NestedNameSpecifierBase.h.

◆ NestedNameSpecifier() [3/5]

clang::NestedNameSpecifier::NestedNameSpecifier ( const Type * T)
inlineexplicit

Definition at line 56 of file NestedNameSpecifier.h.

References clang::T.

◆ NestedNameSpecifier() [4/5]

clang::NestedNameSpecifier::NestedNameSpecifier ( const ASTContext & Ctx,
const NamespaceBaseDecl * Namespace,
NestedNameSpecifier Prefix )
inline

Builds a nested name specifier that names a namespace.

Definition at line 80 of file NestedNameSpecifier.h.

References getKind(), and Namespace.

◆ NestedNameSpecifier() [5/5]

clang::NestedNameSpecifier::NestedNameSpecifier ( CXXRecordDecl * RD)
inlineexplicit

Builds a nested name specifier that names a class through microsoft's __super specifier.

Definition at line 89 of file NestedNameSpecifier.h.

Member Function Documentation

◆ containsErrors()

bool clang::NestedNameSpecifier::containsErrors ( ) const
inline

Whether this nested name specifier contains an error.

Definition at line 232 of file NestedNameSpecifierBase.h.

References getDependence().

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

◆ containsUnexpandedParameterPack()

bool clang::NestedNameSpecifier::containsUnexpandedParameterPack ( ) const
inline

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

Definition at line 227 of file NestedNameSpecifierBase.h.

References getDependence().

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

◆ dump() [1/4]

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

Definition at line 127 of file NestedNameSpecifier.cpp.

References dump().

◆ dump() [2/4]

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

Definition at line 130 of file NestedNameSpecifier.cpp.

References dump().

◆ dump() [3/4]

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

Definition at line 133 of file NestedNameSpecifier.cpp.

References dump().

◆ dump() [4/4]

LLVM_DUMP_METHOD void NestedNameSpecifier::dump ( llvm::raw_ostream * OS = nullptr,
const LangOptions * LO = nullptr ) const

Dump the nested name specifier to aid in debugging.

Definition at line 122 of file NestedNameSpecifier.cpp.

References print().

Referenced by dump(), dump(), and dump().

◆ getAsMicrosoftSuper()

◆ getAsNamespaceAndPrefix()

◆ getAsRecordDecl()

◆ getAsType()

◆ getAsVoidPointer()

void * clang::NestedNameSpecifier::getAsVoidPointer ( ) const
inline

◆ getCanonical()

NestedNameSpecifier clang::NestedNameSpecifier::getCanonical ( ) const
inline

Retrieves the "canonical" nested name specifier for a given nested name specifier.

The canonical nested name specifier is a nested name specifier that uniquely identifies a type or namespace within the type system. For example, given:

namespace N {
struct S {
template<typename T> struct X { typename T* type; };
};
}
template<typename T> struct Y {
typename N::S::X<T>::type member;
};
#define X(type, name)
Definition Value.h:97
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
RangeSelector member(std::string ID)
Given a MemberExpr, selects the member token. ID is the node's binding in the match result.
const FunctionProtoType * T

Here, the nested-name-specifier for N::S::X<T>:: will be S::X<template-param-0-0>, since 'S' and 'X' are uniquely defined by declarations in the type system and the canonical type for the template type parameter 'T' is template-param-0-0.

Definition at line 108 of file NestedNameSpecifier.h.

References getAsNamespaceAndPrefix(), getAsType(), clang::NamespaceDecl::getCanonicalDecl(), getKind(), clang::NamespaceBaseDecl::getNamespace(), Global, MicrosoftSuper, clang::NamespaceAndPrefix::Namespace, Namespace, NestedNameSpecifier(), Null, and Type.

Referenced by clang::Sema::CheckUsingDeclRedeclaration(), getCommonNNS(), clang::ASTContext::getDependentNameType(), and isCanonical().

◆ getDependence()

◆ getFromVoidPointer()

NestedNameSpecifier clang::NestedNameSpecifier::getFromVoidPointer ( const void * Ptr)
inlinestatic

◆ getGlobal()

◆ getKind()

auto clang::NestedNameSpecifier::getKind ( ) const
inline

Definition at line 24 of file NestedNameSpecifier.h.

References getKind(), Global, MicrosoftSuper, Namespace, Null, and Type.

Referenced by clang::Sema::ActOnFriendFunctionDecl(), clang::TypoCorrectionConsumer::addNamespaces(), clang::ODRHash::AddNestedNameSpecifier(), clang::Sema::CheckDependentFriend(), clang::Sema::CheckDependentFunctionTemplateSpecialization(), clang::Sema::checkLiteralOperatorId(), clang::SemaCodeCompletion::CodeCompleteQualifiedId(), clang::Sema::computeDeclContext(), clang::TextNodeDumper::dumpNestedNameSpecifier(), clang::Sema::FindFirstQualifierInScope(), getAsRecordDecl(), getCanonical(), getCommonNNS(), clang::Sema::getCurrentInstantiationOf(), getDependence(), getKind(), getNestedNameSpecifierIdentifiers(), GetQualifierClassTemplateSpecializationType(), getRangeOfTypeInNestedNameSpecifier(), hasRecursiveCallInPath(), clang::ASTImporter::Import(), clang::ASTImporter::Import(), isEnableIf(), isFullyQualified(), clang::Sema::isMicrosoftMissingTypename(), isSameQualifier(), IsStructurallyEquivalent(), MarkUsedTemplateParameters(), clang::Sema::MatchTemplateParametersToScopeSpecifier(), NestedNameSpecifier(), print(), ScopeSpecifierHasTemplateId(), clang::Sema::ShouldEnterDeclaratorScope(), clang::TreeTransform< Derived >::TransformNestedNameSpecifierLoc(), clang::RecursiveASTVisitor< Derived >::TraverseNestedNameSpecifier(), clang::RecursiveASTVisitor< Derived >::TraverseNestedNameSpecifierLoc(), warnAboutRedundantParens(), and clang::serialization::DataStreamBasicWriter< Impl >::writeNestedNameSpecifier().

◆ isCanonical()

bool clang::NestedNameSpecifier::isCanonical ( ) const
inline

Whether this nested name specifier is canonical.

Definition at line 129 of file NestedNameSpecifier.h.

References getCanonical().

◆ isDependent()

◆ isFullyQualified()

bool NestedNameSpecifier::isFullyQualified ( ) const

◆ isInstantiationDependent()

bool clang::NestedNameSpecifier::isInstantiationDependent ( ) const
inline

Whether this nested name specifier involves a template parameter.

Definition at line 221 of file NestedNameSpecifierBase.h.

References getDependence().

◆ operator bool()

clang::NestedNameSpecifier::operator bool ( ) const
inlineexplicit

Definition at line 144 of file NestedNameSpecifierBase.h.

◆ print()

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

Print this nested name specifier to the given output stream.

If ResolveTemplateArguments is true, we'll print actual types, e.g. ns::SomeTemplate<int, MyClass> instead of ns::SomeTemplate<Container::value_type, T>.

Definition at line 88 of file NestedNameSpecifier.cpp.

References getAsNamespaceAndPrefix(), getAsType(), getKind(), Global, MicrosoftSuper, Namespace, Null, print(), clang::QualType::print(), clang::PrintingPolicy::SuppressTagKeyword, and Type.

Referenced by dump(), clang::FormatASTNodeDiagnosticArgument(), MaybeAddOverrideCalls(), clang::DependentTemplateStorage::print(), print(), PrintMapper(), printQualifier(), clang::TextNodeDumper::VisitUnresolvedUsingTypenameDecl(), clang::TextNodeDumper::VisitUnresolvedUsingValueDecl(), and clang::TextNodeDumper::VisitUsingDecl().

◆ Profile()

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

◆ operator!=

bool operator!= ( NestedNameSpecifier LHS,
NestedNameSpecifier RHS )
friend

Definition at line 176 of file NestedNameSpecifierBase.h.

◆ operator==

bool operator== ( NestedNameSpecifier LHS,
NestedNameSpecifier RHS )
friend

Definition at line 173 of file NestedNameSpecifierBase.h.

Member Data Documentation

◆ NumLowBitsAvailable

auto clang::NestedNameSpecifier::NumLowBitsAvailable = FlagOffset
staticconstexpr

Definition at line 255 of file NestedNameSpecifierBase.h.


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