class DeclRefExpr

Declaration

class DeclRefExpr : public Expr, private TrailingObjects { /* full declaration omitted */ };

Description

A reference to a declared variable, function, enum, etc. [C99 6.5.1p2] This encodes all the information about how a declaration is referenced within an expression. There are several optional constructs attached to DeclRefExprs only when they apply in order to conserve memory. These are laid out past the end of the object, and flags in the DeclRefExprBitfield track whether they exist: DeclRefExprBits.HasQualifier: Specifies when this declaration reference expression has a C++ nested-name-specifier. DeclRefExprBits.HasFoundDecl: Specifies when this declaration reference expression has a record of a NamedDecl (different from the referenced ValueDecl) which was found during name lookup and/or overload resolution. DeclRefExprBits.HasTemplateKWAndArgsInfo: Specifies when this declaration reference expression has an explicit C++ template keyword and/or template argument list. DeclRefExprBits.RefersToEnclosingVariableOrCapture Specifies when this declaration reference expression (validly) refers to an enclosed local or a captured variable.

Declared at: clang/include/clang/AST/Expr.h:1223

Inherits from: Expr, TrailingObjects

Member Variables

private clang::ValueDecl* D
The declaration that we are referencing.
private clang::DeclarationNameLoc DNLoc
Provides source/type location info for the declaration name embedded in D.

Inherited from Stmt:

protected

Method Overview

  • public static clang::DeclRefExpr * Create(const clang::ASTContext & Context, clang::NestedNameSpecifierLoc QualifierLoc, clang::SourceLocation TemplateKWLoc, clang::ValueDecl * D, bool RefersToEnclosingVariableOrCapture, clang::SourceLocation NameLoc, clang::QualType T, clang::ExprValueKind VK, clang::NamedDecl * FoundD = nullptr, const clang::TemplateArgumentListInfo * TemplateArgs = nullptr, clang::NonOdrUseReason NOUR = NOUR_None)
  • public static clang::DeclRefExpr * Create(const clang::ASTContext & Context, clang::NestedNameSpecifierLoc QualifierLoc, clang::SourceLocation TemplateKWLoc, clang::ValueDecl * D, bool RefersToEnclosingVariableOrCapture, const clang::DeclarationNameInfo & NameInfo, clang::QualType T, clang::ExprValueKind VK, clang::NamedDecl * FoundD = nullptr, const clang::TemplateArgumentListInfo * TemplateArgs = nullptr, clang::NonOdrUseReason NOUR = NOUR_None)
  • public static clang::DeclRefExpr * CreateEmpty(const clang::ASTContext & Context, bool HasQualifier, bool HasFoundDecl, bool HasTemplateKWAndArgsInfo, unsigned int NumTemplateArgs)
  • private DeclRefExpr(const clang::ASTContext & Ctx, clang::NestedNameSpecifierLoc QualifierLoc, clang::SourceLocation TemplateKWLoc, clang::ValueDecl * D, bool RefersToEnlosingVariableOrCapture, const clang::DeclarationNameInfo & NameInfo, clang::NamedDecl * FoundD, const clang::TemplateArgumentListInfo * TemplateArgs, clang::QualType T, clang::ExprValueKind VK, clang::NonOdrUseReason NOUR)
  • private DeclRefExpr(clang::Stmt::EmptyShell Empty)
  • public DeclRefExpr(const clang::ASTContext & Ctx, clang::ValueDecl * D, bool RefersToEnclosingVariableOrCapture, clang::QualType T, clang::ExprValueKind VK, clang::SourceLocation L, const clang::DeclarationNameLoc & LocInfo = clang::DeclarationNameLoc(), clang::NonOdrUseReason NOUR = NOUR_None)
  • public clang::Stmt::const_child_range children() const
  • public clang::Stmt::child_range children()
  • public static bool classof(const clang::Stmt * T)
  • public void copyTemplateArgumentsInto(clang::TemplateArgumentListInfo & List) const
  • public clang::SourceLocation getBeginLoc() const
  • public clang::ValueDecl * getDecl()
  • public const clang::ValueDecl * getDecl() const
  • public clang::SourceLocation getEndLoc() const
  • public const clang::NamedDecl * getFoundDecl() const
  • public clang::NamedDecl * getFoundDecl()
  • public clang::SourceLocation getLAngleLoc() const
  • public clang::SourceLocation getLocation() const
  • public clang::DeclarationNameInfo getNameInfo() const
  • public unsigned int getNumTemplateArgs() const
  • public clang::NestedNameSpecifier * getQualifier() const
  • public clang::NestedNameSpecifierLoc getQualifierLoc() const
  • public clang::SourceLocation getRAngleLoc() const
  • public const clang::TemplateArgumentLoc * getTemplateArgs() const
  • public clang::SourceLocation getTemplateKeywordLoc() const
  • public bool hadMultipleCandidates() const
  • public bool hasExplicitTemplateArgs() const
  • private bool hasFoundDecl() const
  • public bool hasQualifier() const
  • public bool hasTemplateKWAndArgsInfo() const
  • public bool hasTemplateKeyword() const
  • public clang::NonOdrUseReason isNonOdrUse() const
  • private size_t numTrailingObjects(OverloadToken<clang::NestedNameSpecifierLoc>) const
  • private size_t numTrailingObjects(OverloadToken<clang::ASTTemplateKWAndArgsInfo>) const
  • private size_t numTrailingObjects(OverloadToken<clang::NamedDecl *>) const
  • public bool refersToEnclosingVariableOrCapture() const
  • public void setDecl(clang::ValueDecl * NewD)
  • public void setHadMultipleCandidates(bool V = true)
  • public void setLocation(clang::SourceLocation L)
  • public ArrayRef<clang::TemplateArgumentLoc> template_arguments() const

