17 #include "llvm/Support/raw_ostream.h"
19 using namespace clang;
21 void Scope::setFlags(
Scope *parent,
unsigned flags) {
25 if (parent && !(flags &
FnScope)) {
26 BreakParent = parent->BreakParent;
27 ContinueParent = parent->ContinueParent;
31 BreakParent = ContinueParent =
nullptr;
35 Depth = parent->Depth + 1;
36 PrototypeDepth = parent->PrototypeDepth;
38 FnParent = parent->FnParent;
39 BlockParent = parent->BlockParent;
40 TemplateParamParent = parent->TemplateParamParent;
41 MSLastManglingParent = parent->MSLastManglingParent;
51 MSLastManglingParent = FnParent = BlockParent =
nullptr;
52 TemplateParamParent =
nullptr;
53 MSLastManglingNumber = 1;
54 MSCurManglingNumber = 1;
58 if (flags & FnScope) FnParent =
this;
63 MSLastManglingParent =
this;
64 MSCurManglingNumber = 1;
75 if (flags & FunctionPrototypeScope)
89 setFlags(parent, flags);
92 UsingDirectives.clear();
95 NRVO.setPointerAndInt(
nullptr, 0);
109 assert((FlagsToSet & ~(BreakScope | ContinueScope)) == 0 &&
110 "Unsupported scope flags");
111 if (FlagsToSet & BreakScope) {
112 assert((Flags & BreakScope) == 0 &&
"Already set");
115 if (FlagsToSet & ContinueScope) {
116 assert((Flags & ContinueScope) == 0 &&
"Already set");
117 ContinueParent =
this;
123 if (
VarDecl *Candidate = NRVO.getPointer()) {
125 Candidate->setNRVOVariable(
true);
133 else if (NRVO.getPointer())
141 bool HasFlags = Flags != 0;
147 if (Flags & FnScope) {
150 }
else if (Flags & BreakScope) {
152 Flags &= ~BreakScope;
153 }
else if (Flags & ContinueScope) {
154 OS <<
"ContinueScope";
155 Flags &= ~ContinueScope;
156 }
else if (Flags & DeclScope) {
160 OS <<
"ControlScope";
161 Flags &= ~ControlScope;
162 }
else if (Flags & ClassScope) {
164 Flags &= ~ClassScope;
165 }
else if (Flags & BlockScope) {
167 Flags &= ~BlockScope;
168 }
else if (Flags & TemplateParamScope) {
169 OS <<
"TemplateParamScope";
170 Flags &= ~TemplateParamScope;
171 }
else if (Flags & FunctionPrototypeScope) {
172 OS <<
"FunctionPrototypeScope";
173 Flags &= ~FunctionPrototypeScope;
175 OS <<
"FunctionDeclarationScope";
176 Flags &= ~FunctionDeclarationScope;
178 OS <<
"AtCatchScope";
179 Flags &= ~AtCatchScope;
181 OS <<
"ObjCMethodScope";
182 Flags &= ~ObjCMethodScope;
185 Flags &= ~SwitchScope;
190 OS <<
"FnTryCatchScope";
191 Flags &= ~FnTryCatchScope;
194 Flags &= ~SEHTryScope;
196 OS <<
"SEHExceptScope";
197 Flags &= ~SEHExceptScope;
199 OS <<
"OpenMPDirectiveScope";
200 Flags &= ~OpenMPDirectiveScope;
202 OS <<
"OpenMPLoopDirectiveScope";
203 Flags &= ~OpenMPLoopDirectiveScope;
205 OS <<
"OpenMPSimdDirectiveScope";
206 Flags &= ~OpenMPSimdDirectiveScope;
216 OS <<
"Parent: (clang::Scope*)" << Parent <<
'\n';
218 OS <<
"Depth: " << Depth <<
'\n';
222 OS <<
"Entity : (clang::DeclContext*)" << DC <<
'\n';
225 OS <<
"NRVO not allowed\n";
226 else if (NRVO.getPointer())
227 OS <<
"NRVO candidate : (clang::VarDecl*)" << NRVO.getPointer() <<
'\n';
void AddFlags(unsigned Flags)
Sets up the specified scope flags and adjusts the scope state variables accordingly.
unsigned getFlags() const
getFlags - Return the flags for this scope.
This is the scope of a C++ try statement.
This is a scope that corresponds to the parameters within a function prototype.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
This is a while, do, switch, for, etc that can have break statements embedded into it...
This indicates that the scope corresponds to a function, which means that labels are set here...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
The controlling scope in a if/switch/while/for statement.
This is a scope that corresponds to a block/closure object.
This scope corresponds to an enum.
This is a scope that corresponds to a switch statement.
This is a while, do, for, which can have continue statements embedded into it.
Scope - A scope is a transient data structure that is used while parsing the program.
void incrementMSManglingNumber()
unsigned getMSLastManglingNumber() const
bool isDeclScope(Decl *D)
isDeclScope - Return true if this is the scope that the specified decl is declared in...
This is the scope of OpenMP executable directive.
This scope corresponds to an SEH try.
This scope corresponds to an SEH except.
This is a scope that corresponds to the parameters within a function prototype for a function declara...
DeclContext * getEntity() const
bool containedInPrototypeScope() const
containedInPrototypeScope - Return true if this or a parent scope is a FunctionPrototypeScope.
This is a scope that corresponds to the Objective-C @catch statement.
void reset()
Set to initial state of "no errors occurred".
void dumpImpl(raw_ostream &OS) const
void Init(Scope *parent, unsigned flags)
Init - This is used by the parser to implement scope caching.
The scope of a struct/union/class definition.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
unsigned getMSCurManglingNumber() const
This is the scope of some OpenMP simd directive.
void addNRVOCandidate(VarDecl *VD)
This is a scope that corresponds to the template parameters of a C++ template.
void mergeNRVOIntoParent()
This is the scope for a function-level C++ try or catch scope.
This is a scope that can contain a declaration.
bool isFunctionPrototypeScope() const
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
This is the scope of some OpenMP loop directive.
This scope corresponds to an Objective-C method body.