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);
99 const Scope *S =
this;
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;
146 std::pair<unsigned, const char *> FlagInfo[] = {
172 for (
auto Info : FlagInfo) {
173 if (Flags & Info.first) {
175 Flags &= ~Info.first;
181 assert(Flags == 0 &&
"Unknown scope flags");
187 OS <<
"Parent: (clang::Scope*)" <<
Parent <<
'\n';
189 OS <<
"Depth: " << Depth <<
'\n';
193 OS <<
"Entity : (clang::DeclContext*)" << DC <<
'\n';
196 OS <<
"NRVO not allowed\n";
197 else if (NRVO.getPointer())
198 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 scope corresponds to an Objective-C method body.