clang API Documentation
A reference to a declared variable, function, enum, etc. [C99 6.5.1p2]. More...
#include <Expr.h>
Public Member Functions | |
DeclRefExpr (ValueDecl *D, bool refersToEnclosingLocal, QualType T, ExprValueKind VK, SourceLocation L, const DeclarationNameLoc &LocInfo=DeclarationNameLoc()) | |
ValueDecl * | getDecl () |
const ValueDecl * | getDecl () 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 . | |
NestedNameSpecifier * | getQualifier () 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. | |
NamedDecl * | getFoundDecl () |
Get the NamedDecl through which this reference occurred. | |
const NamedDecl * | getFoundDecl () const |
Get the NamedDecl through which this reference occurred. See non-const variant. | |
bool | hasTemplateKWAndArgsInfo () const |
ASTTemplateKWAndArgsInfo * | getTemplateKWAndArgsInfo () |
Return the optional template keyword and arguments info. | |
const ASTTemplateKWAndArgsInfo * | getTemplateKWAndArgsInfo () 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. | |
ASTTemplateArgumentListInfo & | getExplicitTemplateArgs () |
Retrieve the explicit template argument list that followed the member template name. | |
const ASTTemplateArgumentListInfo & | getExplicitTemplateArgs () const |
Retrieve the explicit template argument list that followed the member template name. | |
const ASTTemplateArgumentListInfo * | getOptionalExplicitTemplateArgs () 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 TemplateArgumentLoc * | getTemplateArgs () 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 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 * | 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 * | CreateEmpty (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 |
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.
clang::DeclRefExpr::DeclRefExpr | ( | ValueDecl * | D, |
bool | refersToEnclosingLocal, | ||
QualType | T, | ||
ExprValueKind | VK, | ||
SourceLocation | L, | ||
const DeclarationNameLoc & | LocInfo = DeclarationNameLoc() |
||
) | [inline] |
Definition at line 951 of file Expr.h.
References clang::Stmt::DeclRefExprBits, clang::Decl::getASTContext(), and refersToEnclosingLocal().
child_range clang::DeclRefExpr::children | ( | ) | [inline] |
Reimplemented from clang::Stmt.
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().
void clang::DeclRefExpr::copyTemplateArgumentsInto | ( | TemplateArgumentListInfo & | List | ) | const [inline] |
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] |
Definition at line 366 of file Expr.cpp.
References clang::NamedDecl::getDeclName().
Referenced by clang::Sema::ActOnOpenMPFirstprivateClause(), clang::Sema::ActOnOpenMPPrivateClause(), clang::Sema::BuildDeclRefExpr(), BuildImplicitBaseInitializer(), BuildImplicitMemberInitializer(), clang::Sema::CheckConditionVariable(), clang::Sema::FixOverloadedFunctionReference(), and clang::ASTNodeImporter::VisitDeclRefExpr().
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] |
Definition at line 382 of file Expr.cpp.
References clang::ASTContext::Allocate(), clang::SourceLocation::isValid(), clang::TemplateArgumentListInfo::size(), and clang::ASTTemplateKWAndArgsInfo::sizeFor().
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().
ValueDecl* clang::DeclRefExpr::getDecl | ( | ) | [inline] |
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] |
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().
const ASTTemplateArgumentListInfo& clang::DeclRefExpr::getExplicitTemplateArgs | ( | ) | const [inline] |
Retrieve the explicit template argument list that followed the member template name.
Definition at line 1098 of file Expr.h.
References getExplicitTemplateArgs().
NamedDecl* clang::DeclRefExpr::getFoundDecl | ( | ) | [inline] |
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] |
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 1069 of file Expr.h.
References getTemplateKWAndArgsInfo(), hasTemplateKWAndArgsInfo(), and clang::ASTTemplateArgumentListInfo::LAngleLoc.
Referenced by hasExplicitTemplateArgs().
SourceLocation clang::DeclRefExpr::getLocation | ( | ) | const [inline] |
Definition at line 993 of file Expr.h.
Referenced by DiagnoseSelfAssignment(), clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(), clang::Sema::MarkDeclRefReferenced(), and clang::ASTNodeImporter::VisitDeclRefExpr().
SourceLocation DeclRefExpr::getLocEnd | ( | ) | const |
Reimplemented from clang::Stmt.
Definition at line 434 of file Expr.cpp.
References clang::DeclarationNameInfo::getLocEnd(), getNameInfo(), getRAngleLoc(), and hasExplicitTemplateArgs().
SourceLocation DeclRefExpr::getLocStart | ( | ) | const |
Reimplemented from clang::Stmt.
Definition at line 429 of file Expr.cpp.
References clang::NestedNameSpecifierLoc::getBeginLoc(), clang::DeclarationNameInfo::getLocStart(), getNameInfo(), getQualifierLoc(), and hasQualifier().
Referenced by clang::Sema::ActOnOpenMPFirstprivateClause(), clang::Sema::ActOnOpenMPPrivateClause(), and clang::Sema::BuildDeclRefExpr().
DeclarationNameInfo clang::DeclRefExpr::getNameInfo | ( | ) | const [inline] |
Definition at line 989 of file Expr.h.
References getDecl().
Referenced by getLocEnd(), and getLocStart().
unsigned clang::DeclRefExpr::getNumTemplateArgs | ( | ) | const [inline] |
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.
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 1105 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 1004 of file Expr.h.
References clang::NestedNameSpecifierLoc::getNestedNameSpecifier(), and hasQualifier().
Referenced by clang::Sema::CheckAddressOfOperand(), and 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 1013 of file Expr.h.
References hasQualifier().
Referenced by getLocStart(), 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 1076 of file Expr.h.
References getTemplateKWAndArgsInfo(), hasTemplateKWAndArgsInfo(), and clang::ASTTemplateArgumentListInfo::RAngleLoc.
Referenced by getLocEnd().
const TemplateArgumentLoc* clang::DeclRefExpr::getTemplateArgs | ( | ) | const [inline] |
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().
SourceLocation clang::DeclRefExpr::getTemplateKeywordLoc | ( | ) | const [inline] |
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().
const ASTTemplateKWAndArgsInfo* clang::DeclRefExpr::getTemplateKWAndArgsInfo | ( | ) | const [inline] |
Return the optional template keyword and arguments info.
Definition at line 1056 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 1137 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 1087 of file Expr.h.
References getLAngleLoc(), and clang::SourceLocation::isValid().
Referenced by copyTemplateArgumentsInto(), getExplicitTemplateArgs(), getLocEnd(), getNumTemplateArgs(), getOptionalExplicitTemplateArgs(), 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 1000 of file Expr.h.
References clang::Stmt::DeclRefExprBits.
Referenced by getLocStart(), getQualifier(), getQualifierLoc(), 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 1083 of file Expr.h.
References getTemplateKeywordLoc(), and clang::SourceLocation::isValid().
bool clang::DeclRefExpr::hasTemplateKWAndArgsInfo | ( | ) | const [inline] |
Definition at line 1035 of file Expr.h.
References clang::Stmt::DeclRefExprBits.
Referenced by getLAngleLoc(), getRAngleLoc(), getTemplateKeywordLoc(), and getTemplateKWAndArgsInfo().
bool clang::DeclRefExpr::refersToEnclosingLocal | ( | ) | const [inline] |
Does this DeclRefExpr refer to a local declaration from an enclosing function scope?
Definition at line 1149 of file Expr.h.
References clang::Stmt::DeclRefExprBits.
Referenced by DeclRefExpr(), clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(), EvalAddr(), EvalVal(), clang::Sema::getCopyElisionCandidate(), isReferenceToNonConstCapture(), and clang::ASTNodeImporter::VisitDeclRefExpr().
void clang::DeclRefExpr::setDecl | ( | ValueDecl * | NewD | ) | [inline] |
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 1143 of file Expr.h.
References clang::Stmt::DeclRefExprBits.
Referenced by CreateFunctionRefExpr(), clang::Sema::FixOverloadedFunctionReference(), and clang::ASTNodeImporter::VisitDeclRefExpr().
void clang::DeclRefExpr::setLocation | ( | SourceLocation | L | ) | [inline] |
friend class ASTStmtReader [friend] |
Reimplemented from clang::Stmt.
friend class ASTStmtWriter [friend] |
Reimplemented from clang::Stmt.