aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Parse/Scope.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Parse/Scope.h')
-rw-r--r--include/clang/Parse/Scope.h41
1 files changed, 25 insertions, 16 deletions
diff --git a/include/clang/Parse/Scope.h b/include/clang/Parse/Scope.h
index c9825f60c25c..d7a0e3583ca5 100644
--- a/include/clang/Parse/Scope.h
+++ b/include/clang/Parse/Scope.h
@@ -52,8 +52,8 @@ public:
/// BlockScope - This is a scope that corresponds to a block object.
/// Blocks serve as top-level scopes for some objects like labels, they
- /// also prevent things like break and continue. BlockScopes have the
- /// other flags set as well.
+ /// also prevent things like break and continue. BlockScopes always have
+ /// the FnScope, BreakScope, ContinueScope, and DeclScope flags set as well.
BlockScope = 0x40,
/// TemplateParamScope - This is a scope that corresponds to the
@@ -68,7 +68,15 @@ public:
/// AtCatchScope - This is a scope that corresponds to the Objective-C
/// @catch statement.
- AtCatchScope = 0x200
+ AtCatchScope = 0x200,
+
+ /// ObjCMethodScope - This scope corresponds to an Objective-C method body.
+ /// It always has FnScope and DeclScope set as well.
+ ObjCMethodScope = 0x400,
+
+ /// ElseScope - This scoep corresponds to an 'else' scope of an if/then/else
+ /// statement.
+ ElseScope = 0x800
};
private:
/// The parent scope for this scope. This is null for the translation-unit
@@ -77,15 +85,11 @@ private:
/// Depth - This is the depth of this scope. The translation-unit scope has
/// depth 0.
- unsigned Depth : 16;
+ unsigned short Depth;
/// Flags - This contains a set of ScopeFlags, which indicates how the scope
/// interrelates with other control flow statements.
- unsigned Flags : 10;
-
- /// WithinElse - Whether this scope is part of the "else" branch in
- /// its parent ControlScope.
- bool WithinElse : 1;
+ unsigned short Flags;
/// FnParent - If this scope has a parent scope that is a function body, this
/// pointer is non-null and points to it. This is used for label processing.
@@ -140,6 +144,7 @@ public:
/// getFlags - Return the flags for this scope.
///
unsigned getFlags() const { return Flags; }
+ void setFlags(unsigned F) { Flags = F; }
/// isBlockScope - Return true if this scope does not correspond to a
/// closure.
@@ -233,6 +238,17 @@ public:
}
return false;
}
+
+ /// isInObjcMethodScope - Return true if this scope is, or is contained in, an
+ /// Objective-C method body. Note that this method is not constant time.
+ bool isInObjcMethodScope() const {
+ for (const Scope *S = this; S; S = S->getParent()) {
+ // If this scope is an objc method scope, then we succeed.
+ if (S->getFlags() & ObjCMethodScope)
+ return true;
+ }
+ return false;
+ }
/// isTemplateParamScope - Return true if this scope is a C++
/// template parameter scope.
@@ -251,12 +267,6 @@ public:
return getFlags() & Scope::AtCatchScope;
}
- /// isWithinElse - Whether we are within the "else" of the
- /// ControlParent (if any).
- bool isWithinElse() const { return WithinElse; }
-
- void setWithinElse(bool WE) { WithinElse = WE; }
-
typedef UsingDirectivesTy::iterator udir_iterator;
typedef UsingDirectivesTy::const_iterator const_udir_iterator;
@@ -286,7 +296,6 @@ public:
AnyParent = Parent;
Depth = AnyParent ? AnyParent->Depth+1 : 0;
Flags = ScopeFlags;
- WithinElse = false;
if (AnyParent) {
FnParent = AnyParent->FnParent;