clang  12.0.0git
ComputeDependence.cpp
Go to the documentation of this file.
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 
10 #include "clang/AST/Attr.h"
11 #include "clang/AST/DeclCXX.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"
20 #include "llvm/ADT/ArrayRef.h"
21 
22 using namespace clang;
23 
25  return E->getSubExpr()->getDependence();
26 }
27 
29  auto D = toExprDependence(E->getType()->getDependence());
30  if (auto *S = E->getSourceExpr())
31  D |= S->getDependence();
32  assert(!(D & ExprDependence::UnexpandedPack));
33  return D;
34 }
35 
37  return E->getSubExpr()->getDependence();
38 }
39 
41  return toExprDependence(E->getType()->getDependence()) |
42  E->getSubExpr()->getDependence();
43 }
44 
46  // Never type-dependent (C++ [temp.dep.expr]p3).
47  // Value-dependent if the argument is type-dependent.
48  if (E->isArgumentType())
51 
52  auto ArgDeps = E->getArgumentExpr()->getDependence();
53  auto Deps = ArgDeps & ~ExprDependence::TypeValue;
54  // Value-dependent if the argument is type-dependent.
55  if (ArgDeps & ExprDependence::Type)
56  Deps |= ExprDependence::Value;
57  // Check to see if we are in the situation where alignof(decl) should be
58  // dependent because decl's alignment is dependent.
59  auto ExprKind = E->getKind();
60  if (ExprKind != UETT_AlignOf && ExprKind != UETT_PreferredAlignOf)
61  return Deps;
62  if ((Deps & ExprDependence::Value) && (Deps & ExprDependence::Instantiation))
63  return Deps;
64 
65  auto *NoParens = E->getArgumentExpr()->IgnoreParens();
66  const ValueDecl *D = nullptr;
67  if (const auto *DRE = dyn_cast<DeclRefExpr>(NoParens))
68  D = DRE->getDecl();
69  else if (const auto *ME = dyn_cast<MemberExpr>(NoParens))
70  D = ME->getMemberDecl();
71  if (!D)
72  return Deps;
73  for (const auto *I : D->specific_attrs<AlignedAttr>()) {
74  if (I->isAlignmentErrorDependent())
75  Deps |= ExprDependence::Error;
76  if (I->isAlignmentDependent())
77  Deps |= ExprDependence::ValueInstantiation;
78  }
79  return Deps;
80 }
81 
83  return E->getLHS()->getDependence() | E->getRHS()->getDependence();
84 }
85 
87  return E->getBase()->getDependence() | E->getRowIdx()->getDependence() |
90 }
91 
95 }
96 
98  // Cast expressions are type-dependent if the type is
99  // dependent (C++ [temp.dep.expr]p3).
100  // Cast expressions are value-dependent if the type is
101  // dependent or if the subexpression is value-dependent.
102  auto D = toExprDependence(E->getType()->getDependence());
103  if (E->getStmtClass() == Stmt::ImplicitCastExprClass) {
104  // An implicit cast expression doesn't (lexically) contain an
105  // unexpanded pack, even if its target type does.
106  D &= ~ExprDependence::UnexpandedPack;
107  }
108  if (auto *S = E->getSubExpr())
109  D |= S->getDependence() & ~ExprDependence::Type;
110  return D;
111 }
112 
114  return E->getLHS()->getDependence() | E->getRHS()->getDependence();
115 }
116 
118  // The type of the conditional operator depends on the type of the conditional
119  // to support the GCC vector conditional extension. Additionally,
120  // [temp.dep.expr] does specify state that this should be dependent on ALL sub
121  // expressions.
122  return E->getCond()->getDependence() | E->getLHS()->getDependence() |
123  E->getRHS()->getDependence();
124 }
125 
127  return E->getCommon()->getDependence() | E->getFalseExpr()->getDependence();
128 }
129 
130 ExprDependence clang::computeDependence(StmtExpr *E, unsigned TemplateDepth) {
131  auto D = toExprDependence(E->getType()->getDependence());
132  // Propagate dependence of the result.
133  if (const auto *CompoundExprResult =
134  dyn_cast_or_null<ValueStmt>(E->getSubStmt()->getStmtExprResult()))
135  if (const Expr *ResultExpr = CompoundExprResult->getExprStmt())
136  D |= ResultExpr->getDependence();
137  // Note: we treat a statement-expression in a dependent context as always
138  // being value- and instantiation-dependent. This matches the behavior of
139  // lambda-expressions and GCC.
140  if (TemplateDepth)
141  D |= ExprDependence::ValueInstantiation;
142  // A param pack cannot be expanded over stmtexpr boundaries.
143  return D & ~ExprDependence::UnexpandedPack;
144 }
145 
147  auto D = toExprDependence(E->getType()->getDependence()) |
148  E->getSrcExpr()->getDependence();
149  if (!E->getType()->isDependentType())
150  D &= ~ExprDependence::Type;
151  return D;
152 }
153 
155  if (E->isConditionDependent())
156  return ExprDependence::TypeValueInstantiation |
157  E->getCond()->getDependence() | E->getLHS()->getDependence() |
158  E->getRHS()->getDependence();
159 
160  auto Cond = E->getCond()->getDependence();
161  auto Active = E->getLHS()->getDependence();
162  auto Inactive = E->getRHS()->getDependence();
163  if (!E->isConditionTrue())
164  std::swap(Active, Inactive);
165  // Take type- and value- dependency from the active branch. Propagate all
166  // other flags from all branches.
167  return (Active & ExprDependence::TypeValue) |
168  ((Cond | Active | Inactive) & ~ExprDependence::TypeValue);
169 }
170 
172  auto D = ExprDependence::None;
173  for (auto *E : P->exprs())
174  D |= E->getDependence();
175  return D;
176 }
177 
179  auto D =
182  return D & ~ExprDependence::Value;
183 }
184 
186  return toExprDependence(E->getType()->getDependence()) &
187  (ExprDependence::Instantiation | ExprDependence::Error);
188 }
189 
191  auto D = E->getCommonExpr()->getDependence() |
192  E->getSubExpr()->getDependence() | ExprDependence::Instantiation;
194  D &= ~ExprDependence::Instantiation;
195  return turnTypeToValueDependence(D);
196 }
197 
199  return toExprDependence(E->getType()->getDependence()) &
200  ExprDependence::Instantiation;
201 }
202 
204  return E->getBase()->getDependence();
205 }
206 
208  auto D = toExprDependence(E->getType()->getDependence());
209  if (E->getBlockDecl()->isDependentContext())
210  D |= ExprDependence::Instantiation;
211  return D & ~ExprDependence::UnexpandedPack;
212 }
213 
215  auto D = toExprDependence(E->getType()->getDependence()) |
216  E->getSrcExpr()->getDependence();
217  if (!E->getType()->isDependentType())
218  D &= ~ExprDependence::Type;
219  return D;
220 }
221 
223  return E->getSemanticForm()->getDependence();
224 }
225 
228  D |= toExprDependence(E->getType()->getDependence()) &
230  return D;
231 }
232 
234  auto D = ExprDependence::None;
235  if (E->isTypeOperand())
236  D = toExprDependence(
238  else
240  // typeid is never type-dependent (C++ [temp.dep.expr]p4)
241  return D & ~ExprDependence::Type;
242 }
243 
246 }
247 
249  return E->getIdx()->getDependence();
250 }
251 
253  if (E->isTypeOperand())
256 
258 }
259 
261  // 'this' is type-dependent if the class type of the enclosing
262  // member function is dependent (C++ [temp.dep.expr]p2)
263  auto D = toExprDependence(E->getType()->getDependence());
264  assert(!(D & ExprDependence::UnexpandedPack));
265  return D;
266 }
267 
269  auto *Op = E->getSubExpr();
270  if (!Op)
271  return ExprDependence::None;
272  return Op->getDependence() & ~ExprDependence::TypeValue;
273 }
274 
276  return E->getSubExpr()->getDependence();
277 }
278 
280  return toExprDependence(E->getType()->getDependence()) &
281  ~ExprDependence::TypeValue;
282 }
283 
286 }
287 
290  if (auto *Dim = E->getDimensionExpression())
291  D |= Dim->getDependence();
292  return turnTypeToValueDependence(D);
293 }
294 
296  // Never type-dependent.
298  // Value-dependent if the argument is type-dependent.
301  return D;
302 }
303 
305  auto D = E->getOperand()->getDependence() & ~ExprDependence::TypeValue;
306  if (CT == CT_Dependent)
307  D |= ExprDependence::ValueInstantiation;
308  return D;
309 }
310 
312  return (E->getPattern()->getDependence() & ~ExprDependence::UnexpandedPack) |
313  ExprDependence::TypeValueInstantiation;
314 }
315 
317  return E->getReplacement()->getDependence();
318 }
319 
321  if (auto *Resume = E->getResumeExpr())
322  return (Resume->getDependence() &
323  (ExprDependence::TypeValue | ExprDependence::Error)) |
324  (E->getCommonExpr()->getDependence() & ~ExprDependence::TypeValue);
325  return E->getCommonExpr()->getDependence() |
326  ExprDependence::TypeValueInstantiation;
327 }
328 
330  return E->getOperand()->getDependence() |
331  ExprDependence::TypeValueInstantiation;
332 }
333 
335  return E->getSubExpr()->getDependence();
336 }
337 
340 }
341 
344 }
345 
347  if (E->isObjectReceiver())
348  return E->getBase()->getDependence() & ~ExprDependence::Type;
349  if (E->isSuperReceiver())
351  ~ExprDependence::TypeValue;
352  assert(E->isClassReceiver());
353  return ExprDependence::None;
354 }
355 
357  return E->getBaseExpr()->getDependence() | E->getKeyExpr()->getDependence();
358 }
359 
361  return E->getBase()->getDependence() & ~ExprDependence::Type &
362  ~ExprDependence::UnexpandedPack;
363 }
364 
366  return E->getSubExpr()->getDependence();
367 }
368 
370  auto D = E->getBase()->getDependence();
371  if (auto *LB = E->getLowerBound())
372  D |= LB->getDependence();
373  if (auto *Len = E->getLength())
374  D |= Len->getDependence();
375  return D;
376 }
377 
379  auto D = E->getBase()->getDependence() |
381  for (Expr *Dim: E->getDimensions())
382  if (Dim)
383  D |= Dim->getDependence();
384  return D;
385 }
386 
388  auto D = toExprDependence(E->getType()->getDependence());
389  for (unsigned I = 0, End = E->numOfIterators(); I < End; ++I) {
390  if (auto *VD = cast_or_null<ValueDecl>(E->getIteratorDecl(I)))
391  D |= toExprDependence(VD->getType()->getDependence());
393  if (Expr *BE = IR.Begin)
394  D |= BE->getDependence();
395  if (Expr *EE = IR.End)
396  D |= EE->getDependence();
397  if (Expr *SE = IR.Step)
398  D |= SE->getDependence();
399  }
400  return D;
401 }
402 
403 /// Compute the type-, value-, and instantiation-dependence of a
404 /// declaration reference
405 /// based on the declaration being referenced.
407  auto Deps = ExprDependence::None;
408 
409  if (auto *NNS = E->getQualifier())
410  Deps |= toExprDependence(NNS->getDependence() &
411  ~NestedNameSpecifierDependence::Dependent);
412 
413  if (auto *FirstArg = E->getTemplateArgs()) {
414  unsigned NumArgs = E->getNumTemplateArgs();
415  for (auto *Arg = FirstArg, *End = FirstArg + NumArgs; Arg < End; ++Arg)
416  Deps |= toExprDependence(Arg->getArgument().getDependence());
417  }
418 
419  auto *Decl = E->getDecl();
420  auto Type = E->getType();
421 
422  if (Decl->isParameterPack())
423  Deps |= ExprDependence::UnexpandedPack;
425 
426  // (TD) C++ [temp.dep.expr]p3:
427  // An id-expression is type-dependent if it contains:
428  //
429  // and
430  //
431  // (VD) C++ [temp.dep.constexpr]p2:
432  // An identifier is value-dependent if it is:
433 
434  // (TD) - an identifier that was declared with dependent type
435  // (VD) - a name declared with a dependent type,
436  if (Type->isDependentType())
437  return Deps | ExprDependence::TypeValueInstantiation;
439  Deps |= ExprDependence::Instantiation;
440 
441  // (TD) - a conversion-function-id that specifies a dependent type
442  if (Decl->getDeclName().getNameKind() ==
444  QualType T = Decl->getDeclName().getCXXNameType();
445  if (T->isDependentType())
446  return Deps | ExprDependence::TypeValueInstantiation;
447 
449  Deps |= ExprDependence::Instantiation;
450  }
451 
452  // (VD) - the name of a non-type template parameter,
453  if (isa<NonTypeTemplateParmDecl>(Decl))
454  return Deps | ExprDependence::ValueInstantiation;
455 
456  // (VD) - a constant with integral or enumeration type and is
457  // initialized with an expression that is value-dependent.
458  // (VD) - a constant with literal type and is initialized with an
459  // expression that is value-dependent [C++11].
460  // (VD) - FIXME: Missing from the standard:
461  // - an entity with reference type and is initialized with an
462  // expression that is value-dependent [C++11]
463  if (VarDecl *Var = dyn_cast<VarDecl>(Decl)) {
464  if ((Ctx.getLangOpts().CPlusPlus11
465  ? Var->getType()->isLiteralType(Ctx)
466  : Var->getType()->isIntegralOrEnumerationType()) &&
467  (Var->getType().isConstQualified() ||
468  Var->getType()->isReferenceType())) {
469  if (const Expr *Init = Var->getAnyInitializer()) {
470  if (Init->isValueDependent())
471  Deps |= ExprDependence::ValueInstantiation;
472  if (Init->containsErrors())
473  Deps |= ExprDependence::Error;
474  }
475  }
476 
477  // (VD) - FIXME: Missing from the standard:
478  // - a member function or a static data member of the current
479  // instantiation
480  if (Var->isStaticDataMember() &&
481  Var->getDeclContext()->isDependentContext()) {
482  Deps |= ExprDependence::ValueInstantiation;
483  TypeSourceInfo *TInfo = Var->getFirstDecl()->getTypeSourceInfo();
484  if (TInfo->getType()->isIncompleteArrayType())
485  Deps |= ExprDependence::Type;
486  }
487 
488  return Deps;
489  }
490 
491  // (VD) - FIXME: Missing from the standard:
492  // - a member function or a static data member of the current
493  // instantiation
494  if (isa<CXXMethodDecl>(Decl) && Decl->getDeclContext()->isDependentContext())
495  Deps |= ExprDependence::ValueInstantiation;
496  return Deps;
497 }
498 
500  // RecoveryExpr is
501  // - always value-dependent, and therefore instantiation dependent
502  // - contains errors (ExprDependence::Error), by definition
503  // - type-dependent if we don't know the type (fallback to an opaque
504  // dependent type), or the type is known and dependent, or it has
505  // type-dependent subexpressions.
506  auto D = toExprDependence(E->getType()->getDependence()) |
507  ExprDependence::ErrorDependent;
508  // FIXME: remove the type-dependent bit from subexpressions, if the
509  // RecoveryExpr has a non-dependent type.
510  for (auto *S : E->subExpressions())
511  D |= S->getDependence();
512  return D;
513 }
514 
516  return toExprDependence(E->getType()->getDependence()) &
517  ~ExprDependence::UnexpandedPack;
518 }
519 
521  llvm::ArrayRef<Expr *> PreArgs) {
522  auto D = E->getCallee()->getDependence();
523  for (auto *A : llvm::makeArrayRef(E->getArgs(), E->getNumArgs())) {
524  if (A)
525  D |= A->getDependence();
526  }
527  for (auto *A : PreArgs)
528  D |= A->getDependence();
529  return D;
530 }
531 
533  auto D = turnTypeToValueDependence(
535  for (unsigned I = 0, N = E->getNumExpressions(); I < N; ++I)
537  return D;
538 }
539 
541  auto *MemberDecl = E->getMemberDecl();
542  auto D = E->getBase()->getDependence();
543  if (FieldDecl *FD = dyn_cast<FieldDecl>(MemberDecl)) {
544  DeclContext *DC = MemberDecl->getDeclContext();
545  // dyn_cast_or_null is used to handle objC variables which do not
546  // have a declaration context.
547  CXXRecordDecl *RD = dyn_cast_or_null<CXXRecordDecl>(DC);
548  if (RD && RD->isDependentContext() && RD->isCurrentInstantiation(DC)) {
549  if (!E->getType()->isDependentType())
550  D &= ~ExprDependence::Type;
551  }
552 
553  // Bitfield with value-dependent width is type-dependent.
554  if (FD && FD->isBitField() && FD->getBitWidth()->isValueDependent()) {
556  }
557  }
558  // FIXME: move remaining dependence computation from MemberExpr::Create()
559  return D;
560 }
561 
563  auto D = ExprDependence::None;
564  for (auto *A : E->inits())
565  D |= A->getDependence();
566  return D;
567 }
568 
570  auto D = toExprDependence(E->getType()->getDependence());
571  for (auto *C : llvm::makeArrayRef(E->getSubExprs(), E->getNumSubExprs()))
572  D |= C->getDependence();
573  return D;
574 }
575 
577  bool ContainsUnexpandedPack) {
578  auto D = ContainsUnexpandedPack ? ExprDependence::UnexpandedPack
580  for (auto *AE : E->getAssocExprs())
581  D |= AE->getDependence() & ExprDependence::Error;
583 
584  if (E->isResultDependent())
585  return D | ExprDependence::TypeValueInstantiation;
586  return D | (E->getResultExpr()->getDependence() &
587  ~ExprDependence::UnexpandedPack);
588 }
589 
591  auto Deps = E->getInit()->getDependence();
592  for (auto D : E->designators()) {
593  auto DesignatorDeps = ExprDependence::None;
594  if (D.isArrayDesignator())
595  DesignatorDeps |= E->getArrayIndex(D)->getDependence();
596  else if (D.isArrayRangeDesignator())
597  DesignatorDeps |= E->getArrayRangeStart(D)->getDependence() |
599  Deps |= DesignatorDeps;
600  if (DesignatorDeps & ExprDependence::TypeValue)
601  Deps |= ExprDependence::TypeValueInstantiation;
602  }
603  return Deps;
604 }
605 
607  auto D = O->getSyntacticForm()->getDependence();
608  for (auto *E : O->semantics())
609  D |= E->getDependence();
610  return D;
611 }
612 
614  auto D = ExprDependence::None;
615  for (auto *E : llvm::makeArrayRef(A->getSubExprs(), A->getNumSubExprs()))
616  D |= E->getDependence();
617  return D;
618 }
619 
621  auto D = toExprDependence(E->getType()->getDependence());
622  auto Size = E->getArraySize();
623  if (Size.hasValue() && *Size)
624  D |= turnTypeToValueDependence((*Size)->getDependence());
625  if (auto *I = E->getInitializer())
626  D |= turnTypeToValueDependence(I->getDependence());
627  for (auto *A : E->placement_arguments())
628  D |= turnTypeToValueDependence(A->getDependence());
629  return D;
630 }
631 
633  auto D = E->getBase()->getDependence();
634  if (!E->getDestroyedType().isNull())
636  if (auto *ST = E->getScopeTypeInfo())
638  toExprDependence(ST->getType()->getDependence()));
639  if (auto *Q = E->getQualifier())
640  D |= toExprDependence(Q->getDependence() &
641  ~NestedNameSpecifierDependence::Dependent);
642  return D;
643 }
644 
646  auto D = ExprDependence::None;
647  if (Name.isInstantiationDependent())
648  D |= ExprDependence::Instantiation;
650  D |= ExprDependence::UnexpandedPack;
651  return D;
652 }
653 
655 clang::computeDependence(OverloadExpr *E, bool KnownDependent,
656  bool KnownInstantiationDependent,
657  bool KnownContainsUnexpandedParameterPack) {
658  auto Deps = ExprDependence::None;
659  if (KnownDependent)
660  Deps |= ExprDependence::TypeValue;
661  if (KnownInstantiationDependent)
662  Deps |= ExprDependence::Instantiation;
663  if (KnownContainsUnexpandedParameterPack)
664  Deps |= ExprDependence::UnexpandedPack;
665  Deps |= getDependenceInExpr(E->getNameInfo());
666  if (auto *Q = E->getQualifier())
667  Deps |= toExprDependence(Q->getDependence() &
668  ~NestedNameSpecifierDependence::Dependent);
669  for (auto *D : E->decls()) {
670  if (D->getDeclContext()->isDependentContext() ||
671  isa<UnresolvedUsingValueDecl>(D))
672  Deps |= ExprDependence::TypeValueInstantiation;
673  }
674  // If we have explicit template arguments, check for dependent
675  // template arguments and whether they contain any unexpanded pack
676  // expansions.
677  for (auto A : E->template_arguments())
678  Deps |= toExprDependence(A.getArgument().getDependence());
679  return Deps;
680 }
681 
683  auto D = ExprDependence::TypeValue;
684  D |= getDependenceInExpr(E->getNameInfo());
685  if (auto *Q = E->getQualifier())
686  D |= toExprDependence(Q->getDependence());
687  for (auto A : E->template_arguments())
688  D |= toExprDependence(A.getArgument().getDependence());
689  return D;
690 }
691 
693  auto D = toExprDependence(E->getType()->getDependence());
694  for (auto *A : E->arguments())
695  D |= A->getDependence() & ~ExprDependence::Type;
696  return D;
697 }
698 
700  return E->getExpr()->getDependence();
701 }
702 
704  bool ContainsUnexpandedParameterPack) {
705  auto D = toExprDependence(E->getType()->getDependence());
706  if (ContainsUnexpandedParameterPack)
707  D |= ExprDependence::UnexpandedPack;
708  return D;
709 }
710 
712  auto D = ExprDependence::ValueInstantiation;
713  D |= toExprDependence(E->getType()->getDependence());
714  for (auto *A : E->arguments())
715  D |= A->getDependence() &
716  (ExprDependence::UnexpandedPack | ExprDependence::Error);
717  return D;
718 }
719 
721  auto D = ExprDependence::TypeValueInstantiation;
722  if (!E->isImplicitAccess())
723  D |= E->getBase()->getDependence();
724  if (auto *Q = E->getQualifier())
725  D |= toExprDependence(Q->getDependence());
727  for (auto A : E->template_arguments())
728  D |= toExprDependence(A.getArgument().getDependence());
729  return D;
730 }
731 
733  return E->getSubExpr()->getDependence();
734 }
735 
737  auto D = ExprDependence::TypeValueInstantiation;
738  for (const auto *C : {E->getLHS(), E->getRHS()}) {
739  if (C)
740  D |= C->getDependence() & ~ExprDependence::UnexpandedPack;
741  }
742  return D;
743 }
744 
746  auto D = ExprDependence::None;
747  for (const auto *A : E->getArgs())
748  D |=
749  toExprDependence(A->getType()->getDependence()) & ~ExprDependence::Type;
750  return D;
751 }
752 
754  bool ValueDependent) {
756  const auto InterestingDeps = TemplateArgumentDependence::Instantiation |
757  TemplateArgumentDependence::UnexpandedPack;
758  for (const TemplateArgumentLoc &ArgLoc :
760  TA |= ArgLoc.getArgument().getDependence() & InterestingDeps;
761  if (TA == InterestingDeps)
762  break;
763  }
764 
765  ExprDependence D =
766  ValueDependent ? ExprDependence::Value : ExprDependence::None;
767  return D | toExprDependence(TA);
768 }
769 
771  auto D = ExprDependence::None;
772  Expr **Elements = E->getElements();
773  for (unsigned I = 0, N = E->getNumElements(); I != N; ++I)
774  D |= turnTypeToValueDependence(Elements[I]->getDependence());
775  return D;
776 }
777 
779  auto Deps = ExprDependence::None;
780  for (unsigned I = 0, N = E->getNumElements(); I < N; ++I) {
781  auto KV = E->getKeyValueElement(I);
782  auto KVDeps = turnTypeToValueDependence(KV.Key->getDependence() |
783  KV.Value->getDependence());
784  if (KV.EllipsisLoc.isValid())
785  KVDeps &= ~ExprDependence::UnexpandedPack;
786  Deps |= KVDeps;
787  }
788  return Deps;
789 }
790 
792  auto D = ExprDependence::None;
793  if (auto *R = E->getInstanceReceiver())
794  D |= R->getDependence();
795  else
796  D |= toExprDependence(E->getType()->getDependence());
797  for (auto *A : E->arguments())
798  D |= A->getDependence();
799  return D;
800 }
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:614
const Expr * getSubExpr() const
Definition: Expr.h:1007
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition: ExprObjC.h:1566
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: Expr.h:1386
const BlockDecl * getBlockDecl() const
Definition: Expr.h:5898
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:1083
Represents a &#39;co_await&#39; expression while the type of the promise is dependent.
Definition: ExprCXX.h:4787
Expr * getArrayIndex(const Designator &D) const
Definition: Expr.cpp:4219
Expr ** getArgs()
Retrieve the call arguments.
Definition: Expr.h:2911
Expr * getLHS() const
Definition: Expr.h:4099
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
Definition: Expr.h:6060
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Definition: ExprObjC.h:362
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Definition: Expr.h:1378
llvm::iterator_range< arg_iterator > placement_arguments()
Definition: ExprCXX.h:2331
A (possibly-)qualified type.
Definition: Type.h:661
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3290
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Definition: Expr.h:3169
Expr * getCond() const
Definition: Expr.h:4484
ExprDependence computeDependence(FullExpr *E)
const Expr * getSubExpr() const
Definition: ExprCXX.h:1191
unsigned getNumSubExprs() const
getNumSubExprs - Return the size of the SubExprs array.
Definition: Expr.h:4351
bool isSuperReceiver() const
Definition: ExprObjC.h:772
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2652
Expr * getResultExpr()
Return the result expression of this controlling expression.
Definition: Expr.h:5734
CompoundStmt * getSubStmt()
Definition: Expr.h:4286
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
Definition: Expr.h:5725
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Definition: Expr.h:2908
Expr * getDimensionExpression() const
Definition: ExprCXX.h:2787
Expr * getBase() const
Definition: Expr.h:3163
TypeSourceInfo * getTypeSourceInfo() const
Definition: Expr.h:3360
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
const Expr * getSubExpr() const
Definition: Expr.h:4569
StringRef P
Expr * getBase()
Fetches base expression of array shaping expression.
Definition: ExprOpenMP.h:214
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:2042
Expr * getLowerBound()
Get lower bound of array section.
Definition: ExprOpenMP.h:94
The base class of the type hierarchy.
Definition: Type.h:1478
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
Definition: ExprCXX.h:3234
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1450
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition: ExprObjC.h:841
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent...
Definition: ExprCXX.h:2740
A container of type source information.
Definition: Type.h:6363
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Definition: ExprCXX.h:2561
MS property subscript expression.
Definition: ExprCXX.h:984
bool isInstantiationDependent() const
Determine whether this name involves a template parameter.
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:4449
Expr * getIndexExpr(unsigned Idx)
Definition: Expr.h:2437
Represents a variable declaration or definition.
Definition: Decl.h:834
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC &#39;id&#39; type.
Definition: ExprObjC.h:1482
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:3327
OpaqueValueExpr * getCommonExpr() const
Get the common subexpression shared by all initializations (the source array).
Definition: Expr.h:5352
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition: ExprCXX.h:781
const Expr * getExprStmt() const
Definition: Stmt.cpp:395
unsigned getNumExpressions() const
Definition: Expr.h:2452
bool isParameterPack() const
Whether this declaration is a parameter pack.
Definition: DeclBase.cpp:211
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:1171
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:639
Expr * getExprOperand() const
Definition: ExprCXX.h:876
Defines the clang::Expr interface and subclasses for C++ expressions.
Expr * getExprOperand() const
Definition: ExprCXX.h:1087
Represents a C99 designated initializer expression.
Definition: Expr.h:4948
Expr * getSemanticForm()
Get an equivalent semantic form for this expression.
Definition: ExprCXX.h:302
MatchType Type
TypeSourceInfo * getScopeTypeInfo() const
Retrieve the scope type in a qualified pseudo-destructor expression.
Definition: ExprCXX.h:2581
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:4317
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:186
Expr * getInit() const
Retrieve the initializer value.
Definition: Expr.h:5186
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
Definition: Expr.h:6336
FullExpr - Represents a "full-expression" node.
Definition: Expr.h:994
Represents a member of a struct/union/class.
Definition: Decl.h:2776
An explicit cast in C or a C-style cast in C++, which uses the syntax ([s1][s2]...[sn])expr.
Definition: ExprOpenMP.h:146
Defines the ExceptionSpecificationType enumeration and various utility functions. ...
Represents a place-holder for an object not to be initialized by anything.
Definition: Expr.h:5246
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
Definition: ExprCXX.h:2973
Stmt * getStmtExprResult()
Definition: Stmt.h:1490
ExprDependence toExprDependence(TemplateArgumentDependence TA)
Computes dependencies of a reference with the name having template arguments with TA dependencies...
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition: ExprCXX.cpp:333
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition: Expr.h:1175
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition: Expr.h:5826
Expr * getSubExpr()
Definition: Expr.h:3448
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
Definition: ExprObjC.h:190
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3033
Expr * getLHS() const
Definition: ExprCXX.h:4597
Describes an C or C++ initializer list.
Definition: Expr.h:4710
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition: ExprCXX.h:829
Expr * getKeyExpr() const
Definition: ExprObjC.h:883
Optional< Expr * > getArraySize()
Definition: ExprCXX.h:2251
Expr * getBaseExpr() const
Definition: ExprObjC.h:880
Expr * getOperand() const
Definition: ExprCXX.h:4001
ArrayRef< Expr * > getDimensions() const
Fetches the dimensions for array shaping expression.
Definition: ExprOpenMP.h:204
Expr * getInitializer()
The initializer of this new-expression.
Definition: ExprCXX.h:2301
OpenMP 5.0 [2.1.6 Iterators] Iterators are identifiers that expand to multiple values in the clause o...
Definition: ExprOpenMP.h:272
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3727
bool isClassReceiver() const
Definition: ExprObjC.h:773
TypeDependence getDependence() const
Definition: Type.h:2149
Expr * getRHS() const
Definition: ExprCXX.h:4598
ArrayRef< Expr * > subExpressions()
Definition: Expr.h:6344
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Definition: ExprCXX.h:2982
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3397
Expr * getOperand() const
Definition: ExprCXX.h:4810
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1402
Expr * getCommonExpr() const
Definition: ExprCXX.h:4711
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1855
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition: Expr.h:185
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3537
bool containsUnexpandedParameterPack() const
Determine whether this name contains an unexpanded parameter pack.
bool isTypeOperand() const
Definition: ExprCXX.h:1076
Represents the this expression in C++.
Definition: ExprCXX.h:1132
const Expr * getExpr() const
Get the initialization expression that will be used.
Definition: ExprCXX.h:1336
Expr ** getSubExprs()
Retrieve the array of expressions.
Definition: Expr.h:4354
OpenMP 5.0 [2.1.5, Array Sections].
Definition: ExprOpenMP.h:56
ConditionalOperator - The ?: ternary operator.
Definition: Expr.h:4065
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2504
QualType getQueriedType() const
Definition: ExprCXX.h:2781
Expr ** getSubExprs()
Definition: Expr.h:6217
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
Definition: Expr.h:2479
ArrayRef< TypeSourceInfo * > getArgs() const
Retrieve the argument types.
Definition: ExprCXX.h:2710
Represents a call to the builtin function __builtin_va_arg.
Definition: Expr.h:4553
bool isImplicitAccess() const
True if this is an implicit access, i.e.
Definition: ExprCXX.h:3627
static unsigned getNumSubExprs(AtomicOp Op)
Determine the number of arguments the specified atomic builtin should have.
Definition: Expr.cpp:4533
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition: Expr.h:5966
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
Definition: ExprCXX.h:2080
Expr * getCond() const
Definition: Expr.h:4088
llvm::MutableArrayRef< Designator > designators()
Definition: Expr.h:5151
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:634
This represents one expression.
Definition: Expr.h:109
SourceLocation End
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5886
Expr * getCallee()
Definition: Expr.h:2880
Expr * getSubExpr() const
Get the initializer to use for each array element.
Definition: Expr.h:5357
QualType getArgumentType() const
Definition: Expr.h:2521
arg_range arguments()
Definition: ExprCXX.h:1582
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:306
DeclContext * getDeclContext()
Definition: DeclBase.h:439
TypeSourceInfo * getTypeSourceInfo() const
Definition: Expr.h:2416
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition: Expr.h:5947
ArrayRef< Expr * > inits()
Definition: Expr.h:4750
QualType getType() const
Definition: Expr.h:141
ArrayRef< Expr * > getAssocExprs() const
Definition: Expr.h:5743
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4563
QualType getEncodedType() const
Definition: ExprObjC.h:428
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:940
UnaryOperator - This represents the unary-expression&#39;s (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Definition: Expr.h:2093
IteratorRange getIteratorRange(unsigned I)
Gets the iterator range for the given iterator.
Definition: Expr.cpp:4749
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:913
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:4232
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Definition: DeclBase.cpp:1141
ValueDecl * getDecl()
Definition: Expr.h:1285
const Expr * getSubExpr() const
Definition: Expr.h:2057
const Expr * getSubExpr() const
Definition: ExprCXX.h:1424
llvm::iterator_range< semantics_iterator > semantics()
Definition: Expr.h:6097
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:726
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
Definition: Expr.h:2603
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Definition: ASTConcept.h:158
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
Definition: ExprCXX.h:3652
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:3218
Expr * getArgument()
Definition: ExprCXX.h:2426
CanThrowResult
Possible results from evaluation of a noexcept expression.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:1125
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:4385
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
Definition: ExprCXX.h:2867
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:6016
Decl * getIteratorDecl(unsigned I)
Gets the iterator declaration for the given iterator.
Definition: Expr.cpp:4745
Expr * getSubExpr() const
Definition: Expr.h:2140
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:2126
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
Definition: ExprObjC.h:360
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>, and corresponding __opencl_atomic_* for OpenCL 2.0.
Definition: Expr.h:6150
UnaryExprOrTypeTrait getKind() const
Definition: Expr.h:2510
Expr * getArrayRangeStart(const Designator &D) const
Definition: Expr.cpp:4224
Expr * getSubExpr()
Definition: ExprObjC.h:144
An expression trait intrinsic.
Definition: ExprCXX.h:2810
ArrayRef< Expr * > exprs()
Definition: Expr.h:5494
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:4269
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:128
bool isArgumentType() const
Definition: Expr.h:2520
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3746
unsigned numOfIterators() const
Returns number of iterator definitions.
Definition: ExprOpenMP.h:399
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
Definition: Type.h:2168
ExprDependence getDependence() const
Definition: Expr.h:155
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:3178
const Expr * getInitializer() const
Definition: Expr.h:3350
Expr * getLHS() const
Definition: Expr.h:3776
Expr ** getElements()
Retrieve elements of array of literals.
Definition: ExprObjC.h:221
Represents a C11 generic selection.
Definition: Expr.h:5544
const Expr * getBase() const
Definition: Expr.h:5843
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
Definition: ExprObjC.h:1250
bool isCurrentInstantiation(const DeclContext *CurContext) const
Determine whether this dependent class is a current instantiation, when viewed from within the given ...
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
Definition: Expr.h:4181
bool isTypeOperand() const
Definition: ExprCXX.h:865
Dataflow Directional Tag Classes.
bool isResultDependent() const
Whether this generic selection is result-dependent.
Definition: Expr.h:5722
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1947
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1302
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:2385
StmtClass getStmtClass() const
Definition: Stmt.h:1162
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:4038
Iterator range representation begin:end[:step].
Definition: ExprOpenMP.h:278
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:872
Expr * getArrayRangeEnd(const Designator &D) const
Definition: Expr.cpp:4230
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:3984
bool isIncompleteArrayType() const
Definition: Type.h:6714
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:457
Expr * getBase() const
Definition: ExprObjC.h:1507
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2574
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c array literal.
Definition: ExprObjC.h:229
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:409
const Expr * getBase() const
Definition: ExprObjC.h:580
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:548
Represents an expression that might suspend coroutine execution; either a co_await or co_yield expres...
Definition: ExprCXX.h:4666
Expr * getRHS() const
Definition: Expr.h:4488
llvm::iterator_range< decls_iterator > decls() const
Definition: ExprCXX.h:2965
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3415
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
Definition: DeclBase.h:529
Expr * getResumeExpr() const
Definition: ExprCXX.h:4726
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1308
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition: Expr.h:4405
QualType getSuperReceiverType() const
Definition: ExprObjC.h:763
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.
Definition: Expr.h:3086
llvm::iterator_range< arg_iterator > arguments()
Definition: ExprObjC.h:1453
Defines Expressions and AST nodes for C++2a concepts.
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
Represents a loop initializing the elements of an array.
Definition: Expr.h:5337
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition: Expr.h:4444
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:4127
Expr * getRHS() const
Definition: Expr.h:4100
Represents the specialization of a concept - evaluates to a prvalue of type bool. ...
Definition: ExprConcepts.h:40
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:3635
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2730
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:4067
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Definition: Expr.h:2652
Expr * getLHS() const
Definition: Expr.h:4486
bool isObjectReceiver() const
Definition: ExprObjC.h:771
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2160
static ExprDependence getDependenceInExpr(DeclarationNameInfo Name)
A rewritten comparison expression that was originally written using operator syntax.
Definition: ExprCXX.h:284
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1213
Expr * getRHS() const
Definition: Expr.h:3778
ExprDependence turnTypeToValueDependence(ExprDependence D)
bool isConditionDependent() const
Definition: Expr.h:4474
const Expr * getBase() const
Definition: ExprObjC.h:752
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
Definition: Expr.h:1312
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Definition: Expr.h:2374
Expr * getQueriedExpression() const
Definition: ExprCXX.h:2847
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:1046
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
Definition: Expr.h:4162
TypeSourceInfo * getWrittenTypeInfo() const
Definition: Expr.h:4577
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
Definition: ExprCXX.h:4466
const LangOptions & getLangOpts() const
Definition: ASTContext.h:676
bool isConditionTrue() const
isConditionTrue - Return whether the condition is true (i.e.
Definition: Expr.h:4467
Expr * getBaseExpr() const
Definition: ExprCXX.h:966
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:5426
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6374
Expr * getLength()
Get length of array section.
Definition: ExprOpenMP.h:102
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3678
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point...
Definition: Expr.cpp:2760
Expr * getBase()
An array section can be written only as Base[LowerBound:Length].
Definition: ExprOpenMP.h:85