13#ifndef LLVM_CLANG_SEMA_SCOPE_H
14#define LLVM_CLANG_SEMA_SCOPE_H
18#include "llvm/ADT/PointerIntPair.h"
19#include "llvm/ADT/SmallPtrSet.h"
20#include "llvm/ADT/SmallVector.h"
21#include "llvm/ADT/iterator_range.h"
35class UsingDirectiveDecl;
178 unsigned short Depth;
182 unsigned short MSLastManglingNumber;
184 unsigned short MSCurManglingNumber;
188 unsigned short PrototypeDepth;
192 unsigned short PrototypeIndex;
197 Scope *MSLastManglingParent;
203 Scope *BreakParent, *ContinueParent;
213 Scope *TemplateParamParent;
226 DeclSetTy DeclsInScope;
234 UsingDirectivesTy UsingDirectives;
246 std::optional<VarDecl *> NRVO;
278 return MSLastManglingParent;
285 return ContinueParent;
295 Flags = (Flags & ~ConditionVarScope) |
327 return PrototypeDepth;
334 return PrototypeIndex++;
337 using decl_range = llvm::iterator_range<DeclSetTy::iterator>;
340 return decl_range(DeclsInScope.begin(), DeclsInScope.end());
346 if (
auto *VD = dyn_cast<VarDecl>(
D))
347 if (!isa<ParmVarDecl>(VD))
348 ReturnSlots.insert(VD);
350 DeclsInScope.insert(
D);
357 MSLMP->MSLastManglingNumber += 1;
358 MSCurManglingNumber += 1;
364 MSLMP->MSLastManglingNumber -= 1;
365 MSCurManglingNumber -= 1;
371 return MSLMP->MSLastManglingNumber;
376 return MSCurManglingNumber;
394 "entity associated with template param scope");
423 assert(FnS->getParent() &&
"TUScope not created?");
424 return FnS->getParent()->isClassScope();
432 for (
const Scope *S =
this; S; S = S->getParent()) {
443 if (
const Scope *S =
this) {
479 for (
const Scope *S =
this; S; S = S->getParent()) {
509 "OpenMP loop directive scope is not a directive scope");
525 return P &&
P->isOpenMPLoopDirectiveScope();
544 for (
const Scope *S =
this; S; S = S->getParent()) {
545 if (S->isOpenACCComputeConstructScope())
548 if (S->getFlags() & Flags)
551 else if (S->getFlags() &
606 UsingDirectives.push_back(UDir);
610 llvm::iterator_range<UsingDirectivesTy::iterator>;
614 UsingDirectives.end());
622 void Init(
Scope *parent,
unsigned flags);
628 void dumpImpl(raw_ostream &OS)
const;
Defines the Diagnostic-related interfaces.
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.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Decl - This represents one declaration (or definition), e.g.
RAII class that determines when any errors have occurred between the time the instance was created an...
bool hasUnrecoverableErrorOccurred() const
Determine whether any unrecoverable errors have occurred since this object instance was created.
Concrete class used by the front-end to report problems and issues.
Scope - A scope is a transient data structure that is used while parsing the program.
bool isFriendScope() const
Determine whether this scope is a friend scope.
Scope * getMSLastManglingParent()
void setEntity(DeclContext *E)
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.
bool isBlockScope() const
isBlockScope - Return true if this scope correspond to a closure.
unsigned getDepth() const
Returns the depth of this scope. The translation-unit has scope depth 0.
unsigned getNextFunctionPrototypeIndex()
Return the number of parameters declared in this function prototype, increasing it by one for the nex...
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
bool isSEHExceptScope() const
Determine whether this scope is a SEH '__except' block.
llvm::iterator_range< DeclSetTy::iterator > decl_range
bool isInObjcMethodOuterScope() const
isInObjcMethodOuterScope - Return true if this scope is an Objective-C method outer most body.
bool isAtCatchScope() const
isAtCatchScope - Return true if this scope is @catch.
bool isCatchScope() const
isCatchScope - Return true if this scope is a C++ catch statement.
void setFlags(unsigned F)
bool isInObjcMethodScope() const
isInObjcMethodScope - Return true if this scope is, or is contained in, an Objective-C method body.
void incrementMSManglingNumber()
const Scope * getBreakParent() const
bool isInCXXInlineMethodScope() const
isInCXXInlineMethodScope - Return true if this scope is a C++ inline method scope or is inside one.
bool Contains(const Scope &rhs) const
Returns if rhs has a higher scope depth than this.
const Scope * getMSLastManglingParent() const
bool isOpenMPLoopDirectiveScope() const
Determine whether this scope is some OpenMP loop directive scope (for example, 'omp for',...
unsigned getFlags() const
getFlags - Return the flags for this scope.
DeclContext * getLookupEntity() const
Get the DeclContext in which to continue unqualified lookup after a lookup in this scope.
bool isSwitchScope() const
isSwitchScope - Return true if this scope is a switch scope.
bool isTypeAliasScope() const
Determine whether this scope is a type alias scope.
bool isOpenMPDirectiveScope() const
Determines whether this scope is the OpenMP directive scope.
using_directives_range using_directives()
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by.
llvm::iterator_range< UsingDirectivesTy::iterator > using_directives_range
Scope(Scope *Parent, unsigned ScopeFlags, DiagnosticsEngine &Diag)
void setIsConditionVarScope(bool InConditionVarScope)
bool isDeclScope(const Decl *D) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
bool isFnTryCatchScope() const
Determine whether this scope is a function-level C++ try or catch scope.
void decrementMSManglingNumber()
bool isControlScope() const
Determine whether this scope is a controlling scope in a if/switch/while/for statement.
const Scope * getTemplateParamParent() const
void setLookupEntity(DeclContext *E)
unsigned getMSLastManglingNumber() const
DeclContext * getEntity() const
Get the entity corresponding to this scope.
unsigned getMSCurManglingNumber() const
bool isLoopScope() const
Return true if this scope is a loop.
bool isSEHTryScope() const
Determine whether this scope is a SEH '__try' block.
bool isOpenMPSimdDirectiveScope() const
Determine whether this scope is (or is nested into) some OpenMP loop simd directive scope (for exampl...
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
unsigned getFunctionPrototypeDepth() const
Returns the number of function prototype scopes in this scope chain.
Scope * getBreakParent()
getBreakParent - Return the closest scope that a break statement would be affected by.
bool isCompoundStmtScope() const
Determine whether this scope is a compound statement scope.
bool isInOpenACCComputeConstructScope(ScopeFlags Flags=NoScope) const
Determine if this scope (or its parents) are a compute construct.
bool isFunctionDeclarationScope() const
isFunctionDeclarationScope - Return true if this scope is a function prototype scope.
bool containedInPrototypeScope() const
containedInPrototypeScope - Return true if this or a parent scope is a FunctionPrototypeScope.
bool isOpenMPOrderClauseScope() const
Determine whether this scope is some OpenMP directive with order clause which specifies concurrent sc...
const Scope * getParent() const
getParent - Return the scope that this is nested in.
bool isContinueScope() const
Determine whether this scope is a while/do/for statement, which can have continue statements embedded...
bool isClassInheritanceScope() const
Determines whether this scope is between inheritance colon and the real class/struct definition.
bool isConditionVarScope() const
bool isFunctionPrototypeScope() const
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
bool isTryScope() const
Determine whether this scope is a C++ 'try' block.
void updateNRVOCandidate(VarDecl *VD)
const Scope * getBlockParent() const
bool isFunctionScope() const
isFunctionScope() - Return true if this scope is a function scope.
const Scope * getContinueParent() const
bool isOpenACCComputeConstructScope() const
Determine whether this scope is the statement associated with an OpenACC Compute construct directive.
void dumpImpl(raw_ostream &OS) const
const Scope * getDeclParent() const
bool hasUnrecoverableErrorOccurred() const
Determine whether any unrecoverable errors have occurred within this scope.
bool isOpenMPLoopScope() const
Determine whether this scope is a loop having OpenMP loop directive attached.
Scope * getTemplateParamParent()
ScopeFlags
ScopeFlags - These are bitfields that are or'd together when creating a scope, which defines the sort...
@ 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.
void PushUsingDirective(UsingDirectiveDecl *UDir)
Represents C++ using-directive.
Represents a variable declaration or definition.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
The JSON file list parser is used to communicate input to InstallAPI.
Diagnostic wrappers for TextAPI types for error reporting.