14 #ifndef LLVM_CLANG_SEMA_SCOPE_H
15 #define LLVM_CLANG_SEMA_SCOPE_H
18 #include "llvm/ADT/PointerIntPair.h"
19 #include "llvm/ADT/SmallPtrSet.h"
20 #include "llvm/ADT/SmallVector.h"
31 class UsingDirectiveDecl;
138 unsigned short Depth;
142 unsigned short MSLastManglingNumber;
144 unsigned short MSCurManglingNumber;
148 unsigned short PrototypeDepth;
152 unsigned short PrototypeIndex;
157 Scope *MSLastManglingParent;
163 Scope *BreakParent, *ContinueParent;
173 Scope *TemplateParamParent;
181 typedef llvm::SmallPtrSet<Decl *, 32> DeclSetTy;
182 DeclSetTy DeclsInScope;
190 UsingDirectivesTy UsingDirectives;
197 llvm::PointerIntPair<VarDecl *, 1, bool> NRVO;
202 Init(Parent, ScopeFlags);
224 return MSLastManglingParent;
231 return ContinueParent;
256 return PrototypeDepth;
263 return PrototypeIndex++;
266 typedef llvm::iterator_range<DeclSetTy::iterator>
decl_range;
268 return decl_range(DeclsInScope.begin(), DeclsInScope.end());
273 DeclsInScope.insert(D);
277 DeclsInScope.erase(D);
282 MSLMP->MSLastManglingNumber += 1;
283 MSCurManglingNumber += 1;
289 MSLMP->MSLastManglingNumber -= 1;
290 MSCurManglingNumber -= 1;
296 return MSLMP->MSLastManglingNumber;
301 return MSCurManglingNumber;
307 return DeclsInScope.count(D) != 0;
331 assert(FnS->getParent() &&
"TUScope not created?");
332 return FnS->getParent()->isClassScope();
340 for (
const Scope *
S =
this;
S;
S =
S->getParent()) {
351 if (
const Scope *
S =
this) {
379 for (
const Scope *
S =
this;
S;
S =
S->getParent()) {
401 "OpenMP loop directive scope is not a directive scope");
440 UsingDirectives.push_back(UDir);
443 typedef llvm::iterator_range<UsingDirectivesTy::iterator>
448 UsingDirectives.end());
454 if (NRVO.getPointer() ==
nullptr) {
458 if (NRVO.getPointer() != VD)
464 NRVO.setPointer(
nullptr);
471 void Init(
Scope *parent,
unsigned flags);
478 void dumpImpl(raw_ostream &OS)
const;
void AddFlags(unsigned Flags)
Sets up the specified scope flags and adjusts the scope state variables accordingly.
unsigned getFlags() const
This is the scope of a C++ try statement.
const Scope * getContinueParent() const
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
This is a scope that corresponds to the parameters within a function prototype.
bool hasErrorOccurred() const
const Scope * getFnParent() const
const Scope * getParent() const
void setFlags(unsigned F)
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...
unsigned getFunctionPrototypeDepth() const
Scope * getContinueParent()
bool hasErrorOccurred() const
Determine whether any errors have occurred since this object instance was created.
RAII class that determines when any errors have occurred between the time the instance was created an...
Scope(Scope *Parent, unsigned ScopeFlags, DiagnosticsEngine &Diag)
bool isInObjcMethodOuterScope() const
Scope * getTemplateParamParent()
bool isSEHTryScope() const
Determine whether this scope is a SEH '__try' block.
bool Contains(const Scope &rhs) const
Returns if rhs has a higher scope depth than this.
void decrementMSManglingNumber()
The controlling scope in a if/switch/while/for statement.
This is a scope that corresponds to a block/closure object. Blocks serve as top-level scopes for some...
bool hasUnrecoverableErrorOccurred() const
Determine whether any unrecoverable errors have occurred since this object instance was created...
This scope corresponds to an enum.
This is a scope that corresponds to a switch statement.
bool isOpenMPSimdDirectiveScope() const
Determine whether this scope is (or is nested into) some OpenMP loop simd directive scope (for exampl...
bool isOpenMPLoopDirectiveScope() const
Determine whether this scope is some OpenMP loop directive scope (for example, 'omp for'...
This is a while, do, for, which can have continue statements embedded into it.
Concrete class used by the front-end to report problems and issues.
const Scope * getBreakParent() const
using_directives_range using_directives()
bool isOpenMPLoopScope() const
Determine whether this scope is a loop having OpenMP loop directive attached.
bool hasUnrecoverableErrorOccurred() const
void incrementMSManglingNumber()
unsigned getMSLastManglingNumber() const
llvm::iterator_range< DeclSetTy::iterator > decl_range
bool isAtCatchScope() const
isAtCatchScope - Return true if this scope is @catch.
bool isDeclScope(Decl *D)
bool isSEHExceptScope() const
Determine whether this scope is a SEH '__except' block.
This is the scope of OpenMP executable directive.
This scope corresponds to an SEH try.
Scope * getMSLastManglingParent()
This scope corresponds to an SEH except.
bool isInCXXInlineMethodScope() const
bool isBlockScope() const
isBlockScope - Return true if this scope correspond to a closure.
const Scope * getMSLastManglingParent() const
This is a scope that corresponds to the parameters within a function prototype for a function declara...
DeclContext * getEntity() const
bool isSwitchScope() const
isSwitchScope - Return true if this scope is a switch scope.
bool containedInPrototypeScope() const
This is a scope that corresponds to the Objective-C @catch statement.
bool isTryScope() const
Determine whether this scope is a C++ 'try' block.
void setEntity(DeclContext *E)
bool isOpenMPDirectiveScope() const
Determines whether this scope is the OpenMP directive scope.
bool isTemplateParamScope() const
const Scope * getTemplateParamParent() const
void dumpImpl(raw_ostream &OS) const
void Init(Scope *parent, unsigned flags)
We are currently in the filter expression of an SEH except block.
The scope of a struct/union/class definition.
unsigned getMSCurManglingNumber() const
This is the scope of some OpenMP simd directive. For example, it is used for 'omp simd'...
const Scope * getBlockParent() const
void addNRVOCandidate(VarDecl *VD)
unsigned getNextFunctionPrototypeIndex()
This is a scope that corresponds to the template parameters of a C++ template. Template parameter sco...
void mergeNRVOIntoParent()
llvm::iterator_range< UsingDirectivesTy::iterator > using_directives_range
Defines the Diagnostic-related interfaces.
void PushUsingDirective(UsingDirectiveDecl *UDir)
bool isInObjcMethodScope() const
This is the scope for a function-level C++ try or catch scope.
This is a scope that can contain a declaration. Some scopes just contain loop constructs but don't co...
bool isFunctionPrototypeScope() const
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
bool isFunctionScope() const
isFunctionScope() - Return true if this scope is a function scope.
This is the scope of some OpenMP loop directive.
Represents C++ using-directive.
This scope corresponds to an Objective-C method body. It always has FnScope and DeclScope set as well...