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  }
473  }
474 
475  // (VD) - FIXME: Missing from the standard:
476  // - a member function or a static data member of the current
477  // instantiation
478  if (Var->isStaticDataMember() &&
479  Var->getDeclContext()->isDependentContext()) {
480  Deps |= ExprDependence::ValueInstantiation;
481  TypeSourceInfo *TInfo = Var->getFirstDecl()->getTypeSourceInfo();
482  if (TInfo->getType()->isIncompleteArrayType())
483  Deps |= ExprDependence::Type;
484  }
485 
486  return Deps;
487  }
488 
489  // (VD) - FIXME: Missing from the standard:
490  // - a member function or a static data member of the current
491  // instantiation
492  if (isa<CXXMethodDecl>(Decl) && Decl->getDeclContext()->isDependentContext())
493  Deps |= ExprDependence::ValueInstantiation;
494  return Deps;
495 }
496 
498  // RecoveryExpr is
499  // - always value-dependent, and therefore instantiation dependent
500  // - contains errors (ExprDependence::Error), by definition
501  // - type-dependent if we don't know the type (fallback to an opaque
502  // dependent type), or the type is known and dependent, or it has
503  // type-dependent subexpressions.
504  auto D = toExprDependence(E->getType()->getDependence()) |
505  ExprDependence::ValueInstantiation | ExprDependence::Error;
506  // FIXME: remove the type-dependent bit from subexpressions, if the
507  // RecoveryExpr has a non-dependent type.
508  for (auto *S : E->subExpressions())
509  D |= S->getDependence();
510  return D;
511 }
512 
514  return toExprDependence(E->getType()->getDependence()) &
515  ~ExprDependence::UnexpandedPack;
516 }
517 
519  llvm::ArrayRef<Expr *> PreArgs) {
520  auto D = E->getCallee()->getDependence();
521  for (auto *A : llvm::makeArrayRef(E->getArgs(), E->getNumArgs())) {
522  if (A)
523  D |= A->getDependence();
524  }
525  for (auto *A : PreArgs)
526  D |= A->getDependence();
527  return D;
528 }
529 
531  auto D = turnTypeToValueDependence(
533  for (unsigned I = 0, N = E->getNumExpressions(); I < N; ++I)
535  return D;
536 }
537 
539  auto *MemberDecl = E->getMemberDecl();
540  auto D = E->getBase()->getDependence();
541  if (FieldDecl *FD = dyn_cast<FieldDecl>(MemberDecl)) {
542  DeclContext *DC = MemberDecl->getDeclContext();
543  // dyn_cast_or_null is used to handle objC variables which do not
544  // have a declaration context.
545  CXXRecordDecl *RD = dyn_cast_or_null<CXXRecordDecl>(DC);
546  if (RD && RD->isDependentContext() && RD->isCurrentInstantiation(DC)) {
547  if (!E->getType()->isDependentType())
548  D &= ~ExprDependence::Type;
549  }
550 
551  // Bitfield with value-dependent width is type-dependent.
552  if (FD && FD->isBitField() && FD->getBitWidth()->isValueDependent()) {
554  }
555  }
556  // FIXME: move remaining dependence computation from MemberExpr::Create()
557  return D;
558 }
559 
561  auto D = ExprDependence::None;
562  for (auto *A : E->inits())
563  D |= A->getDependence();
564  return D;
565 }
566 
568  auto D = toExprDependence(E->getType()->getDependence());
569  for (auto *C : llvm::makeArrayRef(E->getSubExprs(), E->getNumSubExprs()))
570  D |= C->getDependence();
571  return D;
572 }
573 
575  bool ContainsUnexpandedPack) {
576  auto D = ContainsUnexpandedPack ? ExprDependence::UnexpandedPack
578  for (auto *AE : E->getAssocExprs())
579  D |= AE->getDependence() & ExprDependence::Error;
581 
582  if (E->isResultDependent())
583  return D | ExprDependence::TypeValueInstantiation;
584  return D | (E->getResultExpr()->getDependence() &
585  ~ExprDependence::UnexpandedPack);
586 }
587 
589  auto Deps = E->getInit()->getDependence();
590  for (auto D : E->designators()) {
591  auto DesignatorDeps = ExprDependence::None;
592  if (D.isArrayDesignator())
593  DesignatorDeps |= E->getArrayIndex(D)->getDependence();
594  else if (D.isArrayRangeDesignator())
595  DesignatorDeps |= E->getArrayRangeStart(D)->getDependence() |
597  Deps |= DesignatorDeps;
598  if (DesignatorDeps & ExprDependence::TypeValue)
599  Deps |= ExprDependence::TypeValueInstantiation;
600  }
601  return Deps;
602 }
603 
605  auto D = O->getSyntacticForm()->getDependence();
606  for (auto *E : O->semantics())
607  D |= E->getDependence();
608  return D;
609 }
610 
612  auto D = ExprDependence::None;
613  for (auto *E : llvm::makeArrayRef(A->getSubExprs(), A->getNumSubExprs()))
614  D |= E->getDependence();
615  return D;
616 }
617 
619  auto D = toExprDependence(E->getType()->getDependence());
620  auto Size = E->getArraySize();
621  if (Size.hasValue() && *Size)
622  D |= turnTypeToValueDependence((*Size)->getDependence());
623  if (auto *I = E->getInitializer())
624  D |= turnTypeToValueDependence(I->getDependence());
625  for (auto *A : E->placement_arguments())
626  D |= turnTypeToValueDependence(A->getDependence());
627  return D;
628 }
629 
631  auto D = E->getBase()->getDependence();
632  if (!E->getDestroyedType().isNull())
634  if (auto *ST = E->getScopeTypeInfo())
636  toExprDependence(ST->getType()->getDependence()));
637  if (auto *Q = E->getQualifier())
638  D |= toExprDependence(Q->getDependence() &
639  ~NestedNameSpecifierDependence::Dependent);
640  return D;
641 }
642 
644  auto D = ExprDependence::None;
645  if (Name.isInstantiationDependent())
646  D |= ExprDependence::Instantiation;
648  D |= ExprDependence::UnexpandedPack;
649  return D;
650 }
651 
653 clang::computeDependence(OverloadExpr *E, bool KnownDependent,
654  bool KnownInstantiationDependent,
655  bool KnownContainsUnexpandedParameterPack) {
656  auto Deps = ExprDependence::None;
657  if (KnownDependent)
658  Deps |= ExprDependence::TypeValue;
659  if (KnownInstantiationDependent)
660  Deps |= ExprDependence::Instantiation;
661  if (KnownContainsUnexpandedParameterPack)
662  Deps |= ExprDependence::UnexpandedPack;
663  Deps |= getDependenceInExpr(E->getNameInfo());
664  if (auto *Q = E->getQualifier())
665  Deps |= toExprDependence(Q->getDependence() &
666  ~NestedNameSpecifierDependence::Dependent);
667  for (auto *D : E->decls()) {
668  if (D->getDeclContext()->isDependentContext() ||
669  isa<UnresolvedUsingValueDecl>(D))
670  Deps |= ExprDependence::TypeValueInstantiation;
671  }
672  // If we have explicit template arguments, check for dependent
673  // template arguments and whether they contain any unexpanded pack
674  // expansions.
675  for (auto A : E->template_arguments())
676  Deps |= toExprDependence(A.getArgument().getDependence());
677  return Deps;
678 }
679 
681  auto D = ExprDependence::TypeValue;
682  D |= getDependenceInExpr(E->getNameInfo());
683  if (auto *Q = E->getQualifier())
684  D |= toExprDependence(Q->getDependence());
685  for (auto A : E->template_arguments())
686  D |= toExprDependence(A.getArgument().getDependence());
687  return D;
688 }
689 
691  auto D = toExprDependence(E->getType()->getDependence());
692  for (auto *A : E->arguments())
693  D |= A->getDependence() & ~ExprDependence::Type;
694  return D;
695 }
696 
698  bool ContainsUnexpandedParameterPack) {
699  auto D = toExprDependence(E->getType()->getDependence());
700  if (ContainsUnexpandedParameterPack)
701  D |= ExprDependence::UnexpandedPack;
702  return D;
703 }
704 
706  auto D = ExprDependence::ValueInstantiation;
707  D |= toExprDependence(E->getType()->getDependence());
708  if (E->getType()->getContainedDeducedType())
710  for (auto *A : E->arguments())
711  D |= A->getDependence() &
712  (ExprDependence::UnexpandedPack | ExprDependence::Error);
713  return D;
714 }
715 
717  auto D = ExprDependence::TypeValueInstantiation;
718  if (!E->isImplicitAccess())
719  D |= E->getBase()->getDependence();
720  if (auto *Q = E->getQualifier())
721  D |= toExprDependence(Q->getDependence());
723  for (auto A : E->template_arguments())
724  D |= toExprDependence(A.getArgument().getDependence());
725  return D;
726 }
727 
729  return E->getSubExpr()->getDependence();
730 }
731 
733  auto D = ExprDependence::TypeValueInstantiation;
734  for (const auto *C : {E->getLHS(), E->getRHS()}) {
735  if (C)
736  D |= C->getDependence() & ~ExprDependence::UnexpandedPack;
737  }
738  return D;
739 }
740 
742  auto D = ExprDependence::None;
743  for (const auto *A : E->getArgs())
744  D |=
745  toExprDependence(A->getType()->getDependence()) & ~ExprDependence::Type;
746  return D;
747 }
748 
750  bool ValueDependent) {
752  const auto InterestingDeps = TemplateArgumentDependence::Instantiation |
753  TemplateArgumentDependence::UnexpandedPack;
754  for (const TemplateArgumentLoc &ArgLoc :
756  TA |= ArgLoc.getArgument().getDependence() & InterestingDeps;
757  if (TA == InterestingDeps)
758  break;
759  }
760 
761  ExprDependence D =
762  ValueDependent ? ExprDependence::Value : ExprDependence::None;
763  return D | toExprDependence(TA);
764 }
765 
767  auto D = ExprDependence::None;
768  Expr **Elements = E->getElements();
769  for (unsigned I = 0, N = E->getNumElements(); I != N; ++I)
770  D |= turnTypeToValueDependence(Elements[I]->getDependence());
771  return D;
772 }
773 
775  auto Deps = ExprDependence::None;
776  for (unsigned I = 0, N = E->getNumElements(); I < N; ++I) {
777  auto KV = E->getKeyValueElement(I);
778  auto KVDeps = turnTypeToValueDependence(KV.Key->getDependence() |
779  KV.Value->getDependence());
780  if (KV.EllipsisLoc.isValid())
781  KVDeps &= ~ExprDependence::UnexpandedPack;
782  Deps |= KVDeps;
783  }
784  return Deps;
785 }
786 
788  auto D = ExprDependence::None;
789  if (auto *R = E->getInstanceReceiver())
790  D |= R->getDependence();
791  else
792  D |= toExprDependence(E->getType()->getDependence());
793  for (auto *A : E->arguments())
794  D |= A->getDependence();
795  return D;
796 }
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:614
const Expr * getSubExpr() const
Definition: Expr.h:984
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:1363
const BlockDecl * getBlockDecl() const
Definition: Expr.h:5808
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:1059
Represents a &#39;co_await&#39; expression while the type of the promise is dependent.
Definition: ExprCXX.h:4719
Expr * getArrayIndex(const Designator &D) const
Definition: Expr.cpp:4368
Expr ** getArgs()
Retrieve the call arguments.
Definition: Expr.h:2912
Expr * getLHS() const
Definition: Expr.h:4016
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
Definition: Expr.h:5970
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:1355
llvm::iterator_range< arg_iterator > placement_arguments()
Definition: ExprCXX.h:2298
A (possibly-)qualified type.
Definition: Type.h:655
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3257
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Definition: Expr.h:3145
Expr * getCond() const
Definition: Expr.h:4401
ExprDependence computeDependence(FullExpr *E)
const Expr * getSubExpr() const
Definition: ExprCXX.h:1167
unsigned getNumSubExprs() const
getNumSubExprs - Return the size of the SubExprs array.
Definition: Expr.h:4268
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:2619
Expr * getResultExpr()
Return the result expression of this controlling expression.
Definition: Expr.h:5644
CompoundStmt * getSubStmt()
Definition: Expr.h:4203
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
Definition: Expr.h:5635
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Definition: Expr.h:2909
Expr * getDimensionExpression() const
Definition: ExprCXX.h:2754
Expr * getBase() const
Definition: Expr.h:3139
TypeSourceInfo * getTypeSourceInfo() const
Definition: Expr.h:3336
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
const Expr * getSubExpr() const
Definition: Expr.h:4486
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:2080
Expr * getLowerBound()
Get lower bound of array section.
Definition: ExprOpenMP.h:94
The base class of the type hierarchy.
Definition: Type.h:1472
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
Definition: ExprCXX.h:3201
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1426
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:2707
A container of type source information.
Definition: Type.h:6373
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Definition: ExprCXX.h:2528
MS property subscript expression.
Definition: ExprCXX.h:960
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:4406
Expr * getIndexExpr(unsigned Idx)
Definition: Expr.h:2475
Represents a variable declaration or definition.
Definition: Decl.h:820
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:3303
OpaqueValueExpr * getCommonExpr() const
Get the common subexpression shared by all initializations (the source array).
Definition: Expr.h:5262
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition: ExprCXX.h:761
const Expr * getExprStmt() const
Definition: Stmt.cpp:334
unsigned getNumExpressions() const
Definition: Expr.h:2490
bool isParameterPack() const
Whether this declaration is a parameter pack.
Definition: DeclBase.cpp:211
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:1147
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:633
Expr * getExprOperand() const
Definition: ExprCXX.h:852
Defines the clang::Expr interface and subclasses for C++ expressions.
Expr * getExprOperand() const
Definition: ExprCXX.h:1063
Represents a C99 designated initializer expression.
Definition: Expr.h:4858
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:2548
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:4234
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:174
Expr * getInit() const
Retrieve the initializer value.
Definition: Expr.h:5096
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
Definition: Expr.h:6246
FullExpr - Represents a "full-expression" node.
Definition: Expr.h:971
Represents a member of a struct/union/class.
Definition: Decl.h:2746
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:5156
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
Definition: ExprCXX.h:2940
Stmt * getStmtExprResult()
Definition: Stmt.h:1456
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:321
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition: Expr.h:1152
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition: Expr.h:5736
Expr * getSubExpr()
Definition: Expr.h:3412
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:3000
Expr * getLHS() const
Definition: ExprCXX.h:4543
Describes an C or C++ initializer list.
Definition: Expr.h:4627
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition: ExprCXX.h:809
Expr * getKeyExpr() const
Definition: ExprObjC.h:883
Optional< Expr * > getArraySize()
Definition: ExprCXX.h:2218
Expr * getBaseExpr() const
Definition: ExprObjC.h:880
Expr * getOperand() const
Definition: ExprCXX.h:3967
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:2268
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:3644
bool isClassReceiver() const
Definition: ExprObjC.h:773
TypeDependence getDependence() const
Definition: Type.h:2174
Expr * getRHS() const
Definition: ExprCXX.h:4544
ArrayRef< Expr * > subExpressions()
Definition: Expr.h:6254
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Definition: ExprCXX.h:2949
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3373
Expr * getOperand() const
Definition: ExprCXX.h:4742
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1378
Expr * getCommonExpr() const
Definition: ExprCXX.h:4643
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1822
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition: Expr.h:186
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3503
bool containsUnexpandedParameterPack() const
Determine whether this name contains an unexpanded parameter pack.
bool isTypeOperand() const
Definition: ExprCXX.h:1052
Represents the this expression in C++.
Definition: ExprCXX.h:1108
Expr ** getSubExprs()
Retrieve the array of expressions.
Definition: Expr.h:4271
OpenMP 5.0 [2.1.5, Array Sections].
Definition: ExprOpenMP.h:56
ConditionalOperator - The ?: ternary operator.
Definition: Expr.h:3982
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2471
QualType getQueriedType() const
Definition: ExprCXX.h:2748
Expr ** getSubExprs()
Definition: Expr.h:6127
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
Definition: Expr.h:2517
ArrayRef< TypeSourceInfo * > getArgs() const
Retrieve the argument types.
Definition: ExprCXX.h:2677
Represents a call to the builtin function __builtin_va_arg.
Definition: Expr.h:4470
bool isImplicitAccess() const
True if this is an implicit access, i.e.
Definition: ExprCXX.h:3593
static unsigned getNumSubExprs(AtomicOp Op)
Determine the number of arguments the specified atomic builtin should have.
Definition: Expr.cpp:4680
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition: Expr.h:5876
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
Definition: ExprCXX.h:2047
Expr * getCond() const
Definition: Expr.h:4005
llvm::MutableArrayRef< Designator > designators()
Definition: Expr.h:5061
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:619
This represents one expression.
Definition: Expr.h:110
SourceLocation End
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5796
Expr * getCallee()
Definition: Expr.h:2883
Expr * getSubExpr() const
Get the initializer to use for each array element.
Definition: Expr.h:5267
QualType getArgumentType() const
Definition: Expr.h:2559
arg_range arguments()
Definition: ExprCXX.h:1558
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:2454
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition: Expr.h:5857
ArrayRef< Expr * > inits()
Definition: Expr.h:4667
QualType getType() const
Definition: Expr.h:142
ArrayRef< Expr * > getAssocExprs() const
Definition: Expr.h:5653
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4516
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:2131
IteratorRange getIteratorRange(unsigned I)
Gets the iterator range for the given iterator.
Definition: Expr.cpp:4896
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:889
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:4198
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Definition: DeclBase.cpp:1140
ValueDecl * getDecl()
Definition: Expr.h:1262
const Expr * getSubExpr() const
Definition: Expr.h:2095
const Expr * getSubExpr() const
Definition: ExprCXX.h:1400
llvm::iterator_range< semantics_iterator > semantics()
Definition: Expr.h:6007
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:720
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
Definition: Expr.h:2641
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Definition: ASTConcept.h:158
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
Definition: ExprCXX.h:3618
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:3185
Expr * getArgument()
Definition: ExprCXX.h:2393
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:1102
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:4302
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
Definition: ExprCXX.h:2834
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:5926
Decl * getIteratorDecl(unsigned I)
Gets the iterator declaration for the given iterator.
Definition: Expr.cpp:4892
Expr * getSubExpr() const
Definition: Expr.h:2178
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:2093
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:6060
UnaryExprOrTypeTrait getKind() const
Definition: Expr.h:2548
Expr * getArrayRangeStart(const Designator &D) const
Definition: Expr.cpp:4373
Expr * getSubExpr()
Definition: ExprObjC.h:144
An expression trait intrinsic.
Definition: ExprCXX.h:2777
ArrayRef< Expr * > exprs()
Definition: Expr.h:5404
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:4186
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:128
bool isArgumentType() const
Definition: Expr.h:2558
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3712
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:2193
ExprDependence getDependence() const
Definition: Expr.h:156
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:3145
const Expr * getInitializer() const
Definition: Expr.h:3326
Expr * getLHS() const
Definition: Expr.h:3693
Expr ** getElements()
Retrieve elements of array of literals.
Definition: ExprObjC.h:221
Represents a C11 generic selection.
Definition: Expr.h:5454
const Expr * getBase() const
Definition: Expr.h:5753
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:4098
bool isTypeOperand() const
Definition: ExprCXX.h:841
Dataflow Directional Tag Classes.
bool isResultDependent() const
Whether this generic selection is result-dependent.
Definition: Expr.h:5632
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
Definition: Type.cpp:1884
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1924
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1303
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:2352
StmtClass getStmtClass() const
Definition: Stmt.h:1148
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:4004
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:848
Expr * getArrayRangeEnd(const Designator &D) const
Definition: Expr.cpp:4379
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:3950
bool isIncompleteArrayType() const
Definition: Type.h:6724
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:451
Expr * getBase() const
Definition: ExprObjC.h:1507
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2612
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:4598
Expr * getRHS() const
Definition: Expr.h:4405
llvm::iterator_range< decls_iterator > decls() const
Definition: ExprCXX.h:2932
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3382
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
Definition: DeclBase.h:529
Expr * getResumeExpr() const
Definition: ExprCXX.h:4658
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition: Expr.h:4322
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:3062
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:5247
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition: Expr.h:4361
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:4044
Expr * getRHS() const
Definition: Expr.h:4017
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:3601
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2768
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:4033
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Definition: Expr.h:2690
Expr * getLHS() const
Definition: Expr.h:4403
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:2185
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:1190
Expr * getRHS() const
Definition: Expr.h:3695
ExprDependence turnTypeToValueDependence(ExprDependence D)
bool isConditionDependent() const
Definition: Expr.h:4391
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:1289
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Definition: Expr.h:2412
Expr * getQueriedExpression() const
Definition: ExprCXX.h:2814
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:1022
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
Definition: Expr.h:4079
TypeSourceInfo * getWrittenTypeInfo() const
Definition: Expr.h:4494
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
Definition: ExprCXX.h:4423
const LangOptions & getLangOpts() const
Definition: ASTContext.h:664
bool isConditionTrue() const
isConditionTrue - Return whether the condition is true (i.e.
Definition: Expr.h:4384
Expr * getBaseExpr() const
Definition: ExprCXX.h:942
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:5336
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6384
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:3644
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point...
Definition: Expr.cpp:2943
Expr * getBase()
An array section can be written only as Base[LowerBound:Length].
Definition: ExprOpenMP.h:85