Inherited from Expr:

Inherited from ValueStmt:

Inherited from Stmt:

Methods

static clang::DeclRefExpr* Create(
    const clang::ASTContext& Context,
    clang::NestedNameSpecifierLoc QualifierLoc,
    clang::SourceLocation TemplateKWLoc,
    clang::ValueDecl* D,
    bool RefersToEnclosingVariableOrCapture,
    clang::SourceLocation NameLoc,
    clang::QualType T,
    clang::ExprValueKind VK,
    clang::NamedDecl* FoundD = nullptr,
    const clang::TemplateArgumentListInfo*
        TemplateArgs = nullptr,
    clang::NonOdrUseReason NOUR = NOUR_None)

Declared at: clang/include/clang/AST/Expr.h:1273

Parameters

const clang::ASTContext& Context
clang::NestedNameSpecifierLoc QualifierLoc
clang::SourceLocation TemplateKWLoc
clang::ValueDecl* D
bool RefersToEnclosingVariableOrCapture
clang::SourceLocation NameLoc
clang::QualType T
clang::ExprValueKind VK
clang::NamedDecl* FoundD = nullptr
const clang::TemplateArgumentListInfo* TemplateArgs = nullptr
clang::NonOdrUseReason NOUR = NOUR_None

static clang::DeclRefExpr* Create(
    const clang::ASTContext& Context,
    clang::NestedNameSpecifierLoc QualifierLoc,
    clang::SourceLocation TemplateKWLoc,
    clang::ValueDecl* D,
    bool RefersToEnclosingVariableOrCapture,
    const clang::DeclarationNameInfo& NameInfo,
    clang::QualType T,
    clang::ExprValueKind VK,
    clang::NamedDecl* FoundD = nullptr,
    const clang::TemplateArgumentListInfo*
        TemplateArgs = nullptr,
    clang::NonOdrUseReason NOUR = NOUR_None)

Declared at: clang/include/clang/AST/Expr.h:1281

Parameters

const clang::ASTContext& Context
clang::NestedNameSpecifierLoc QualifierLoc
clang::SourceLocation TemplateKWLoc
clang::ValueDecl* D
bool RefersToEnclosingVariableOrCapture
const clang::DeclarationNameInfo& NameInfo
clang::QualType T
clang::ExprValueKind VK
clang::NamedDecl* FoundD = nullptr
const clang::TemplateArgumentListInfo* TemplateArgs = nullptr
clang::NonOdrUseReason NOUR = NOUR_None

static clang::DeclRefExpr* CreateEmpty(
    const clang::ASTContext& Context,
    bool HasQualifier,
    bool HasFoundDecl,
    bool HasTemplateKWAndArgsInfo,
    unsigned int NumTemplateArgs)

Description

