23 using namespace clang;
47 WeakObjectUses.clear();
58 FunctionScopeInfo::WeakObjectProfileTy::BaseInfoTy
59 FunctionScopeInfo::WeakObjectProfileTy::getBaseInfo(
const Expr *
E) {
65 switch (E->getStmtClass()) {
66 case Stmt::DeclRefExprClass:
67 D = cast<DeclRefExpr>(
E)->getDecl();
68 IsExact = isa<VarDecl>(D);
70 case Stmt::MemberExprClass: {
76 case Stmt::ObjCIvarRefExprClass: {
82 case Stmt::PseudoObjectExprClass: {
89 if (BaseProp->isObjectReceiver()) {
90 const Expr *DoubleBase = BaseProp->getBase();
92 DoubleBase = OVE->getSourceExpr();
103 return BaseInfoTy(D, IsExact);
108 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(
this))
110 else if (
auto CRSI = dyn_cast<CapturedRegionScopeInfo>(
this))
111 RD = CRSI->TheRecordDecl;
114 for (
auto *FD : RD->
fields()) {
115 if (FD->hasCapturedVLAType() && FD->getCapturedVLAType() == VAT)
121 FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(
128 Base = getBaseInfo(E);
136 FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(
const Expr *BaseE,
140 Base = getBaseInfo(BaseE);
144 FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(
147 assert(isa<VarDecl>(Property));
150 FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(
152 :
Base(getBaseInfo(IvarE->getBase())),
Property(IvarE->getDecl()) {
178 dyn_cast<BinaryConditionalOperator>(E)) {
187 if (!RefExpr->isObjectReceiver())
189 if (isa<OpaqueValueExpr>(RefExpr->getBase()))
198 else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
201 Uses = WeakObjectUses.end();
213 if (Uses == WeakObjectUses.end())
217 FunctionScopeInfo::WeakUseVector::reverse_iterator ThisUse =
218 llvm::find(llvm::reverse(Uses->second),
WeakUseTy(E,
true));
219 if (ThisUse == Uses->second.rend())
227 assert(Idx < getNumPotentialVariableCaptures() &&
228 "Index of potential capture must be within 0 to less than the "
229 "number of captures!");
230 E = PotentiallyCapturingExprs[Idx];
232 VD = dyn_cast<
VarDecl>(DRE->getFoundDecl());
233 else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E))
236 llvm_unreachable(
"Only DeclRefExprs or MemberExprs should be added for "
237 "potential captures");
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
const Expr * getBase() const
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
static const NamedDecl * getBestPropertyDecl(const ObjCPropertyRefExpr *PropE)
VarDecl - An instance of this class is created to represent a variable declaration or definition...
bool isExplicitProperty() const
SmallVector< SwitchStmt *, 8 > SwitchStack
SwitchStack - This is the current set of active switch statements in the block.
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.
Defines the clang::Expr interface and subclasses for C++ expressions.
bool HasDroppedStmt
Whether a statement was dropped because it was invalid.
RecordDecl - Represents a struct/union/class.
ObjCInterfaceDecl * getClassReceiver() const
~CapturedRegionScopeInfo() override
SourceLocation FirstSEHTryLoc
First SEH '__try' statement in the current function.
DiagnosticErrorTrap ErrorTrap
Used to determine if errors occurred in this function or block.
void getPotentialVariableCapture(unsigned Idx, VarDecl *&VD, Expr *&E) const
bool isSuperReceiver() const
field_range fields() const
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
const Expr * getBase() const
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.
bool isObjCSelfExpr() const
Check if this expression is the ObjC 'self' implicit parameter.
Expr - This represents one expression.
ObjCMethodDecl * getImplicitPropertyGetter() const
bool HasBranchProtectedScope
Whether this function contains a VLA, @try, try, C++ initializer, or anything else that can't be jump...
bool isVLATypeCaptured(const VariableArrayType *VAT) const
Determine whether the given variable-array type has been captured.
An expression that sends a message to the given Objective-C object or class.
llvm::SmallPtrSet< const ParmVarDecl *, 8 > ModifiedNonNullParams
A list of parameters which have the nonnull attribute and are modified in the function.
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...
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Encodes a location in the source.
const TemplateArgument * iterator
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
SmallVector< Stmt *, 4 > CoroutineStmts
The list of coroutine control flow constructs (co_await, co_yield, co_return) that occur within the f...
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".
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 isObjectReceiver() const
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...
bool ObjCIsSecondaryInit
True when this is an initializer method not marked as a designated initializer within a class that ha...
bool isClassReceiver() const
bool HasIndirectGoto
Whether this function contains any indirect gotos.
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...
detail::InMemoryDirectory::const_iterator E
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
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.
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver. ...
ObjCPropertyDecl * getExplicitProperty() const
ObjCIvarRefExpr - A reference to an ObjC instance variable.
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...
Represents a single use of a weak object.
A reference to a declared variable, function, enum, etc.
~BlockScopeInfo() override
NamedDecl - This represents a decl with 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.