clang
10.0.0git
|
Retains information about a function, method, or block that is currently being parsed. More...
#include "clang/Sema/ScopeInfo.h"
Classes | |
class | WeakObjectProfileTy |
Represents a simple identification of a weak object. More... | |
class | WeakUseTy |
Represents a single use of a weak object. More... | |
Public Types | |
using | SwitchInfo = llvm::PointerIntPair< SwitchStmt *, 1, bool > |
A SwitchStmt, along with a flag indicating if its list of case statements is incomplete (because we dropped an invalid one while parsing). More... | |
using | WeakUseVector = SmallVector< WeakUseTy, 4 > |
Used to collect uses of a particular weak object in a function body. More... | |
using | WeakObjectUseMap = llvm::SmallDenseMap< WeakObjectProfileTy, WeakUseVector, 8, WeakObjectProfileTy::DenseMapInfo > |
Used to collect all uses of weak objects in a function body. More... | |
Public Attributes | |
ScopeKind | Kind: 3 |
What kind of scope we are describing. More... | |
bool | HasBranchProtectedScope: 1 |
Whether this function contains a VLA, @try, try, C++ initializer, or anything else that can't be jumped past. More... | |
bool | HasBranchIntoScope: 1 |
Whether this function contains any switches or direct gotos. More... | |
bool | HasIndirectGoto: 1 |
Whether this function contains any indirect gotos. More... | |
bool | HasDroppedStmt: 1 |
Whether a statement was dropped because it was invalid. More... | |
bool | HasOMPDeclareReductionCombiner: 1 |
True if current scope is for OpenMP declare reduction combiner. More... | |
bool | HasFallthroughStmt: 1 |
Whether there is a fallthrough statement in this function. More... | |
bool | HasPotentialAvailabilityViolations: 1 |
Whether we make reference to a declaration that could be unavailable. More... | |
bool | ObjCShouldCallSuper: 1 |
A flag that is set when parsing a method that must call super's implementation, such as -dealloc , -finalize , or any method marked with attribute ((objc_requires_super)). More... | |
bool | ObjCIsDesignatedInit: 1 |
True when this is a method marked as a designated initializer. More... | |
bool | ObjCWarnForNoDesignatedInitChain: 1 |
This starts true for a method marked as designated initializer and will be set to false if there is an invocation to a designated initializer of the super class. More... | |
bool | ObjCIsSecondaryInit: 1 |
True when this is an initializer method not marked as a designated initializer within a class that has at least one initializer marked as a designated initializer. More... | |
bool | ObjCWarnForNoInitDelegation: 1 |
This starts true for a secondary initializer method and will be set to false if there is an invocation of an initializer on 'self'. More... | |
bool | NeedsCoroutineSuspends: 1 |
True only when this function has not already built, or attempted to build, the initial and final coroutine suspend points. More... | |
unsigned char | FirstCoroutineStmtKind: 2 |
An enumeration represeting the kind of the first coroutine statement in the function. More... | |
SourceLocation | FirstCoroutineStmtLoc |
First coroutine statement in the current function. More... | |
SourceLocation | FirstReturnLoc |
First 'return' statement in the current function. More... | |
SourceLocation | FirstCXXTryLoc |
First C++ 'try' statement in the current function. More... | |
SourceLocation | FirstSEHTryLoc |
First SEH '__try' statement in the current function. More... | |
DiagnosticErrorTrap | ErrorTrap |
Used to determine if errors occurred in this function or block. More... | |
SmallVector< SwitchInfo, 8 > | SwitchStack |
SwitchStack - This is the current set of active switch statements in the block. More... | |
SmallVector< ReturnStmt *, 4 > | Returns |
The list of return statements that occur within the function or block, if there is any chance of applying the named return value optimization, or if we need to infer a return type. More... | |
VarDecl * | CoroutinePromise = nullptr |
The promise object for this coroutine, if any. More... | |
llvm::SmallMapVector< ParmVarDecl *, Stmt *, 4 > | CoroutineParameterMoves |
A mapping between the coroutine function parameters that were moved to the coroutine frame, and their move statements. More... | |
std::pair< Stmt *, Stmt * > | CoroutineSuspends |
The initial and final coroutine suspend points. More... | |
SmallVector< CompoundScopeInfo, 4 > | CompoundScopes |
The stack of currently active compound stamement scopes in the function. More... | |
llvm::SmallPtrSet< const BlockDecl *, 1 > | Blocks |
The set of blocks that are introduced in this function. More... | |
llvm::TinyPtrVector< VarDecl * > | ByrefBlockVars |
The set of __block variables that are introduced in this function. More... | |
SmallVector< PossiblyUnreachableDiag, 4 > | PossiblyUnreachableDiags |
A list of PartialDiagnostics created but delayed within the current function scope. More... | |
llvm::SmallPtrSet< const ParmVarDecl *, 8 > | ModifiedNonNullParams |
A list of parameters which have the nonnull attribute and are modified in the function. More... | |
Protected Types | |
enum | ScopeKind { SK_Function, SK_Block, SK_Lambda, SK_CapturedRegion } |
Protected Member Functions | |
FunctionScopeInfo (const FunctionScopeInfo &)=default | |
Retains information about a function, method, or block that is currently being parsed.
Definition at line 98 of file ScopeInfo.h.
using clang::sema::FunctionScopeInfo::SwitchInfo = llvm::PointerIntPair<SwitchStmt*, 1, bool> |
A SwitchStmt, along with a flag indicating if its list of case statements is incomplete (because we dropped an invalid one while parsing).
Definition at line 182 of file ScopeInfo.h.
using clang::sema::FunctionScopeInfo::WeakObjectUseMap = llvm::SmallDenseMap<WeakObjectProfileTy, WeakUseVector, 8, WeakObjectProfileTy::DenseMapInfo> |
Used to collect all uses of weak objects in a function body.
Part of the implementation of -Wrepeated-use-of-weak.
Definition at line 354 of file ScopeInfo.h.
Used to collect uses of a particular weak object in a function body.
Part of the implementation of -Wrepeated-use-of-weak.
Definition at line 347 of file ScopeInfo.h.
|
protected |
Enumerator | |
---|---|
SK_Function | |
SK_Block | |
SK_Lambda | |
SK_CapturedRegion |
Definition at line 100 of file ScopeInfo.h.
|
protecteddefault |
|
inline |
Definition at line 366 of file ScopeInfo.h.
|
virtual |
Definition at line 248 of file ScopeInfo.cpp.
|
inline |
Definition at line 438 of file ScopeInfo.h.
|
inline |
Definition at line 443 of file ScopeInfo.h.
void FunctionScopeInfo::Clear | ( | ) |
Clear out the information in this function scope, making it suitable for reuse.
Definition at line 25 of file ScopeInfo.cpp.
References Blocks, ByrefBlockVars, CoroutineParameterMoves, CoroutinePromise, CoroutineSuspends, ErrorTrap, FirstCoroutineStmtLoc, FirstCXXTryLoc, FirstReturnLoc, FirstSEHTryLoc, HasBranchIntoScope, HasBranchProtectedScope, HasDroppedStmt, HasFallthroughStmt, HasIndirectGoto, HasOMPDeclareReductionCombiner, HasPotentialAvailabilityViolations, ModifiedNonNullParams, NeedsCoroutineSuspends, ObjCIsDesignatedInit, ObjCIsSecondaryInit, ObjCShouldCallSuper, ObjCWarnForNoDesignatedInitChain, ObjCWarnForNoInitDelegation, PossiblyUnreachableDiags, clang::DiagnosticErrorTrap::reset(), Returns, and SwitchStack.
|
inline |
Definition at line 459 of file ScopeInfo.h.
References clang::SourceLocation::isValid().
Referenced by clang::Sema::CheckCompletedCoroutineBody(), diagReturnOnAllocFailure(), and noteMemberDeclaredHere().
|
inline |
Definition at line 393 of file ScopeInfo.h.
Referenced by diagnoseRepeatedUseOfWeak().
|
inline |
Definition at line 477 of file ScopeInfo.h.
Referenced by clang::CoroutineStmtBuilder::buildDependentStatements().
|
inline |
Definition at line 447 of file ScopeInfo.h.
References clang::SourceLocation::isInvalid().
Referenced by clang::Sema::CheckCompletedCoroutineBody(), CheckFallThroughForBody(), and clang::sema::AnalysisBasedWarnings::IssueWarnings().
|
inline |
Definition at line 493 of file ScopeInfo.h.
Referenced by clang::Sema::PoppedFunctionScopeDeleter::operator()().
void FunctionScopeInfo::markSafeWeakUse | ( | const Expr * | E | ) |
Record that a given expression is a "safe" access of a weak object (e.g.
assigning it to a strong variable.)
Part of the implementation of -Wrepeated-use-of-weak.
Definition at line 157 of file ScopeInfo.cpp.
References clang::ObjCPropertyDecl::findPropertyDecl(), and clang::Expr::IgnoreParenCasts().
Referenced by LookupMethodInReceiverType().
|
inline |
Definition at line 431 of file ScopeInfo.h.
|
inline |
Record that a weak object was accessed.
Part of the implementation of -Wrepeated-use-of-weak.
Definition at line 1007 of file ScopeInfo.h.
Referenced by LookupMemberExpr(), and LookupMethodInReceiverType().
void FunctionScopeInfo::recordUseOfWeak | ( | const ObjCMessageExpr * | Msg, |
const ObjCPropertyDecl * | Prop | ||
) |
Definition at line 149 of file ScopeInfo.cpp.
References clang::ObjCMessageExpr::getInstanceReceiver(), and clang::ObjCMessageExpr::getNumArgs().
Definition at line 481 of file ScopeInfo.h.
|
inline |
Definition at line 449 of file ScopeInfo.h.
References clang::SourceLocation::isInvalid().
|
inline |
Definition at line 397 of file ScopeInfo.h.
|
inline |
Definition at line 401 of file ScopeInfo.h.
|
inline |
Definition at line 421 of file ScopeInfo.h.
|
inline |
Definition at line 409 of file ScopeInfo.h.
|
inline |
Definition at line 417 of file ScopeInfo.h.
|
inline |
Definition at line 405 of file ScopeInfo.h.
|
inline |
Definition at line 413 of file ScopeInfo.h.
|
inline |
Definition at line 426 of file ScopeInfo.h.
Referenced by clang::Sema::ActOnSEHTryBlock().
Definition at line 471 of file ScopeInfo.h.
llvm::SmallPtrSet<const BlockDecl *, 1> clang::sema::FunctionScopeInfo::Blocks |
The set of blocks that are introduced in this function.
Definition at line 208 of file ScopeInfo.h.
Referenced by Clear(), and markEscapingByrefs().
llvm::TinyPtrVector<VarDecl *> clang::sema::FunctionScopeInfo::ByrefBlockVars |
The set of __block variables that are introduced in this function.
Definition at line 211 of file ScopeInfo.h.
Referenced by Clear(), and markEscapingByrefs().
SmallVector<CompoundScopeInfo, 4> clang::sema::FunctionScopeInfo::CompoundScopes |
The stack of currently active compound stamement scopes in the function.
Definition at line 205 of file ScopeInfo.h.
Referenced by clang::Sema::DiagnoseUnexpandedParameterPacks(), clang::Sema::PopCompoundScope(), and clang::Sema::PushCompoundScope().
llvm::SmallMapVector<ParmVarDecl *, Stmt *, 4> clang::sema::FunctionScopeInfo::CoroutineParameterMoves |
A mapping between the coroutine function parameters that were moved to the coroutine frame, and their move statements.
Definition at line 198 of file ScopeInfo.h.
Referenced by Clear().
VarDecl* clang::sema::FunctionScopeInfo::CoroutinePromise = nullptr |
The promise object for this coroutine, if any.
Definition at line 194 of file ScopeInfo.h.
Referenced by clang::CoroutineStmtBuilder::buildDependentStatements(), clang::Sema::CheckCompletedCoroutineBody(), CheckFallThroughForBody(), Clear(), and diagReturnOnAllocFailure().
The initial and final coroutine suspend points.
Definition at line 201 of file ScopeInfo.h.
Referenced by clang::CoroutineStmtBuilder::buildDependentStatements(), and Clear().
DiagnosticErrorTrap clang::sema::FunctionScopeInfo::ErrorTrap |
Used to determine if errors occurred in this function or block.
Definition at line 178 of file ScopeInfo.h.
Referenced by Clear(), and clang::Sema::hasAnyUnrecoverableErrorsInThisFunction().
unsigned char clang::sema::FunctionScopeInfo::FirstCoroutineStmtKind |
An enumeration represeting the kind of the first coroutine statement in the function.
One of co_return, co_await, or co_yield.
Definition at line 162 of file ScopeInfo.h.
SourceLocation clang::sema::FunctionScopeInfo::FirstCoroutineStmtLoc |
First coroutine statement in the current function.
(ex co_return, co_await, co_yield)
Definition at line 166 of file ScopeInfo.h.
Referenced by clang::Sema::CheckCompletedCoroutineBody(), Clear(), diagReturnOnAllocFailure(), and noteMemberDeclaredHere().
SourceLocation clang::sema::FunctionScopeInfo::FirstCXXTryLoc |
First C++ 'try' statement in the current function.
Definition at line 172 of file ScopeInfo.h.
Referenced by clang::Sema::ActOnSEHTryBlock(), and Clear().
SourceLocation clang::sema::FunctionScopeInfo::FirstReturnLoc |
First 'return' statement in the current function.
Definition at line 169 of file ScopeInfo.h.
Referenced by clang::Sema::CheckCompletedCoroutineBody(), and Clear().
SourceLocation clang::sema::FunctionScopeInfo::FirstSEHTryLoc |
First SEH '__try' statement in the current function.
Definition at line 175 of file ScopeInfo.h.
Referenced by clang::Sema::ActOnCXXTryBlock(), Clear(), and diagReturnOnAllocFailure().
bool clang::sema::FunctionScopeInfo::HasBranchIntoScope |
Whether this function contains any switches or direct gotos.
Definition at line 116 of file ScopeInfo.h.
Referenced by Clear().
bool clang::sema::FunctionScopeInfo::HasBranchProtectedScope |
Whether this function contains a VLA, @try, try, C++ initializer, or anything else that can't be jumped past.
Definition at line 113 of file ScopeInfo.h.
Referenced by Clear().
bool clang::sema::FunctionScopeInfo::HasDroppedStmt |
Whether a statement was dropped because it was invalid.
Definition at line 122 of file ScopeInfo.h.
Referenced by Clear().
bool clang::sema::FunctionScopeInfo::HasFallthroughStmt |
Whether there is a fallthrough statement in this function.
Definition at line 128 of file ScopeInfo.h.
Referenced by Clear(), and clang::sema::AnalysisBasedWarnings::IssueWarnings().
bool clang::sema::FunctionScopeInfo::HasIndirectGoto |
Whether this function contains any indirect gotos.
Definition at line 119 of file ScopeInfo.h.
Referenced by Clear().
bool clang::sema::FunctionScopeInfo::HasOMPDeclareReductionCombiner |
True if current scope is for OpenMP declare reduction combiner.
Definition at line 125 of file ScopeInfo.h.
Referenced by Clear().
bool clang::sema::FunctionScopeInfo::HasPotentialAvailabilityViolations |
Whether we make reference to a declaration that could be unavailable.
Definition at line 132 of file ScopeInfo.h.
Referenced by Clear().
ScopeKind clang::sema::FunctionScopeInfo::Kind |
What kind of scope we are describing.
Definition at line 109 of file ScopeInfo.h.
Referenced by clang::sema::CapturingScopeInfo::classof(), clang::sema::BlockScopeInfo::classof(), clang::sema::CapturedRegionScopeInfo::classof(), and clang::sema::LambdaScopeInfo::classof().
llvm::SmallPtrSet<const ParmVarDecl *, 8> clang::sema::FunctionScopeInfo::ModifiedNonNullParams |
A list of parameters which have the nonnull attribute and are modified in the function.
Definition at line 220 of file ScopeInfo.h.
Referenced by Clear().
bool clang::sema::FunctionScopeInfo::NeedsCoroutineSuspends |
True only when this function has not already built, or attempted to build, the initial and final coroutine suspend points.
Definition at line 158 of file ScopeInfo.h.
Referenced by Clear().
bool clang::sema::FunctionScopeInfo::ObjCIsDesignatedInit |
True when this is a method marked as a designated initializer.
Definition at line 140 of file ScopeInfo.h.
Referenced by clang::Sema::ActOnStartOfObjCMethodDef(), and Clear().
bool clang::sema::FunctionScopeInfo::ObjCIsSecondaryInit |
True when this is an initializer method not marked as a designated initializer within a class that has at least one initializer marked as a designated initializer.
Definition at line 150 of file ScopeInfo.h.
Referenced by clang::Sema::ActOnStartOfObjCMethodDef(), and Clear().
bool clang::sema::FunctionScopeInfo::ObjCShouldCallSuper |
A flag that is set when parsing a method that must call super's implementation, such as -dealloc
, -finalize
, or any method marked with attribute
((objc_requires_super)).
Definition at line 137 of file ScopeInfo.h.
Referenced by clang::Sema::ActOnStartOfObjCMethodDef(), and Clear().
bool clang::sema::FunctionScopeInfo::ObjCWarnForNoDesignatedInitChain |
This starts true for a method marked as designated initializer and will be set to false if there is an invocation to a designated initializer of the super class.
Definition at line 145 of file ScopeInfo.h.
Referenced by clang::Sema::ActOnStartOfObjCMethodDef(), and Clear().
bool clang::sema::FunctionScopeInfo::ObjCWarnForNoInitDelegation |
This starts true for a secondary initializer method and will be set to false if there is an invocation of an initializer on 'self'.
Definition at line 154 of file ScopeInfo.h.
Referenced by clang::Sema::ActOnStartOfObjCMethodDef(), and Clear().
SmallVector<PossiblyUnreachableDiag, 4> clang::sema::FunctionScopeInfo::PossiblyUnreachableDiags |
A list of PartialDiagnostics created but delayed within the current function scope.
These diagnostics are vetted for reachability prior to being emitted.
Definition at line 216 of file ScopeInfo.h.
Referenced by Clear(), flushDiagnostics(), and clang::sema::AnalysisBasedWarnings::IssueWarnings().
SmallVector<ReturnStmt*, 4> clang::sema::FunctionScopeInfo::Returns |
The list of return statements that occur within the function or block, if there is any chance of applying the named return value optimization, or if we need to infer a return type.
Definition at line 191 of file ScopeInfo.h.
Referenced by Clear(), clang::Sema::computeNRVO(), and clang::Sema::deduceClosureReturnType().
SmallVector<SwitchInfo, 8> clang::sema::FunctionScopeInfo::SwitchStack |
SwitchStack - This is the current set of active switch statements in the block.
Definition at line 186 of file ScopeInfo.h.
Referenced by AddKeywordsToConsumer(), and Clear().