1 //===- Scope.cpp - Lexical scope information --------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the Scope class, which is used for recording
11 // information about a lexical scope.
13 //===----------------------------------------------------------------------===//
15 #include "clang/Sema/Scope.h"
17 using namespace clang;
19 void Scope::Init(Scope *parent, unsigned flags) {
24 Depth = parent->Depth + 1;
25 PrototypeDepth = parent->PrototypeDepth;
27 FnParent = parent->FnParent;
28 BreakParent = parent->BreakParent;
29 ContinueParent = parent->ContinueParent;
30 ControlParent = parent->ControlParent;
31 BlockParent = parent->BlockParent;
32 TemplateParamParent = parent->TemplateParamParent;
37 FnParent = BreakParent = ContinueParent = BlockParent = 0;
39 TemplateParamParent = 0;
42 // If this scope is a function or contains breaks/continues, remember it.
43 if (flags & FnScope) FnParent = this;
44 if (flags & BreakScope) BreakParent = this;
45 if (flags & ContinueScope) ContinueParent = this;
46 if (flags & ControlScope) ControlParent = this;
47 if (flags & BlockScope) BlockParent = this;
48 if (flags & TemplateParamScope) TemplateParamParent = this;
50 // If this is a prototype scope, record that.
51 if (flags & FunctionPrototypeScope) PrototypeDepth++;
54 UsingDirectives.clear();