Construct an empty declaration reference expression.

Declared at: clang/include/clang/AST/Expr.h:1290

Parameters

const clang::ASTContext& Context
bool HasQualifier
bool HasFoundDecl
bool HasTemplateKWAndArgsInfo
unsigned int NumTemplateArgs

DeclRefExpr(
    const clang::ASTContext& Ctx,
    clang::NestedNameSpecifierLoc QualifierLoc,
    clang::SourceLocation TemplateKWLoc,
    clang::ValueDecl* D,
    bool RefersToEnlosingVariableOrCapture,
    const clang::DeclarationNameInfo& NameInfo,
    clang::NamedDecl* FoundD,
    const clang::TemplateArgumentListInfo*
        TemplateArgs,
    clang::QualType T,
    clang::ExprValueKind VK,
    clang::NonOdrUseReason NOUR)

Declared at: clang/include/clang/AST/Expr.h:1255

Parameters

const clang::ASTContext& Ctx
clang::NestedNameSpecifierLoc QualifierLoc
clang::SourceLocation TemplateKWLoc
clang::ValueDecl* D
bool RefersToEnlosingVariableOrCapture
const clang::DeclarationNameInfo& NameInfo
clang::NamedDecl* FoundD
const clang::TemplateArgumentListInfo* TemplateArgs
clang::QualType T
clang::ExprValueKind VK
clang::NonOdrUseReason NOUR

DeclRefExpr(clang::Stmt::EmptyShell Empty)

Description

Construct an empty declaration reference expression.

Declared at: clang/include/clang/AST/Expr.h:1263

Parameters

clang::Stmt::EmptyShell Empty

DeclRefExpr(
    const clang::ASTContext& Ctx,
    clang::ValueDecl* D,
    bool RefersToEnclosingVariableOrCapture,
    clang::QualType T,
    clang::ExprValueKind VK,
    clang::SourceLocation L,
    const clang::DeclarationNameLoc& LocInfo =
        clang::DeclarationNameLoc(),
    clang::NonOdrUseReason NOUR = NOUR_None)

Declared at: clang/include/clang/AST/Expr.h:1266

Parameters

const clang::ASTContext& Ctx
clang::ValueDecl* D
bool RefersToEnclosingVariableOrCapture
clang::QualType T
clang::ExprValueKind VK
clang::SourceLocation L
const clang::DeclarationNameLoc& LocInfo = clang::DeclarationNameLoc()
clang::NonOdrUseReason NOUR = NOUR_None

clang::Stmt::const_child_range children() const

Declared at: clang/include/clang/AST/Expr.h:1438

clang::Stmt::child_range children()

Declared at: clang/include/clang/AST/Expr.h:1434

static bool classof(const clang::Stmt* T)

Declared at: clang/include/clang/AST/Expr.h:1429

Parameters

const clang::Stmt* T

void copyTemplateArgumentsInto(
    clang::TemplateArgumentListInfo& List) const

Description

Copies the template arguments (if present) into the given structure.

Declared at: clang/include/clang/AST/Expr.h:1380

Parameters

clang::TemplateArgumentListInfo& List

clang::SourceLocation getBeginLoc() const

Declared at: clang/include/clang/AST/Expr.h:1305

clang::ValueDecl* getDecl()

Declared at: clang/include/clang/AST/Expr.h:1295

const clang::ValueDecl* getDecl() const

Declared at: clang/include/clang/AST/Expr.h:1296

clang::SourceLocation getEndLoc() const

Declared at: clang/include/clang/AST/Expr.h:1306

const clang::NamedDecl* getFoundDecl() const

Description

Get the NamedDecl through which this reference occurred. See non-const variant.

Declared at: clang/include/clang/AST/Expr.h:1338

clang::NamedDecl* getFoundDecl()

Description

Get the NamedDecl through which this reference occurred. This Decl may be different from the ValueDecl actually referred to in the presence of using declarations, etc. It always returns non-NULL, and may simple return the ValueDecl when appropriate.

Declared at: clang/include/clang/AST/Expr.h:1332

clang::SourceLocation getLAngleLoc() const

Description

Retrieve the location of the left angle bracket starting the explicit template argument list following the name, if any.

Declared at: clang/include/clang/AST/Expr.h:1356

clang::SourceLocation getLocation() const

