clang API Documentation

Public Member Functions | Static Public Member Functions | Friends
clang::DeclRefExpr Class Reference

A reference to a declared variable, function, enum, etc. [C99 6.5.1p2]. More...

#include <Expr.h>

Inheritance diagram for clang::DeclRefExpr:
Inheritance graph
[legend]
Collaboration diagram for clang::DeclRefExpr:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 DeclRefExpr (ValueDecl *D, QualType T, ExprValueKind VK, SourceLocation L, const DeclarationNameLoc &LocInfo=DeclarationNameLoc())
ValueDeclgetDecl ()
const ValueDeclgetDecl () const
void setDecl (ValueDecl *NewD)
DeclarationNameInfo getNameInfo () const
SourceLocation getLocation () const
void setLocation (SourceLocation L)
SourceRange getSourceRange () const
bool hasQualifier () const
 Determine whether this declaration reference was preceded by a C++ nested-name-specifier, e.g., N::foo.
NestedNameSpecifiergetQualifier () const
 If the name was qualified, retrieves the nested-name-specifier that precedes the name. Otherwise, returns NULL.
NestedNameSpecifierLoc getQualifierLoc () const
 If the name was qualified, retrieves the nested-name-specifier that precedes the name, with source-location information.
NamedDeclgetFoundDecl ()
 Get the NamedDecl through which this reference occured.
const NamedDeclgetFoundDecl () const
 Get the NamedDecl through which this reference occurred. See non-const variant.
bool hasTemplateKWAndArgsInfo () const
ASTTemplateKWAndArgsInfogetTemplateKWAndArgsInfo ()
 Return the optional template keyword and arguments info.
const ASTTemplateKWAndArgsInfogetTemplateKWAndArgsInfo () const
 Return the optional template keyword and arguments info.
SourceLocation getTemplateKeywordLoc () const
 Retrieve the location of the template keyword preceding this name, if any.
SourceLocation getLAngleLoc () const
 Retrieve the location of the left angle bracket starting the explicit template argument list following the name, if any.
SourceLocation getRAngleLoc () const
 Retrieve the location of the right angle bracket ending the explicit template argument list following the name, if any.
bool hasTemplateKeyword () const
 Determines whether the name in this declaration reference was preceded by the template keyword.
bool hasExplicitTemplateArgs () const
 Determines whether this declaration reference was followed by an explicit template argument list.
ASTTemplateArgumentListInfogetExplicitTemplateArgs ()
 Retrieve the explicit template argument list that followed the member template name.
const ASTTemplateArgumentListInfogetExplicitTemplateArgs () const
 Retrieve the explicit template argument list that followed the member template name.
const ASTTemplateArgumentListInfogetOptionalExplicitTemplateArgs () const
 Retrieves the optional explicit template arguments. This points to the same data as getExplicitTemplateArgs(), but returns null if there are no explicit template arguments.
void copyTemplateArgumentsInto (TemplateArgumentListInfo &List) const
 Copies the template arguments (if present) into the given structure.
const TemplateArgumentLocgetTemplateArgs () const
 Retrieve the template arguments provided as part of this template-id.
unsigned getNumTemplateArgs () const
 Retrieve the number of template arguments provided as part of this template-id.
bool hadMultipleCandidates () const
 Returns true if this expression refers to a function that was resolved from an overloaded set having size greater than 1.
void setHadMultipleCandidates (bool V=true)
 Sets the flag telling whether this expression refers to a function that was resolved from an overloaded set having size greater than 1.
child_range children ()

Static Public Member Functions

static DeclRefExprCreate (ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=0, const TemplateArgumentListInfo *TemplateArgs=0)
static DeclRefExprCreate (ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, const DeclarationNameInfo &NameInfo, QualType T, ExprValueKind VK, NamedDecl *FoundD=0, const TemplateArgumentListInfo *TemplateArgs=0)
static DeclRefExprCreateEmpty (ASTContext &Context, bool HasQualifier, bool HasFoundDecl, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
 Construct an empty declaration reference expression.
static bool classof (const Stmt *T)
static bool classof (const DeclRefExpr *)

Friends

class ASTStmtReader
class ASTStmtWriter

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

Definition at line 758 of file Expr.h.


Constructor & Destructor Documentation

clang::DeclRefExpr::DeclRefExpr ( ValueDecl D,
QualType  T,
ExprValueKind  VK,
SourceLocation  L,
const DeclarationNameLoc LocInfo = DeclarationNameLoc() 
) [inline]

Definition at line 815 of file Expr.h.

References clang::Stmt::DeclRefExprBits.


Member Function Documentation

child_range clang::DeclRefExpr::children ( ) [inline]

Reimplemented from clang::Stmt.

Definition at line 1018 of file Expr.h.

static bool clang::DeclRefExpr::classof ( const Stmt T) [inline, static]

Reimplemented from clang::Expr.

Definition at line 1012 of file Expr.h.

References clang::Stmt::getStmtClass().

static bool clang::DeclRefExpr::classof ( const DeclRefExpr ) [inline, static]

Definition at line 1015 of file Expr.h.

void clang::DeclRefExpr::copyTemplateArgumentsInto ( TemplateArgumentListInfo List) const [inline]

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

Definition at line 977 of file Expr.h.

References clang::ASTTemplateArgumentListInfo::copyInto(), getExplicitTemplateArgs(), and hasExplicitTemplateArgs().

DeclRefExpr * DeclRefExpr::Create ( ASTContext Context,
NestedNameSpecifierLoc  QualifierLoc,
SourceLocation  TemplateKWLoc,
ValueDecl D,
SourceLocation  NameLoc,
QualType  T,
ExprValueKind  VK,
NamedDecl FoundD = 0,
const TemplateArgumentListInfo TemplateArgs = 0 
) [static]
DeclRefExpr * DeclRefExpr::Create ( ASTContext Context,
NestedNameSpecifierLoc  QualifierLoc,
SourceLocation  TemplateKWLoc,
ValueDecl D,
const DeclarationNameInfo NameInfo,
QualType  T,
ExprValueKind  VK,
NamedDecl FoundD = 0,
const TemplateArgumentListInfo TemplateArgs = 0 
) [static]
DeclRefExpr * DeclRefExpr::CreateEmpty ( ASTContext Context,
bool  HasQualifier,
bool  HasFoundDecl,
bool  HasTemplateKWAndArgsInfo,
unsigned  NumTemplateArgs 
) [static]

Construct an empty declaration reference expression.

Definition at line 336 of file Expr.cpp.

References clang::ASTContext::Allocate(), and clang::ASTTemplateKWAndArgsInfo::sizeFor().

ValueDecl* clang::DeclRefExpr::getDecl ( ) [inline]
const ValueDecl* clang::DeclRefExpr::getDecl ( ) const [inline]

Definition at line 852 of file Expr.h.

ASTTemplateArgumentListInfo& clang::DeclRefExpr::getExplicitTemplateArgs ( ) [inline]

Retrieve the explicit template argument list that followed the member template name.

Definition at line 956 of file Expr.h.

References getTemplateKWAndArgsInfo(), and hasExplicitTemplateArgs().

Referenced by copyTemplateArgumentsInto(), getExplicitTemplateArgs(), getNumTemplateArgs(), getOptionalExplicitTemplateArgs(), and getTemplateArgs().

const ASTTemplateArgumentListInfo& clang::DeclRefExpr::getExplicitTemplateArgs ( ) const [inline]

Retrieve the explicit template argument list that followed the member template name.

Definition at line 963 of file Expr.h.

References getExplicitTemplateArgs().

NamedDecl* clang::DeclRefExpr::getFoundDecl ( ) [inline]

Get the NamedDecl through which this reference occured.

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.

Definition at line 890 of file Expr.h.

Referenced by clang::ASTNodeImporter::VisitDeclRefExpr().

const NamedDecl* clang::DeclRefExpr::getFoundDecl ( ) const [inline]

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

Definition at line 896 of file Expr.h.

SourceLocation clang::DeclRefExpr::getLAngleLoc ( ) const [inline]

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

Definition at line 934 of file Expr.h.

References getTemplateKWAndArgsInfo(), hasTemplateKWAndArgsInfo(), and clang::ASTTemplateArgumentListInfo::LAngleLoc.

Referenced by hasExplicitTemplateArgs().

SourceLocation clang::DeclRefExpr::getLocation ( ) const [inline]
DeclarationNameInfo clang::DeclRefExpr::getNameInfo ( ) const [inline]

Definition at line 855 of file Expr.h.

References getDecl().

Referenced by getSourceRange().

unsigned clang::DeclRefExpr::getNumTemplateArgs ( ) const [inline]

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

Definition at line 993 of file Expr.h.

References getExplicitTemplateArgs(), hasExplicitTemplateArgs(), and clang::ASTTemplateArgumentListInfo::NumTemplateArgs.

const ASTTemplateArgumentListInfo* clang::DeclRefExpr::getOptionalExplicitTemplateArgs ( ) const [inline]

Retrieves the optional explicit template arguments. This points to the same data as getExplicitTemplateArgs(), but returns null if there are no explicit template arguments.

Definition at line 970 of file Expr.h.

References getExplicitTemplateArgs(), and hasExplicitTemplateArgs().

NestedNameSpecifier* clang::DeclRefExpr::getQualifier ( ) const [inline]

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

Definition at line 869 of file Expr.h.

References clang::NestedNameSpecifierLoc::getNestedNameSpecifier(), and hasQualifier().

Referenced by CheckAddressOfOperand(), and clang::Sema::CheckTemplateArgumentPointerToMember().

NestedNameSpecifierLoc clang::DeclRefExpr::getQualifierLoc ( ) const [inline]

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

Definition at line 878 of file Expr.h.

References hasQualifier().

Referenced by getSourceRange(), and clang::ASTNodeImporter::VisitDeclRefExpr().

SourceLocation clang::DeclRefExpr::getRAngleLoc ( ) const [inline]

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

Definition at line 941 of file Expr.h.

References getTemplateKWAndArgsInfo(), hasTemplateKWAndArgsInfo(), and clang::ASTTemplateArgumentListInfo::RAngleLoc.

Referenced by getSourceRange().

SourceRange DeclRefExpr::getSourceRange ( ) const

SourceLocation tokens are not useful in isolation - they are low level value objects created/interpreted by SourceManager. We assume AST clients will have a pointer to the respective SourceManager.

Reimplemented from clang::Stmt.

Definition at line 353 of file Expr.cpp.

References getNameInfo(), getQualifierLoc(), getRAngleLoc(), clang::DeclarationNameInfo::getSourceRange(), hasExplicitTemplateArgs(), hasQualifier(), clang::SourceRange::setBegin(), and clang::SourceRange::setEnd().

const TemplateArgumentLoc* clang::DeclRefExpr::getTemplateArgs ( ) const [inline]

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

Definition at line 984 of file Expr.h.

References getExplicitTemplateArgs(), clang::ASTTemplateArgumentListInfo::getTemplateArgs(), and hasExplicitTemplateArgs().

SourceLocation clang::DeclRefExpr::getTemplateKeywordLoc ( ) const [inline]

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

Definition at line 927 of file Expr.h.

References clang::ASTTemplateKWAndArgsInfo::getTemplateKeywordLoc(), getTemplateKWAndArgsInfo(), and hasTemplateKWAndArgsInfo().

Referenced by hasTemplateKeyword(), and clang::ASTNodeImporter::VisitDeclRefExpr().

ASTTemplateKWAndArgsInfo* clang::DeclRefExpr::getTemplateKWAndArgsInfo ( ) [inline]

Return the optional template keyword and arguments info.

Definition at line 905 of file Expr.h.

References hasQualifier(), and hasTemplateKWAndArgsInfo().

Referenced by getExplicitTemplateArgs(), getLAngleLoc(), getRAngleLoc(), getTemplateKeywordLoc(), and getTemplateKWAndArgsInfo().

const ASTTemplateKWAndArgsInfo* clang::DeclRefExpr::getTemplateKWAndArgsInfo ( ) const [inline]

Return the optional template keyword and arguments info.

Definition at line 921 of file Expr.h.

References getTemplateKWAndArgsInfo().

bool clang::DeclRefExpr::hadMultipleCandidates ( ) const [inline]

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

Definition at line 1002 of file Expr.h.

References clang::Stmt::DeclRefExprBits.

Referenced by clang::ASTNodeImporter::VisitDeclRefExpr().

bool clang::DeclRefExpr::hasExplicitTemplateArgs ( ) const [inline]

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

Definition at line 952 of file Expr.h.

References getLAngleLoc(), and clang::SourceLocation::isValid().

Referenced by copyTemplateArgumentsInto(), getExplicitTemplateArgs(), getNumTemplateArgs(), getOptionalExplicitTemplateArgs(), getSourceRange(), and getTemplateArgs().

bool clang::DeclRefExpr::hasQualifier ( ) const [inline]

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

Definition at line 865 of file Expr.h.

References clang::Stmt::DeclRefExprBits.

Referenced by getQualifier(), getQualifierLoc(), getSourceRange(), and getTemplateKWAndArgsInfo().

bool clang::DeclRefExpr::hasTemplateKeyword ( ) const [inline]

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

Definition at line 948 of file Expr.h.

References getTemplateKeywordLoc(), and clang::SourceLocation::isValid().

bool clang::DeclRefExpr::hasTemplateKWAndArgsInfo ( ) const [inline]
void clang::DeclRefExpr::setDecl ( ValueDecl NewD) [inline]

Definition at line 853 of file Expr.h.

void clang::DeclRefExpr::setHadMultipleCandidates ( bool  V = true) [inline]

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

Definition at line 1008 of file Expr.h.

References clang::Stmt::DeclRefExprBits.

Referenced by clang::CreateFunctionRefExpr(), clang::Sema::FixOverloadedFunctionReference(), and clang::ASTNodeImporter::VisitDeclRefExpr().

void clang::DeclRefExpr::setLocation ( SourceLocation  L) [inline]

Definition at line 860 of file Expr.h.


Friends And Related Function Documentation

friend class ASTStmtReader [friend]

Reimplemented from clang::Stmt.

Definition at line 1020 of file Expr.h.

friend class ASTStmtWriter [friend]

Definition at line 1021 of file Expr.h.


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