clang 20.0.0git
|
Represents a C++ nested name specifier, such as "\::std::vector<int>::". More...
#include "clang/AST/NestedNameSpecifier.h"
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 | |
NestedNameSpecifier & | operator= (const NestedNameSpecifier &)=delete |
NestedNameSpecifier * | getPrefix () const |
Return the prefix of this nested name specifier. | |
SpecifierKind | getKind () const |
Determine what kind of nested name specifier is stored. | |
IdentifierInfo * | getAsIdentifier () const |
Retrieve the identifier stored in this nested name specifier. | |
NamespaceDecl * | getAsNamespace () const |
Retrieve the namespace stored in this nested name specifier. | |
NamespaceAliasDecl * | getAsNamespaceAlias () const |
Retrieve the namespace alias stored in this nested name specifier. | |
CXXRecordDecl * | getAsRecordDecl () const |
Retrieve the record declaration stored in this nested name specifier. | |
const Type * | getAsType () 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 NestedNameSpecifier * | Create (const ASTContext &Context, NestedNameSpecifier *Prefix, const IdentifierInfo *II) |
Builds a specifier combining a prefix and an identifier. | |
static NestedNameSpecifier * | Create (const ASTContext &Context, NestedNameSpecifier *Prefix, const NamespaceDecl *NS) |
Builds a nested name specifier that names a namespace. | |
static NestedNameSpecifier * | Create (const ASTContext &Context, NestedNameSpecifier *Prefix, const NamespaceAliasDecl *Alias) |
Builds a nested name specifier that names a namespace alias. | |
static NestedNameSpecifier * | Create (const ASTContext &Context, NestedNameSpecifier *Prefix, bool Template, const Type *T) |
Builds a nested name specifier that names a type. | |
static NestedNameSpecifier * | Create (const ASTContext &Context, const IdentifierInfo *II) |
Builds a specifier that consists of just an identifier. | |
static NestedNameSpecifier * | GlobalSpecifier (const ASTContext &Context) |
Returns the nested name specifier representing the global scope. | |
static NestedNameSpecifier * | SuperSpecifier (const ASTContext &Context, CXXRecordDecl *RD) |
Returns the nested name specifier representing the __super scope for the given CXXRecordDecl. | |
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.
The kind of specifier that completes this nested name specifier.
Definition at line 79 of file NestedNameSpecifier.h.
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().
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().
|
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.
|
static |
Builds a nested name specifier that names a type.
Definition at line 104 of file NestedNameSpecifier.cpp.
References clang::T.
|
static |
Builds a specifier combining a prefix and an identifier.
The prefix must be dependent, since nested name specifiers referencing an identifier are only permitted when the identifier cannot be resolved.
Definition at line 58 of file NestedNameSpecifier.cpp.
References isDependent().
Referenced by clang::Sema::ActOnMSVCUnknownTypeName(), clang::Sema::BuildExpressionFromDeclTemplateArgument(), buildSingleCopyAssignRecursively(), clang::Sema::BuildStdInitializerList(), clang::Sema::CheckComparisonCategoryType(), clang::TypeName::createNestedNameSpecifier(), clang::NestedNameSpecifierLocBuilder::Extend(), clang::ASTContext::getCanonicalNestedNameSpecifier(), getRequiredQualification(), clang::ASTImporter::Import(), lookupPromiseType(), clang::serialization::DataStreamBasicReader< Impl >::readNestedNameSpecifier(), recoverFromMSUnqualifiedLookup(), recoverFromTypeInKnownDependentBase(), and synthesizeCurrentNestedNameSpecifier().
|
static |
Builds a nested name specifier that names a namespace alias.
Definition at line 88 of file NestedNameSpecifier.cpp.
References getAsIdentifier(), and getAsType().
|
static |
Builds a nested name specifier that names a namespace.
Definition at line 72 of file NestedNameSpecifier.cpp.
References getAsIdentifier(), and getAsType().
LLVM_DUMP_METHOD void NestedNameSpecifier::dump | ( | ) | const |
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().
LLVM_DUMP_METHOD void NestedNameSpecifier::dump | ( | llvm::raw_ostream & | OS | ) | const |
Definition at line 345 of file NestedNameSpecifier.cpp.
References dump().
LLVM_DUMP_METHOD void NestedNameSpecifier::dump | ( | llvm::raw_ostream & | OS, |
const LangOptions & | LO | ||
) | const |
Definition at line 350 of file NestedNameSpecifier.cpp.
References print().
|
inline |
Retrieve the identifier stored in this nested name specifier.
Definition at line 176 of file NestedNameSpecifier.h.
References Specifier.
Referenced by clang::ODRHash::AddNestedNameSpecifier(), clang::ASTRecordWriter::AddNestedNameSpecifierLoc(), Create(), clang::Sema::FindFirstQualifierInScope(), clang::ASTContext::getCanonicalNestedNameSpecifier(), GetFullTypeForDeclarator(), clang::Sema::getInheritingConstructorName(), getNestedNameSpecifierIdentifiers(), clang::ASTImporter::Import(), isSameQualifier(), IsStructurallyEquivalent(), print(), clang::TreeTransform< Derived >::TransformNestedNameSpecifierLoc(), and clang::serialization::DataStreamBasicWriter< Impl >::writeNestedNameSpecifier().
NamespaceDecl * NestedNameSpecifier::getAsNamespace | ( | ) | const |
Retrieve the namespace stored in this nested name specifier.
Definition at line 169 of file NestedNameSpecifier.cpp.
Referenced by clang::ODRHash::AddNestedNameSpecifier(), clang::ASTRecordWriter::AddNestedNameSpecifierLoc(), clang::Sema::computeDeclContext(), clang::ASTContext::getCanonicalNestedNameSpecifier(), getNestedNameSpecifierIdentifiers(), clang::ASTImporter::Import(), clang::index::IndexingContext::indexNestedNameSpecifierLoc(), IsStructurallyEquivalent(), print(), clang::TreeTransform< Derived >::TransformNestedNameSpecifierLoc(), clang::tooling::RecursiveSymbolVisitor< T >::TraverseNestedNameSpecifierLoc(), and clang::serialization::DataStreamBasicWriter< Impl >::writeNestedNameSpecifier().
NamespaceAliasDecl * NestedNameSpecifier::getAsNamespaceAlias | ( | ) | const |
Retrieve the namespace alias stored in this nested name specifier.
Definition at line 177 of file NestedNameSpecifier.cpp.
Referenced by clang::ODRHash::AddNestedNameSpecifier(), clang::ASTRecordWriter::AddNestedNameSpecifierLoc(), clang::Sema::computeDeclContext(), clang::ASTContext::getCanonicalNestedNameSpecifier(), getNestedNameSpecifierIdentifiers(), clang::ASTImporter::Import(), clang::index::IndexingContext::indexNestedNameSpecifierLoc(), IsStructurallyEquivalent(), print(), clang::TreeTransform< Derived >::TransformNestedNameSpecifierLoc(), and clang::serialization::DataStreamBasicWriter< Impl >::writeNestedNameSpecifier().
CXXRecordDecl * NestedNameSpecifier::getAsRecordDecl | ( | ) | const |
Retrieve the record declaration stored in this nested name specifier.
Definition at line 185 of file NestedNameSpecifier.cpp.
References clang::Type::getAsCXXRecordDecl(), and getAsType().
Referenced by clang::ASTRecordWriter::AddNestedNameSpecifierLoc(), clang::Sema::computeDeclContext(), clang::ConstructorUsingShadowDecl::getNominatedBaseClass(), clang::ASTImporter::Import(), IsStructurallyEquivalent(), print(), clang::TreeTransform< Derived >::TransformNestedNameSpecifierLoc(), and clang::serialization::DataStreamBasicWriter< Impl >::writeNestedNameSpecifier().
|
inline |
Retrieve the type stored in this nested name specifier.
Definition at line 196 of file NestedNameSpecifier.h.
References Specifier.
Referenced by clang::TypoCorrectionConsumer::addNamespaces(), clang::ODRHash::AddNestedNameSpecifier(), clang::Sema::CheckInheritingConstructorUsingDecl(), clang::Sema::CheckTypenameType(), clang::SemaCodeCompletion::CodeCompleteQualifiedId(), clang::Sema::computeDeclContext(), Create(), clang::Sema::DiagnoseEmptyLookup(), clang::Sema::diagnoseQualifiedDeclaration(), getAsRecordDecl(), clang::ASTContext::getCanonicalNestedNameSpecifier(), clang::Sema::getCurrentInstantiationOf(), getDependence(), GetFullTypeForDeclarator(), clang::Sema::getInheritingConstructorName(), clang::UnresolvedMemberExpr::getNamingClass(), getNestedNameSpecifierIdentifiers(), clang::ASTImporter::Import(), isEnableIf(), clang::Sema::isMicrosoftMissingTypename(), isSameQualifier(), IsStructurallyEquivalent(), clang::NestedNameSpecifierLocBuilder::MakeTrivial(), MarkUsedTemplateParameters(), clang::Sema::MatchTemplateParametersToScopeSpecifier(), print(), ScopeSpecifierHasTemplateId(), clang::RecursiveASTVisitor< Derived >::TraverseNestedNameSpecifier(), and clang::serialization::DataStreamBasicWriter< Impl >::writeNestedNameSpecifier().
NestedNameSpecifierDependence NestedNameSpecifier::getDependence | ( | ) | const |
Definition at line 201 of file NestedNameSpecifier.cpp.
References clang::CXXRecordDecl::bases(), getAsType(), getDependence(), getKind(), getPrefix(), Global, Identifier, Namespace, NamespaceAlias, Super, clang::toNestedNameSpecifierDependendence(), TypeSpec, and TypeSpecWithTemplate.
Referenced by containsErrors(), containsUnexpandedParameterPack(), getDependence(), isDependent(), and isInstantiationDependent().
NestedNameSpecifier::SpecifierKind NestedNameSpecifier::getKind | ( | ) | const |
Determine what kind of nested name specifier is stored.
Definition at line 143 of file NestedNameSpecifier.cpp.
References Global, Identifier, Namespace, NamespaceAlias, Super, TypeSpec, and TypeSpecWithTemplate.
Referenced by clang::ODRHash::AddNestedNameSpecifier(), clang::ASTRecordWriter::AddNestedNameSpecifierLoc(), clang::Sema::checkLiteralOperatorId(), clang::Sema::computeDeclContext(), clang::Sema::diagnoseQualifiedDeclaration(), clang::TextNodeDumper::dumpNestedNameSpecifier(), clang::Sema::FindFirstQualifierInScope(), clang::ASTContext::getCanonicalNestedNameSpecifier(), getDependence(), GetFullTypeForDeclarator(), clang::Sema::getInheritingConstructorName(), getNestedNameSpecifierIdentifiers(), clang::ASTImporter::Import(), clang::index::IndexingContext::indexNestedNameSpecifierLoc(), isFullyQualified(), clang::Sema::isMicrosoftMissingTypename(), isSameQualifier(), IsStructurallyEquivalent(), clang::Sema::LookupParsedName(), clang::NestedNameSpecifierLocBuilder::MakeTrivial(), print(), clang::TreeTransform< Derived >::TransformNestedNameSpecifierLoc(), clang::RecursiveASTVisitor< Derived >::TraverseNestedNameSpecifier(), clang::RecursiveASTVisitor< Derived >::TraverseNestedNameSpecifierLoc(), and clang::serialization::DataStreamBasicWriter< Impl >::writeNestedNameSpecifier().
|
inline |
Return the prefix of this nested name specifier.
The prefix contains all of the parts of the nested name specifier that precede this current specifier. For example, for a nested name specifier that represents "foo::bar::", the current specifier will contain "bar::" and the prefix will contain "foo::".
Definition at line 169 of file NestedNameSpecifier.h.
Referenced by clang::ODRHash::AddNestedNameSpecifier(), clang::TextNodeDumper::dumpNestedNameSpecifier(), clang::Sema::FindFirstQualifierInScope(), clang::ASTContext::getCanonicalNestedNameSpecifier(), getDependence(), clang::Sema::getDestructorName(), GetFullTypeForDeclarator(), clang::Sema::getInheritingConstructorName(), getNestedNameSpecifierIdentifiers(), clang::ASTImporter::Import(), isFullyQualified(), isSameQualifier(), IsStructurallyEquivalent(), clang::NestedNameSpecifierLocBuilder::MakeTrivial(), MarkUsedTemplateParameters(), print(), ScopeSpecifierHasTemplateId(), clang::RecursiveASTVisitor< Derived >::TraverseNestedNameSpecifier(), and clang::serialization::DataStreamBasicWriter< Impl >::writeNestedNameSpecifier().
|
static |
Returns the nested name specifier representing the global scope.
Definition at line 126 of file NestedNameSpecifier.cpp.
Referenced by clang::TypeName::createNestedNameSpecifierForScopeOf(), clang::TypeName::createOuterNNS(), clang::ASTImporter::Import(), clang::NestedNameSpecifierLocBuilder::MakeGlobal(), clang::serialization::DataStreamBasicReader< Impl >::readNestedNameSpecifier(), and synthesizeCurrentNestedNameSpecifier().
bool NestedNameSpecifier::isDependent | ( | ) | const |
Whether this nested name specifier refers to a dependent type or not.
Definition at line 234 of file NestedNameSpecifier.cpp.
References getDependence().
Referenced by clang::Sema::ActOnFriendFunctionDecl(), clang::Sema::BuildMemberReferenceExpr(), clang::Sema::CheckTypenameType(), clang::Sema::CheckUsingDeclRedeclaration(), clang::SemaCodeCompletion::CodeCompleteQualifiedId(), clang::Sema::computeDeclContext(), Create(), clang::Sema::getCurrentInstantiationOf(), clang::ASTContext::getDependentTemplateName(), clang::ASTContext::getDependentTemplateSpecializationType(), clang::Sema::isDependentScopeSpecifier(), and clang::TreeTransform< Derived >::RebuildDependentNameType().
bool NestedNameSpecifier::isInstantiationDependent | ( | ) | const |
Whether this nested name specifier involves a template parameter.
Definition at line 238 of file NestedNameSpecifier.cpp.
References getDependence().
|
delete |
void NestedNameSpecifier::print | ( | raw_ostream & | OS, |
const PrintingPolicy & | Policy, | ||
bool | ResolveTemplateArguments = false |
||
) | 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 252 of file NestedNameSpecifier.cpp.
References getAsIdentifier(), getAsNamespace(), getAsNamespaceAlias(), getAsRecordDecl(), getAsType(), getKind(), clang::NamedDecl::getName(), clang::IdentifierInfo::getName(), getPrefix(), Global, Identifier, Namespace, NamespaceAlias, clang::TemplateName::None, print(), clang::QualType::print(), clang::printTemplateArgumentList(), Super, clang::PrintingPolicy::SuppressScope, clang::T, TypeSpec, and TypeSpecWithTemplate.
Referenced by dump(), clang::FormatASTNodeDiagnosticArgument(), clang::TypoCorrection::getAsString(), MaybeAddOverrideCalls(), clang::ConceptReference::print(), print(), PrintMapper(), and printQualifier().
|
inline |
Definition at line 228 of file NestedNameSpecifier.h.
|
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().