/src/llvm-project/clang/lib/AST/ComputeDependence.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===- ComputeDependence.cpp ----------------------------------------------===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | |
9 | | #include "clang/AST/ComputeDependence.h" |
10 | | #include "clang/AST/Attr.h" |
11 | | #include "clang/AST/DeclCXX.h" |
12 | | #include "clang/AST/DeclarationName.h" |
13 | | #include "clang/AST/DependenceFlags.h" |
14 | | #include "clang/AST/Expr.h" |
15 | | #include "clang/AST/ExprCXX.h" |
16 | | #include "clang/AST/ExprConcepts.h" |
17 | | #include "clang/AST/ExprObjC.h" |
18 | | #include "clang/AST/ExprOpenMP.h" |
19 | | #include "clang/Basic/ExceptionSpecificationType.h" |
20 | | #include "llvm/ADT/ArrayRef.h" |
21 | | |
22 | | using namespace clang; |
23 | | |
24 | 8 | ExprDependence clang::computeDependence(FullExpr *E) { |
25 | 8 | return E->getSubExpr()->getDependence(); |
26 | 8 | } |
27 | | |
28 | 0 | ExprDependence clang::computeDependence(OpaqueValueExpr *E) { |
29 | 0 | auto D = toExprDependenceForImpliedType(E->getType()->getDependence()); |
30 | 0 | if (auto *S = E->getSourceExpr()) |
31 | 0 | D |= S->getDependence(); |
32 | 0 | assert(!(D & ExprDependence::UnexpandedPack)); |
33 | 0 | return D; |
34 | 0 | } |
35 | | |
36 | 0 | ExprDependence clang::computeDependence(ParenExpr *E) { |
37 | 0 | return E->getSubExpr()->getDependence(); |
38 | 0 | } |
39 | | |
40 | | ExprDependence clang::computeDependence(UnaryOperator *E, |
41 | 11 | const ASTContext &Ctx) { |
42 | 11 | ExprDependence Dep = |
43 | | // FIXME: Do we need to look at the type? |
44 | 11 | toExprDependenceForImpliedType(E->getType()->getDependence()) | |
45 | 11 | E->getSubExpr()->getDependence(); |
46 | | |
47 | | // C++ [temp.dep.constexpr]p5: |
48 | | // An expression of the form & qualified-id where the qualified-id names a |
49 | | // dependent member of the current instantiation is value-dependent. An |
50 | | // expression of the form & cast-expression is also value-dependent if |
51 | | // evaluating cast-expression as a core constant expression succeeds and |
52 | | // the result of the evaluation refers to a templated entity that is an |
53 | | // object with static or thread storage duration or a member function. |
54 | | // |
55 | | // What this amounts to is: constant-evaluate the operand and check whether it |
56 | | // refers to a templated entity other than a variable with local storage. |
57 | 11 | if (Ctx.getLangOpts().CPlusPlus && E->getOpcode() == UO_AddrOf && |
58 | 11 | !(Dep & ExprDependence::Value)) { |
59 | 0 | Expr::EvalResult Result; |
60 | 0 | SmallVector<PartialDiagnosticAt, 8> Diag; |
61 | 0 | Result.Diag = &Diag; |
62 | | // FIXME: This doesn't enforce the C++98 constant expression rules. |
63 | 0 | if (E->getSubExpr()->EvaluateAsConstantExpr(Result, Ctx) && Diag.empty() && |
64 | 0 | Result.Val.isLValue()) { |
65 | 0 | auto *VD = Result.Val.getLValueBase().dyn_cast<const ValueDecl *>(); |
66 | 0 | if (VD && VD->isTemplated()) { |
67 | 0 | auto *VarD = dyn_cast<VarDecl>(VD); |
68 | 0 | if (!VarD || !VarD->hasLocalStorage()) |
69 | 0 | Dep |= ExprDependence::Value; |
70 | 0 | } |
71 | 0 | } |
72 | 0 | } |
73 | | |
74 | 11 | return Dep; |
75 | 11 | } |
76 | | |
77 | 0 | ExprDependence clang::computeDependence(UnaryExprOrTypeTraitExpr *E) { |
78 | | // Never type-dependent (C++ [temp.dep.expr]p3). |
79 | | // Value-dependent if the argument is type-dependent. |
80 | 0 | if (E->isArgumentType()) |
81 | 0 | return turnTypeToValueDependence( |
82 | 0 | toExprDependenceAsWritten(E->getArgumentType()->getDependence())); |
83 | | |
84 | 0 | auto ArgDeps = E->getArgumentExpr()->getDependence(); |
85 | 0 | auto Deps = ArgDeps & ~ExprDependence::TypeValue; |
86 | | // Value-dependent if the argument is type-dependent. |
87 | 0 | if (ArgDeps & ExprDependence::Type) |
88 | 0 | Deps |= ExprDependence::Value; |
89 | | // Check to see if we are in the situation where alignof(decl) should be |
90 | | // dependent because decl's alignment is dependent. |
91 | 0 | auto ExprKind = E->getKind(); |
92 | 0 | if (ExprKind != UETT_AlignOf && ExprKind != UETT_PreferredAlignOf) |
93 | 0 | return Deps; |
94 | 0 | if ((Deps & ExprDependence::Value) && (Deps & ExprDependence::Instantiation)) |
95 | 0 | return Deps; |
96 | | |
97 | 0 | auto *NoParens = E->getArgumentExpr()->IgnoreParens(); |
98 | 0 | const ValueDecl *D = nullptr; |
99 | 0 | if (const auto *DRE = dyn_cast<DeclRefExpr>(NoParens)) |
100 | 0 | D = DRE->getDecl(); |
101 | 0 | else if (const auto *ME = dyn_cast<MemberExpr>(NoParens)) |
102 | 0 | D = ME->getMemberDecl(); |
103 | 0 | if (!D) |
104 | 0 | return Deps; |
105 | 0 | for (const auto *I : D->specific_attrs<AlignedAttr>()) { |
106 | 0 | if (I->isAlignmentErrorDependent()) |
107 | 0 | Deps |= ExprDependence::Error; |
108 | 0 | if (I->isAlignmentDependent()) |
109 | 0 | Deps |= ExprDependence::ValueInstantiation; |
110 | 0 | } |
111 | 0 | return Deps; |
112 | 0 | } |
113 | | |
114 | 0 | ExprDependence clang::computeDependence(ArraySubscriptExpr *E) { |
115 | 0 | return E->getLHS()->getDependence() | E->getRHS()->getDependence(); |
116 | 0 | } |
117 | | |
118 | 0 | ExprDependence clang::computeDependence(MatrixSubscriptExpr *E) { |
119 | 0 | return E->getBase()->getDependence() | E->getRowIdx()->getDependence() | |
120 | 0 | (E->getColumnIdx() ? E->getColumnIdx()->getDependence() |
121 | 0 | : ExprDependence::None); |
122 | 0 | } |
123 | | |
124 | 0 | ExprDependence clang::computeDependence(CompoundLiteralExpr *E) { |
125 | 0 | return toExprDependenceAsWritten( |
126 | 0 | E->getTypeSourceInfo()->getType()->getDependence()) | |
127 | 0 | toExprDependenceForImpliedType(E->getType()->getDependence()) | |
128 | 0 | turnTypeToValueDependence(E->getInitializer()->getDependence()); |
129 | 0 | } |
130 | | |
131 | 28 | ExprDependence clang::computeDependence(ImplicitCastExpr *E) { |
132 | | // We model implicit conversions as combining the dependence of their |
133 | | // subexpression, apart from its type, with the semantic portion of the |
134 | | // target type. |
135 | 28 | ExprDependence D = |
136 | 28 | toExprDependenceForImpliedType(E->getType()->getDependence()); |
137 | 28 | if (auto *S = E->getSubExpr()) |
138 | 28 | D |= S->getDependence() & ~ExprDependence::Type; |
139 | 28 | return D; |
140 | 28 | } |
141 | | |
142 | 0 | ExprDependence clang::computeDependence(ExplicitCastExpr *E) { |
143 | | // Cast expressions are type-dependent if the type is |
144 | | // dependent (C++ [temp.dep.expr]p3). |
145 | | // Cast expressions are value-dependent if the type is |
146 | | // dependent or if the subexpression is value-dependent. |
147 | | // |
148 | | // Note that we also need to consider the dependence of the actual type here, |
149 | | // because when the type as written is a deduced type, that type is not |
150 | | // dependent, but it may be deduced as a dependent type. |
151 | 0 | ExprDependence D = |
152 | 0 | toExprDependenceAsWritten( |
153 | 0 | cast<ExplicitCastExpr>(E)->getTypeAsWritten()->getDependence()) | |
154 | 0 | toExprDependenceForImpliedType(E->getType()->getDependence()); |
155 | 0 | if (auto *S = E->getSubExpr()) |
156 | 0 | D |= S->getDependence() & ~ExprDependence::Type; |
157 | 0 | return D; |
158 | 0 | } |
159 | | |
160 | 26 | ExprDependence clang::computeDependence(BinaryOperator *E) { |
161 | 26 | return E->getLHS()->getDependence() | E->getRHS()->getDependence(); |
162 | 26 | } |
163 | | |
164 | 2 | ExprDependence clang::computeDependence(ConditionalOperator *E) { |
165 | | // The type of the conditional operator depends on the type of the conditional |
166 | | // to support the GCC vector conditional extension. Additionally, |
167 | | // [temp.dep.expr] does specify state that this should be dependent on ALL sub |
168 | | // expressions. |
169 | 2 | return E->getCond()->getDependence() | E->getLHS()->getDependence() | |
170 | 2 | E->getRHS()->getDependence(); |
171 | 2 | } |
172 | | |
173 | 0 | ExprDependence clang::computeDependence(BinaryConditionalOperator *E) { |
174 | 0 | return E->getCommon()->getDependence() | E->getFalseExpr()->getDependence(); |
175 | 0 | } |
176 | | |
177 | 0 | ExprDependence clang::computeDependence(StmtExpr *E, unsigned TemplateDepth) { |
178 | 0 | auto D = toExprDependenceForImpliedType(E->getType()->getDependence()); |
179 | | // Propagate dependence of the result. |
180 | 0 | if (const auto *CompoundExprResult = |
181 | 0 | dyn_cast_or_null<ValueStmt>(E->getSubStmt()->getStmtExprResult())) |
182 | 0 | if (const Expr *ResultExpr = CompoundExprResult->getExprStmt()) |
183 | 0 | D |= ResultExpr->getDependence(); |
184 | | // Note: we treat a statement-expression in a dependent context as always |
185 | | // being value- and instantiation-dependent. This matches the behavior of |
186 | | // lambda-expressions and GCC. |
187 | 0 | if (TemplateDepth) |
188 | 0 | D |= ExprDependence::ValueInstantiation; |
189 | | // A param pack cannot be expanded over stmtexpr boundaries. |
190 | 0 | return D & ~ExprDependence::UnexpandedPack; |
191 | 0 | } |
192 | | |
193 | 0 | ExprDependence clang::computeDependence(ConvertVectorExpr *E) { |
194 | 0 | auto D = toExprDependenceAsWritten( |
195 | 0 | E->getTypeSourceInfo()->getType()->getDependence()) | |
196 | 0 | E->getSrcExpr()->getDependence(); |
197 | 0 | if (!E->getType()->isDependentType()) |
198 | 0 | D &= ~ExprDependence::Type; |
199 | 0 | return D; |
200 | 0 | } |
201 | | |
202 | 0 | ExprDependence clang::computeDependence(ChooseExpr *E) { |
203 | 0 | if (E->isConditionDependent()) |
204 | 0 | return ExprDependence::TypeValueInstantiation | |
205 | 0 | E->getCond()->getDependence() | E->getLHS()->getDependence() | |
206 | 0 | E->getRHS()->getDependence(); |
207 | | |
208 | 0 | auto Cond = E->getCond()->getDependence(); |
209 | 0 | auto Active = E->getLHS()->getDependence(); |
210 | 0 | auto Inactive = E->getRHS()->getDependence(); |
211 | 0 | if (!E->isConditionTrue()) |
212 | 0 | std::swap(Active, Inactive); |
213 | | // Take type- and value- dependency from the active branch. Propagate all |
214 | | // other flags from all branches. |
215 | 0 | return (Active & ExprDependence::TypeValue) | |
216 | 0 | ((Cond | Active | Inactive) & ~ExprDependence::TypeValue); |
217 | 0 | } |
218 | | |
219 | 11 | ExprDependence clang::computeDependence(ParenListExpr *P) { |
220 | 11 | auto D = ExprDependence::None; |
221 | 11 | for (auto *E : P->exprs()) |
222 | 11 | D |= E->getDependence(); |
223 | 11 | return D; |
224 | 11 | } |
225 | | |
226 | 0 | ExprDependence clang::computeDependence(VAArgExpr *E) { |
227 | 0 | auto D = toExprDependenceAsWritten( |
228 | 0 | E->getWrittenTypeInfo()->getType()->getDependence()) | |
229 | 0 | (E->getSubExpr()->getDependence() & ~ExprDependence::Type); |
230 | 0 | return D; |
231 | 0 | } |
232 | | |
233 | 0 | ExprDependence clang::computeDependence(NoInitExpr *E) { |
234 | 0 | return toExprDependenceForImpliedType(E->getType()->getDependence()) & |
235 | 0 | (ExprDependence::Instantiation | ExprDependence::Error); |
236 | 0 | } |
237 | | |
238 | 0 | ExprDependence clang::computeDependence(ArrayInitLoopExpr *E) { |
239 | 0 | auto D = E->getCommonExpr()->getDependence() | |
240 | 0 | E->getSubExpr()->getDependence() | ExprDependence::Instantiation; |
241 | 0 | if (!E->getType()->isInstantiationDependentType()) |
242 | 0 | D &= ~ExprDependence::Instantiation; |
243 | 0 | return turnTypeToValueDependence(D); |
244 | 0 | } |
245 | | |
246 | 0 | ExprDependence clang::computeDependence(ImplicitValueInitExpr *E) { |
247 | 0 | return toExprDependenceForImpliedType(E->getType()->getDependence()) & |
248 | 0 | ExprDependence::Instantiation; |
249 | 0 | } |
250 | | |
251 | 0 | ExprDependence clang::computeDependence(ExtVectorElementExpr *E) { |
252 | 0 | return E->getBase()->getDependence(); |
253 | 0 | } |
254 | | |
255 | 1 | ExprDependence clang::computeDependence(BlockExpr *E) { |
256 | 1 | auto D = toExprDependenceForImpliedType(E->getType()->getDependence()); |
257 | 1 | if (E->getBlockDecl()->isDependentContext()) |
258 | 0 | D |= ExprDependence::Instantiation; |
259 | 1 | return D; |
260 | 1 | } |
261 | | |
262 | 0 | ExprDependence clang::computeDependence(AsTypeExpr *E) { |
263 | | // FIXME: AsTypeExpr doesn't store the type as written. Assume the expression |
264 | | // type has identical sugar for now, so is a type-as-written. |
265 | 0 | auto D = toExprDependenceAsWritten(E->getType()->getDependence()) | |
266 | 0 | E->getSrcExpr()->getDependence(); |
267 | 0 | if (!E->getType()->isDependentType()) |
268 | 0 | D &= ~ExprDependence::Type; |
269 | 0 | return D; |
270 | 0 | } |
271 | | |
272 | 0 | ExprDependence clang::computeDependence(CXXRewrittenBinaryOperator *E) { |
273 | 0 | return E->getSemanticForm()->getDependence(); |
274 | 0 | } |
275 | | |
276 | 0 | ExprDependence clang::computeDependence(CXXStdInitializerListExpr *E) { |
277 | 0 | auto D = turnTypeToValueDependence(E->getSubExpr()->getDependence()); |
278 | 0 | D |= toExprDependenceForImpliedType(E->getType()->getDependence()); |
279 | 0 | return D; |
280 | 0 | } |
281 | | |
282 | 0 | ExprDependence clang::computeDependence(CXXTypeidExpr *E) { |
283 | 0 | auto D = ExprDependence::None; |
284 | 0 | if (E->isTypeOperand()) |
285 | 0 | D = toExprDependenceAsWritten( |
286 | 0 | E->getTypeOperandSourceInfo()->getType()->getDependence()); |
287 | 0 | else |
288 | 0 | D = turnTypeToValueDependence(E->getExprOperand()->getDependence()); |
289 | | // typeid is never type-dependent (C++ [temp.dep.expr]p4) |
290 | 0 | return D & ~ExprDependence::Type; |
291 | 0 | } |
292 | | |
293 | 0 | ExprDependence clang::computeDependence(MSPropertyRefExpr *E) { |
294 | 0 | return E->getBaseExpr()->getDependence() & ~ExprDependence::Type; |
295 | 0 | } |
296 | | |
297 | 0 | ExprDependence clang::computeDependence(MSPropertySubscriptExpr *E) { |
298 | 0 | return E->getIdx()->getDependence(); |
299 | 0 | } |
300 | | |
301 | 0 | ExprDependence clang::computeDependence(CXXUuidofExpr *E) { |
302 | 0 | if (E->isTypeOperand()) |
303 | 0 | return turnTypeToValueDependence(toExprDependenceAsWritten( |
304 | 0 | E->getTypeOperandSourceInfo()->getType()->getDependence())); |
305 | | |
306 | 0 | return turnTypeToValueDependence(E->getExprOperand()->getDependence()); |
307 | 0 | } |
308 | | |
309 | 0 | ExprDependence clang::computeDependence(CXXThisExpr *E) { |
310 | | // 'this' is type-dependent if the class type of the enclosing |
311 | | // member function is dependent (C++ [temp.dep.expr]p2) |
312 | 0 | auto D = toExprDependenceForImpliedType(E->getType()->getDependence()); |
313 | 0 | assert(!(D & ExprDependence::UnexpandedPack)); |
314 | 0 | return D; |
315 | 0 | } |
316 | | |
317 | 0 | ExprDependence clang::computeDependence(CXXThrowExpr *E) { |
318 | 0 | auto *Op = E->getSubExpr(); |
319 | 0 | if (!Op) |
320 | 0 | return ExprDependence::None; |
321 | 0 | return Op->getDependence() & ~ExprDependence::TypeValue; |
322 | 0 | } |
323 | | |
324 | 0 | ExprDependence clang::computeDependence(CXXBindTemporaryExpr *E) { |
325 | 0 | return E->getSubExpr()->getDependence(); |
326 | 0 | } |
327 | | |
328 | 0 | ExprDependence clang::computeDependence(CXXScalarValueInitExpr *E) { |
329 | 0 | auto D = toExprDependenceForImpliedType(E->getType()->getDependence()); |
330 | 0 | if (auto *TSI = E->getTypeSourceInfo()) |
331 | 0 | D |= toExprDependenceAsWritten(TSI->getType()->getDependence()); |
332 | 0 | return D; |
333 | 0 | } |
334 | | |
335 | 0 | ExprDependence clang::computeDependence(CXXDeleteExpr *E) { |
336 | 0 | return turnTypeToValueDependence(E->getArgument()->getDependence()); |
337 | 0 | } |
338 | | |
339 | 0 | ExprDependence clang::computeDependence(ArrayTypeTraitExpr *E) { |
340 | 0 | auto D = toExprDependenceAsWritten(E->getQueriedType()->getDependence()); |
341 | 0 | if (auto *Dim = E->getDimensionExpression()) |
342 | 0 | D |= Dim->getDependence(); |
343 | 0 | return turnTypeToValueDependence(D); |
344 | 0 | } |
345 | | |
346 | 0 | ExprDependence clang::computeDependence(ExpressionTraitExpr *E) { |
347 | | // Never type-dependent. |
348 | 0 | auto D = E->getQueriedExpression()->getDependence() & ~ExprDependence::Type; |
349 | | // Value-dependent if the argument is type-dependent. |
350 | 0 | if (E->getQueriedExpression()->isTypeDependent()) |
351 | 0 | D |= ExprDependence::Value; |
352 | 0 | return D; |
353 | 0 | } |
354 | | |
355 | 0 | ExprDependence clang::computeDependence(CXXNoexceptExpr *E, CanThrowResult CT) { |
356 | 0 | auto D = E->getOperand()->getDependence() & ~ExprDependence::TypeValue; |
357 | 0 | if (CT == CT_Dependent) |
358 | 0 | D |= ExprDependence::ValueInstantiation; |
359 | 0 | return D; |
360 | 0 | } |
361 | | |
362 | 0 | ExprDependence clang::computeDependence(PackExpansionExpr *E) { |
363 | 0 | return (E->getPattern()->getDependence() & ~ExprDependence::UnexpandedPack) | |
364 | 0 | ExprDependence::TypeValueInstantiation; |
365 | 0 | } |
366 | | |
367 | 0 | ExprDependence clang::computeDependence(SubstNonTypeTemplateParmExpr *E) { |
368 | 0 | return E->getReplacement()->getDependence(); |
369 | 0 | } |
370 | | |
371 | 0 | ExprDependence clang::computeDependence(CoroutineSuspendExpr *E) { |
372 | 0 | if (auto *Resume = E->getResumeExpr()) |
373 | 0 | return (Resume->getDependence() & |
374 | 0 | (ExprDependence::TypeValue | ExprDependence::Error)) | |
375 | 0 | (E->getCommonExpr()->getDependence() & ~ExprDependence::TypeValue); |
376 | 0 | return E->getCommonExpr()->getDependence() | |
377 | 0 | ExprDependence::TypeValueInstantiation; |
378 | 0 | } |
379 | | |
380 | 0 | ExprDependence clang::computeDependence(DependentCoawaitExpr *E) { |
381 | 0 | return E->getOperand()->getDependence() | |
382 | 0 | ExprDependence::TypeValueInstantiation; |
383 | 0 | } |
384 | | |
385 | 0 | ExprDependence clang::computeDependence(ObjCBoxedExpr *E) { |
386 | 0 | return E->getSubExpr()->getDependence(); |
387 | 0 | } |
388 | | |
389 | 0 | ExprDependence clang::computeDependence(ObjCEncodeExpr *E) { |
390 | 0 | return toExprDependenceAsWritten(E->getEncodedType()->getDependence()); |
391 | 0 | } |
392 | | |
393 | 0 | ExprDependence clang::computeDependence(ObjCIvarRefExpr *E) { |
394 | 0 | return turnTypeToValueDependence(E->getBase()->getDependence()); |
395 | 0 | } |
396 | | |
397 | 0 | ExprDependence clang::computeDependence(ObjCPropertyRefExpr *E) { |
398 | 0 | if (E->isObjectReceiver()) |
399 | 0 | return E->getBase()->getDependence() & ~ExprDependence::Type; |
400 | 0 | if (E->isSuperReceiver()) |
401 | 0 | return toExprDependenceForImpliedType( |
402 | 0 | E->getSuperReceiverType()->getDependence()) & |
403 | 0 | ~ExprDependence::TypeValue; |
404 | 0 | assert(E->isClassReceiver()); |
405 | 0 | return ExprDependence::None; |
406 | 0 | } |
407 | | |
408 | 0 | ExprDependence clang::computeDependence(ObjCSubscriptRefExpr *E) { |
409 | 0 | return E->getBaseExpr()->getDependence() | E->getKeyExpr()->getDependence(); |
410 | 0 | } |
411 | | |
412 | 0 | ExprDependence clang::computeDependence(ObjCIsaExpr *E) { |
413 | 0 | return E->getBase()->getDependence() & ~ExprDependence::Type & |
414 | 0 | ~ExprDependence::UnexpandedPack; |
415 | 0 | } |
416 | | |
417 | 0 | ExprDependence clang::computeDependence(ObjCIndirectCopyRestoreExpr *E) { |
418 | 0 | return E->getSubExpr()->getDependence(); |
419 | 0 | } |
420 | | |
421 | 0 | ExprDependence clang::computeDependence(OMPArraySectionExpr *E) { |
422 | 0 | auto D = E->getBase()->getDependence(); |
423 | 0 | if (auto *LB = E->getLowerBound()) |
424 | 0 | D |= LB->getDependence(); |
425 | 0 | if (auto *Len = E->getLength()) |
426 | 0 | D |= Len->getDependence(); |
427 | 0 | return D; |
428 | 0 | } |
429 | | |
430 | 0 | ExprDependence clang::computeDependence(OMPArrayShapingExpr *E) { |
431 | 0 | auto D = E->getBase()->getDependence(); |
432 | 0 | for (Expr *Dim: E->getDimensions()) |
433 | 0 | if (Dim) |
434 | 0 | D |= turnValueToTypeDependence(Dim->getDependence()); |
435 | 0 | return D; |
436 | 0 | } |
437 | | |
438 | 0 | ExprDependence clang::computeDependence(OMPIteratorExpr *E) { |
439 | 0 | auto D = toExprDependenceForImpliedType(E->getType()->getDependence()); |
440 | 0 | for (unsigned I = 0, End = E->numOfIterators(); I < End; ++I) { |
441 | 0 | if (auto *DD = cast_or_null<DeclaratorDecl>(E->getIteratorDecl(I))) { |
442 | | // If the type is omitted, it's 'int', and is not dependent in any way. |
443 | 0 | if (auto *TSI = DD->getTypeSourceInfo()) { |
444 | 0 | D |= toExprDependenceAsWritten(TSI->getType()->getDependence()); |
445 | 0 | } |
446 | 0 | } |
447 | 0 | OMPIteratorExpr::IteratorRange IR = E->getIteratorRange(I); |
448 | 0 | if (Expr *BE = IR.Begin) |
449 | 0 | D |= BE->getDependence(); |
450 | 0 | if (Expr *EE = IR.End) |
451 | 0 | D |= EE->getDependence(); |
452 | 0 | if (Expr *SE = IR.Step) |
453 | 0 | D |= SE->getDependence(); |
454 | 0 | } |
455 | 0 | return D; |
456 | 0 | } |
457 | | |
458 | | /// Compute the type-, value-, and instantiation-dependence of a |
459 | | /// declaration reference |
460 | | /// based on the declaration being referenced. |
461 | 102 | ExprDependence clang::computeDependence(DeclRefExpr *E, const ASTContext &Ctx) { |
462 | 102 | auto Deps = ExprDependence::None; |
463 | | |
464 | 102 | if (auto *NNS = E->getQualifier()) |
465 | 0 | Deps |= toExprDependence(NNS->getDependence() & |
466 | 0 | ~NestedNameSpecifierDependence::Dependent); |
467 | | |
468 | 102 | if (auto *FirstArg = E->getTemplateArgs()) { |
469 | 0 | unsigned NumArgs = E->getNumTemplateArgs(); |
470 | 0 | for (auto *Arg = FirstArg, *End = FirstArg + NumArgs; Arg < End; ++Arg) |
471 | 0 | Deps |= toExprDependence(Arg->getArgument().getDependence()); |
472 | 0 | } |
473 | | |
474 | 102 | auto *Decl = E->getDecl(); |
475 | 102 | auto Type = E->getType(); |
476 | | |
477 | 102 | if (Decl->isParameterPack()) |
478 | 0 | Deps |= ExprDependence::UnexpandedPack; |
479 | 102 | Deps |= toExprDependenceForImpliedType(Type->getDependence()) & |
480 | 102 | ExprDependence::Error; |
481 | | |
482 | | // C++ [temp.dep.expr]p3: |
483 | | // An id-expression is type-dependent if it contains: |
484 | | |
485 | | // - an identifier associated by name lookup with one or more declarations |
486 | | // declared with a dependent type |
487 | | // - an identifier associated by name lookup with an entity captured by |
488 | | // copy ([expr.prim.lambda.capture]) |
489 | | // in a lambda-expression that has an explicit object parameter whose |
490 | | // type is dependent ([dcl.fct]), |
491 | | // |
492 | | // [The "or more" case is not modeled as a DeclRefExpr. There are a bunch |
493 | | // more bullets here that we handle by treating the declaration as having a |
494 | | // dependent type if they involve a placeholder type that can't be deduced.] |
495 | 102 | if (Type->isDependentType()) |
496 | 1 | Deps |= ExprDependence::TypeValueInstantiation; |
497 | 101 | else if (Type->isInstantiationDependentType()) |
498 | 0 | Deps |= ExprDependence::Instantiation; |
499 | | |
500 | | // - an identifier associated by name lookup with an entity captured by |
501 | | // copy ([expr.prim.lambda.capture]) |
502 | 102 | if (E->isCapturedByCopyInLambdaWithExplicitObjectParameter()) |
503 | 0 | Deps |= ExprDependence::Type; |
504 | | |
505 | | // - a conversion-function-id that specifies a dependent type |
506 | 102 | if (Decl->getDeclName().getNameKind() == |
507 | 102 | DeclarationName::CXXConversionFunctionName) { |
508 | 0 | QualType T = Decl->getDeclName().getCXXNameType(); |
509 | 0 | if (T->isDependentType()) |
510 | 0 | return Deps | ExprDependence::TypeValueInstantiation; |
511 | | |
512 | 0 | if (T->isInstantiationDependentType()) |
513 | 0 | Deps |= ExprDependence::Instantiation; |
514 | 0 | } |
515 | | |
516 | | // - a template-id that is dependent, |
517 | | // - a nested-name-specifier or a qualified-id that names a member of an |
518 | | // unknown specialization |
519 | | // [These are not modeled as DeclRefExprs.] |
520 | | |
521 | | // or if it names a dependent member of the current instantiation that is a |
522 | | // static data member of type "array of unknown bound of T" for some T |
523 | | // [handled below]. |
524 | | |
525 | | // C++ [temp.dep.constexpr]p2: |
526 | | // An id-expression is value-dependent if: |
527 | | |
528 | | // - it is type-dependent [handled above] |
529 | | |
530 | | // - it is the name of a non-type template parameter, |
531 | 102 | if (isa<NonTypeTemplateParmDecl>(Decl)) |
532 | 0 | return Deps | ExprDependence::ValueInstantiation; |
533 | | |
534 | | // - it names a potentially-constant variable that is initialized with an |
535 | | // expression that is value-dependent |
536 | 102 | if (const auto *Var = dyn_cast<VarDecl>(Decl)) { |
537 | 102 | if (const Expr *Init = Var->getAnyInitializer()) { |
538 | 0 | if (Init->containsErrors()) |
539 | 0 | Deps |= ExprDependence::Error; |
540 | |
|
541 | 0 | if (Var->mightBeUsableInConstantExpressions(Ctx) && |
542 | 0 | Init->isValueDependent()) |
543 | 0 | Deps |= ExprDependence::ValueInstantiation; |
544 | 0 | } |
545 | | |
546 | | // - it names a static data member that is a dependent member of the |
547 | | // current instantiation and is not initialized in a member-declarator, |
548 | 102 | if (Var->isStaticDataMember() && |
549 | 102 | Var->getDeclContext()->isDependentContext() && |
550 | 102 | !Var->getFirstDecl()->hasInit()) { |
551 | 0 | const VarDecl *First = Var->getFirstDecl(); |
552 | 0 | TypeSourceInfo *TInfo = First->getTypeSourceInfo(); |
553 | 0 | if (TInfo->getType()->isIncompleteArrayType()) { |
554 | 0 | Deps |= ExprDependence::TypeValueInstantiation; |
555 | 0 | } else if (!First->hasInit()) { |
556 | 0 | Deps |= ExprDependence::ValueInstantiation; |
557 | 0 | } |
558 | 0 | } |
559 | | |
560 | 102 | return Deps; |
561 | 102 | } |
562 | | |
563 | | // - it names a static member function that is a dependent member of the |
564 | | // current instantiation |
565 | | // |
566 | | // FIXME: It's unclear that the restriction to static members here has any |
567 | | // effect: any use of a non-static member function name requires either |
568 | | // forming a pointer-to-member or providing an object parameter, either of |
569 | | // which makes the overall expression value-dependent. |
570 | 0 | if (auto *MD = dyn_cast<CXXMethodDecl>(Decl)) { |
571 | 0 | if (MD->isStatic() && Decl->getDeclContext()->isDependentContext()) |
572 | 0 | Deps |= ExprDependence::ValueInstantiation; |
573 | 0 | } |
574 | |
|
575 | 0 | return Deps; |
576 | 102 | } |
577 | | |
578 | 258 | ExprDependence clang::computeDependence(RecoveryExpr *E) { |
579 | | // RecoveryExpr is |
580 | | // - always value-dependent, and therefore instantiation dependent |
581 | | // - contains errors (ExprDependence::Error), by definition |
582 | | // - type-dependent if we don't know the type (fallback to an opaque |
583 | | // dependent type), or the type is known and dependent, or it has |
584 | | // type-dependent subexpressions. |
585 | 258 | auto D = toExprDependenceAsWritten(E->getType()->getDependence()) | |
586 | 258 | ExprDependence::ErrorDependent; |
587 | | // FIXME: remove the type-dependent bit from subexpressions, if the |
588 | | // RecoveryExpr has a non-dependent type. |
589 | 258 | for (auto *S : E->subExpressions()) |
590 | 42 | D |= S->getDependence(); |
591 | 258 | return D; |
592 | 258 | } |
593 | | |
594 | 0 | ExprDependence clang::computeDependence(SYCLUniqueStableNameExpr *E) { |
595 | 0 | return toExprDependenceAsWritten( |
596 | 0 | E->getTypeSourceInfo()->getType()->getDependence()); |
597 | 0 | } |
598 | | |
599 | 0 | ExprDependence clang::computeDependence(PredefinedExpr *E) { |
600 | 0 | return toExprDependenceForImpliedType(E->getType()->getDependence()); |
601 | 0 | } |
602 | | |
603 | | ExprDependence clang::computeDependence(CallExpr *E, |
604 | 0 | llvm::ArrayRef<Expr *> PreArgs) { |
605 | 0 | auto D = E->getCallee()->getDependence(); |
606 | 0 | if (E->getType()->isDependentType()) |
607 | 0 | D |= ExprDependence::Type; |
608 | 0 | for (auto *A : llvm::ArrayRef(E->getArgs(), E->getNumArgs())) { |
609 | 0 | if (A) |
610 | 0 | D |= A->getDependence(); |
611 | 0 | } |
612 | 0 | for (auto *A : PreArgs) |
613 | 0 | D |= A->getDependence(); |
614 | 0 | return D; |
615 | 0 | } |
616 | | |
617 | 0 | ExprDependence clang::computeDependence(OffsetOfExpr *E) { |
618 | 0 | auto D = turnTypeToValueDependence(toExprDependenceAsWritten( |
619 | 0 | E->getTypeSourceInfo()->getType()->getDependence())); |
620 | 0 | for (unsigned I = 0, N = E->getNumExpressions(); I < N; ++I) |
621 | 0 | D |= turnTypeToValueDependence(E->getIndexExpr(I)->getDependence()); |
622 | 0 | return D; |
623 | 0 | } |
624 | | |
625 | 3 | static inline ExprDependence getDependenceInExpr(DeclarationNameInfo Name) { |
626 | 3 | auto D = ExprDependence::None; |
627 | 3 | if (Name.isInstantiationDependent()) |
628 | 0 | D |= ExprDependence::Instantiation; |
629 | 3 | if (Name.containsUnexpandedParameterPack()) |
630 | 0 | D |= ExprDependence::UnexpandedPack; |
631 | 3 | return D; |
632 | 3 | } |
633 | | |
634 | 0 | ExprDependence clang::computeDependence(MemberExpr *E) { |
635 | 0 | auto D = E->getBase()->getDependence(); |
636 | 0 | D |= getDependenceInExpr(E->getMemberNameInfo()); |
637 | |
|
638 | 0 | if (auto *NNS = E->getQualifier()) |
639 | 0 | D |= toExprDependence(NNS->getDependence() & |
640 | 0 | ~NestedNameSpecifierDependence::Dependent); |
641 | |
|
642 | 0 | auto *MemberDecl = E->getMemberDecl(); |
643 | 0 | if (FieldDecl *FD = dyn_cast<FieldDecl>(MemberDecl)) { |
644 | 0 | DeclContext *DC = MemberDecl->getDeclContext(); |
645 | | // dyn_cast_or_null is used to handle objC variables which do not |
646 | | // have a declaration context. |
647 | 0 | CXXRecordDecl *RD = dyn_cast_or_null<CXXRecordDecl>(DC); |
648 | 0 | if (RD && RD->isDependentContext() && RD->isCurrentInstantiation(DC)) { |
649 | 0 | if (!E->getType()->isDependentType()) |
650 | 0 | D &= ~ExprDependence::Type; |
651 | 0 | } |
652 | | |
653 | | // Bitfield with value-dependent width is type-dependent. |
654 | 0 | if (FD && FD->isBitField() && FD->getBitWidth()->isValueDependent()) { |
655 | 0 | D |= ExprDependence::Type; |
656 | 0 | } |
657 | 0 | } |
658 | | // FIXME: move remaining dependence computation from MemberExpr::Create() |
659 | 0 | return D; |
660 | 0 | } |
661 | | |
662 | 3 | ExprDependence clang::computeDependence(InitListExpr *E) { |
663 | 3 | auto D = ExprDependence::None; |
664 | 3 | for (auto *A : E->inits()) |
665 | 2 | D |= A->getDependence(); |
666 | 3 | return D; |
667 | 3 | } |
668 | | |
669 | 0 | ExprDependence clang::computeDependence(ShuffleVectorExpr *E) { |
670 | 0 | auto D = toExprDependenceForImpliedType(E->getType()->getDependence()); |
671 | 0 | for (auto *C : llvm::ArrayRef(E->getSubExprs(), E->getNumSubExprs())) |
672 | 0 | D |= C->getDependence(); |
673 | 0 | return D; |
674 | 0 | } |
675 | | |
676 | | ExprDependence clang::computeDependence(GenericSelectionExpr *E, |
677 | 0 | bool ContainsUnexpandedPack) { |
678 | 0 | auto D = ContainsUnexpandedPack ? ExprDependence::UnexpandedPack |
679 | 0 | : ExprDependence::None; |
680 | 0 | for (auto *AE : E->getAssocExprs()) |
681 | 0 | D |= AE->getDependence() & ExprDependence::Error; |
682 | |
|
683 | 0 | if (E->isExprPredicate()) |
684 | 0 | D |= E->getControllingExpr()->getDependence() & ExprDependence::Error; |
685 | 0 | else |
686 | 0 | D |= toExprDependenceAsWritten( |
687 | 0 | E->getControllingType()->getType()->getDependence()); |
688 | |
|
689 | 0 | if (E->isResultDependent()) |
690 | 0 | return D | ExprDependence::TypeValueInstantiation; |
691 | 0 | return D | (E->getResultExpr()->getDependence() & |
692 | 0 | ~ExprDependence::UnexpandedPack); |
693 | 0 | } |
694 | | |
695 | 0 | ExprDependence clang::computeDependence(DesignatedInitExpr *E) { |
696 | 0 | auto Deps = E->getInit()->getDependence(); |
697 | 0 | for (const auto &D : E->designators()) { |
698 | 0 | auto DesignatorDeps = ExprDependence::None; |
699 | 0 | if (D.isArrayDesignator()) |
700 | 0 | DesignatorDeps |= E->getArrayIndex(D)->getDependence(); |
701 | 0 | else if (D.isArrayRangeDesignator()) |
702 | 0 | DesignatorDeps |= E->getArrayRangeStart(D)->getDependence() | |
703 | 0 | E->getArrayRangeEnd(D)->getDependence(); |
704 | 0 | Deps |= DesignatorDeps; |
705 | 0 | if (DesignatorDeps & ExprDependence::TypeValue) |
706 | 0 | Deps |= ExprDependence::TypeValueInstantiation; |
707 | 0 | } |
708 | 0 | return Deps; |
709 | 0 | } |
710 | | |
711 | 0 | ExprDependence clang::computeDependence(PseudoObjectExpr *O) { |
712 | 0 | auto D = O->getSyntacticForm()->getDependence(); |
713 | 0 | for (auto *E : O->semantics()) |
714 | 0 | D |= E->getDependence(); |
715 | 0 | return D; |
716 | 0 | } |
717 | | |
718 | 0 | ExprDependence clang::computeDependence(AtomicExpr *A) { |
719 | 0 | auto D = ExprDependence::None; |
720 | 0 | for (auto *E : llvm::ArrayRef(A->getSubExprs(), A->getNumSubExprs())) |
721 | 0 | D |= E->getDependence(); |
722 | 0 | return D; |
723 | 0 | } |
724 | | |
725 | 0 | ExprDependence clang::computeDependence(CXXNewExpr *E) { |
726 | 0 | auto D = toExprDependenceAsWritten( |
727 | 0 | E->getAllocatedTypeSourceInfo()->getType()->getDependence()); |
728 | 0 | D |= toExprDependenceForImpliedType(E->getAllocatedType()->getDependence()); |
729 | 0 | auto Size = E->getArraySize(); |
730 | 0 | if (Size && *Size) |
731 | 0 | D |= turnTypeToValueDependence((*Size)->getDependence()); |
732 | 0 | if (auto *I = E->getInitializer()) |
733 | 0 | D |= turnTypeToValueDependence(I->getDependence()); |
734 | 0 | for (auto *A : E->placement_arguments()) |
735 | 0 | D |= turnTypeToValueDependence(A->getDependence()); |
736 | 0 | return D; |
737 | 0 | } |
738 | | |
739 | 0 | ExprDependence clang::computeDependence(CXXPseudoDestructorExpr *E) { |
740 | 0 | auto D = E->getBase()->getDependence(); |
741 | 0 | if (auto *TSI = E->getDestroyedTypeInfo()) |
742 | 0 | D |= toExprDependenceAsWritten(TSI->getType()->getDependence()); |
743 | 0 | if (auto *ST = E->getScopeTypeInfo()) |
744 | 0 | D |= turnTypeToValueDependence( |
745 | 0 | toExprDependenceAsWritten(ST->getType()->getDependence())); |
746 | 0 | if (auto *Q = E->getQualifier()) |
747 | 0 | D |= toExprDependence(Q->getDependence() & |
748 | 0 | ~NestedNameSpecifierDependence::Dependent); |
749 | 0 | return D; |
750 | 0 | } |
751 | | |
752 | | ExprDependence |
753 | | clang::computeDependence(OverloadExpr *E, bool KnownDependent, |
754 | | bool KnownInstantiationDependent, |
755 | 1 | bool KnownContainsUnexpandedParameterPack) { |
756 | 1 | auto Deps = ExprDependence::None; |
757 | 1 | if (KnownDependent) |
758 | 0 | Deps |= ExprDependence::TypeValue; |
759 | 1 | if (KnownInstantiationDependent) |
760 | 0 | Deps |= ExprDependence::Instantiation; |
761 | 1 | if (KnownContainsUnexpandedParameterPack) |
762 | 0 | Deps |= ExprDependence::UnexpandedPack; |
763 | 1 | Deps |= getDependenceInExpr(E->getNameInfo()); |
764 | 1 | if (auto *Q = E->getQualifier()) |
765 | 0 | Deps |= toExprDependence(Q->getDependence() & |
766 | 0 | ~NestedNameSpecifierDependence::Dependent); |
767 | 1 | for (auto *D : E->decls()) { |
768 | 0 | if (D->getDeclContext()->isDependentContext() || |
769 | 0 | isa<UnresolvedUsingValueDecl>(D)) |
770 | 0 | Deps |= ExprDependence::TypeValueInstantiation; |
771 | 0 | } |
772 | | // If we have explicit template arguments, check for dependent |
773 | | // template arguments and whether they contain any unexpanded pack |
774 | | // expansions. |
775 | 1 | for (const auto &A : E->template_arguments()) |
776 | 0 | Deps |= toExprDependence(A.getArgument().getDependence()); |
777 | 1 | return Deps; |
778 | 1 | } |
779 | | |
780 | 0 | ExprDependence clang::computeDependence(DependentScopeDeclRefExpr *E) { |
781 | 0 | auto D = ExprDependence::TypeValue; |
782 | 0 | D |= getDependenceInExpr(E->getNameInfo()); |
783 | 0 | if (auto *Q = E->getQualifier()) |
784 | 0 | D |= toExprDependence(Q->getDependence()); |
785 | 0 | for (const auto &A : E->template_arguments()) |
786 | 0 | D |= toExprDependence(A.getArgument().getDependence()); |
787 | 0 | return D; |
788 | 0 | } |
789 | | |
790 | 0 | ExprDependence clang::computeDependence(CXXConstructExpr *E) { |
791 | 0 | ExprDependence D = |
792 | 0 | toExprDependenceForImpliedType(E->getType()->getDependence()); |
793 | 0 | for (auto *A : E->arguments()) |
794 | 0 | D |= A->getDependence() & ~ExprDependence::Type; |
795 | 0 | return D; |
796 | 0 | } |
797 | | |
798 | 0 | ExprDependence clang::computeDependence(CXXTemporaryObjectExpr *E) { |
799 | 0 | CXXConstructExpr *BaseE = E; |
800 | 0 | return toExprDependenceAsWritten( |
801 | 0 | E->getTypeSourceInfo()->getType()->getDependence()) | |
802 | 0 | computeDependence(BaseE); |
803 | 0 | } |
804 | | |
805 | 0 | ExprDependence clang::computeDependence(CXXDefaultInitExpr *E) { |
806 | 0 | return E->getExpr()->getDependence(); |
807 | 0 | } |
808 | | |
809 | 0 | ExprDependence clang::computeDependence(CXXDefaultArgExpr *E) { |
810 | 0 | return E->getExpr()->getDependence(); |
811 | 0 | } |
812 | | |
813 | | ExprDependence clang::computeDependence(LambdaExpr *E, |
814 | 0 | bool ContainsUnexpandedParameterPack) { |
815 | 0 | auto D = toExprDependenceForImpliedType(E->getType()->getDependence()); |
816 | 0 | if (ContainsUnexpandedParameterPack) |
817 | 0 | D |= ExprDependence::UnexpandedPack; |
818 | 0 | return D; |
819 | 0 | } |
820 | | |
821 | 0 | ExprDependence clang::computeDependence(CXXUnresolvedConstructExpr *E) { |
822 | 0 | auto D = ExprDependence::ValueInstantiation; |
823 | 0 | D |= toExprDependenceAsWritten(E->getTypeAsWritten()->getDependence()); |
824 | 0 | D |= toExprDependenceForImpliedType(E->getType()->getDependence()); |
825 | 0 | for (auto *A : E->arguments()) |
826 | 0 | D |= A->getDependence() & |
827 | 0 | (ExprDependence::UnexpandedPack | ExprDependence::Error); |
828 | 0 | return D; |
829 | 0 | } |
830 | | |
831 | 2 | ExprDependence clang::computeDependence(CXXDependentScopeMemberExpr *E) { |
832 | 2 | auto D = ExprDependence::TypeValueInstantiation; |
833 | 2 | if (!E->isImplicitAccess()) |
834 | 2 | D |= E->getBase()->getDependence(); |
835 | 2 | if (auto *Q = E->getQualifier()) |
836 | 0 | D |= toExprDependence(Q->getDependence()); |
837 | 2 | D |= getDependenceInExpr(E->getMemberNameInfo()); |
838 | 2 | for (const auto &A : E->template_arguments()) |
839 | 0 | D |= toExprDependence(A.getArgument().getDependence()); |
840 | 2 | return D; |
841 | 2 | } |
842 | | |
843 | 0 | ExprDependence clang::computeDependence(MaterializeTemporaryExpr *E) { |
844 | 0 | return E->getSubExpr()->getDependence(); |
845 | 0 | } |
846 | | |
847 | 0 | ExprDependence clang::computeDependence(CXXFoldExpr *E) { |
848 | 0 | auto D = ExprDependence::TypeValueInstantiation; |
849 | 0 | for (const auto *C : {E->getLHS(), E->getRHS()}) { |
850 | 0 | if (C) |
851 | 0 | D |= C->getDependence() & ~ExprDependence::UnexpandedPack; |
852 | 0 | } |
853 | 0 | return D; |
854 | 0 | } |
855 | | |
856 | 0 | ExprDependence clang::computeDependence(CXXParenListInitExpr *E) { |
857 | 0 | auto D = ExprDependence::None; |
858 | 0 | for (const auto *A : E->getInitExprs()) |
859 | 0 | D |= A->getDependence(); |
860 | 0 | return D; |
861 | 0 | } |
862 | | |
863 | 0 | ExprDependence clang::computeDependence(TypeTraitExpr *E) { |
864 | 0 | auto D = ExprDependence::None; |
865 | 0 | for (const auto *A : E->getArgs()) |
866 | 0 | D |= toExprDependenceAsWritten(A->getType()->getDependence()) & |
867 | 0 | ~ExprDependence::Type; |
868 | 0 | return D; |
869 | 0 | } |
870 | | |
871 | | ExprDependence clang::computeDependence(ConceptSpecializationExpr *E, |
872 | 0 | bool ValueDependent) { |
873 | 0 | auto TA = TemplateArgumentDependence::None; |
874 | 0 | const auto InterestingDeps = TemplateArgumentDependence::Instantiation | |
875 | 0 | TemplateArgumentDependence::UnexpandedPack; |
876 | 0 | for (const TemplateArgumentLoc &ArgLoc : |
877 | 0 | E->getTemplateArgsAsWritten()->arguments()) { |
878 | 0 | TA |= ArgLoc.getArgument().getDependence() & InterestingDeps; |
879 | 0 | if (TA == InterestingDeps) |
880 | 0 | break; |
881 | 0 | } |
882 | |
|
883 | 0 | ExprDependence D = |
884 | 0 | ValueDependent ? ExprDependence::Value : ExprDependence::None; |
885 | 0 | auto Res = D | toExprDependence(TA); |
886 | 0 | if(!ValueDependent && E->getSatisfaction().ContainsErrors) |
887 | 0 | Res |= ExprDependence::Error; |
888 | 0 | return Res; |
889 | 0 | } |
890 | | |
891 | 0 | ExprDependence clang::computeDependence(ObjCArrayLiteral *E) { |
892 | 0 | auto D = ExprDependence::None; |
893 | 0 | Expr **Elements = E->getElements(); |
894 | 0 | for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) |
895 | 0 | D |= turnTypeToValueDependence(Elements[I]->getDependence()); |
896 | 0 | return D; |
897 | 0 | } |
898 | | |
899 | 0 | ExprDependence clang::computeDependence(ObjCDictionaryLiteral *E) { |
900 | 0 | auto Deps = ExprDependence::None; |
901 | 0 | for (unsigned I = 0, N = E->getNumElements(); I < N; ++I) { |
902 | 0 | auto KV = E->getKeyValueElement(I); |
903 | 0 | auto KVDeps = turnTypeToValueDependence(KV.Key->getDependence() | |
904 | 0 | KV.Value->getDependence()); |
905 | 0 | if (KV.EllipsisLoc.isValid()) |
906 | 0 | KVDeps &= ~ExprDependence::UnexpandedPack; |
907 | 0 | Deps |= KVDeps; |
908 | 0 | } |
909 | 0 | return Deps; |
910 | 0 | } |
911 | | |
912 | 0 | ExprDependence clang::computeDependence(ObjCMessageExpr *E) { |
913 | 0 | auto D = ExprDependence::None; |
914 | 0 | if (auto *R = E->getInstanceReceiver()) |
915 | 0 | D |= R->getDependence(); |
916 | 0 | else |
917 | 0 | D |= toExprDependenceForImpliedType(E->getType()->getDependence()); |
918 | 0 | for (auto *A : E->arguments()) |
919 | 0 | D |= A->getDependence(); |
920 | 0 | return D; |
921 | 0 | } |