clang: clang::Scope Class Reference (original ) (raw )Scope - A scope is a transient data structure that is used while parsing the program. More...
#include "[clang/Sema/Scope.h](Scope%5F8h%5Fsource.html)"
Public Types
enum
ScopeFlags { NoScope = 0 , FnScope = 0x01 , BreakScope = 0x02 , ContinueScope = 0x04 , DeclScope = 0x08 , ControlScope = 0x10 , ClassScope = 0x20 , BlockScope = 0x40 , TemplateParamScope = 0x80 , FunctionPrototypeScope = 0x100 , FunctionDeclarationScope = 0x200 , AtCatchScope = 0x400 , ObjCMethodScope = 0x800 , SwitchScope = 0x1000 , TryScope = 0x2000 , FnTryCatchScope = 0x4000 , OpenMPDirectiveScope = 0x8000 , OpenMPLoopDirectiveScope = 0x10000 , OpenMPSimdDirectiveScope = 0x20000 , EnumScope = 0x40000 , SEHTryScope = 0x80000 , SEHExceptScope = 0x100000 , SEHFilterScope = 0x200000 , CompoundStmtScope = 0x400000 , ClassInheritanceScope = 0x800000 , CatchScope = 0x1000000 , ConditionVarScope = 0x2000000 , OpenMPOrderClauseScope = 0x4000000 , LambdaScope = 0x8000000 , OpenACCComputeConstructScope = 0x10000000 , TypeAliasScope = 0x20000000 , FriendScope = 0x40000000 }
ScopeFlags - These are bitfields that are or'd together when creating a scope, which defines the sorts of things the scope contains. More...
using
decl_range = llvm::iterator_range< DeclSetTy::iterator >
using
using_directives_range = llvm::iterator_range< UsingDirectivesTy::iterator >
Public Member Functions
Scope (Scope *Parent , unsigned ScopeFlags , DiagnosticsEngine &Diag )
unsigned
getFlags () const
getFlags - Return the flags for this scope.
void
setFlags (unsigned F)
bool
isBlockScope () const
isBlockScope - Return true if this scope correspond to a closure.
const Scope *
getParent () const
getParent - Return the scope that this is nested in.
Scope *
getParent ()
const Scope *
getFnParent () const
getFnParent - Return the closest scope that is a function body.
Scope *
getFnParent ()
const Scope *
getMSLastManglingParent () const
Scope *
getMSLastManglingParent ()
Scope *
getContinueParent ()
getContinueParent - Return the closest scope that a continue statement would be affected by.
const Scope *
getContinueParent () const
void
setIsConditionVarScope (bool InConditionVarScope)
bool
isConditionVarScope () const
Scope *
getBreakParent ()
getBreakParent - Return the closest scope that a break statement would be affected by.
const Scope *
getBreakParent () const
Scope *
getBlockParent ()
const Scope *
getBlockParent () const
Scope *
getTemplateParamParent ()
const Scope *
getTemplateParamParent () const
Scope *
getDeclParent ()
const Scope *
getDeclParent () const
unsigned
getDepth () const
Returns the depth of this scope. The translation-unit has scope depth 0.
unsigned
getFunctionPrototypeDepth () const
Returns the number of function prototype scopes in this scope chain.
unsigned
getNextFunctionPrototypeIndex ()
Return the number of parameters declared in this function prototype, increasing it by one for the next call.
decl_range
decls () const
bool
decl_empty () const
void
AddDecl (Decl *D )
void
RemoveDecl (Decl *D )
void
incrementMSManglingNumber ()
void
decrementMSManglingNumber ()
unsigned
getMSLastManglingNumber () const
unsigned
getMSCurManglingNumber () const
bool
isDeclScope (const Decl *D ) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
DeclContext *
getEntity () const
Get the entity corresponding to this scope.
DeclContext *
getLookupEntity () const
Get the DeclContext in which to continue unqualified lookup after a lookup in this scope.
void
setEntity (DeclContext *E )
void
setLookupEntity (DeclContext *E )
bool
hasUnrecoverableErrorOccurred () const
Determine whether any unrecoverable errors have occurred within this scope.
bool
isFunctionScope () const
isFunctionScope() - Return true if this scope is a function scope.
bool
isClassScope () const
isClassScope - Return true if this scope is a class/struct/union scope.
bool
isClassInheritanceScope () const
Determines whether this scope is between inheritance colon and the real class/struct definition.
bool
isInCXXInlineMethodScope () const
isInCXXInlineMethodScope - Return true if this scope is a C++ inline method scope or is inside one.
bool
isInObjcMethodScope () const
isInObjcMethodScope - Return true if this scope is, or is contained in, an Objective-C method body.
bool
isInObjcMethodOuterScope () const
isInObjcMethodOuterScope - Return true if this scope is an Objective-C method outer most body.
bool
isTemplateParamScope () const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
bool
isFunctionPrototypeScope () const
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
bool
isFunctionDeclarationScope () const
isFunctionDeclarationScope - Return true if this scope is a function prototype scope.
bool
isAtCatchScope () const
isAtCatchScope - Return true if this scope is @catch.
bool
isCatchScope () const
isCatchScope - Return true if this scope is a C++ catch statement.
bool
isSwitchScope () const
isSwitchScope - Return true if this scope is a switch scope.
bool
isLoopScope () const
Return true if this scope is a loop.
bool
isOpenMPDirectiveScope () const
Determines whether this scope is the OpenMP directive scope.
bool
isOpenMPLoopDirectiveScope () const
Determine whether this scope is some OpenMP loop directive scope (for example, 'omp for', 'omp simd').
bool
isOpenMPSimdDirectiveScope () const
Determine whether this scope is (or is nested into) some OpenMP loop simd directive scope (for example, 'omp simd', 'omp for simd').
bool
isOpenMPLoopScope () const
Determine whether this scope is a loop having OpenMP loop directive attached.
bool
isOpenMPOrderClauseScope () const
Determine whether this scope is some OpenMP directive with order clause which specifies concurrent scope.
bool
isOpenACCComputeConstructScope () const
Determine whether this scope is the statement associated with an OpenACC Compute construct directive.
bool
isInOpenACCComputeConstructScope (ScopeFlags Flags=NoScope ) const
Determine if this scope (or its parents) are a compute construct.
bool
isContinueScope () const
Determine whether this scope is a while/do/for statement, which can have continue statements embedded into it.
bool
isTryScope () const
Determine whether this scope is a C++ 'try' block.
bool
isFnTryCatchScope () const
Determine whether this scope is a function-level C++ try or catch scope.
bool
isSEHTryScope () const
Determine whether this scope is a SEH '__try' block.
bool
isSEHExceptScope () const
Determine whether this scope is a SEH '__except' block.
bool
isCompoundStmtScope () const
Determine whether this scope is a compound statement scope.
bool
isControlScope () const
Determine whether this scope is a controlling scope in a if/switch/while/for statement.
bool
isTypeAliasScope () const
Determine whether this scope is a type alias scope.
bool
isFriendScope () const
Determine whether this scope is a friend scope.
bool
Contains (const Scope &rhs) const
Returns if rhs has a higher scope depth than this.
bool
containedInPrototypeScope () const
containedInPrototypeScope - Return true if this or a parent scope is a FunctionPrototypeScope.
void
PushUsingDirective (UsingDirectiveDecl *UDir)
using_directives_range
using_directives ()
void
updateNRVOCandidate (VarDecl *VD)
void
applyNRVO ()
void
Init (Scope *parent, unsigned flags)
Init - This is used by the parser to implement scope caching.
void
AddFlags (unsigned Flags)
Sets up the specified scope flags and adjusts the scope state variables accordingly.
void
dumpImpl (raw_ostream &OS) const
void
dump () const
Scope - A scope is a transient data structure that is used while parsing the program.
It assists with resolving identifiers to the appropriate declaration.
Definition at line 41 of file Scope.h .
◆ decl_range◆ using_directives_range◆ ScopeFlagsScopeFlags - These are bitfields that are or'd together when creating a scope, which defines the sorts of things the scope contains.
Enumerator
NoScope
FnScope
This indicates that the scope corresponds to a function, which means that labels are set here.
BreakScope
This is a while, do, switch, for, etc that can have break statements embedded into it.
ContinueScope
This is a while, do, for, which can have continue statements embedded into it.
DeclScope
This is a scope that can contain a declaration. Some scopes just contain loop constructs but don't contain decls.
ControlScope
The controlling scope in a if/switch/while/for statement.
ClassScope
The scope of a struct/union/class definition.
BlockScope
This is a scope that corresponds to a block/closure object. Blocks serve as top-level scopes for some objects like labels, they also prevent things like break and continue. BlockScopes always have the FnScope and DeclScope flags set as well.
TemplateParamScope
This is a scope that corresponds to the template parameters of a C++ template. Template parameter scope starts at the 'template' keyword and ends when the template declaration ends.
FunctionPrototypeScope
This is a scope that corresponds to the parameters within a function prototype.
FunctionDeclarationScope
This is a scope that corresponds to the parameters within a function prototype for a function declaration (as opposed to any other kind of function declarator). Always has FunctionPrototypeScope set as well.
AtCatchScope
This is a scope that corresponds to the Objective-C @catch statement.
ObjCMethodScope
This scope corresponds to an Objective-C method body. It always has FnScope and DeclScope set as well.
SwitchScope
This is a scope that corresponds to a switch statement.
TryScope
This is the scope of a C++ try statement.
FnTryCatchScope
This is the scope for a function-level C++ try or catch scope.
OpenMPDirectiveScope
This is the scope of OpenMP executable directive.
OpenMPLoopDirectiveScope
This is the scope of some OpenMP loop directive.
OpenMPSimdDirectiveScope
This is the scope of some OpenMP simd directive. For example, it is used for 'omp simd', 'omp for simd'. This flag is propagated to children scopes.
EnumScope
This scope corresponds to an enum.
SEHTryScope
This scope corresponds to an SEH try.
SEHExceptScope
This scope corresponds to an SEH except.
SEHFilterScope
We are currently in the filter expression of an SEH except block.
CompoundStmtScope
This is a compound statement scope.
ClassInheritanceScope
We are between inheritance colon and the real class/struct definition scope.
CatchScope
This is the scope of a C++ catch statement.
ConditionVarScope
This is a scope in which a condition variable is currently being parsed. If such a scope is a ContinueScope, it's invalid to jump to the continue block from here.
OpenMPOrderClauseScope
This is a scope of some OpenMP directive with order clause which specifies concurrent.
LambdaScope
This is the scope for a lambda, after the lambda introducer. Lambdas need two FunctionPrototypeScope scopes (because there is a template scope in between), the outer scope does not increase the depth of recursion.
OpenACCComputeConstructScope
This is the scope of an OpenACC Compute Construct, which restricts jumping into/out of it. We also use this to represent 'combined' constructs, since they have the same behavior.
TypeAliasScope
This is a scope of type alias declaration.
FriendScope
This is a scope of friend declaration.
Definition at line 45 of file Scope.h .
◆ AddDecl()
void clang::Scope::AddDecl ( Decl * D )
inline
◆ AddFlags()◆ applyNRVO()
void Scope::applyNRVO
(
)
◆ containedInPrototypeScope()
bool Scope::containedInPrototypeScope
(
)
const
containedInPrototypeScope - Return true if this or a parent scope is a FunctionPrototypeScope.
Definition at line 105 of file Scope.cpp .
◆ Contains()
bool clang::Scope::Contains ( const Scope & rhs ) const
inline
Returns if rhs has a higher scope depth than this.
The caller is responsible for calling this only if one of the two scopes is an ancestor of the other.
Definition at line 600 of file Scope.h .
Referenced by CheckJumpOutOfSEHFinally() .
◆ decl_empty()
bool clang::Scope::decl_empty ( ) const
inline
◆ decls()◆ decrementMSManglingNumber()
void clang::Scope::decrementMSManglingNumber ( )
inline
◆ dump()
LLVM_DUMP_METHOD void Scope::dump
(
)
const
◆ dumpImpl()
void Scope::dumpImpl
(
raw_ostream &
OS
)
const
Definition at line 198 of file Scope.cpp .
References AtCatchScope , BlockScope , BreakScope , CatchScope , ClassInheritanceScope , ClassScope , CompoundStmtScope , ConditionVarScope , ContinueScope , ControlScope , DeclScope , EnumScope , FnScope , FnTryCatchScope , FriendScope , FunctionDeclarationScope , FunctionPrototypeScope , getEntity() , getFlags() , getMSCurManglingNumber() , getMSLastManglingNumber() , getParent() , LambdaScope , ObjCMethodScope , OpenACCComputeConstructScope , OpenMPDirectiveScope , OpenMPLoopDirectiveScope , OpenMPOrderClauseScope , OpenMPSimdDirectiveScope , Parent , SEHExceptScope , SEHFilterScope , SEHTryScope , SwitchScope , TemplateParamScope , TryScope , and TypeAliasScope .
Referenced by dump() .
◆ getBlockParent() [1/2]
Scope * clang::Scope::getBlockParent ( )
inline
◆ getBlockParent() [2/2]
const Scope * clang::Scope::getBlockParent ( ) const
inline
◆ getBreakParent() [1/2]
Scope * clang::Scope::getBreakParent ( )
inline
◆ getBreakParent() [2/2]
const Scope * clang::Scope::getBreakParent ( ) const
inline
◆ getContinueParent() [1/2]
Scope * clang::Scope::getContinueParent ( )
inline
◆ getContinueParent() [2/2]
const Scope * clang::Scope::getContinueParent ( ) const
inline
◆ getDeclParent() [1/2]
Scope * clang::Scope::getDeclParent ( )
inline
◆ getDeclParent() [2/2]
const Scope * clang::Scope::getDeclParent ( ) const
inline
◆ getDepth()
unsigned clang::Scope::getDepth ( ) const
inline
Returns the depth of this scope. The translation-unit has scope depth 0.
Definition at line 323 of file Scope.h .
◆ getEntity()◆ getFlags()
unsigned clang::Scope::getFlags ( ) const
inline
getFlags - Return the flags for this scope.
Definition at line 263 of file Scope.h .
Referenced by clang::Sema::CheckClassTemplate() , clang::Sema::DiagnoseCommaOperator() , dumpImpl() , handleDependencyAttr() , isAtCatchScope() , isCatchScope() , isClassInheritanceScope() , isClassScope() , isCompoundStmtScope() , isContinueScope() , isControlScope() , isFnTryCatchScope() , isFriendScope() , isFunctionDeclarationScope() , isFunctionPrototypeScope() , isFunctionScope() , isLoopScope() , isOpenACCComputeConstructScope() , isOpenMPDirectiveScope() , isOpenMPLoopDirectiveScope() , isOpenMPOrderClauseScope() , isOpenMPSimdDirectiveScope() , isSEHExceptScope() , isSEHTryScope() , isTemplateParamScope() , isTryScope() , and isTypeAliasScope() .
◆ getFnParent() [1/2]
Scope * clang::Scope::getFnParent ( )
inline
◆ getFnParent() [2/2]
const Scope * clang::Scope::getFnParent ( ) const
inline
◆ getFunctionPrototypeDepth()
unsigned clang::Scope::getFunctionPrototypeDepth ( ) const
inline
Returns the number of function prototype scopes in this scope chain.
Definition at line 327 of file Scope.h .
◆ getLookupEntity()
DeclContext * clang::Scope::getLookupEntity ( ) const
inline
Get the DeclContext in which to continue unqualified lookup after a lookup in this scope.
Definition at line 391 of file Scope.h .
◆ getMSCurManglingNumber()
unsigned clang::Scope::getMSCurManglingNumber ( ) const
inline
◆ getMSLastManglingNumber()
unsigned clang::Scope::getMSLastManglingNumber ( ) const
inline
◆ getMSLastManglingParent() [1/2]
Scope * clang::Scope::getMSLastManglingParent ( )
inline
◆ getMSLastManglingParent() [2/2]
const Scope * clang::Scope::getMSLastManglingParent ( ) const
inline
◆ getNextFunctionPrototypeIndex()
unsigned clang::Scope::getNextFunctionPrototypeIndex ( )
inline
Return the number of parameters declared in this function prototype, increasing it by one for the next call.
Definition at line 333 of file Scope.h .
References isFunctionPrototypeScope() .
◆ getParent() [1/2]
Scope * clang::Scope::getParent ( )
inline
◆ getParent() [2/2]
const Scope * clang::Scope::getParent ( ) const
inline
getParent - Return the scope that this is nested in.
Definition at line 271 of file Scope.h .
Referenced by clang::Sema::ActOnLambdaExpressionAfterIntroducer() , clang::SemaObjC::ActOnObjCAtThrowStmt() , clang::SemaOpenMP::ActOnOpenMPScanDirective() , clang::Sema::ActOnSEHLeaveStmt() , clang::Sema::ActOnStartNamespaceDef() , clang::Sema::ActOnStartOfFunctionDef() , applyNRVO() , CheckAccess() , clang::Sema::CheckClassTemplate() , dumpImpl() , clang::Sema::EnterDeclaratorContext() , clang::Sema::ExitDeclaratorContext() , clang::Parser::ExitScope() , clang::Sema::ImplicitlyDefineFunction() , isOpenMPLoopScope() , and setFlags() .
◆ getTemplateParamParent() [1/2]
Scope * clang::Scope::getTemplateParamParent ( )
inline
◆ getTemplateParamParent() [2/2]
const Scope * clang::Scope::getTemplateParamParent ( ) const
inline
◆ hasUnrecoverableErrorOccurred()
bool clang::Scope::hasUnrecoverableErrorOccurred ( ) const
inline
Determine whether any unrecoverable errors have occurred within this scope.
Note that this may return false even if the scope contains invalid declarations or statements, if the errors for those invalid constructs were suppressed because some prior invalid construct was referenced.
Definition at line 404 of file Scope.h .
References clang::DiagnosticErrorTrap::hasUnrecoverableErrorOccurred() .
◆ incrementMSManglingNumber()
void clang::Scope::incrementMSManglingNumber ( )
inline
◆ Init()◆ isAtCatchScope()
bool clang::Scope::isAtCatchScope ( ) const
inline
◆ isBlockScope()
bool clang::Scope::isBlockScope ( ) const
inline
isBlockScope - Return true if this scope correspond to a closure.
Definition at line 268 of file Scope.h .
References BlockScope .
◆ isCatchScope()
bool clang::Scope::isCatchScope ( ) const
inline
◆ isClassInheritanceScope()
bool clang::Scope::isClassInheritanceScope ( ) const
inline
◆ isClassScope()
bool clang::Scope::isClassScope ( ) const
inline
isClassScope - Return true if this scope is a class/struct/union scope.
Definition at line 412 of file Scope.h .
References ClassScope , and getFlags() .
◆ isCompoundStmtScope()
bool clang::Scope::isCompoundStmtScope ( ) const
inline
◆ isConditionVarScope()
bool clang::Scope::isConditionVarScope ( ) const
inline
◆ isContinueScope()
bool clang::Scope::isContinueScope ( ) const
inline
Determine whether this scope is a while/do/for statement, which can have continue statements embedded into it.
Definition at line 563 of file Scope.h .
References ContinueScope , and getFlags() .
◆ isControlScope()
bool clang::Scope::isControlScope ( ) const
inline
Determine whether this scope is a controlling scope in a if/switch/while/for statement.
Definition at line 588 of file Scope.h .
References ControlScope , and getFlags() .
◆ isDeclScope()
bool clang::Scope::isDeclScope ( const Decl * D ) const
inline
◆ isFnTryCatchScope()
bool clang::Scope::isFnTryCatchScope ( ) const
inline
◆ isFriendScope()
bool clang::Scope::isFriendScope ( ) const
inline
◆ isFunctionDeclarationScope()
bool clang::Scope::isFunctionDeclarationScope ( ) const
inline
◆ isFunctionPrototypeScope()
bool clang::Scope::isFunctionPrototypeScope ( ) const
inline
◆ isFunctionScope()
bool clang::Scope::isFunctionScope ( ) const
inline
◆ isInCXXInlineMethodScope()
bool clang::Scope::isInCXXInlineMethodScope ( ) const
inline
isInCXXInlineMethodScope - Return true if this scope is a C++ inline method scope or is inside one.
Definition at line 422 of file Scope.h .
References getFnParent() .
◆ isInObjcMethodOuterScope()
bool clang::Scope::isInObjcMethodOuterScope ( ) const
inline
isInObjcMethodOuterScope - Return true if this scope is an Objective-C method outer most body.
Definition at line 443 of file Scope.h .
References ObjCMethodScope .
◆ isInObjcMethodScope()
bool clang::Scope::isInObjcMethodScope ( ) const
inline
isInObjcMethodScope - Return true if this scope is, or is contained in, an Objective-C method body.
Note that this method is not constant time.
Definition at line 432 of file Scope.h .
References ObjCMethodScope .
◆ isInOpenACCComputeConstructScope()◆ isLoopScope()
bool clang::Scope::isLoopScope ( ) const
inline
◆ isOpenACCComputeConstructScope()
bool clang::Scope::isOpenACCComputeConstructScope ( ) const
inline
◆ isOpenMPDirectiveScope()
bool clang::Scope::isOpenMPDirectiveScope ( ) const
inline
◆ isOpenMPLoopDirectiveScope()
bool clang::Scope::isOpenMPLoopDirectiveScope ( ) const
inline
◆ isOpenMPLoopScope()
bool clang::Scope::isOpenMPLoopScope ( ) const
inline
◆ isOpenMPOrderClauseScope()
bool clang::Scope::isOpenMPOrderClauseScope ( ) const
inline
◆ isOpenMPSimdDirectiveScope()
bool clang::Scope::isOpenMPSimdDirectiveScope ( ) const
inline
Determine whether this scope is (or is nested into) some OpenMP loop simd directive scope (for example, 'omp simd', 'omp for simd').
Definition at line 518 of file Scope.h .
References getFlags() , and OpenMPSimdDirectiveScope .
◆ isSEHExceptScope()
bool clang::Scope::isSEHExceptScope ( ) const
inline
◆ isSEHTryScope()
bool clang::Scope::isSEHTryScope ( ) const
inline
◆ isSwitchScope()
bool clang::Scope::isSwitchScope ( ) const
inline
◆ isTemplateParamScope()
bool clang::Scope::isTemplateParamScope ( ) const
inline
◆ isTryScope()
bool clang::Scope::isTryScope ( ) const
inline
◆ isTypeAliasScope()
bool clang::Scope::isTypeAliasScope ( ) const
inline
◆ PushUsingDirective()◆ RemoveDecl()
void clang::Scope::RemoveDecl ( Decl * D )
inline
◆ setEntity()◆ setFlags()
void clang::Scope::setFlags ( unsigned F )
inline
◆ setIsConditionVarScope()
void clang::Scope::setIsConditionVarScope ( bool InConditionVarScope )
inline
◆ setLookupEntity()
void clang::Scope::setLookupEntity ( DeclContext * E )
inline
◆ updateNRVOCandidate()
void Scope::updateNRVOCandidate
(
VarDecl *
VD
)
◆ using_directives()
The documentation for this class was generated from the following files: