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, 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) |
| SourceRange | getSourceRange () const |
| 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 occured. | |
| 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. | |
| child_range | children () |
Static Public Member Functions | |
| static 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 * | 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 * | CreateEmpty (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 |
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.
| 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.
| 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 1012 of file Expr.h.
References clang::Stmt::getStmtClass().
| static bool clang::DeclRefExpr::classof | ( | const DeclRefExpr * | ) | [inline, static] |
| 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] |
Definition at line 294 of file Expr.cpp.
References clang::NamedDecl::getDeclName().
Referenced by clang::Sema::BuildDeclRefExpr(), BuildImplicitBaseInitializer(), BuildImplicitMemberInitializer(), clang::Sema::CheckConditionVariable(), and clang::ASTNodeImporter::VisitDeclRefExpr().
| 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] |
Definition at line 308 of file Expr.cpp.
References clang::ASTContext::Allocate(), clang::SourceLocation::isValid(), clang::TemplateArgumentListInfo::size(), and clang::ASTTemplateKWAndArgsInfo::sizeFor().
| 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] |
Definition at line 851 of file Expr.h.
Referenced by AddVariableConstraints(), CheckAddressOfOperand(), CheckForDanglingReferenceOrPointer(), CheckForModifiableLvalue(), CheckTemplateArgumentAddressOfObjectOrFunction(), clang::Sema::CheckTemplateArgumentPointerToMember(), clang::ento::containsEnum(), clang::ento::containsStaticLocal(), DiagnoseSelfAssignment(), clang::CodeGen::CodeGenFunction::EmitDeclRefExprDbgValue(), clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(), EvalAddr(), EvalVal(), GenerateMinimalPathDiagnostic(), clang::Sema::getCopyElisionCandidate(), GetMostRecentVarDeclBinding(), getNameInfo(), clang::CallExpr::isBuiltinCall(), clang::Sema::MarkDeclRefReferenced(), MarkUsedTemplateParameters(), shouldExtendReceiverForInnerPointerMessage(), clang::CFGRecStmtDeclVisitor< ImplClass >::VisitDeclRefExpr(), clang::ASTNodeImporter::VisitDeclRefExpr(), and clang::ento::ConditionBRVisitor::VisitTrueTest().
| const ValueDecl* clang::DeclRefExpr::getDecl | ( | ) | const [inline] |
| 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] |
| 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] |
Definition at line 859 of file Expr.h.
Referenced by DiagnoseSelfAssignment(), clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(), clang::Sema::MarkDeclRefReferenced(), and clang::ASTNodeImporter::VisitDeclRefExpr().
| DeclarationNameInfo clang::DeclRefExpr::getNameInfo | ( | ) | const [inline] |
| 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] |
Definition at line 900 of file Expr.h.
References clang::Stmt::DeclRefExprBits.
Referenced by getLAngleLoc(), getRAngleLoc(), getTemplateKeywordLoc(), and getTemplateKWAndArgsInfo().
| 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 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] |
friend class ASTStmtReader [friend] |
Reimplemented from clang::Stmt.
friend class ASTStmtWriter [friend] |