clang API Documentation

Public Types | Public Member Functions
clang::Scope Class Reference

#include <Scope.h>

List of all members.

Public Types

enum  ScopeFlags {
  FnScope = 0x01, BreakScope = 0x02, ContinueScope = 0x04, DeclScope = 0x08,
  ControlScope = 0x10, ClassScope = 0x20, BlockScope = 0x40, TemplateParamScope = 0x80,
  FunctionPrototypeScope = 0x100, AtCatchScope = 0x200, ObjCMethodScope = 0x400, SwitchScope = 0x800,
  ThisScope = 0x1000, TryScope = 0x2000
}
typedef DeclSetTy::iterator decl_iterator
typedef UsingDirectivesTy::iterator udir_iterator
typedef
UsingDirectivesTy::const_iterator 
const_udir_iterator

Public Member Functions

 Scope (Scope *Parent, unsigned ScopeFlags, DiagnosticsEngine &Diag)
unsigned getFlags () const
void setFlags (unsigned F)
bool isBlockScope () const
 isBlockScope - Return true if this scope correspond to a closure.
const ScopegetParent () const
ScopegetParent ()
const ScopegetFnParent () const
ScopegetFnParent ()
ScopegetContinueParent ()
const ScopegetContinueParent () const
ScopegetBreakParent ()
const ScopegetBreakParent () const
ScopegetControlParent ()
const ScopegetControlParent () const
ScopegetBlockParent ()
const ScopegetBlockParent () const
ScopegetTemplateParamParent ()
const ScopegetTemplateParamParent () const
unsigned getFunctionPrototypeDepth () const
unsigned getNextFunctionPrototypeIndex ()
decl_iterator decl_begin () const
decl_iterator decl_end () const
bool decl_empty () const
void AddDecl (Decl *D)
void RemoveDecl (Decl *D)
bool isDeclScope (Decl *D)
void * getEntity () const
void setEntity (void *E)
bool hasErrorOccurred () const
bool isClassScope () const
 isClassScope - Return true if this scope is a class/struct/union scope.
bool isInCXXInlineMethodScope () const
bool isInObjcMethodScope () const
bool isTemplateParamScope () const
bool isFunctionPrototypeScope () const
bool isAtCatchScope () const
 isAtCatchScope - Return true if this scope is .
bool isSwitchScope () const
 isSwitchScope - Return true if this scope is a switch scope.
bool isTryScope () const
 Determine whether this scope is a C++ 'try' block.
void PushUsingDirective (UsingDirectiveDecl *UDir)
udir_iterator using_directives_begin ()
udir_iterator using_directives_end ()
const_udir_iterator using_directives_begin () const
const_udir_iterator using_directives_end () const
void Init (Scope *parent, unsigned flags)

Detailed Description

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 30 of file Scope.h.


Member Typedef Documentation

typedef UsingDirectivesTy::const_iterator clang::Scope::const_udir_iterator

Definition at line 314 of file Scope.h.

typedef DeclSetTy::iterator clang::Scope::decl_iterator

Definition at line 229 of file Scope.h.

typedef UsingDirectivesTy::iterator clang::Scope::udir_iterator

Definition at line 313 of file Scope.h.


Member Enumeration Documentation

ScopeFlags - These are bitfields that are or'd together when creating a scope, which defines the sorts of things the scope contains.

Enumerator:
FnScope 

FnScope - This indicates that the scope corresponds to a function, which means that labels are set here.

BreakScope 

BreakScope - This is a while,do,switch,for, etc that can have break stmts embedded into it.

ContinueScope 

ContinueScope - This is a while,do,for, which can have continue stmt embedded into it.

DeclScope 

DeclScope - This is a scope that can contain a declaration. Some scopes just contain loop constructs but don't contain decls.

ControlScope 

ControlScope - The controlling scope in a if/switch/while/for statement.

ClassScope 

ClassScope - The scope of a struct/union/class definition.

