clang 20.0.0git
|
Scope - A scope is a transient data structure that is used while parsing the program. More...
#include "clang/Sema/Scope.h"
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.
using clang::Scope::decl_range = llvm::iterator_range<DeclSetTy::iterator> |
using clang::Scope::using_directives_range = llvm::iterator_range<UsingDirectivesTy::iterator> |
ScopeFlags - These are bitfields that are or'd together when creating a scope, which defines the sorts of things the scope contains.
|
inline |
Definition at line 257 of file Scope.h.
References clang::Init, and Parent.
Referenced by CollectARMPACBTIOptions().
|
inline |
Definition at line 346 of file Scope.h.
References D.
Referenced by clang::Sema::ActOnReenterTemplateScope().
void Scope::AddFlags | ( | unsigned | Flags | ) |
Sets up the specified scope flags and adjusts the scope state variables accordingly.
Definition at line 115 of file Scope.cpp.
References BreakScope, and ContinueScope.
void Scope::applyNRVO | ( | ) |
Definition at line 165 of file Scope.cpp.
References getEntity(), getParent(), and isDeclScope().
bool Scope::containedInPrototypeScope | ( | ) | const |
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().
|
inline |
|
inline |
Definition at line 363 of file Scope.h.
References getMSLastManglingParent().
LLVM_DUMP_METHOD void Scope::dump | ( | ) | const |
Definition at line 196 of file Scope.cpp.
References 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().
|
inline |
getBreakParent - Return the closest scope that a break statement would be affected by.
Definition at line 306 of file Scope.h.
Referenced by clang::Sema::ActOnBreakStmt(), clang::SemaOpenMP::ActOnOpenMPScanDirective(), and getBreakParent().
|
inline |
Definition at line 309 of file Scope.h.
References getBreakParent().
|
inline |
getContinueParent - Return the closest scope that a continue statement would be affected by.
Definition at line 285 of file Scope.h.
Referenced by clang::Sema::ActOnContinueStmt(), and getContinueParent().
|
inline |
Definition at line 289 of file Scope.h.
References getContinueParent().
|
inline |
|
inline |
Get the entity corresponding to this scope.
Definition at line 385 of file Scope.h.
References isTemplateParamScope().
Referenced by applyNRVO(), dumpImpl(), clang::Sema::EnterDeclaratorContext(), clang::Sema::ExitDeclaratorContext(), and clang::Sema::ImplicitlyDefineFunction().
|
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().
|
inline |
getFnParent - Return the closest scope that is a function body.
Definition at line 275 of file Scope.h.
Referenced by clang::Sema::ActOnReturnStmt(), isInCXXInlineMethodScope(), and clang::Sema::LookupOrCreateLabel().
|
inline |
|
inline |
Get the DeclContext in which to continue unqualified lookup after a lookup in this scope.
|
inline |
Definition at line 376 of file Scope.h.
Referenced by dumpImpl().
|
inline |
Definition at line 370 of file Scope.h.
References getMSLastManglingParent().
Referenced by dumpImpl().
|
inline |
Definition at line 278 of file Scope.h.
Referenced by decrementMSManglingNumber(), getMSLastManglingNumber(), and incrementMSManglingNumber().
|
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().
|
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().
|
inline |
Definition at line 316 of file Scope.h.
Referenced by clang::Sema::ActOnLambdaExpressionAfterIntroducer().
|
inline |
|
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().
|
inline |
Definition at line 356 of file Scope.h.
References getMSLastManglingParent().
Referenced by clang::Sema::incrementMSManglingNumber().
Init - This is used by the parser to implement scope caching.
Definition at line 95 of file Scope.cpp.
References clang::DiagnosticErrorTrap::reset().
Referenced by clang::Parser::EnterScope().
|
inline |
isAtCatchScope - Return true if this scope is @catch.
Definition at line 471 of file Scope.h.
References AtCatchScope, and getFlags().
Referenced by clang::SemaObjC::ActOnObjCAtThrowStmt().
|
inline |
isBlockScope - Return true if this scope correspond to a closure.
Definition at line 268 of file Scope.h.
References BlockScope.
|
inline |
isCatchScope - Return true if this scope is a C++ catch statement.
Definition at line 476 of file Scope.h.
References CatchScope, and getFlags().
|
inline |
Determines whether this scope is between inheritance colon and the real class/struct definition.
Definition at line 416 of file Scope.h.
References ClassInheritanceScope, and getFlags().
|
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().
|
inline |
Determine whether this scope is a compound statement scope.
Definition at line 582 of file Scope.h.
References CompoundStmtScope, and getFlags().
Referenced by clang::Sema::ImplicitlyDefineFunction().
|
inline |
Definition at line 300 of file Scope.h.
References ConditionVarScope.
|
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().
|
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 - Return true if this is the scope that the specified decl is declared in.
Definition at line 382 of file Scope.h.
References D.
Referenced by applyNRVO(), and clang::Sema::MergeTypedefNameDecl().
|
inline |
Determine whether this scope is a function-level C++ try or catch scope.
Definition at line 571 of file Scope.h.
References FnTryCatchScope, and getFlags().
|
inline |
Determine whether this scope is a friend scope.
Definition at line 594 of file Scope.h.
References FriendScope, and getFlags().
Referenced by CheckAccess().
|
inline |
isFunctionDeclarationScope - Return true if this scope is a function prototype scope.
Definition at line 466 of file Scope.h.
References FunctionDeclarationScope, and getFlags().
Referenced by GetDeclSpecTypeForDeclarator().
|
inline |
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
Definition at line 460 of file Scope.h.
References FunctionPrototypeScope, and getFlags().
Referenced by getNextFunctionPrototypeIndex().
|
inline |
isFunctionScope() - Return true if this scope is a function scope.
Definition at line 409 of file Scope.h.
References FnScope, and getFlags().
|
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().
|
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.
|
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.
|
inline |
Determine if this scope (or its parents) are a compute construct.
If the argument is provided, the search will stop at any of the specified scopes. Otherwise, it will stop only at the normal 'no longer search' scopes.
Definition at line 544 of file Scope.h.
References AtCatchScope, BlockScope, ClassScope, FnScope, FunctionPrototypeScope, ObjCMethodScope, and TemplateParamScope.
|
inline |
Return true if this scope is a loop.
Definition at line 493 of file Scope.h.
References BreakScope, getFlags(), and SwitchScope.
|
inline |
Determine whether this scope is the statement associated with an OpenACC Compute construct directive.
Definition at line 537 of file Scope.h.
References getFlags(), and OpenACCComputeConstructScope.
|
inline |
Determines whether this scope is the OpenMP directive scope.
Definition at line 501 of file Scope.h.
References getFlags(), and OpenMPDirectiveScope.
Referenced by isOpenMPLoopDirectiveScope().
|
inline |
Determine whether this scope is some OpenMP loop directive scope (for example, 'omp for', 'omp simd').
Definition at line 507 of file Scope.h.
References getFlags(), isOpenMPDirectiveScope(), and OpenMPLoopDirectiveScope.
|
inline |
Determine whether this scope is a loop having OpenMP loop directive attached.
Definition at line 524 of file Scope.h.
References getParent(), and P.
Referenced by clang::SemaOpenMP::ActOnOpenMPScanDirective().
|
inline |
Determine whether this scope is some OpenMP directive with order clause which specifies concurrent scope.
Definition at line 531 of file Scope.h.
References getFlags(), and OpenMPOrderClauseScope.
Referenced by clang::SemaOpenMP::ActOnOpenMPCall().
|
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.
|
inline |
Determine whether this scope is a SEH '__except' block.
Definition at line 579 of file Scope.h.
References getFlags(), and SEHExceptScope.
|
inline |
Determine whether this scope is a SEH '__try' block.
Definition at line 576 of file Scope.h.
References getFlags(), and SEHTryScope.
Referenced by clang::Sema::ActOnSEHLeaveStmt().
|
inline |
isSwitchScope - Return true if this scope is a switch scope.
Definition at line 479 of file Scope.h.
References AtCatchScope, BlockScope, ClassScope, FnScope, FunctionPrototypeScope, ObjCMethodScope, SwitchScope, and TemplateParamScope.
|
inline |
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
Definition at line 454 of file Scope.h.
References getFlags(), and TemplateParamScope.
Referenced by getEntity(), and setEntity().
|
inline |
Determine whether this scope is a C++ 'try' block.
Definition at line 568 of file Scope.h.
References getFlags(), and TryScope.
|
inline |
Determine whether this scope is a type alias scope.
Definition at line 591 of file Scope.h.
References getFlags(), and TypeAliasScope.
|
inline |
|
inline |
Definition at line 354 of file Scope.h.
References D.
Referenced by clang::Sema::MergeTypedefNameDecl().
|
inline |
Definition at line 393 of file Scope.h.
References E, and isTemplateParamScope().
Referenced by clang::Sema::ActOnFriendFunctionDecl().
|
inline |
Definition at line 265 of file Scope.h.
References getParent(), and setFlags().
Referenced by setFlags().
|
inline |
Definition at line 295 of file Scope.h.
References ConditionVarScope.
|
inline |
void Scope::updateNRVOCandidate | ( | VarDecl * | VD | ) |
Definition at line 136 of file Scope.cpp.
Referenced by clang::Sema::ActOnReturnStmt().
|
inline |