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, bool refersToEnclosingLocal, 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)
SourceLocation getLocStart () const LLVM_READONLY
SourceLocation getLocEnd () const LLVM_READONLY
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 occurred.
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.
bool refersToEnclosingLocal () const
child_range children ()

Static Public Member Functions

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

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. DeclRefExprBits.RefersToEnclosingLocal Specifies when this declaration reference expression (validly) refers to a local variable from a different function.

Definition at line 892 of file Expr.h.


Constructor & Destructor Documentation

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

Member Function Documentation

Reimplemented from clang::Stmt.

Definition at line 1158 of file Expr.h.

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

Reimplemented from clang::Expr.

Definition at line 1153 of file Expr.h.

References clang::Stmt::getStmtClass().

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

Definition at line 1112 of file Expr.h.

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

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

Construct an empty declaration reference expression.

Definition at line 412 of file Expr.cpp.

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

Definition at line 985 of file Expr.h.

Referenced by clang::Sema::ActOnOpenMPAlignedClause(), clang::Sema::ActOnOpenMPCopyinClause(), clang::Sema::ActOnOpenMPCopyprivateClause(), clang::Sema::ActOnOpenMPFirstprivateClause(), clang::Sema::ActOnOpenMPLastprivateClause(), clang::Sema::ActOnOpenMPLinearClause(), clang::Sema::ActOnOpenMPPrivateClause(), clang::Sema::ActOnOpenMPSharedClause(), AddVariableConstraints(), clang::Sema::BuildCXXForRangeStmt(), clang::Sema::CheckAddressOfOperand(), clang::Sema::CheckAssignmentOperands(), CheckForDanglingReferenceOrPointer(), checkFormatStringExpr(), CheckForModifiableLvalue(), CheckForReference(), CheckIdentityFieldAssignment(), clang::Sema::CheckOMPThreadPrivateDecl(), CheckTemplateArgumentAddressOfObjectOrFunction(), CheckTemplateArgumentPointerToMember(), clang::ento::containsEnum(), clang::ento::containsStaticLocal(), DiagnoseSelfAssignment(), clang::CodeGen::CodeGenFunction::EmitDeclRefExprDbgValue(), clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(), EvalAddr(), EvalVal(), clang::CallExpr::getBuiltinCallee(), clang::Sema::getCopyElisionCandidate(), getNameInfo(), getSelfInitExpr(), isEnumConstant(), isIdenticalStmt(), clang::Expr::isObjCSelfExpr(), isReferenceToNonConstCapture(), isTemplateArgumentTemplateParameter(), clang::Expr::isUnusedResultAWarning(), clang::Sema::MarkDeclRefReferenced(), MarkUsedTemplateParameters(), shouldExtendReceiverForInnerPointerMessage(), clang::CodeGen::CodeGenFunction::tryEmitAsConstant(), ValidDuplicateEnum(), clang::ento::ExprEngine::Visit(), clang::ASTNodeImporter::VisitDeclRefExpr(), clang::consumed::ConsumedStmtVisitor::VisitDeclRefExpr(), and clang::ento::ConditionBRVisitor::VisitTrueTest().

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

Definition at line 986 of file Expr.h.

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

Definition at line 1091 of file Expr.h.

References getTemplateKWAndArgsInfo(), and hasExplicitTemplateArgs().

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

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

Definition at line 1098 of file Expr.h.

References getExplicitTemplateArgs().

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.

Definition at line 1025 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 1031 of file Expr.h.

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

Definition at line 1069 of file Expr.h.

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

Referenced by hasExplicitTemplateArgs().

Definition at line 989 of file Expr.h.

References getDecl().

Referenced by getLocEnd(), and getLocStart().

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

Definition at line 1128 of file Expr.h.

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

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 1105 of file Expr.h.

References getExplicitTemplateArgs(), and hasExplicitTemplateArgs().

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

Definition at line 1004 of file Expr.h.

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

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

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

Definition at line 1013 of file Expr.h.

References hasQualifier().

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

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

Definition at line 1076 of file Expr.h.

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

Referenced by getLocEnd().

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

Definition at line 1119 of file Expr.h.

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

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

Definition at line 1062 of file Expr.h.

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

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

Return the optional template keyword and arguments info.

Definition at line 1040 of file Expr.h.

References hasQualifier(), and hasTemplateKWAndArgsInfo().

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

Return the optional template keyword and arguments info.

Definition at line 1056 of file Expr.h.

References getTemplateKWAndArgsInfo().

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

Definition at line 1137 of file Expr.h.

References clang::Stmt::DeclRefExprBits.

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

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

Definition at line 1087 of file Expr.h.

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

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

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

Definition at line 1000 of file Expr.h.

References clang::Stmt::DeclRefExprBits.

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

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

Definition at line 1083 of file Expr.h.

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

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

Definition at line 987 of file Expr.h.

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 1143 of file Expr.h.

References clang::Stmt::DeclRefExprBits.

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

Definition at line 994 of file Expr.h.


Friends And Related Function Documentation

friend class ASTStmtReader [friend]

Reimplemented from clang::Stmt.

Definition at line 1160 of file Expr.h.

friend class ASTStmtWriter [friend]

Reimplemented from clang::Stmt.

Definition at line 1161 of file Expr.h.


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