clang: lib/Sema/ScopeInfo.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

20

21using namespace clang;

22using namespace sema;

23

43

44

51

54 ErrorTrap.reset();

56 WeakObjectUses.clear();

61}

62

69

70FunctionScopeInfo::WeakObjectProfileTy::BaseInfoTy

71FunctionScopeInfo::WeakObjectProfileTy::getBaseInfo(const Expr *E) {

73

74 const NamedDecl *D = nullptr;

75 bool IsExact = false;

76

78 case Stmt::DeclRefExprClass:

81 break;

82 case Stmt::MemberExprClass: {

86 break;

87 }

88 case Stmt::ObjCIvarRefExprClass: {

92 break;

93 }

94 case Stmt::PseudoObjectExprClass: {

96 const ObjCPropertyRefExpr *BaseProp =

98 if (BaseProp) {

100

102 const Expr *DoubleBase = BaseProp->getBase();

103 if (const OpaqueValueExpr *OVE = dyn_cast(DoubleBase))

104 DoubleBase = OVE->getSourceExpr();

105

107 }

108 }

109 break;

110 }

111 default:

112 break;

113 }

114

115 return BaseInfoTy(D, IsExact);

116}

117

118FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(

121

123 const OpaqueValueExpr *OVE = cast(PropE->getBase());

124 const Expr *E = OVE->getSourceExpr();

125 Base = getBaseInfo(E);

127 Base.setPointer(PropE->getClassReceiver());

128 } else {

129 assert(PropE->isSuperReceiver());

130 }

131}

132

133FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(const Expr *BaseE,

136 if (BaseE)

137 Base = getBaseInfo(BaseE);

138

139}

140

141FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(

143 : Base(nullptr, true), Property(DRE->getDecl()) {

145}

146

147FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(

149 : Base(getBaseInfo(IvarE->getBase())), Property(IvarE->getDecl()) {

150}

151

154 assert(Msg && Prop);

158}

159

162

163 if (const PseudoObjectExpr *POE = dyn_cast(E)) {

165 return;

166 }

167

171 return;

172 }

173

175 dyn_cast(E)) {

178 return;

179 }

180

181

182 FunctionScopeInfo::WeakObjectUseMap::iterator Uses = WeakObjectUses.end();

183 if (const ObjCPropertyRefExpr *RefExpr = dyn_cast(E)) {

184 if (!RefExpr->isObjectReceiver())

185 return;

188 else {

190 return;

191 }

192 }

193 else if (const ObjCIvarRefExpr *IvarE = dyn_cast(E))

195 else if (const DeclRefExpr *DRE = dyn_cast(E)) {

198 } else if (const ObjCMessageExpr *MsgE = dyn_cast(E)) {

199 if (const ObjCMethodDecl *MD = MsgE->getMethodDecl()) {

201 Uses =

203 Prop));

204 }

205 }

206 }

207 else

208 return;

209

210 if (Uses == WeakObjectUses.end())

211 return;

212

213

214 FunctionScopeInfo::WeakUseVector::reverse_iterator ThisUse =

215 llvm::find(llvm::reverse(Uses->second), WeakUseTy(E, true));

216 if (ThisUse == Uses->second.rend())

217 return;

218

219 ThisUse->markSafe();

220}

221

227

230 if (Cap.isVLATypeCapture() && Cap.getCapturedVLAType() == VAT)

231 return true;

232 return false;

233}

234

236 llvm::function_ref<void(ValueDecl *, Expr *)> Callback) const {

238 if (auto *DRE = dyn_cast(E)) {

240 } else if (auto *ME = dyn_cast(E)) {

242 } else if (auto *FP = dyn_cast(E)) {

244 Callback(VD, E);

245 } else {

246 llvm_unreachable("unexpected expression in potential captures list");

247 }

248 }

249}

250

254 .getNonReferenceType()

255 .isConstQualified();

257}

258

Defines the clang::Expr interface and subclasses for C++ expressions.

static const NamedDecl * getBestPropertyDecl(const ObjCPropertyRefExpr *PropE)

Definition ScopeInfo.cpp:63

BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...

ConditionalOperator - The ?

A reference to a declared variable, function, enum, etc.

This represents one expression.

Expr * IgnoreParenCasts() LLVM_READONLY

Skip past any parentheses and casts which might surround this expression until reaching a fixed point...

Expr * IgnoreParenImpCasts() LLVM_READONLY

Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...

bool isObjCSelfExpr() const

Check if this expression is the ObjC 'self' implicit parameter.

ValueDecl * getMemberDecl() const

Retrieve the member declaration to which this expression refers.

This represents a decl that may have a name.

ObjCIvarRefExpr - A reference to an ObjC instance variable.

const Expr * getBase() const

An expression that sends a message to the given Objective-C object or class.

Expr * getInstanceReceiver()

Returns the object expression (receiver) for an instance message, or null for a message that is not a...

unsigned getNumArgs() const

Return the number of actual arguments in this message, not counting the receiver.

ObjCMethodDecl - Represents an instance or class method declaration.

Represents one property declaration in an Objective-C interface.

static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)

Lookup a property by name in the specified DeclContext.

ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.

ObjCPropertyDecl * getExplicitProperty() const

ObjCMethodDecl * getImplicitPropertyGetter() const

const Expr * getBase() const

bool isObjectReceiver() const

bool isExplicitProperty() const

