clang API Documentation

Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends
clang::VarDecl Class Reference

#include <Decl.h>

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

List of all members.

Classes

class  ParmVarDeclBitfields
class  VarDeclBitfields

Public Types

enum  InitializationStyle { CInit, CallInit, ListInit }
 Initialization styles. More...
enum  TLSKind { TLS_None, TLS_Static, TLS_Dynamic }
 Kinds of thread-local storage. More...
enum  DefinitionKind { DeclarationOnly, TentativeDefinition, Definition }
typedef
redeclarable_base::redecl_range 
redecl_range
typedef
redeclarable_base::redecl_iterator 
redecl_iterator

Public Member Functions

SourceRange getSourceRange () const override LLVM_READONLY
 Source range that this declaration covers.
StorageClass getStorageClass () const
 Returns the storage class as written in the source. For the computed linkage of symbol, see getLinkage.
void setStorageClass (StorageClass SC)
void setTSCSpec (ThreadStorageClassSpecifier TSC)
ThreadStorageClassSpecifier getTSCSpec () const
TLSKind getTLSKind () const
bool hasLocalStorage () const
bool isStaticLocal () const
bool hasExternalStorage () const
 Returns true if a variable has extern or __private_extern__ storage.
bool hasGlobalStorage () const
 Returns true for all variables that do not have local storage.
StorageDuration getStorageDuration () const
 Get the storage duration of this variable, per C++ [basic.stc].
LanguageLinkage getLanguageLinkage () const
 Compute the language linkage.
bool isExternC () const
 Determines whether this variable is a variable with external, C linkage.
bool isInExternCContext () const
 Determines whether this variable's context is, or is nested within, a C++ extern "C" linkage spec.
bool isInExternCXXContext () const
 Determines whether this variable's context is, or is nested within, a C++ extern "C++" linkage spec.
bool isLocalVarDecl () const
bool isFunctionOrMethodVarDecl () const
bool isStaticDataMember () const
 Determines whether this is a static data member.
VarDeclgetCanonicalDecl () override
 Retrieves the "canonical" declaration of the given declaration.
const VarDeclgetCanonicalDecl () const
DefinitionKind isThisDeclarationADefinition (ASTContext &) const
 Check whether this declaration is a definition. If this could be a tentative definition (in C), don't check whether there's an overriding definition.
DefinitionKind isThisDeclarationADefinition () const
DefinitionKind hasDefinition (ASTContext &) const
 Check whether this variable is defined in this translation unit.
DefinitionKind hasDefinition () const
VarDeclgetActingDefinition ()
 Get the tentative definition that acts as the real definition in a TU. Returns null if there is a proper definition available.
const VarDeclgetActingDefinition () const
VarDeclgetDefinition (ASTContext &)
 Get the real (not just tentative) definition for this declaration.
const VarDeclgetDefinition (ASTContext &C) const
VarDeclgetDefinition ()
const VarDeclgetDefinition () const
bool isOutOfLine () const override
 Determine whether this is or was instantiated from an out-of-line definition of a static data member.
VarDeclgetOutOfLineDefinition ()
 If this is a static data member, find its out-of-line definition.
bool isFileVarDecl () const
 isFileVarDecl - Returns true for file scoped variable declaration.
const ExprgetAnyInitializer () const
const ExprgetAnyInitializer (const VarDecl *&D) const
bool hasInit () const
const ExprgetInit () const
ExprgetInit ()
Stmt ** getInitAddress ()
 Retrieve the address of the initializer expression.
void setInit (Expr *I)
bool isUsableInConstantExpressions (ASTContext &C) const
 Determine whether this variable's value can be used in a constant expression, according to the relevant language standard. This only checks properties of the declaration, and does not check whether the initializer is in fact a constant expression.
EvaluatedStmtensureEvaluatedStmt () const
APValueevaluateValue () const
 Attempt to evaluate the value of the initializer attached to this declaration, and produce notes explaining why it cannot be evaluated or is not a constant expression. Returns a pointer to the value if evaluation succeeded, 0 otherwise.
APValueevaluateValue (SmallVectorImpl< PartialDiagnosticAt > &Notes) const
APValuegetEvaluatedValue () const
 Return the already-evaluated value of this variable's initializer, or NULL if the value is not yet known. Returns pointer to untyped APValue if the value could not be evaluated.
