]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - contrib/llvm/tools/clang/lib/Sema/Scope.cpp
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.git] / contrib / llvm / tools / clang / lib / Sema / Scope.cpp
1 //===- Scope.cpp - Lexical scope information --------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the Scope class, which is used for recording
11 // information about a lexical scope.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "clang/Sema/Scope.h"
16
17 using namespace clang;
18
19 void Scope::Init(Scope *parent, unsigned flags) {
20   AnyParent = parent;
21   Flags = flags;
22     
23   if (parent) {
24     Depth = parent->Depth + 1;
25     PrototypeDepth = parent->PrototypeDepth;
26     PrototypeIndex = 0;
27     FnParent       = parent->FnParent;
28     BreakParent    = parent->BreakParent;
29     ContinueParent = parent->ContinueParent;
30     ControlParent  = parent->ControlParent;
31     BlockParent    = parent->BlockParent;
32     TemplateParamParent = parent->TemplateParamParent;
33   } else {
34     Depth = 0;
35     PrototypeDepth = 0;
36     PrototypeIndex = 0;
37     FnParent = BreakParent = ContinueParent = BlockParent = 0;
38     ControlParent = 0;
39     TemplateParamParent = 0;
40   }
41
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;
49
50   // If this is a prototype scope, record that.
51   if (flags & FunctionPrototypeScope) PrototypeDepth++;
52
53   DeclsInScope.clear();
54   UsingDirectives.clear();
55   Entity = 0;
56   ErrorTrap.reset();
57 }