Home | History | Annotate | Download | only in Sema

Lines Matching refs:Scope

1 //===--- Scope.h - Scope interface ------------------------------*- C++ -*-===//
10 // This file defines the Scope interface.
34 /// Scope - A scope is a transient data structure that is used while parsing the
38 class Scope {
41 /// scope, which defines the sorts of things the scope contains.
43 /// \brief This indicates that the scope corresponds to a function, which
55 /// \brief This is a scope that can contain a declaration. Some scopes
59 /// \brief The controlling scope in a if/switch/while/for statement.
62 /// \brief The scope of a struct/union/class definition.
65 /// \brief This is a scope that corresponds to a block/closure object.
71 /// \brief This is a scope that corresponds to the
73 /// scope starts at the 'template' keyword and ends when the
77 /// \brief This is a scope that corresponds to the
81 /// \brief This is a scope that corresponds to the parameters within
87 /// \brief This is a scope that corresponds to the Objective-C
91 /// \brief This scope corresponds to an Objective-C method body.
95 /// \brief This is a scope that corresponds to a switch statement.
98 /// \brief This is the scope of a C++ try statement.
101 /// \brief This is the scope for a function-level C++ try or catch scope.
104 /// \brief This is the scope of OpenMP executable directive.
107 /// \brief This is the scope of some OpenMP loop directive.
110 /// \brief This is the scope of some OpenMP simd directive.
115 /// This scope corresponds to an enum.
118 /// This scope corresponds to an SEH try.
121 /// This scope corresponds to an SEH except.
128 /// The parent scope for this scope. This is null for the translation-unit
129 /// scope.
130 Scope *AnyParent;
132 /// Flags - This contains a set of ScopeFlags, which indicates how the scope
136 /// Depth - This is the depth of this scope. The translation-unit scope has
147 /// enclosing this scope, including this scope.
151 /// declared in this scope.
154 /// FnParent - If this scope has a parent scope that is a function body, this
156 Scope *FnParent;
157 Scope *MSLastManglingParent;
160 /// BreakScope/ContinueScope which contains the contents of this scope
161 /// for control flow purposes (and might be this scope itself), or null
162 /// if there is no such scope.
163 Scope *BreakParent, *ContinueParent;
166 /// BlockScope if this scope is not one, or null if there is none.
167 Scope *BlockParent;
170 /// immediately containing template parameter scope. In the
173 Scope *TemplateParamParent;
175 /// DeclsInScope - This keeps track of all declarations in this scope. When
176 /// the declaration is added to the scope, it is set as the current
177 /// declaration for the identifier in the IdentifierTable. When the scope is
184 /// The DeclContext with which this scope is associated. For
185 /// example, the entity of a class scope is the class itself, the
186 /// entity of a function scope is a function, etc.
192 /// \brief Used to determine if errors occurred in this scope.
196 /// this scope, or over-defined. The bit is true when over-defined.
200 Scope(Scope *Parent, unsigned ScopeFlags, DiagnosticsEngine &Diag)
205 /// getFlags - Return the flags for this scope.
210 /// isBlockScope - Return true if this scope correspond to a closure.
213 /// getParent - Return the scope that this is nested in.
215 const Scope *getParent() const { return AnyParent; }
216 Scope *getParent() { return AnyParent; }
218 /// getFnParent - Return the closest scope that is a function body.
220 const Scope *getFnParent() const { return FnParent; }
221 Scope *getFnParent() { return FnParent; }
223 const Scope *getMSLastManglingParent() const {
226 Scope *getMSLastManglingParent() { return MSLastManglingParent; }
228 /// getContinueParent - Return the closest scope that a continue statement
230 Scope *getContinueParent() {
234 const Scope *getContinueParent() const {
235 return const_cast<Scope*>(this)->getContinueParent();
238 /// getBreakParent - Return the closest scope that a break statement
240 Scope *getBreakParent() {
243 const Scope *getBreakParent() const {
244 return const_cast<Scope*>(this)->getBreakParent();
247 Scope *getBlockParent() { return BlockParent; }
248 const Scope *getBlockParent() const { return BlockParent; }
250 Scope *getTemplateParamParent() { return TemplateParamParent; }
251 const Scope *getTemplateParamParent() const { return TemplateParamParent; }
253 /// Returns the number of function prototype scopes in this scope
281 if (Scope *MSLMP = getMSLastManglingParent()) {
288 if (Scope *MSLMP = getMSLastManglingParent()) {
295 if (const Scope *MSLMP = getMSLastManglingParent())
304 /// isDeclScope - Return true if this is the scope that the specified decl is
319 /// isFunctionScope() - Return true if this scope is a function scope.
320 bool isFunctionScope() const { return (getFlags() & Scope::FnScope); }
322 /// isClassScope - Return true if this scope is a class/struct/union scope.
324 return (getFlags() & Scope::ClassScope);
327 /// isInCXXInlineMethodScope - Return true if this scope is a C++ inline
328 /// method scope or is inside one.
330 if (const Scope *FnS = getFnParent()) {
337 /// isInObjcMethodScope - Return true if this scope is, or is contained in, an
340 for (const Scope *S = this; S; S = S->getParent()) {
341 // If this scope is an objc method scope, then we succeed.
348 /// isInObjcMethodOuterScope - Return true if this scope is an
351 if (const Scope *S = this) {
352 // If this scope is an objc method scope, then we succeed.
360 /// isTemplateParamScope - Return true if this scope is a C++
361 /// template parameter scope.
363 return getFlags() & Scope::TemplateParamScope;
366 /// isFunctionPrototypeScope - Return true if this scope is a
367 /// function prototype scope.
369 return getFlags() & Scope::FunctionPrototypeScope;
372 /// isAtCatchScope - Return true if this scope is \@catch.
374 return getFlags() & Scope::AtCatchScope;
377 /// isSwitchScope - Return true if this scope is a switch scope.
379 for (const Scope *S = this; S; S = S->getParent()) {
380 if (S->getFlags() & Scope::SwitchScope)
382 else if (S->getFlags() & (Scope::FnScope | Scope::ClassScope |
383 Scope::BlockScope | Scope::TemplateParamScope |
384 Scope::FunctionPrototypeScope |
385 Scope::AtCatchScope | Scope::ObjCMethodScope))
391 /// \brief Determines whether this scope is the OpenMP directive scope
393 return (getFlags() & Scope::OpenMPDirectiveScope);
396 /// \brief Determine whether this scope is some OpenMP loop directive scope
399 if (getFlags() & Scope::OpenMPLoopDirectiveScope) {
401 "OpenMP loop directive scope is not a directive scope");
407 /// \brief Determine whether this scope is (or is nested into) some OpenMP
408 /// loop simd directive scope (for example, 'omp simd', 'omp for simd').
410 return getFlags() & Scope::OpenMPSimdDirectiveScope;
413 /// \brief Determine whether this scope is a loop having OpenMP loop
416 const Scope *P = getParent();
420 /// \brief Determine whether this scope is a C++ 'try' block.
421 bool isTryScope() const { return getFlags() & Scope::TryScope; }
423 /// \brief Determine whether this scope is a SEH '__try' block.
424 bool isSEHTryScope() const { return getFlags() & Scope::SEHTryScope; }
426 /// \brief Determine whether this scope is a SEH '__except' block.
427 bool isSEHExceptScope() const { return getFlags() & Scope::SEHExceptScope; }
429 /// \brief Returns if rhs has a higher scope depth than this.
433 bool Contains(const Scope& rhs) const { return Depth < rhs.Depth; }
435 /// containedInPrototypeScope - Return true if this or a parent scope
469 /// Init - This is used by the parser to implement scope caching.
471 void Init(Scope *parent, unsigned flags);
473 /// \brief Sets up the specified scope flags and adjusts the scope state