bool isInitKnownICE () const
 Determines whether it is already known whether the initializer is an integral constant expression or not.
bool isInitICE () const
 Determines whether the initializer is an integral constant expression, or in C++11, whether the initializer is a constant expression.
bool checkInitIsICE () const
 Determine whether the value of the initializer attached to this declaration is an integral constant expression.
void setInitStyle (InitializationStyle Style)
InitializationStyle getInitStyle () const
 The style of initialization for this declaration.
bool isDirectInit () const
 Whether the initializer is a direct-initializer (list or call).
bool isExceptionVariable () const
 Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C @catch statement.
void setExceptionVariable (bool EV)
bool isNRVOVariable () const
 Determine whether this local variable can be used with the named return value optimization (NRVO).
void setNRVOVariable (bool NRVO)
bool isCXXForRangeDecl () const
 Determine whether this variable is the for-range-declaration in a C++0x for-range statement.
void setCXXForRangeDecl (bool FRD)
bool isARCPseudoStrong () const
 Determine whether this variable is an ARC pseudo-__strong variable. A pseudo-__strong variable has a __strong-qualified type but does not actually retain the object written into it. Generally such variables are also 'const' for safety.
void setARCPseudoStrong (bool ps)
bool isConstexpr () const
 Whether this variable is (C++11) constexpr.
void setConstexpr (bool IC)
bool isInitCapture () const
 Whether this variable is the implicit variable for a lambda init-capture.
void setInitCapture (bool IC)
bool isPreviousDeclInSameBlockScope () const
void setPreviousDeclInSameBlockScope (bool Same)
VarDeclgetInstantiatedFromStaticDataMember () const
 If this variable is an instantiated static data member of a class template specialization, returns the templated static data member from which it was instantiated.
TemplateSpecializationKind getTemplateSpecializationKind () const
 If this variable is an instantiation of a variable template or a static data member of a class template, determine what kind of template specialization or instantiation this is.
SourceLocation getPointOfInstantiation () const
 If this variable is an instantiation of a variable template or a static data member of a class template, determine its point of instantiation.
MemberSpecializationInfogetMemberSpecializationInfo () const
 If this variable is an instantiation of a static data member of a class template specialization, retrieves the member specialization information.