BlockScope 

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, BreakScope, ContinueScope, and DeclScope flags set as well.

TemplateParamScope 

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 

FunctionPrototypeScope - This is a scope that corresponds to the parameters within a function prototype.

AtCatchScope 

AtCatchScope - This is a scope that corresponds to the Objective-C statement.

ObjCMethodScope 

ObjCMethodScope - This scope corresponds to an Objective-C method body. It always has FnScope and DeclScope set as well.

SwitchScope 

SwitchScope - This is a scope that corresponds to a switch statement.

ThisScope 

ThisScope - This is the scope of a struct/union/class definition, outside of any member function definition, where 'this' is nonetheless usable.

TryScope 

TryScope - This is the scope of a C++ try statement.

Definition at line 34 of file Scope.h.


Constructor & Destructor Documentation

clang::Scope::Scope ( Scope Parent,
unsigned  ScopeFlags,
DiagnosticsEngine Diag 
) [inline]

Definition at line 159 of file Scope.h.

References Init().


Member Function Documentation

void clang::Scope::AddDecl ( Decl D) [inline]
decl_iterator clang::Scope::decl_begin ( ) const [inline]

Definition at line 230 of file Scope.h.

Referenced by clang::Sema::ActOnPopScope(), and LookupVisibleDecls().

bool clang::Scope::decl_empty ( ) const [inline]

Definition at line 232 of file Scope.h.

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

decl_iterator clang::Scope::decl_end ( ) const [inline]

Definition at line 231 of file Scope.h.

Referenced by clang::Sema::ActOnPopScope(), and LookupVisibleDecls().

Scope* clang::Scope::getBlockParent ( ) [inline]

Definition at line 210 of file Scope.h.

const Scope* clang::Scope::getBlockParent ( ) const [inline]

Definition at line 211 of file Scope.h.

Scope* clang::Scope::getBreakParent ( ) [inline]

getBreakParent - Return the closest scope that a break statement would be affected by. If the closest scope is a block scope, we know that there is no loop *inside* the block.

Definition at line 198 of file Scope.h.

References isBlockScope().

Referenced by clang::Sema::ActOnBreakStmt(), AddKeywordsToConsumer(), AddOrdinaryNameResults(), and getBreakParent().

const Scope* clang::Scope::getBreakParent ( ) const [inline]

Definition at line 203 of file Scope.h.

References getBreakParent().

Scope* clang::Scope::getContinueParent ( ) [inline]

getContinueParent - Return the closest scope that a continue statement would be affected by. If the closest scope is a closure scope, we know that there is no loop *inside* the closure.

Definition at line 185 of file Scope.h.

References isBlockScope().

Referenced by clang::Sema::ActOnContinueStmt(), AddKeywordsToConsumer(), AddOrdinaryNameResults(), and getContinueParent().

const Scope* clang::Scope::getContinueParent ( ) const [inline]

Definition at line 191 of file Scope.h.

References getContinueParent().

Scope* clang::Scope::getControlParent ( ) [inline]

Definition at line 207 of file Scope.h.

const Scope* clang::Scope::getControlParent ( ) const [inline]

Definition at line 208 of file Scope.h.

void* clang::Scope::getEntity ( ) const [inline]
unsigned clang::Scope::getFlags ( ) const [inline]
const Scope* clang::Scope::getFnParent ( ) const [inline]
Scope* clang::Scope::getFnParent ( ) [inline]

Definition at line 180 of file Scope.h.

unsigned clang::Scope::getFunctionPrototypeDepth ( ) const [inline]

Returns the number of function prototype scopes in this scope chain.

Definition at line 218 of file Scope.h.

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

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 224 of file Scope.h.

References isFunctionPrototypeScope().

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

const Scope* clang::Scope::getParent ( ) const [inline]
Scope* clang::Scope::getParent ( ) [inline]

Definition at line 175 of file Scope.h.

Scope* clang::Scope::getTemplateParamParent ( ) [inline]
const Scope* clang::Scope::getTemplateParamParent ( ) const [inline]

