14 #ifndef LLVM_CLANG_SEMA_SCOPE_H
15 #define LLVM_CLANG_SEMA_SCOPE_H
19 #include "llvm/ADT/PointerIntPair.h"
20 #include "llvm/ADT/SmallPtrSet.h"
21 #include "llvm/ADT/SmallVector.h"
32 class UsingDirectiveDecl;
139 unsigned short Depth;
143 unsigned short MSLastManglingNumber;
145 unsigned short MSCurManglingNumber;
149 unsigned short PrototypeDepth;
153 unsigned short PrototypeIndex;
158 Scope *MSLastManglingParent;
164 Scope *BreakParent, *ContinueParent;
174 Scope *TemplateParamParent;
182 typedef llvm::SmallPtrSet<Decl *, 32> DeclSetTy;
183 DeclSetTy DeclsInScope;
191 UsingDirectivesTy UsingDirectives;
198 llvm::PointerIntPair<VarDecl *, 1, bool> NRVO;
200 void setFlags(
Scope *Parent,
unsigned F);
205 Init(Parent, ScopeFlags);
227 return MSLastManglingParent;
234 return ContinueParent;
259 return PrototypeDepth;
266 return PrototypeIndex++;
269 typedef llvm::iterator_range<DeclSetTy::iterator>
decl_range;
271 return decl_range(DeclsInScope.begin(), DeclsInScope.end());
276 DeclsInScope.insert(D);
280 DeclsInScope.erase(D);
285 MSLMP->MSLastManglingNumber += 1;
286 MSCurManglingNumber += 1;
292 MSLMP->MSLastManglingNumber -= 1;
293 MSCurManglingNumber -= 1;
299 return MSLMP->MSLastManglingNumber;
304 return MSCurManglingNumber;
310 return DeclsInScope.count(D) != 0;
334 assert(FnS->getParent() &&
"TUScope not created?");
335 return FnS->getParent()->isClassScope();
343 for (
const Scope *
S =
this;
S;
S =
S->getParent()) {
354 if (
const Scope *
S =
this) {
382 for (
const Scope *
S =
this;
S;
S =
S->getParent()) {
404 "OpenMP loop directive scope is not a directive scope");
443 UsingDirectives.push_back(UDir);
446 typedef llvm::iterator_range<UsingDirectivesTy::iterator>
451 UsingDirectives.end());
457 if (NRVO.getPointer() ==
nullptr) {
461 if (NRVO.getPointer() != VD)
467 NRVO.setPointer(
nullptr);
474 void Init(
Scope *parent,
unsigned flags);
481 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
getFlags - Return the flags for this scope.
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
getFnParent - Return the closest scope that is a function body.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
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
Returns the number of function prototype scopes in this scope chain.
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by...
bool hasErrorOccurred() const
Determine whether any errors have occurred since this object instance was created.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
ScopeFlags
ScopeFlags - These are bitfields that are or'd together when creating a scope, which defines the sort...
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
isInObjcMethodOuterScope - Return true if this scope is an Objective-C method outer most body...
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()
Scope * getBreakParent()
getBreakParent - Return the closest scope that a break statement would be affected by...
The controlling scope in a if/switch/while/for statement.
This is a scope that corresponds to a block/closure object.
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
Scope - A scope is a transient data structure that is used while parsing the program.
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)
isDeclScope - Return true if this is the scope that the specified decl is declared in...
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
isInCXXInlineMethodScope - Return true if this scope is a C++ inline method scope or is inside one...
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
containedInPrototypeScope - Return true if this or a parent scope is a FunctionPrototypeScope.
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
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
const Scope * getTemplateParamParent() const
void dumpImpl(raw_ostream &OS) const
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.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
unsigned getMSCurManglingNumber() const
This is the scope of some OpenMP simd directive.
const Scope * getBlockParent() const
void addNRVOCandidate(VarDecl *VD)
unsigned getNextFunctionPrototypeIndex()
Return the number of parameters declared in this function prototype, increasing it by one for the nex...
This is a scope that corresponds to the template parameters of a C++ template.
detail::InMemoryDirectory::const_iterator E
void mergeNRVOIntoParent()
llvm::iterator_range< UsingDirectivesTy::iterator > using_directives_range
Defines the Diagnostic-related interfaces.
void PushUsingDirective(UsingDirectiveDecl *UDir)
bool isInObjcMethodScope() const
isInObjcMethodScope - Return true if this scope is, or is contained in, an Objective-C method body...
This is the scope for a function-level C++ try or catch scope.
This is a scope that can contain a declaration.
bool isFunctionPrototypeScope() const
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
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.