void setTemplateSpecializationKind (TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
 For a static data member that was instantiated from a static data member of a class template, set the template specialiation kind.
void setInstantiationOfStaticDataMember (VarDecl *VD, TemplateSpecializationKind TSK)
 Specify that this variable is an instantiation of the static data member VD.
VarTemplateDeclgetDescribedVarTemplate () const
 Retrieves the variable template that is described by this variable declaration.
void setDescribedVarTemplate (VarTemplateDecl *Template)

Static Public Member Functions

static const char * getStorageClassSpecifierString (StorageClass SC)
static VarDeclCreate (ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
static VarDeclCreateDeserialized (ASTContext &C, unsigned ID)
static bool classof (const Decl *D)
static bool classofKind (Kind K)

Protected Types

enum  { NumParameterIndexBits = 8 }
typedef llvm::PointerUnion4
< Stmt *, EvaluatedStmt
*, UnparsedDefaultArgument
*, UninstantiatedDefaultArgument * > 
InitType
typedef Redeclarable< VarDeclredeclarable_base

Protected Member Functions

 VarDecl (Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass SC)
VarDeclgetNextRedeclarationImpl () override
 Returns the next redeclaration or itself if this is the only decl.
VarDeclgetPreviousDeclImpl () override
 Implementation of getPreviousDecl(), to be overridden by any subclass that has a redeclaration chain.
VarDeclgetMostRecentDeclImpl () override
 Implementation of getMostRecentDecl(), to be overridden by any subclass that has a redeclaration chain.

Protected Attributes

InitType Init
 The initializer for this variable or, for a ParmVarDecl, the C++ default argument.
union {
   unsigned   AllBits
   VarDeclBitfields   VarDeclBits
   ParmVarDeclBitfields   ParmVarDeclBits
}; 

Friends

class ASTDeclReader
class StmtIteratorBase
class ASTNodeImporter

Detailed Description

VarDecl - An instance of this class is created to represent a variable declaration or definition.

Definition at line 666 of file Decl.h.


Member Typedef Documentation

typedef llvm::PointerUnion4<Stmt *, EvaluatedStmt *, UnparsedDefaultArgument *, UninstantiatedDefaultArgument *> clang::VarDecl::InitType [protected]

Definition at line 695 of file Decl.h.

typedef redeclarable_base::redecl_iterator clang::VarDecl::redecl_iterator

Definition at line 802 of file Decl.h.

Reimplemented from clang::Redeclarable< VarDecl >.

Definition at line 801 of file Decl.h.

Definition at line 789 of file Decl.h.


Member Enumeration Documentation

anonymous enum [protected]
Enumerator:
NumParameterIndexBits 

Definition at line 750 of file Decl.h.

Enumerator:
DeclarationOnly 

This declaration is only a declaration.

TentativeDefinition 

This declaration is a tentative definition.

Definition 

This declaration is definitely a definition.

Definition at line 937 of file Decl.h.

Initialization styles.

Enumerator:
CInit 

C-style initialization with assignment.

CallInit 

Call-style initialization (C++98)

ListInit 

Direct list-initialization (C++11)

Definition at line 675 of file Decl.h.

Kinds of thread-local storage.

Enumerator:
TLS_None 

Not a TLS variable.

TLS_Static 

TLS with a known-constant initializer.

TLS_Dynamic 

TLS with a dynamic initializer.

Definition at line 682 of file Decl.h.


Constructor & Destructor Documentation

VarDecl::VarDecl ( Kind  DK,
ASTContext C,
DeclContext DC,
SourceLocation  StartLoc,
SourceLocation  IdLoc,
IdentifierInfo Id,
QualType  T,
TypeSourceInfo TInfo,
StorageClass  SC 
) [protected]

Definition at line 1707 of file Decl.cpp.

References AllBits, clang::SrcMgr::static_assert(), and VarDeclBits.

Referenced by Create(), and CreateDeserialized().


Member Function Documentation

static bool clang::VarDecl::classof ( const Decl D) [inline, static]
static bool clang::VarDecl::classofKind ( Kind  K) [inline, static]
VarDecl * VarDecl::Create ( ASTContext C,
DeclContext DC,
SourceLocation  StartLoc,
SourceLocation  IdLoc,
IdentifierInfo Id,
QualType  T,
TypeSourceInfo TInfo,
StorageClass  S 
) [static]

Convert the initializer for this declaration to the elaborated EvaluatedStmt form, which contains extra information on the evaluated value of the initializer.

Definition at line 2013 of file Decl.cpp.

References clang::Decl::getASTContext(), Init, and S.

Referenced by checkInitIsICE(), evaluateValue(), IsVariableNonDependentAndAConstantExpression(), VariableCanNeverBeAConstantExpression(), clang::ASTNodeImporter::VisitVarDecl(), and clang::ASTDeclReader::VisitVarDeclImpl().

Attempt to evaluate the value of the initializer attached to this declaration, and produce notes explaining why it cannot be evaluated or is not a constant expression. Returns a pointer to the value if evaluation succeeded, 0 otherwise.

Definition at line 2028 of file Decl.cpp.

Referenced by clang::Sema::CheckCompleteVariableDeclaration(), checkInitIsICE(), clang::CodeGen::CodeGenModule::EmitConstantInit(), and evaluateVarDeclInit().

APValue * VarDecl::evaluateValue ( SmallVectorImpl< PartialDiagnosticAt > &  Notes) const

Get the tentative definition that acts as the real definition in a TU. Returns null if there is a proper definition available.

Definition at line 1897 of file Decl.cpp.

References Definition, clang::Redeclarable< VarDecl >::getFirstDecl(), isThisDeclarationADefinition(), clang::Redeclarable< decl_type >::redecls(), and TentativeDefinition.

Referenced by clang::Sema::ActOnEndOfTranslationUnit(), and getDefinition().

const VarDecl* clang::VarDecl::getActingDefinition ( ) const [inline]

Definition at line 961 of file Decl.h.

const Expr* clang::VarDecl::getAnyInitializer ( ) const [inline]
const Expr * VarDecl::getAnyInitializer ( const VarDecl *&  D) const

getAnyInitializer - Get the initializer for this variable, no matter which declaration it is attached to. Also get that declaration.

Definition at line 1936 of file Decl.cpp.

References clang::Redeclarable< VarDecl >::redecls().

VarDecl * VarDecl::getCanonicalDecl ( ) [override, virtual]
const VarDecl* clang::VarDecl::getCanonicalDecl ( ) const [inline]

Reimplemented from clang::Decl.

Definition at line 933 of file Decl.h.

const VarDecl* clang::VarDecl::getDefinition ( ASTContext C) const [inline]

Definition at line 967 of file Decl.h.

References getDefinition().

Definition at line 970 of file Decl.h.

References getDefinition().

const VarDecl* clang::VarDecl::getDefinition ( ) const [inline]

Definition at line 973 of file Decl.h.

References getDefinition().

Retrieves the variable template that is described by this variable declaration.

Every variable template is represented as a VarTemplateDecl and a VarDecl. The former contains template properties (such as the template parameter lists) while the latter contains the actual description of the template's contents. VarTemplateDecl::getTemplatedDecl() retrieves the VarDecl that from a VarTemplateDecl, while getDescribedVarTemplate() retrieves the VarTemplateDecl from a VarDecl.

Definition at line 2151 of file Decl.cpp.

References clang::Decl::getASTContext(), and clang::ASTContext::getTemplateOrSpecializationInfo().

Referenced by clang::Sema::ActOnVariableDeclarator(), clang::Sema::BuildVarTemplateInstantiation(), clang::Sema::FinalizeDeclaration(), clang::Sema::MergeVarDecl(), clang::ASTDeclWriter::VisitVarDecl(), and clang::ASTNodeImporter::VisitVarTemplateDecl().

Return the already-evaluated value of this variable's initializer, or NULL if the value is not yet known. Returns pointer to untyped APValue if the value could not be evaluated.

Definition at line 1072 of file Decl.h.

Referenced by evaluateVarDeclInit().

const Expr* clang::VarDecl::getInit ( ) const [inline]

Definition at line 1013 of file Decl.h.

References S.

Referenced by clang::Sema::ActOnOpenMPReductionClause(), clang::Sema::AddInitializerToDecl(), clang::CodeGen::CodeGenFunction::AddInitializerToStaticVarDecl(), clang::Sema::BuildCXXDefaultArgExpr(), clang::Sema::BuildDeclaratorGroup(), clang::Sema::buildInitCaptureField(), clang::Sema::CheckCompleteVariableDeclaration(), checkElementNonNil(), clang::ASTContext::DeclMustBeEmitted(), DiagnoseUninitializedUse(), clang::CodeGen::CodeGenFunction::EmitAutoVarAlloca(), clang::CodeGen::CodeGenFunction::EmitAutoVarInit(), clang::CodeGen::CodeGenModule::EmitConstantInit(), clang::CodeGen::CodeGenFunction::EmitCXXGlobalVarDeclInit(), EmitDeclInit(), clang::CodeGen::CodeGenFunction::EmitStaticVarDecl(), clang::CodeGen::CodeGenModule::EmitTentativeDefinition(), clang::Sema::FinalizeDeclaration(), clang::CodeGen::CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(), clang::ParmVarDecl::getDefaultArg(), clang::ParmVarDecl::getDefaultArgRange(), clang::CXXForRangeStmt::getRangeInit(), getSelfInitExpr(), getSourceRange(), InitCatchParam(), clang::Sema::InstantiateVariableInitializer(), isVarDeclStrongDefinition(), maybeEmitZeroInitializationFixit(), clang::Sema::MergeCXXFunctionDecl(), SuggestInitializationFixit(), tryCaptureAsConstant(), clang::ento::ExprEngine::VisitDeclStmt(), clang::ento::FindLastStoreBRVisitor::VisitNode(), clang::ento::ExprEngine::VisitObjCForCollectionStmt(), clang::ASTDeclWriter::VisitParmVarDecl(), clang::ASTDeclWriter::VisitVarDecl(), and clang::consumed::ConsumedStmtVisitor::VisitVarDecl().

Definition at line 1024 of file Decl.h.

References S.

Retrieve the address of the initializer expression.

Definition at line 1038 of file Decl.h.

Referenced by clang::StmtIteratorBase::GetDeclExpr().

The style of initialization for this declaration.

C-style initialization is "int x = 1;". Call-style initialization is a C++98 direct-initializer, e.g. "int x(1);". The Init expression will be the expression inside the parens or a "ClassType(a,b,c)" class constructor expression for class types. List-style initialization is C++11 syntax, e.g. "int x{1};". Clients can distinguish between different forms of initialization by checking this value. In particular, "int x = {1};" is C-style, "int x({1})" is call-style, and "int x{1};" is list-style; the Init expression in all three cases is an InitListExpr.

Definition at line 1118 of file Decl.h.

Referenced by clang::Sema::BuildVariableInstantiation(), clang::Sema::InstantiateVariableInitializer(), clang::ASTDeclWriter::VisitParmVarDecl(), and clang::ASTDeclWriter::VisitVarDecl().

If this variable is an instantiated static data member of a class template specialization, returns the templated static data member from which it was instantiated.

Definition at line 2122 of file Decl.cpp.

References getMemberSpecializationInfo().

Referenced by clang::Sema::ActOnExplicitInstantiation(), clang::Sema::CheckMemberSpecialization(), getExplicitVisibilityAux(), clang::Sema::InstantiateClassMembers(), clang::Sema::InstantiateVariableDefinition(), isInstantiationOfStaticDataMember(), and isOutOfLine().

Compute the language linkage.

Definition at line 1807 of file Decl.cpp.

References getDeclLanguageLinkage().

VarDecl* clang::VarDecl::getMostRecentDeclImpl ( ) [inline, override, protected, virtual]

Implementation of getMostRecentDecl(), to be overridden by any subclass that has a redeclaration chain.

Reimplemented from clang::Decl.

Definition at line 796 of file Decl.h.

VarDecl* clang::VarDecl::getNextRedeclarationImpl ( ) [inline, override, protected, virtual]

Returns the next redeclaration or itself if this is the only decl.

Decl subclasses that can be redeclared should override this method so that Decl::redecl_iterator can iterate over them.

Reimplemented from clang::Decl.

Definition at line 790 of file Decl.h.

If this is a static data member, find its out-of-line definition.

Definition at line 1962 of file Decl.cpp.

References isStaticDataMember(), and clang::Redeclarable< VarDecl >::redecls().

Referenced by clang::Sema::InstantiateClassMembers().

If this variable is an instantiation of a variable template or a static data member of a class template, determine its point of instantiation.

Reimplemented in clang::VarTemplateSpecializationDecl.

Definition at line 2140 of file Decl.cpp.

References getMemberSpecializationInfo().

Referenced by clang::Sema::ActOnExplicitInstantiation(), DoMarkVarDeclReferenced(), and clang::Sema::InstantiateVariableDefinition().

VarDecl* clang::VarDecl::getPreviousDeclImpl ( ) [inline, override, protected, virtual]

Implementation of getPreviousDecl(), to be overridden by any subclass that has a redeclaration chain.

Reimplemented from clang::Decl.

Definition at line 793 of file Decl.h.

SourceRange VarDecl::getSourceRange ( ) const [override, virtual]

getStorageClassSpecifierString - Return the string used to specify the storage class SC.

It is illegal to call this function with SC == None.

Definition at line 1693 of file Decl.cpp.

References clang::SC_Auto, clang::SC_Extern, clang::SC_None, clang::SC_OpenCLWorkGroupLocal, clang::SC_PrivateExtern, clang::SC_Register, and clang::SC_Static.

Get the storage duration of this variable, per C++ [basic.stc].

Definition at line 875 of file Decl.h.

References clang::SD_Automatic, clang::SD_Static, and clang::SD_Thread.

Check whether this variable is defined in this translation unit.

Definition at line 1923 of file Decl.cpp.

References DeclarationOnly, Definition, clang::Redeclarable< VarDecl >::getFirstDecl(), and clang::Redeclarable< decl_type >::redecls().

Referenced by clang::MarkVarDeclODRUsed().

Definition at line 954 of file Decl.h.

bool clang::VarDecl::hasInit ( ) const [inline]

Determine whether this variable is an ARC pseudo-__strong variable. A pseudo-__strong variable has a __strong-qualified type but does not actually retain the object written into it. Generally such variables are also 'const' for safety.

Definition at line 1156 of file Decl.h.

Referenced by CheckForModifiableLvalue(), clang::CodeGen::CodeGenFunction::emitAutoVarTypeCleanup(), clang::CodeGen::CodeGenFunction::EmitObjCForCollectionStmt(), clang::CodeGen::CodeGenFunction::EmitParmDecl(), clang::ASTDeclWriter::VisitParmVarDecl(), and clang::ASTDeclWriter::VisitVarDecl().

bool clang::VarDecl::isConstexpr ( ) const [inline]

Determine whether this variable is the for-range-declaration in a C++0x for-range statement.

Definition at line 1149 of file Decl.h.

Referenced by clang::Sema::BuildVariableInstantiation(), clang::Sema::InstantiateVariableInitializer(), and clang::ASTDeclWriter::VisitVarDecl().

bool clang::VarDecl::isDirectInit ( ) const [inline]

Whether the initializer is a direct-initializer (list or call).

Definition at line 1123 of file Decl.h.

Referenced by clang::Sema::InstantiateVariableInitializer().

Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C @catch statement.

Definition at line 1129 of file Decl.h.

Referenced by clang::Sema::isCopyElisionCandidate(), isTrackedVar(), clang::ASTDeclWriter::VisitParmVarDecl(), and clang::ASTDeclWriter::VisitVarDecl().

Determines whether this variable is a variable with external, C linkage.

Definition at line 1811 of file Decl.cpp.

References isDeclExternC().

Referenced by clang::Sema::AddInitializerToDecl().

bool clang::VarDecl::isFileVarDecl ( ) const [inline]

isFunctionOrMethodVarDecl - Similar to isLocalVarDecl, but excludes variables declared in blocks.

Definition at line 911 of file Decl.h.

References clang::DeclContext::getDeclKind(), getKind(), clang::DeclContext::getRedeclContext(), and clang::DeclContext::isFunctionOrMethod().

Determines whether this variable's context is, or is nested within, a C++ extern "C" linkage spec.

Definition at line 1815 of file Decl.cpp.

References clang::Decl::getLexicalDeclContext(), and clang::DeclContext::isExternCContext().

Determines whether this variable's context is, or is nested within, a C++ extern "C++" linkage spec.

Definition at line 1819 of file Decl.cpp.

References clang::Decl::getLexicalDeclContext(), and clang::DeclContext::isExternCXXContext().

bool clang::VarDecl::isInitCapture ( ) const [inline]
bool clang::VarDecl::isInitICE ( ) const [inline]

Determines whether the initializer is an integral constant expression, or in C++11, whether the initializer is a constant expression.

Precondition:
isInitKnownICE()

Definition at line 1094 of file Decl.h.

Referenced by clang::Sema::CheckCompleteVariableDeclaration(), and clang::ASTDeclWriter::VisitVarDecl().

Determines whether it is already known whether the initializer is an integral constant expression or not.

Definition at line 1082 of file Decl.h.

Referenced by clang::ASTDeclWriter::VisitVarDecl().

isLocalVarDecl - Returns true for local variable declarations other than parameters. Note that this includes static variables inside of functions. It also includes variables inside blocks.

void foo() { int x; static int y; extern int z; }

Definition at line 901 of file Decl.h.

References getKind().

Referenced by clang::Sema::ActOnForStmt(), clang::Sema::ActOnVariableDeclarator(), clang::Sema::AddInitializerToDecl(), clang::CodeGen::CodeGenFunction::OMPPrivateScope::addPrivate(), clang::CodeGen::CodeGenFunction::EmitDecl(), isTrackedVar(), clang::Sema::MergeVarDecl(), clang::Sema::MergeVarDeclTypes(), and ReportOriginalDSA().

Determine whether this local variable can be used with the named return value optimization (NRVO).

The named return value optimization (NRVO) works by marking certain non-volatile local variables of class type as NRVO objects. These locals can be allocated within the return slot of their containing function, in which case there is no need to copy the object to the return slot when returning from the function. Within the function body, each return that returns the NRVO object will have this variable as its NRVO candidate.

Definition at line 1144 of file Decl.h.

Referenced by clang::CodeGen::CodeGenFunction::EmitAutoVarAlloca(), clang::CodeGen::CodeGenFunction::EmitReturnStmt(), and clang::ASTDeclWriter::VisitVarDecl().

bool VarDecl::isOutOfLine ( ) const [override, virtual]

Whether this local extern variable declaration's previous declaration was declared in the same block scope. Only correct in C++.

Definition at line 1169 of file Decl.h.

Referenced by clang::Sema::BuildVariableInstantiation(), mergeTypeWithPrevious(), and clang::ASTDeclWriter::VisitVarDecl().

bool clang::VarDecl::isStaticLocal ( ) const [inline]

Definition at line 947 of file Decl.h.

Referenced by getActingDefinition().

Determine whether this variable's value can be used in a constant expression, according to the relevant language standard. This only checks properties of the declaration, and does not check whether the initializer is in fact a constant expression.

Definition at line 1983 of file Decl.cpp.

References clang::ASTContext::getLangOpts(), clang::ValueDecl::getType(), and isConstexpr().

Referenced by clang::Sema::CheckCompleteVariableDeclaration(), DoMarkVarDeclReferenced(), and clang::IsVariableAConstantExpression().

Definition at line 1157 of file Decl.h.

Referenced by clang::Sema::ActOnForEachDeclStmt().

void clang::VarDecl::setConstexpr ( bool  IC) [inline]
void clang::VarDecl::setCXXForRangeDecl ( bool  FRD) [inline]
void VarDecl::setInit ( Expr I)
void clang::VarDecl::setInitCapture ( bool  IC) [inline]

Definition at line 1104 of file Decl.h.

References Style.

Referenced by clang::Sema::AddInitializerToDecl(), and clang::Sema::BuildVariableInstantiation().

Specify that this variable is an instantiation of the static data member VD.

Definition at line 2192 of file Decl.cpp.

References clang::Decl::getASTContext(), and clang::ASTContext::setInstantiatedFromStaticDataMember().

Referenced by clang::Sema::ActOnVarTemplateSpecialization(), and clang::Sema::BuildVariableInstantiation().

void clang::VarDecl::setNRVOVariable ( bool  NRVO) [inline]

Definition at line 1145 of file Decl.h.

Definition at line 1735 of file Decl.cpp.

References clang::isLegalForVariable(), and VarDeclBits.

Referenced by clang::Sema::ActOnVariableDeclarator().

For a static data member that was instantiated from a static data member of a class template, set the template specialiation kind.

Definition at line 2169 of file Decl.cpp.

References getMemberSpecializationInfo(), clang::SourceLocation::isValid(), and clang::TSK_ExplicitSpecialization.

Referenced by clang::Sema::CheckMemberSpecialization(), clang::Sema::CheckVarTemplateId(), DoMarkVarDeclReferenced(), clang::Sema::InstantiateClassMembers(), and clang::Sema::InstantiateVariableDefinition().


Friends And Related Function Documentation

friend class ASTDeclReader [friend]

Reimplemented from clang::DeclaratorDecl.

Reimplemented in clang::VarTemplatePartialSpecializationDecl, and clang::VarTemplateSpecializationDecl.

Definition at line 745 of file Decl.h.

friend class ASTNodeImporter [friend]

Definition at line 747 of file Decl.h.

friend class StmtIteratorBase [friend]

Definition at line 746 of file Decl.h.


Member Data Documentation

union { ... } [protected]

Definition at line 780 of file Decl.h.

Referenced by VarDecl().

InitType clang::VarDecl::Init [mutable, protected]

The initializer for this variable or, for a ParmVarDecl, the C++ default argument.

Definition at line 703 of file Decl.h.

Referenced by checkInitIsICE(), ensureEvaluatedStmt(), evaluateValue(), getSourceRange(), and setInit().

Definition at line 782 of file Decl.h.

Referenced by clang::ASTDeclReader::VisitParmVarDecl().

VarDeclBitfields clang::VarDecl::VarDeclBits

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