Go to the documentation of this file.
16 #include "llvm/Support/raw_ostream.h"
18 using namespace clang;
20 void Scope::setFlags(
Scope *parent,
unsigned flags) {
24 if (parent && !(flags &
FnScope)) {
25 BreakParent = parent->BreakParent;
26 ContinueParent = parent->ContinueParent;
30 BreakParent = ContinueParent =
nullptr;
34 Depth = parent->Depth + 1;
35 PrototypeDepth = parent->PrototypeDepth;
37 FnParent = parent->FnParent;
38 BlockParent = parent->BlockParent;
39 TemplateParamParent = parent->TemplateParamParent;
40 MSLastManglingParent = parent->MSLastManglingParent;
50 MSLastManglingParent = FnParent = BlockParent =
nullptr;
51 TemplateParamParent =
nullptr;
52 MSLastManglingNumber = 1;
53 MSCurManglingNumber = 1;
57 if (flags &
FnScope) FnParent =
this;
62 MSLastManglingParent =
this;
63 MSCurManglingNumber = 1;
88 setFlags(parent, flags);
91 UsingDirectives.clear();
94 NRVO.setPointerAndInt(
nullptr,
false);
98 const Scope *S =
this;
100 if (S->isFunctionPrototypeScope())
109 "Unsupported scope flags");
111 assert((Flags &
BreakScope) == 0 &&
"Already set");
116 ContinueParent =
this;
122 if (
VarDecl *Candidate = NRVO.getPointer()) {
124 Candidate->setNRVOVariable(
true);
132 else if (NRVO.getPointer())
140 bool HasFlags = Flags != 0;
145 std::pair<unsigned, const char *> FlagInfo[] = {
173 for (
auto Info : FlagInfo) {
174 if (Flags & Info.first) {
176 Flags &= ~Info.first;
182 assert(Flags == 0 &&
"Unknown scope flags");
188 OS <<
"Parent: (clang::Scope*)" <<
Parent <<
'\n';
190 OS <<
"Depth: " << Depth <<
'\n';
194 OS <<
"Entity : (clang::DeclContext*)" << DC <<
'\n';
197 OS <<
"NRVO not allowed\n";
198 else if (NRVO.getPointer())
199 OS <<
"NRVO candidate : (clang::VarDecl*)" << NRVO.getPointer() <<
'\n';
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
@ FunctionPrototypeScope
This is a scope that corresponds to the parameters within a function prototype.
@ FnScope
This indicates that the scope corresponds to a function, which means that labels are set here.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
void reset()
Set to initial state of "no errors occurred".
@ OpenMPLoopDirectiveScope
This is the scope of some OpenMP loop directive.
@ BlockScope
This is a scope that corresponds to a block/closure object.
unsigned getMSCurManglingNumber() const
@ SwitchScope
This is a scope that corresponds to a switch statement.
bool containedInPrototypeScope() const
containedInPrototypeScope - Return true if this or a parent scope is a FunctionPrototypeScope.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
@ OpenMPDirectiveScope
This is the scope of OpenMP executable directive.
@ SEHTryScope
This scope corresponds to an SEH try.
Scope - A scope is a transient data structure that is used while parsing the program.
bool isDeclScope(const Decl *D) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
void dumpImpl(raw_ostream &OS) const
void Init(Scope *parent, unsigned flags)
Init - This is used by the parser to implement scope caching.
@ CompoundStmtScope
This is a compound statement scope.
@ FunctionDeclarationScope
This is a scope that corresponds to the parameters within a function prototype for a function declara...
@ ContinueScope
This is a while, do, for, which can have continue statements embedded into it.
unsigned getMSLastManglingNumber() const
Represents a variable declaration or definition.
@ ControlScope
The controlling scope in a if/switch/while/for statement.
@ EnumScope
This scope corresponds to an enum.
void AddFlags(unsigned Flags)
Sets up the specified scope flags and adjusts the scope state variables accordingly.
void incrementMSManglingNumber()
@ TemplateParamScope
This is a scope that corresponds to the template parameters of a C++ template.
@ AtCatchScope
This is a scope that corresponds to the Objective-C @catch statement.
@ ClassInheritanceScope
We are between inheritance colon and the real class/struct definition scope.
@ ClassScope
The scope of a struct/union/class definition.
unsigned getFlags() const
getFlags - Return the flags for this scope.
@ SEHExceptScope
This scope corresponds to an SEH except.
void addNRVOCandidate(VarDecl *VD)
void mergeNRVOIntoParent()
@ CatchScope
This is the scope of a C++ catch statement.
DeclContext * getEntity() const
Get the entity corresponding to this scope.
@ SEHFilterScope
We are currently in the filter expression of an SEH except block.
@ ObjCMethodScope
This scope corresponds to an Objective-C method body.
@ TryScope
This is the scope of a C++ try statement.
@ DeclScope
This is a scope that can contain a declaration.
@ FnTryCatchScope
This is the scope for a function-level C++ try or catch scope.
@ BreakScope
This is a while, do, switch, for, etc that can have break statements embedded into it.
@ OpenMPSimdDirectiveScope
This is the scope of some OpenMP simd directive.