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;
74 if (flags & FunctionPrototypeScope)
88 setFlags(parent, flags);
91 UsingDirectives.clear();
94 NRVO.setPointerAndInt(
nullptr, 0);
98 const Scope *S =
this;
108 assert((FlagsToSet & ~(BreakScope | ContinueScope)) == 0 &&
109 "Unsupported scope flags");
110 if (FlagsToSet & BreakScope) {
111 assert((Flags & BreakScope) == 0 &&
"Already set");
114 if (FlagsToSet & ContinueScope) {
115 assert((Flags & ContinueScope) == 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';
void AddFlags(unsigned Flags)
Sets up the specified scope flags and adjusts the scope state variables accordingly.
This is the scope of a C++ try statement.
This is a scope that corresponds to the parameters within a function prototype.
bool containedInPrototypeScope() const
containedInPrototypeScope - Return true if this or a parent scope is a FunctionPrototypeScope.
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...
Represents 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.
bool isFunctionPrototypeScope() const
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
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.
unsigned getMSLastManglingNumber() const
Scope - A scope is a transient data structure that is used while parsing the program.
void incrementMSManglingNumber()
unsigned getFlags() const
getFlags - Return the flags for this scope.
bool isDeclScope(Decl *D)
isDeclScope - Return true if this is the scope that the specified decl is declared in...
DeclContext * getEntity() const
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 compound statement scope.
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
This is a scope that corresponds to the parameters within a function prototype for a function declara...
unsigned getMSCurManglingNumber() const
This is a scope that corresponds to the Objective-C @catch statement.
void reset()
Set to initial state of "no errors occurred".
void Init(Scope *parent, unsigned flags)
Init - This is used by the parser to implement scope caching.
We are currently in the filter expression of an SEH except block.
The scope of a struct/union/class definition.
Dataflow Directional Tag Classes.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
This is the scope of some OpenMP simd directive.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
void addNRVOCandidate(VarDecl *VD)
This is a scope that corresponds to the template parameters of a C++ template.
void dumpImpl(raw_ostream &OS) const
void mergeNRVOIntoParent()
This is the scope for a function-level C++ try or catch scope.
We are between inheritance colon and the real class/struct definition scope.
This is a scope that can contain a declaration.
This is the scope of some OpenMP loop directive.
This is the scope of a C++ catch statement.
This scope corresponds to an Objective-C method body.