Definition at line 214 of file Scope.h.

bool clang::Scope::hasErrorOccurred ( ) const [inline]

Definition at line 251 of file Scope.h.

References clang::DiagnosticErrorTrap::hasErrorOccurred().

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

void Scope::Init ( Scope parent,
unsigned  flags 
)

Init - This is used by the parser to implement scope caching.

Definition at line 19 of file Scope.cpp.

References BlockScope, BreakScope, ContinueScope, ControlScope, FnScope, FunctionPrototypeScope, clang::DiagnosticErrorTrap::reset(), and TemplateParamScope.

Referenced by Scope().

bool clang::Scope::isAtCatchScope ( ) const [inline]

isAtCatchScope - Return true if this scope is .

Definition at line 292 of file Scope.h.

References AtCatchScope, and getFlags().

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

bool clang::Scope::isBlockScope ( ) const [inline]

isBlockScope - Return true if this scope correspond to a closure.

Definition at line 170 of file Scope.h.

References BlockScope.

Referenced by getBreakParent(), and getContinueParent().

bool clang::Scope::isClassScope ( ) const [inline]

isClassScope - Return true if this scope is a class/struct/union scope.

Definition at line 254 of file Scope.h.

References ClassScope, and getFlags().

Referenced by clang::Sema::ActOnTag(), AddKeywordsToConsumer(), clang::Sema::CodeCompleteUsing(), and clang::Sema::getNonFieldDeclScope().

bool clang::Scope::isDeclScope ( Decl D) [inline]
bool clang::Scope::isFunctionPrototypeScope ( ) const [inline]

isFunctionPrototypeScope - Return true if this scope is a function prototype scope.

Definition at line 287 of file Scope.h.

References FunctionPrototypeScope, and getFlags().

Referenced by clang::Sema::ActOnParamDeclarator(), clang::Sema::ActOnTag(), getNextFunctionPrototypeIndex(), and clang::Sema::isMicrosoftMissingTypename().

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 260 of file Scope.h.

References getFnParent().

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 270 of file Scope.h.

References ObjCMethodScope, and S.

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

bool clang::Scope::isSwitchScope ( ) const [inline]

isSwitchScope - Return true if this scope is a switch scope.

Definition at line 297 of file Scope.h.

References AtCatchScope, BlockScope, ClassScope, FnScope, FunctionPrototypeScope, ObjCMethodScope, S, SwitchScope, and TemplateParamScope.

bool clang::Scope::isTemplateParamScope ( ) const [inline]

isTemplateParamScope - Return true if this scope is a C++ template parameter scope.

Definition at line 281 of file Scope.h.

References getFlags(), and TemplateParamScope.

Referenced by clang::Sema::ActOnNonTypeTemplateParameter(), clang::Sema::ActOnTemplateTemplateParameter(), clang::Sema::ActOnTypeParameter(), and findOuterContext().

bool clang::Scope::isTryScope ( ) const [inline]

Determine whether this scope is a C++ 'try' block.

Definition at line 311 of file Scope.h.

References getFlags(), and TryScope.

void clang::Scope::PushUsingDirective ( UsingDirectiveDecl UDir) [inline]

Definition at line 316 of file Scope.h.

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

void clang::Scope::RemoveDecl ( Decl D) [inline]
void clang::Scope::setEntity ( void *  E) [inline]
void clang::Scope::setFlags ( unsigned  F) [inline]

Definition at line 167 of file Scope.h.

udir_iterator clang::Scope::using_directives_begin ( ) [inline]

Definition at line 320 of file Scope.h.

const_udir_iterator clang::Scope::using_directives_begin ( ) const [inline]

Definition at line 328 of file Scope.h.

udir_iterator clang::Scope::using_directives_end ( ) [inline]

Definition at line 324 of file Scope.h.

const_udir_iterator clang::Scope::using_directives_end ( ) const [inline]

Definition at line 332 of file Scope.h.


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