bool isClassReceiver() const

PseudoObjectExpr - An expression which accesses a pseudo-object l-value.

Expr * getSyntacticForm()

Return the syntactic form of this expression, i.e.

Encodes a location in the source.

StmtClass getStmtClass() const

Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...

Represents a C array with a specified size that is not an integer-constant-expression.

~BlockScopeInfo() override

Definition ScopeInfo.cpp:260

ValueDecl * getVariable() const

bool isVariableCapture() const

bool isInitCapture() const

Determine whether this capture is an init-capture.

Definition ScopeInfo.cpp:222

~CapturedRegionScopeInfo() override

Definition ScopeInfo.cpp:261

SmallVector< Capture, 4 > Captures

Captures - The captures.

bool isVLATypeCaptured(const VariableArrayType *VAT) const

Determine whether the given variable-array type has been captured.

Definition ScopeInfo.cpp:228

Represents a simple identification of a weak object.

const NamedDecl * getBase() const

Represents a single use of a weak object.

SmallVector< ReturnStmt *, 4 > Returns

The list of return statements that occur within the function or block, if there is any chance of appl...

bool HasIndirectGoto

Whether this function contains any indirect gotos.

bool HasFallthroughStmt

Whether there is a fallthrough statement in this function.

SourceLocation FirstVLALoc

First use of a VLA within the current function.

SourceLocation FirstCXXOrObjCTryLoc

First C++ 'try' or ObjC @try statement in the current function.

bool UsesFPIntrin

Whether this function uses constrained floating point intrinsics.

llvm::SmallMapVector< ParmVarDecl *, Stmt *, 4 > CoroutineParameterMoves

A mapping between the coroutine function parameters that were moved to the coroutine frame,...

void recordUseOfWeak(const ExprT *E, bool IsRead=true)

Record that a weak object was accessed.

bool HasDroppedStmt

Whether a statement was dropped because it was invalid.

void markSafeWeakUse(const Expr *E)

Record that a given expression is a "safe" access of a weak object (e.g.

Definition ScopeInfo.cpp:160

SourceLocation FirstCoroutineStmtLoc

First coroutine statement in the current function.

bool FoundImmediateEscalatingExpression

Whether we found an immediate-escalating expression.

std::pair< Stmt *, Stmt * > CoroutineSuspends

The initial and final coroutine suspend points.

bool ObjCIsDesignatedInit

True when this is a method marked as a designated initializer.

void Clear()

Clear out the information in this function scope, making it suitable for reuse.

Definition ScopeInfo.cpp:24

bool ObjCShouldCallSuper

A flag that is set when parsing a method that must call super's implementation, such as -dealloc,...

VarDecl * CoroutinePromise

The promise object for this coroutine, if any.

SmallVector< WeakUseTy, 4 > WeakUseVector

Used to collect uses of a particular weak object in a function body.

bool HasBranchProtectedScope

Whether this function contains a VLA, @try, try, C++ initializer, or anything else that can't be jump...

SmallVector< PossiblyUnreachableDiag, 4 > PossiblyUnreachableDiags

A list of PartialDiagnostics created but delayed within the current function scope.

bool ObjCWarnForNoInitDelegation

This starts true for a secondary initializer method and will be set to false if there is an invocatio...

bool HasPotentialAvailabilityViolations

Whether we make reference to a declaration that could be unavailable.

SourceLocation FirstReturnLoc

First 'return' statement in the current function.

bool HasBranchIntoScope

Whether this function contains any switches or direct gotos.

SourceLocation FirstSEHTryLoc

First SEH '__try' statement in the current function.

llvm::SmallPtrSet< const BlockDecl *, 1 > Blocks

The set of blocks that are introduced in this function.

bool ObjCIsSecondaryInit

True when this is an initializer method not marked as a designated initializer within a class that ha...

bool NeedsCoroutineSuspends

True only when this function has not already built, or attempted to build, the initial and final coro...

llvm::SmallVector< AddrLabelExpr *, 4 > AddrLabels

The set of GNU address of label extension "&&label".

llvm::TinyPtrVector< VarDecl * > ByrefBlockVars

The set of __block variables that are introduced in this function.

bool ObjCWarnForNoDesignatedInitChain

This starts true for a method marked as designated initializer and will be set to false if there is a...

SmallVector< SwitchInfo, 8 > SwitchStack

SwitchStack - This is the current set of active switch statements in the block.

bool HasOMPDeclareReductionCombiner

True if current scope is for OpenMP declare reduction combiner.

virtual ~FunctionScopeInfo()

Definition ScopeInfo.cpp:259

llvm::SmallPtrSet< const ParmVarDecl *, 8 > ModifiedNonNullParams

A list of parameters which have the nonnull attribute and are modified in the function.

bool lambdaCaptureShouldBeConst() const

Definition ScopeInfo.cpp:251

ParmVarDecl * ExplicitObjectParameter

void visitPotentialCaptures(llvm::function_ref< void(ValueDecl *, Expr *)> Callback) const

Definition ScopeInfo.cpp:235

bool Mutable

Whether this is a mutable lambda.

llvm::SmallVector< Expr *, 4 > PotentiallyCapturingExprs

Contains all variable-referring-expressions (i.e.

The JSON file list parser is used to communicate input to InstallAPI.

bool isa(CodeGen::Address addr)

if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))

nullptr

This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...

U cast(CodeGen::Address addr)