22 using namespace clang;
54 WeakObjectUses.clear();
67 FunctionScopeInfo::WeakObjectProfileTy::BaseInfoTy
68 FunctionScopeInfo::WeakObjectProfileTy::getBaseInfo(
const Expr *E) {
75 case Stmt::DeclRefExprClass:
76 D = cast<DeclRefExpr>(E)->getDecl();
77 IsExact = isa<VarDecl>(D);
79 case Stmt::MemberExprClass: {
85 case Stmt::ObjCIvarRefExprClass: {
91 case Stmt::PseudoObjectExprClass: {
98 if (BaseProp->isObjectReceiver()) {
99 const Expr *DoubleBase = BaseProp->getBase();
100 if (
const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(DoubleBase))
101 DoubleBase = OVE->getSourceExpr();
112 return BaseInfoTy(D, IsExact);
115 FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(
122 Base = getBaseInfo(E);
130 FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(
const Expr *BaseE,
132 :
Base(nullptr,
true), Property(Prop) {
134 Base = getBaseInfo(BaseE);
138 FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(
140 :
Base(nullptr,
true), Property(DRE->getDecl()) {
141 assert(isa<VarDecl>(Property));
144 FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(
146 :
Base(getBaseInfo(IvarE->
getBase())), Property(IvarE->getDecl()) {
172 dyn_cast<BinaryConditionalOperator>(E)) {
179 FunctionScopeInfo::WeakObjectUseMap::iterator Uses = WeakObjectUses.end();
181 if (!RefExpr->isObjectReceiver())
183 if (isa<OpaqueValueExpr>(RefExpr->getBase()))
192 else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
193 if (isa<VarDecl>(DRE->getDecl()))
195 }
else if (
const ObjCMessageExpr *MsgE = dyn_cast<ObjCMessageExpr>(E)) {
207 if (Uses == WeakObjectUses.end())
211 FunctionScopeInfo::WeakUseVector::reverse_iterator ThisUse =
212 llvm::find(llvm::reverse(Uses->second),
WeakUseTy(E,
true));
213 if (ThisUse == Uses->second.rend())
222 return !isNested() && isVariableCapture() && getVariable()->isInitCapture();
226 for (
auto &Cap : Captures)
227 if (Cap.isVLATypeCapture() && Cap.getCapturedVLAType() == VAT)
233 llvm::function_ref<
void(
VarDecl *,
Expr *)> Callback)
const {
234 for (
Expr *E : PotentiallyCapturingExprs) {
235 if (
auto *DRE = dyn_cast<DeclRefExpr>(E)) {
236 Callback(cast<VarDecl>(DRE->getFoundDecl()), E);
237 }
else if (
auto *ME = dyn_cast<MemberExpr>(E)) {
238 Callback(cast<VarDecl>(ME->getMemberDecl()), E);
239 }
else if (
auto *FP = dyn_cast<FunctionParmPackExpr>(E)) {
243 llvm_unreachable(
"unexpected expression in potential captures list");
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool HasFallthroughStmt
Whether there is a fallthrough statement in this function.
bool isSuperReceiver() const
bool isVLATypeCaptured(const VariableArrayType *VAT) const
Determine whether the given variable-array type has been captured.
static const NamedDecl * getBestPropertyDecl(const ObjCPropertyRefExpr *PropE)
std::pair< Stmt *, Stmt * > CoroutineSuspends
The initial and final coroutine suspend points.
Represents a variable declaration or definition.
ObjCInterfaceDecl * getClassReceiver() const
ObjCMethodDecl - Represents an instance or class method declaration.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
bool NeedsCoroutineSuspends
True only when this function has not already built, or attempted to build, the initial and final coro...
Defines the clang::Expr interface and subclasses for C++ expressions.
bool HasDroppedStmt
Whether a statement was dropped because it was invalid.
ObjCPropertyDecl * getExplicitProperty() const
llvm::SmallMapVector< ParmVarDecl *, Stmt *, 4 > CoroutineParameterMoves
A mapping between the coroutine function parameters that were moved to the coroutine frame...
void visitPotentialCaptures(llvm::function_ref< void(VarDecl *, Expr *)> Callback) const
bool isExplicitProperty() const
~CapturedRegionScopeInfo() override
llvm::SmallPtrSet< const BlockDecl *, 1 > Blocks
The set of blocks that are introduced in this function.
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
SourceLocation FirstSEHTryLoc
First SEH '__try' statement in the current function.
DiagnosticErrorTrap ErrorTrap
Used to determine if errors occurred in this function or block.
bool isClassReceiver() const
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isObjCSelfExpr() const
Check if this expression is the ObjC 'self' implicit parameter.
SourceLocation FirstCXXTryLoc
First C++ 'try' statement in the current function.
ConditionalOperator - The ?: ternary operator.
SmallVector< ReturnStmt *, 4 > Returns
The list of return statements that occur within the function or block, if there is any chance of appl...
virtual ~FunctionScopeInfo()
void recordUseOfWeak(const ExprT *E, bool IsRead=true)
Record that a weak object was accessed.
This represents one expression.
SmallVector< SwitchInfo, 8 > SwitchStack
SwitchStack - This is the current set of active switch statements in the block.
bool HasBranchProtectedScope
Whether this function contains a VLA, @try, try, C++ initializer, or anything else that can't be jump...
An expression that sends a message to the given Objective-C object or class.
ObjCMethodDecl * getImplicitPropertyGetter() const
VarDecl * CoroutinePromise
The promise object for this coroutine, if any.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver. ...
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
bool HasPotentialAvailabilityViolations
Whether we make reference to a declaration that could be unavailable.
Encodes a location in the source.
bool ObjCWarnForNoDesignatedInitChain
This starts true for a method marked as designated initializer and will be set to false if there is a...
void reset()
Set to initial state of "no errors occurred".
SourceLocation FirstCoroutineStmtLoc
First coroutine statement in the current function.
Represents one property declaration in an Objective-C interface.
bool ObjCIsDesignatedInit
True when this is a method marked as a designated initializer.
bool ObjCShouldCallSuper
A flag that is set when parsing a method that must call super's implementation, such as -dealloc...
bool HasOMPDeclareReductionCombiner
True if current scope is for OpenMP declare reduction combiner.
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
Dataflow Directional Tag Classes.
bool ObjCIsSecondaryInit
True when this is an initializer method not marked as a designated initializer within a class that ha...
bool HasIndirectGoto
Whether this function contains any indirect gotos.
StmtClass getStmtClass() const
Represents a simple identification of a weak object.
bool ObjCWarnForNoInitDelegation
This starts true for a secondary initializer method and will be set to false if there is an invocatio...
const NamedDecl * getBase() const
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
SourceLocation FirstReturnLoc
First 'return' statement in the current function.
void markSafeWeakUse(const Expr *E)
Record that a given expression is a "safe" access of a weak object (e.g.
const Expr * getBase() const
ObjCIvarRefExpr - A reference to an ObjC instance variable.
bool isInitCapture() const
Determine whether this capture is an init-capture.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
SmallVector< PossiblyUnreachableDiag, 4 > PossiblyUnreachableDiags
A list of PartialDiagnostics created but delayed within the current function scope.
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
llvm::SmallPtrSet< const ParmVarDecl *, 8 > ModifiedNonNullParams
A list of parameters which have the nonnull attribute and are modified in the function.
Represents a single use of a weak object.
bool isObjectReceiver() const
A reference to a declared variable, function, enum, etc.
~BlockScopeInfo() override
const Expr * getBase() const
llvm::TinyPtrVector< VarDecl * > ByrefBlockVars
The set of __block variables that are introduced in this function.
This represents a decl that may have a name.
Represents a C array with a specified size that is not an integer-constant-expression.
void Clear()
Clear out the information in this function scope, making it suitable for reuse.
bool HasBranchIntoScope
Whether this function contains any switches or direct gotos.