16#include "llvm/Support/raw_ostream.h"
20void 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 DeclParent = parent->DeclParent;
41 MSLastManglingParent = parent->MSLastManglingParent;
54 MSLastManglingParent = FnParent = BlockParent =
nullptr;
55 TemplateParamParent =
nullptr;
57 MSLastManglingNumber = 1;
58 MSCurManglingNumber = 1;
62 if (flags &
FnScope) FnParent =
this;
67 MSLastManglingParent =
this;
68 MSCurManglingNumber = 1;
96 setFlags(parent, flags);
99 UsingDirectives.clear();
106 const Scope *S =
this;
108 if (S->isFunctionPrototypeScope())
117 "Unsupported scope flags");
119 assert((Flags &
BreakScope) == 0 &&
"Already set");
124 ContinueParent =
this;
137 auto UpdateReturnSlotsInScopeForVD = [VD](
Scope *S) ->
bool {
138 bool IsReturnSlotFound = S->ReturnSlots.contains(VD);
143 S->ReturnSlots.clear();
145 if (IsReturnSlotFound)
146 S->ReturnSlots.insert(VD);
148 return IsReturnSlotFound;
151 bool CanBePutInReturnSlot =
false;
153 for (
auto *S =
this; S; S = S->getParent()) {
154 CanBePutInReturnSlot |= UpdateReturnSlotsInScopeForVD(S);
162 NRVO = CanBePutInReturnSlot ? VD :
nullptr;
167 if (!NRVO.has_value())
171 (*NRVO)->setNRVOVariable(
true);
200 bool HasFlags = Flags != 0;
205 std::pair<unsigned, const char *> FlagInfo[] = {
239 for (
auto Info : FlagInfo) {
240 if (Flags & Info.first) {
242 Flags &= ~Info.first;
248 assert(Flags == 0 &&
"Unknown scope flags");
254 OS <<
"Parent: (clang::Scope*)" <<
Parent <<
'\n';
256 OS <<
"Depth: " << Depth <<
'\n';
260 OS <<
"Entity : (clang::DeclContext*)" << DC <<
'\n';
263 OS <<
"there is no NRVO candidate\n";
265 OS <<
"NRVO candidate : (clang::VarDecl*)" << *NRVO <<
'\n';
267 OS <<
"NRVO is not allowed\n";
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".
Scope - A scope is a transient data structure that is used while parsing the program.
void Init(Scope *parent, unsigned flags)
Init - This is used by the parser to implement scope caching.
void AddFlags(unsigned Flags)
Sets up the specified scope flags and adjusts the scope state variables accordingly.
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
void incrementMSManglingNumber()
unsigned getFlags() const
getFlags - Return the flags for this scope.
bool isDeclScope(const Decl *D) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
unsigned getMSLastManglingNumber() const
DeclContext * getEntity() const
Get the entity corresponding to this scope.
unsigned getMSCurManglingNumber() const
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.
void updateNRVOCandidate(VarDecl *VD)
void dumpImpl(raw_ostream &OS) const
@ OpenMPDirectiveScope
This is the scope of OpenMP executable directive.
@ FunctionPrototypeScope
This is a scope that corresponds to the parameters within a function prototype.
@ OpenMPOrderClauseScope
This is a scope of some OpenMP directive with order clause which specifies concurrent.
@ LambdaScope
This is the scope for a lambda, after the lambda introducer.
@ BlockScope
This is a scope that corresponds to a block/closure object.
@ SEHTryScope
This scope corresponds to an SEH try.
@ FriendScope
This is a scope of friend declaration.
@ ContinueScope
This is a while, do, for, which can have continue statements embedded into it.
@ OpenACCComputeConstructScope
This is the scope of an OpenACC Compute Construct, which restricts jumping into/out of it.
@ TypeAliasScope
This is a scope of type alias declaration.
@ ControlScope
The controlling scope in a if/switch/while/for statement.
@ ClassInheritanceScope
We are between inheritance colon and the real class/struct definition scope.
@ AtCatchScope
This is a scope that corresponds to the Objective-C @catch statement.
@ TemplateParamScope
This is a scope that corresponds to the template parameters of a C++ template.
@ SEHFilterScope
We are currently in the filter expression of an SEH except block.
@ SwitchScope
This is a scope that corresponds to a switch statement.
@ BreakScope
This is a while, do, switch, for, etc that can have break statements embedded into it.
@ CatchScope
This is the scope of a C++ catch statement.
@ CompoundStmtScope
This is a compound statement scope.
@ FnTryCatchScope
This is the scope for a function-level C++ try or catch scope.
@ SEHExceptScope
This scope corresponds to an SEH except.
@ ClassScope
The scope of a struct/union/class definition.
@ TryScope
This is the scope of a C++ try statement.
@ OpenMPSimdDirectiveScope
This is the scope of some OpenMP simd directive.
@ FunctionDeclarationScope
This is a scope that corresponds to the parameters within a function prototype for a function declara...
@ ConditionVarScope
This is a scope in which a condition variable is currently being parsed.
@ FnScope
This indicates that the scope corresponds to a function, which means that labels are set here.
@ ObjCMethodScope
This scope corresponds to an Objective-C method body.
@ EnumScope
This scope corresponds to an enum.
@ OpenMPLoopDirectiveScope
This is the scope of some OpenMP loop directive.
@ DeclScope
This is a scope that can contain a declaration.
Represents a variable declaration or definition.
The JSON file list parser is used to communicate input to InstallAPI.