Declared at: clang/include/clang/AST/Expr.h:1303

clang::DeclarationNameInfo getNameInfo() const

Declared at: clang/include/clang/AST/Expr.h:1299

unsigned int getNumTemplateArgs() const

Description

Retrieve the number of template arguments provided as part of this template-id.

Declared at: clang/include/clang/AST/Expr.h:1396

clang::NestedNameSpecifier* getQualifier() const

Description

If the name was qualified, retrieves the nested-name-specifier that precedes the name. Otherwise, returns NULL.

Declared at: clang/include/clang/AST/Expr.h:1322

clang::NestedNameSpecifierLoc getQualifierLoc()
    const

Description

If the name was qualified, retrieves the nested-name-specifier that precedes the name, with source-location information.

Declared at: clang/include/clang/AST/Expr.h:1314

clang::SourceLocation getRAngleLoc() const

Description

Retrieve the location of the right angle bracket ending the explicit template argument list following the name, if any.

Declared at: clang/include/clang/AST/Expr.h:1364

const clang::TemplateArgumentLoc*
getTemplateArgs() const

Description

Retrieve the template arguments provided as part of this template-id.

Declared at: clang/include/clang/AST/Expr.h:1388

clang::SourceLocation getTemplateKeywordLoc()
    const

Description

Retrieve the location of the template keyword preceding this name, if any.

Declared at: clang/include/clang/AST/Expr.h:1348

bool hadMultipleCandidates() const

Description

Returns true if this expression refers to a function that was resolved from an overloaded set having size greater than 1.

Declared at: clang/include/clang/AST/Expr.h:1408

bool hasExplicitTemplateArgs() const

Description

Determines whether this declaration reference was followed by an explicit template argument list.

Declared at: clang/include/clang/AST/Expr.h:1376

bool hasFoundDecl() const

Description

Test whether there is a distinct FoundDecl attached to the end of this DRE.

Declared at: clang/include/clang/AST/Expr.h:1253

bool hasQualifier() const

Description

Determine whether this declaration reference was preceded by a C++ nested-name-specifier, e.g., \c N::foo.

Declared at: clang/include/clang/AST/Expr.h:1310

bool hasTemplateKWAndArgsInfo() const

Declared at: clang/include/clang/AST/Expr.h:1342

bool hasTemplateKeyword() const

Description

Determines whether the name in this declaration reference was preceded by the template keyword.

Declared at: clang/include/clang/AST/Expr.h:1372

clang::NonOdrUseReason isNonOdrUse() const

Description

Is this expression a non-odr-use reference, and if so, why?

Declared at: clang/include/clang/AST/Expr.h:1419

size_t numTrailingObjects(
    OverloadToken<clang::NestedNameSpecifierLoc>)
    const

Declared at: clang/include/clang/AST/Expr.h:1239

Parameters

OverloadToken<clang::NestedNameSpecifierLoc>

size_t numTrailingObjects(
    OverloadToken<
        clang::ASTTemplateKWAndArgsInfo>) const

Declared at: clang/include/clang/AST/Expr.h:1247

Parameters

OverloadToken<clang::ASTTemplateKWAndArgsInfo>

size_t numTrailingObjects(
    OverloadToken<clang::NamedDecl*>) const

Declared at: clang/include/clang/AST/Expr.h:1243

Parameters

OverloadToken<clang::NamedDecl*>

bool refersToEnclosingVariableOrCapture() const

Description

Does this DeclRefExpr refer to an enclosing local or a captured variable?

Declared at: clang/include/clang/AST/Expr.h:1425

void setDecl(clang::ValueDecl* NewD)

Declared at: clang/include/clang/AST/Expr.h:1297

Parameters

clang::ValueDecl* NewD

void setHadMultipleCandidates(bool V = true)

Description

Sets the flag telling whether this expression refers to a function that was resolved from an overloaded set having size greater than 1.

Declared at: clang/include/clang/AST/Expr.h:1414

Parameters

bool V = true

void setLocation(clang::SourceLocation L)

Declared at: clang/include/clang/AST/Expr.h:1304

Parameters

clang::SourceLocation L

ArrayRef<clang::TemplateArgumentLoc>
template_arguments() const

Declared at: clang/include/clang/AST/Expr.h:1402