23 using namespace clang;
55 WeakObjectUses.clear();
66 FunctionScopeInfo::WeakObjectProfileTy::BaseInfoTy
67 FunctionScopeInfo::WeakObjectProfileTy::getBaseInfo(
const Expr *E) {
74 case Stmt::DeclRefExprClass:
75 D = cast<DeclRefExpr>(E)->getDecl();
76 IsExact = isa<VarDecl>(D);
78 case Stmt::MemberExprClass: {
84 case Stmt::ObjCIvarRefExprClass: {
90 case Stmt::PseudoObjectExprClass: {
97 if (BaseProp->isObjectReceiver()) {
98 const Expr *DoubleBase = BaseProp->getBase();
100 DoubleBase = OVE->getSourceExpr();
111 return BaseInfoTy(D, IsExact);
116 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(
this))
118 else if (
auto CRSI = dyn_cast<CapturedRegionScopeInfo>(
this))
119 RD = CRSI->TheRecordDecl;
122 for (
auto *FD : RD->
fields()) {
123 if (FD->hasCapturedVLAType() && FD->getCapturedVLAType() == VAT)
129 FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(
136 Base = getBaseInfo(E);
144 FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(
const Expr *BaseE,
146 :
Base(nullptr,
true), Property(Prop) {
148 Base = getBaseInfo(BaseE);
152 FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(
154 :
Base(nullptr,
true), Property(DRE->getDecl()) {
155 assert(isa<VarDecl>(Property));
158 FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(
160 :
Base(getBaseInfo(IvarE->
getBase())), Property(IvarE->getDecl()) {
186 dyn_cast<BinaryConditionalOperator>(E)) {
193 FunctionScopeInfo::WeakObjectUseMap::iterator Uses = WeakObjectUses.end();
195 if (!RefExpr->isObjectReceiver())
197 if (isa<OpaqueValueExpr>(RefExpr->getBase()))
206 else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
207 if (isa<VarDecl>(DRE->getDecl()))
209 }
else if (
const ObjCMessageExpr *MsgE = dyn_cast<ObjCMessageExpr>(E)) {
221 if (Uses == WeakObjectUses.end())
225 FunctionScopeInfo::WeakUseVector::reverse_iterator ThisUse =
226 llvm::find(llvm::reverse(Uses->second),
WeakUseTy(E,
true));
227 if (ThisUse == Uses->second.rend())
235 assert(Idx < getNumPotentialVariableCaptures() &&
236 "Index of potential capture must be within 0 to less than the " 237 "number of captures!");
238 E = PotentiallyCapturingExprs[Idx];
240 VD = dyn_cast<
VarDecl>(DRE->getFoundDecl());
241 else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E))
242 VD = dyn_cast<VarDecl>(ME->getMemberDecl());
244 llvm_unreachable(
"Only DeclRefExprs or MemberExprs should be added for " 245 "potential captures");
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.
void getPotentialVariableCapture(unsigned Idx, VarDecl *&VD, Expr *&E) const
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...
Represents a struct/union/class.
bool isExplicitProperty() const
field_range fields() const
~CapturedRegionScopeInfo() override
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
IgnoreParenCasts - Ignore parentheses and casts.
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.
Expr - 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
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.
const Expr * getBase() 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...
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
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.