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