class NamedDecl
Declaration
class NamedDecl : public Decl { /* full declaration omitted */ };
Description
This represents a decl that may have a name. Many decls have names such as ObjCMethodDecl, but not @ class, etc. Note that not every NamedDecl is actually named (e.g., a struct might be anonymous), and not every name is an identifier.
Declared at: clang/include/clang/AST/Decl.h:247
Inherits from: Decl
Member Variables
- private clang::DeclarationName Name
- The name of this declaration, which is typically a normal identifier but may also be a special kind of name (C++ constructor, Objective-C selector, etc.)
Inherited from Decl:
- protected NextInContextAndBits
- protected Access
- protected FromASTFile
- protected IdentifierNamespace
- protected CacheValidAndLinkage
Method Overview
- protected NamedDecl(clang::Decl::Kind DK, clang::DeclContext * DC, clang::SourceLocation L, clang::DeclarationName N)
- private virtual void anchor()
- public static bool classof(const clang::Decl * D)
- public static bool classofKind(clang::Decl::Kind K)
- public bool declarationReplaces(clang::NamedDecl * OldD, bool IsKnownNewer = true) const
- public clang::DeclarationName getDeclName() const
- public Optional<clang::Visibility> getExplicitVisibility(clang::NamedDecl::ExplicitVisibilityKind kind) const
- public clang::Linkage getFormalLinkage() const
- public clang::IdentifierInfo * getIdentifier() const
- public clang::LinkageInfo getLinkageAndVisibility() const
- public clang::Linkage getLinkageInternal() const
- public clang::NamedDecl * getMostRecentDecl()
- public const clang::NamedDecl * getMostRecentDecl() const
- public llvm::StringRef getName() const
- public std::string getNameAsString() const
- public virtual void getNameForDiagnostic(llvm::raw_ostream & OS, const clang::PrintingPolicy & Policy, bool Qualified) const
- public clang::ObjCStringFormatFamily getObjCFStringFormattingFamily() const
- public std::string getQualifiedNameAsString() const
- public const clang::NamedDecl * getUnderlyingDecl() const
- public clang::NamedDecl * getUnderlyingDecl()
- private clang::NamedDecl * getUnderlyingDeclImpl()
- public clang::Visibility getVisibility() const
- public bool hasExternalFormalLinkage() const
- public bool hasLinkage() const
- public bool hasLinkageBeenComputed() const
- public bool isCXXClassMember() const
- public bool isCXXInstanceMember() const
- public bool isExternallyDeclarable() const
- public bool isExternallyVisible() const
- public bool isLinkageValid() const
- public clang::ReservedIdentifierStatus isReserved(const clang::LangOptions & LangOpts) const
- public virtual void printName(llvm::raw_ostream & os) const
- public void printNestedNameSpecifier(llvm::raw_ostream & OS, const clang::PrintingPolicy & Policy) const
- public void printNestedNameSpecifier(llvm::raw_ostream & OS) const
- public void printQualifiedName(llvm::raw_ostream & OS, const clang::PrintingPolicy & Policy) const
- public void printQualifiedName(llvm::raw_ostream & OS) const
- public void setDeclName(clang::DeclarationName N)
Inherited from Decl:
- public EnableStatistics
- public PrintStats
- public add
- public addAttr
- public attr_begin
- public attr_end
- public attrs
- public canBeWeakImported
- public castFromDeclContext
- public castToDeclContext
- public classofKind
- public dropAttr
- public dropAttrs
- public dump
- public dump
- public dumpColor
- public getASTContext
- protected getASTMutationListener
- public getAccess
- public getAccessUnsafe
- public getAsFunction
- public getAsFunction
- public getAttr
- public getAttrs
- public getAttrs
- public getAvailability
- public getBeginLoc
- public getBody
- public getBodyRBrace
- protected getCachedLinkage
- public getCanonicalDecl
- public getCanonicalDecl
- public getDeclContext
- public getDeclContext
- public getDeclKindName
- public getDefiningAttr
- public getDescribedTemplate
- public getDescribedTemplateParams
- public getEndLoc
- public getExternalSourceSymbolAttr
- public getFriendObjectKind
- public getFunctionType
- public getGlobalID
- public getID
- public getIdentifierNamespace
- public getIdentifierNamespaceForKind
- public getImportedOwningModule
- public getKind
- public getLangOpts
- public getLexicalDeclContext
- public getLexicalDeclContext
- public getLocalOwningModule
- public getLocation
- public getMaxAlignment
- public getModuleOwnershipKind
- public getMostRecentDecl
- public getMostRecentDecl
- protected getMostRecentDeclImpl
- public getNextDeclInContext
- public getNextDeclInContext
- protected getNextRedeclarationImpl
- public getNonClosureContext
- public getNonClosureContext
- public getOwningModule
- public getOwningModuleForLinkage
- public getOwningModuleID
- public getParentFunctionOrMethod
- public getParentFunctionOrMethod
- public getPreviousDecl
- public getPreviousDecl
- protected getPreviousDeclImpl
- public getSourceRange
- public getTemplateDepth
- public getTranslationUnitDecl
- public getTranslationUnitDecl
- public getVersionIntroduced
- public hasAttr
- public hasAttrs
- public hasBody
- protected hasCachedLinkage
- public hasDefiningAttr
- protected hasLocalOwningModuleStorage
- public hasOwningModule
- public hasTagIdentifierNamespace
- public isCanonicalDecl
- public isDefinedOutsideFunctionOrMethod
- public isDeprecated
- public isDiscardedInGlobalModuleFragment
- public isFirstDecl
- public isFromASTFile
- public isFunctionOrFunctionTemplate
- public isImplicit
- public isInAnonymousNamespace
- public isInExportDeclContext
- public isInIdentifierNamespace
- public isInLocalScopeForInstantiation
- public isInStdNamespace
- public isInvalidDecl
- public isInvisibleOutsideTheOwningModule
- public isLocalExternDecl
- public isModulePrivate
- public isOutOfLine
- public isParameterPack
- public isReachable
- public isReferenced
- public isTagIdentifierNamespace
- public isTemplateDecl
- public isTemplateParameter
- public isTemplateParameterPack
- public isTemplated
- public isThisDeclarationReferenced
- public isTopLevelDeclInObjCContainer
- public isUnavailable
- public isUnconditionallyVisible
- public isUsed
- public isWeakImported
- public markUsed
- public print
- public print
- public printGroup
- public redecls
- public redecls_begin
- public redecls_end
- public setAccess
- public setAttrs
- protected setCachedLinkage
- public setDeclContext
- public setFromASTFile
- public setImplicit
- public setInvalidDecl
- public setIsUsed
- public setLexicalDeclContext
- public setLocalExternDecl
- public setLocalOwningModule
- public setLocation
- public setModuleOwnershipKind
- protected setModulePrivate
- public setNonMemberOperator
- public setObjectOfFriendDecl
- public setOwningModuleID
- public setReferenced
- public setTopLevelDeclInObjCContainer
- public setVisibleDespiteOwningModule
- public specific_attr_begin
- public specific_attr_end
- public specific_attrs
- protected updateOutOfDate
Methods
¶NamedDecl(clang::Decl::Kind DK,
clang::DeclContext* DC,
clang::SourceLocation L,
clang::DeclarationName N)
NamedDecl(clang::Decl::Kind DK,
clang::DeclContext* DC,
clang::SourceLocation L,
clang::DeclarationName N)
Declared at: clang/include/clang/AST/Decl.h:259
Parameters
- clang::Decl::Kind DK
- clang::DeclContext* DC
- clang::SourceLocation L
- clang::DeclarationName N
¶virtual void anchor()
virtual void anchor()
Declared at: clang/include/clang/AST/Decl.h:253
¶static bool classof(const clang::Decl* D)
static bool classof(const clang::Decl* D)
Declared at: clang/include/clang/AST/Decl.h:480
Parameters
- const clang::Decl* D
¶static bool classofKind(clang::Decl::Kind K)
static bool classofKind(clang::Decl::Kind K)
Declared at: clang/include/clang/AST/Decl.h:481
Parameters
- clang::Decl::Kind K
¶bool declarationReplaces(
clang::NamedDecl* OldD,
bool IsKnownNewer = true) const
bool declarationReplaces(
clang::NamedDecl* OldD,
bool IsKnownNewer = true) const
Description
Determine whether this declaration, if known to be well-formed within its context, will replace the declaration OldD if introduced into scope. A declaration will replace another declaration if, for example, it is a redeclaration of the same variable or function, but not if it is a declaration of a different kind (function vs. class) or an overloaded function.
Declared at: clang/include/clang/AST/Decl.h:358
Parameters
- clang::NamedDecl* OldD
- bool IsKnownNewer = true
- \c true if this declaration is known to be newer than \p OldD (for instance, if this declaration is newly-created).
¶clang::DeclarationName getDeclName() const
clang::DeclarationName getDeclName() const
Description
Get the actual, stored name of the declaration, which may be a special name. Note that generally in diagnostics, the non-null \p NamedDecl* itself should be sent into the diagnostic instead of using the result of\p getDeclName(). A \p DeclarationName in a diagnostic will just be streamed to the output, which will directly result in a call to \p DeclarationName::print. A \p NamedDecl* in a diagnostic will also ultimately result in a call to\p DeclarationName::print, but with two customisation points along the way (\p getNameForDiagnostic and \p printName). These are used to print the template arguments if any, and to provide a user-friendly name for some entities (such as unnamed variables and anonymous records).
Declared at: clang/include/clang/AST/Decl.h:311
¶Optional<clang::Visibility> getExplicitVisibility(
clang::NamedDecl::ExplicitVisibilityKind kind)
const
Optional<clang::Visibility> getExplicitVisibility(
clang::NamedDecl::ExplicitVisibilityKind kind)
const
Description
If visibility was explicitly specified for this declaration, return that visibility.
Declared at: clang/include/clang/AST/Decl.h:439
Parameters
- clang::NamedDecl::ExplicitVisibilityKind kind
¶clang::Linkage getFormalLinkage() const
clang::Linkage getFormalLinkage() const
Description
Get the linkage from a semantic point of view. Entities in anonymous namespaces are external (in c++98).
Declared at: clang/include/clang/AST/Decl.h:396
¶clang::IdentifierInfo* getIdentifier() const
clang::IdentifierInfo* getIdentifier() const
Description
Get the identifier that names this declaration, if there is one. This will return NULL if this declaration has no name (e.g., for an unnamed class) or if the name is a special name (C++ constructor, Objective-C selector, etc.).
Declared at: clang/include/clang/AST/Decl.h:268
¶clang::LinkageInfo getLinkageAndVisibility() const
clang::LinkageInfo getLinkageAndVisibility() const
Description
Determines the linkage and visibility of this entity.
Declared at: clang/include/clang/AST/Decl.h:421
¶clang::Linkage getLinkageInternal() const
clang::Linkage getLinkageInternal() const
Description
Determine what kind of linkage this entity has. This is not the linkage as defined by the standard or the codegen notion of linkage. It is just an implementation detail that is used to compute those.
Declared at: clang/include/clang/AST/Decl.h:392
¶clang::NamedDecl* getMostRecentDecl()
clang::NamedDecl* getMostRecentDecl()
Declared at: clang/include/clang/AST/Decl.h:471
¶const clang::NamedDecl* getMostRecentDecl() const
const clang::NamedDecl* getMostRecentDecl() const
Declared at: clang/include/clang/AST/Decl.h:474
¶llvm::StringRef getName() const
llvm::StringRef getName() const
Description
Get the name of identifier for this declaration as a StringRef. This requires that the declaration have a name and that it be a simple identifier.
Declared at: clang/include/clang/AST/Decl.h:274
¶std::string getNameAsString() const
std::string getNameAsString() const
Description
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ constructor, Objective-C selector, etc). Creating this name requires expensive string manipulation, so it should be called only when performance doesn't matter. For simple declarations, getNameAsCString() should suffice.
Declared at: clang/include/clang/AST/Decl.h:290
¶virtual void getNameForDiagnostic(
llvm::raw_ostream& OS,
const clang::PrintingPolicy& Policy,
bool Qualified) const
virtual void getNameForDiagnostic(
llvm::raw_ostream& OS,
const clang::PrintingPolicy& Policy,
bool Qualified) const
Description
Appends a human-readable name for this declaration into the given stream. This is the method invoked by Sema when displaying a NamedDecl in a diagnostic. It does not necessarily produce the same result as printName(); for example, class template specializations are printed with their template arguments.
Declared at: clang/include/clang/AST/Decl.h:344
Parameters
- llvm::raw_ostream& OS
- const clang::PrintingPolicy& Policy
- bool Qualified
¶clang::ObjCStringFormatFamily
getObjCFStringFormattingFamily() const
clang::ObjCStringFormatFamily
getObjCFStringFormattingFamily() const
Declared at: clang/include/clang/AST/Decl.h:478
¶std::string getQualifiedNameAsString() const
std::string getQualifiedNameAsString() const
Declared at: clang/include/clang/AST/Decl.h:336
¶const clang::NamedDecl* getUnderlyingDecl() const
const clang::NamedDecl* getUnderlyingDecl() const
Declared at: clang/include/clang/AST/Decl.h:467
¶clang::NamedDecl* getUnderlyingDecl()
clang::NamedDecl* getUnderlyingDecl()
Description
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Declared at: clang/include/clang/AST/Decl.h:457
¶clang::NamedDecl* getUnderlyingDeclImpl()
clang::NamedDecl* getUnderlyingDeclImpl()
Declared at: clang/include/clang/AST/Decl.h:256
¶clang::Visibility getVisibility() const
clang::Visibility getVisibility() const
Description
Determines the visibility of this entity.
Declared at: clang/include/clang/AST/Decl.h:416
¶bool hasExternalFormalLinkage() const
bool hasExternalFormalLinkage() const
Description
True if this decl has external linkage.
Declared at: clang/include/clang/AST/Decl.h:401
¶bool hasLinkage() const
bool hasLinkage() const
Description
Determine whether this declaration has linkage.
Declared at: clang/include/clang/AST/Decl.h:361
¶bool hasLinkageBeenComputed() const
bool hasLinkageBeenComputed() const
Description
True if something has required us to compute the linkage of this declaration. Language features which can retroactively change linkage (like a typedef name for linkage purposes) may need to consider this, but hopefully only in transitory ways during parsing.
Declared at: clang/include/clang/AST/Decl.h:451
¶bool isCXXClassMember() const
bool isCXXClassMember() const
Description
Determine whether this declaration is a C++ class member.
Declared at: clang/include/clang/AST/Decl.h:367
¶bool isCXXInstanceMember() const
bool isCXXInstanceMember() const
Description
Determine whether the given declaration is an instance member of a C++ class.
Declared at: clang/include/clang/AST/Decl.h:381
¶bool isExternallyDeclarable() const
bool isExternallyDeclarable() const
Description
Determine whether this declaration can be redeclared in a different translation unit.
Declared at: clang/include/clang/AST/Decl.h:411
¶bool isExternallyVisible() const
bool isExternallyVisible() const
Declared at: clang/include/clang/AST/Decl.h:405
¶bool isLinkageValid() const
bool isLinkageValid() const
Description
True if the computed linkage is valid. Used for consistency checking. Should always return true.
Declared at: clang/include/clang/AST/Decl.h:443
¶clang::ReservedIdentifierStatus isReserved(
const clang::LangOptions& LangOpts) const
clang::ReservedIdentifierStatus isReserved(
const clang::LangOptions& LangOpts) const
Description
Determine if the declaration obeys the reserved identifier rules of the given language.
Declared at: clang/include/clang/AST/Decl.h:385
Parameters
- const clang::LangOptions& LangOpts
¶virtual void printName(
llvm::raw_ostream& os) const
virtual void printName(
llvm::raw_ostream& os) const
Description
Pretty-print the unqualified name of this declaration. Can be overloaded by derived classes to provide a more user-friendly name when appropriate.
Declared at: clang/include/clang/AST/Decl.h:294
Parameters
¶void printNestedNameSpecifier(
llvm::raw_ostream& OS,
const clang::PrintingPolicy& Policy) const
void printNestedNameSpecifier(
llvm::raw_ostream& OS,
const clang::PrintingPolicy& Policy) const
Declared at: clang/include/clang/AST/Decl.h:332
Parameters
- llvm::raw_ostream& OS
- const clang::PrintingPolicy& Policy
¶void printNestedNameSpecifier(
llvm::raw_ostream& OS) const
void printNestedNameSpecifier(
llvm::raw_ostream& OS) const
Description
Print only the nested name specifier part of a fully-qualified name, including the '::' at the end. E.g. when `printQualifiedName(D)` prints "A::B::i", this function prints "A::B::".
Declared at: clang/include/clang/AST/Decl.h:331
Parameters
¶void printQualifiedName(
llvm::raw_ostream& OS,
const clang::PrintingPolicy& Policy) const
void printQualifiedName(
llvm::raw_ostream& OS,
const clang::PrintingPolicy& Policy) const
Declared at: clang/include/clang/AST/Decl.h:325
Parameters
- llvm::raw_ostream& OS
- const clang::PrintingPolicy& Policy
¶void printQualifiedName(
llvm::raw_ostream& OS) const
void printQualifiedName(
llvm::raw_ostream& OS) const
Description
Returns a human-readable qualified name for this declaration, like A::B::i, for i being member of namespace A::B. If the declaration is not a member of context which can be named (record, namespace), it will return the same result as printName(). Creating this name is expensive, so it should be called only when performance doesn't matter.
Declared at: clang/include/clang/AST/Decl.h:324
Parameters
¶void setDeclName(clang::DeclarationName N)
void setDeclName(clang::DeclarationName N)
Description
Set the name of this declaration.
Declared at: clang/include/clang/AST/Decl.h:314