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

Inherited from Decl:

Methods

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()

Declared at: clang/include/clang/AST/Decl.h:253

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)

Declared at: clang/include/clang/AST/Decl.h:481

Parameters

clang::Decl::Kind K

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

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

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

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

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

Description

Determines the linkage and visibility of this entity.

Declared at: clang/include/clang/AST/Decl.h:421

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()

Declared at: clang/include/clang/AST/Decl.h:471

const clang::NamedDecl* getMostRecentDecl() const

Declared at: clang/include/clang/AST/Decl.h:474

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

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

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

Declared at: clang/include/clang/AST/Decl.h:478

std::string getQualifiedNameAsString() const

Declared at: clang/include/clang/AST/Decl.h:336

const clang::NamedDecl* getUnderlyingDecl() const

Declared at: clang/include/clang/AST/Decl.h:467

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()

Declared at: clang/include/clang/AST/Decl.h:256

clang::Visibility getVisibility() const

Description

Determines the visibility of this entity.

Declared at: clang/include/clang/AST/Decl.h:416

bool hasExternalFormalLinkage() const

Description

True if this decl has external linkage.

Declared at: clang/include/clang/AST/Decl.h:401

bool hasLinkage() const

Description

Determine whether this declaration has linkage.

Declared at: clang/include/clang/AST/Decl.h:361

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

Description

Determine whether this declaration is a C++ class member.

Declared at: clang/include/clang/AST/Decl.h:367

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

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

Declared at: clang/include/clang/AST/Decl.h:405

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

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

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

llvm::raw_ostream& os

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

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

llvm::raw_ostream& OS

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

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

llvm::raw_ostream& OS

void setDeclName(clang::DeclarationName N)

Description

Set the name of this declaration.

Declared at: clang/include/clang/AST/Decl.h:314

Parameters

clang::DeclarationName N