clang  7.0.0svn
ScopeInfo.h
Go to the documentation of this file.
1 //===--- ScopeInfo.h - Information about a semantic context -----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines FunctionScopeInfo and its subclasses, which contain
11 // information about a single function, block, lambda, or method body.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_SEMA_SCOPEINFO_H
16 #define LLVM_CLANG_SEMA_SCOPEINFO_H
17 
18 #include "clang/AST/Expr.h"
19 #include "clang/AST/Type.h"
22 #include "clang/Sema/CleanupInfo.h"
23 #include "clang/Sema/Ownership.h"
24 #include "llvm/ADT/DenseMap.h"
25 #include "llvm/ADT/MapVector.h"
26 #include "llvm/ADT/SmallSet.h"
27 #include "llvm/ADT/SmallVector.h"
28 #include "llvm/ADT/StringSwitch.h"
29 #include <algorithm>
30 
31 namespace clang {
32 
33 class Decl;
34 class BlockDecl;
35 class CapturedDecl;
36 class CXXMethodDecl;
37 class FieldDecl;
38 class ObjCPropertyDecl;
39 class IdentifierInfo;
40 class ImplicitParamDecl;
41 class LabelDecl;
42 class ReturnStmt;
43 class Scope;
44 class SwitchStmt;
45 class TemplateTypeParmDecl;
46 class TemplateParameterList;
47 class VarDecl;
48 class ObjCIvarRefExpr;
49 class ObjCPropertyRefExpr;
50 class ObjCMessageExpr;
51 
52 namespace sema {
53 
54 /// \brief Contains information about the compound statement currently being
55 /// parsed.
57 public:
59  : HasEmptyLoopBodies(false), IsStmtExpr(IsStmtExpr) { }
60 
61  /// \brief Whether this compound stamement contains `for' or `while' loops
62  /// with empty bodies.
64 
65  /// \brief Whether this compound statement corresponds to a GNU statement
66  /// expression.
67  bool IsStmtExpr;
68 
70  HasEmptyLoopBodies = true;
71  }
72 };
73 
75 public:
78  const Stmt *stmt;
79 
81  const Stmt *stmt)
82  : PD(PD), Loc(Loc), stmt(stmt) {}
83 };
84 
85 /// \brief Retains information about a function, method, or block that is
86 /// currently being parsed.
88 protected:
89  enum ScopeKind {
93  SK_CapturedRegion
94  };
95 
96 public:
97  /// \brief What kind of scope we are describing.
98  ///
100 
101  /// \brief Whether this function contains a VLA, \@try, try, C++
102  /// initializer, or anything else that can't be jumped past.
104 
105  /// \brief Whether this function contains any switches or direct gotos.
107 
108  /// \brief Whether this function contains any indirect gotos.
109  bool HasIndirectGoto : 1;
110 
111  /// \brief Whether a statement was dropped because it was invalid.
112  bool HasDroppedStmt : 1;
113 
114  /// \brief True if current scope is for OpenMP declare reduction combiner.
116 
117  /// \brief Whether there is a fallthrough statement in this function.
119 
120  /// \brief Whether we make reference to a declaration that could be
121  /// unavailable.
123 
124  /// A flag that is set when parsing a method that must call super's
125  /// implementation, such as \c -dealloc, \c -finalize, or any method marked
126  /// with \c __attribute__((objc_requires_super)).
128 
129  /// True when this is a method marked as a designated initializer.
131  /// This starts true for a method marked as designated initializer and will
132  /// be set to false if there is an invocation to a designated initializer of
133  /// the super class.
135 
136  /// True when this is an initializer method not marked as a designated
137  /// initializer within a class that has at least one initializer marked as a
138  /// designated initializer.
140  /// This starts true for a secondary initializer method and will be set to
141  /// false if there is an invocation of an initializer on 'self'.
143 
144  /// \brief True only when this function has not already built, or attempted
145  /// to build, the initial and final coroutine suspend points
147 
148  /// \brief An enumeration represeting the kind of the first coroutine statement
149  /// in the function. One of co_return, co_await, or co_yield.
150  unsigned char FirstCoroutineStmtKind : 2;
151 
152  /// First coroutine statement in the current function.
153  /// (ex co_return, co_await, co_yield)
155 
156  /// First 'return' statement in the current function.
158 
159  /// First C++ 'try' statement in the current function.
161 
162  /// First SEH '__try' statement in the current function.
164 
165  /// \brief Used to determine if errors occurred in this function or block.
167 
168  /// SwitchStack - This is the current set of active switch statements in the
169  /// block.
171 
172  /// \brief The list of return statements that occur within the function or
173  /// block, if there is any chance of applying the named return value
174  /// optimization, or if we need to infer a return type.
176 
177  /// \brief The promise object for this coroutine, if any.
178  VarDecl *CoroutinePromise = nullptr;
179 
180  /// \brief A mapping between the coroutine function parameters that were moved
181  /// to the coroutine frame, and their move statements.
182  llvm::SmallMapVector<ParmVarDecl *, Stmt *, 4> CoroutineParameterMoves;
183 
184  /// \brief The initial and final coroutine suspend points.
185  std::pair<Stmt *, Stmt *> CoroutineSuspends;
186 
187  /// \brief The stack of currently active compound stamement scopes in the
188  /// function.
190 
191  /// \brief A list of PartialDiagnostics created but delayed within the
192  /// current function scope. These diagnostics are vetted for reachability
193  /// prior to being emitted.
195 
196  /// \brief A list of parameters which have the nonnull attribute and are
197  /// modified in the function.
198  llvm::SmallPtrSet<const ParmVarDecl*, 8> ModifiedNonNullParams;
199 
200 public:
201  /// Represents a simple identification of a weak object.
202  ///
203  /// Part of the implementation of -Wrepeated-use-of-weak.
204  ///
205  /// This is used to determine if two weak accesses refer to the same object.
206  /// Here are some examples of how various accesses are "profiled":
207  ///
208  /// Access Expression | "Base" Decl | "Property" Decl
209  /// :---------------: | :-----------------: | :------------------------------:
210  /// self.property | self (VarDecl) | property (ObjCPropertyDecl)
211  /// self.implicitProp | self (VarDecl) | -implicitProp (ObjCMethodDecl)
212  /// self->ivar.prop | ivar (ObjCIvarDecl) | prop (ObjCPropertyDecl)
213  /// cxxObj.obj.prop | obj (FieldDecl) | prop (ObjCPropertyDecl)
214  /// [self foo].prop | 0 (unknown) | prop (ObjCPropertyDecl)
215  /// self.prop1.prop2 | prop1 (ObjCPropertyDecl) | prop2 (ObjCPropertyDecl)
216  /// MyClass.prop | MyClass (ObjCInterfaceDecl) | -prop (ObjCMethodDecl)
217  /// MyClass.foo.prop | +foo (ObjCMethodDecl) | -prop (ObjCPropertyDecl)
218  /// weakVar | 0 (known) | weakVar (VarDecl)
219  /// self->weakIvar | self (VarDecl) | weakIvar (ObjCIvarDecl)
220  ///
221  /// Objects are identified with only two Decls to make it reasonably fast to
222  /// compare them.
224  /// The base object decl, as described in the class documentation.
225  ///
226  /// The extra flag is "true" if the Base and Property are enough to uniquely
227  /// identify the object in memory.
228  ///
229  /// \sa isExactProfile()
230  typedef llvm::PointerIntPair<const NamedDecl *, 1, bool> BaseInfoTy;
231  BaseInfoTy Base;
232 
233  /// The "property" decl, as described in the class documentation.
234  ///
235  /// Note that this may not actually be an ObjCPropertyDecl, e.g. in the
236  /// case of "implicit" properties (regular methods accessed via dot syntax).
237  const NamedDecl *Property;
238 
239  /// Used to find the proper base profile for a given base expression.
240  static BaseInfoTy getBaseInfo(const Expr *BaseE);
241 
242  inline WeakObjectProfileTy();
243  static inline WeakObjectProfileTy getSentinel();
244 
245  public:
247  WeakObjectProfileTy(const Expr *Base, const ObjCPropertyDecl *Property);
248  WeakObjectProfileTy(const DeclRefExpr *RE);
250 
251  const NamedDecl *getBase() const { return Base.getPointer(); }
252  const NamedDecl *getProperty() const { return Property; }
253 
254  /// Returns true if the object base specifies a known object in memory,
255  /// rather than, say, an instance variable or property of another object.
256  ///
257  /// Note that this ignores the effects of aliasing; that is, \c foo.bar is
258  /// considered an exact profile if \c foo is a local variable, even if
259  /// another variable \c foo2 refers to the same object as \c foo.
260  ///
261  /// For increased precision, accesses with base variables that are
262  /// properties or ivars of 'self' (e.g. self.prop1.prop2) are considered to
263  /// be exact, though this is not true for arbitrary variables
264  /// (foo.prop1.prop2).
265  bool isExactProfile() const {
266  return Base.getInt();
267  }
268 
269  bool operator==(const WeakObjectProfileTy &Other) const {
270  return Base == Other.Base && Property == Other.Property;
271  }
272 
273  // For use in DenseMap.
274  // We can't specialize the usual llvm::DenseMapInfo at the end of the file
275  // because by that point the DenseMap in FunctionScopeInfo has already been
276  // instantiated.
277  class DenseMapInfo {
278  public:
280  return WeakObjectProfileTy();
281  }
283  return WeakObjectProfileTy::getSentinel();
284  }
285 
286  static unsigned getHashValue(const WeakObjectProfileTy &Val) {
287  typedef std::pair<BaseInfoTy, const NamedDecl *> Pair;
288  return llvm::DenseMapInfo<Pair>::getHashValue(Pair(Val.Base,
289  Val.Property));
290  }
291 
292  static bool isEqual(const WeakObjectProfileTy &LHS,
293  const WeakObjectProfileTy &RHS) {
294  return LHS == RHS;
295  }
296  };
297  };
298 
299  /// Represents a single use of a weak object.
300  ///
301  /// Stores both the expression and whether the access is potentially unsafe
302  /// (i.e. it could potentially be warned about).
303  ///
304  /// Part of the implementation of -Wrepeated-use-of-weak.
305  class WeakUseTy {
306  llvm::PointerIntPair<const Expr *, 1, bool> Rep;
307  public:
308  WeakUseTy(const Expr *Use, bool IsRead) : Rep(Use, IsRead) {}
309 
310  const Expr *getUseExpr() const { return Rep.getPointer(); }
311  bool isUnsafe() const { return Rep.getInt(); }
312  void markSafe() { Rep.setInt(false); }
313 
314  bool operator==(const WeakUseTy &Other) const {
315  return Rep == Other.Rep;
316  }
317  };
318 
319  /// Used to collect uses of a particular weak object in a function body.
320  ///
321  /// Part of the implementation of -Wrepeated-use-of-weak.
323 
324  /// Used to collect all uses of weak objects in a function body.
325  ///
326  /// Part of the implementation of -Wrepeated-use-of-weak.
327  typedef llvm::SmallDenseMap<WeakObjectProfileTy, WeakUseVector, 8,
330 
331 private:
332  /// Used to collect all uses of weak objects in this function body.
333  ///
334  /// Part of the implementation of -Wrepeated-use-of-weak.
335  WeakObjectUseMap WeakObjectUses;
336 
337 protected:
338  FunctionScopeInfo(const FunctionScopeInfo&) = default;
339 
340 public:
341  /// Record that a weak object was accessed.
342  ///
343  /// Part of the implementation of -Wrepeated-use-of-weak.
344  template <typename ExprT>
345  inline void recordUseOfWeak(const ExprT *E, bool IsRead = true);
346 
347  void recordUseOfWeak(const ObjCMessageExpr *Msg,
348  const ObjCPropertyDecl *Prop);
349 
350  /// Record that a given expression is a "safe" access of a weak object (e.g.
351  /// assigning it to a strong variable.)
352  ///
353  /// Part of the implementation of -Wrepeated-use-of-weak.
354  void markSafeWeakUse(const Expr *E);
355 
357  return WeakObjectUses;
358  }
359 
361  HasBranchIntoScope = true;
362  }
363 
365  HasBranchProtectedScope = true;
366  }
367 
369  HasIndirectGoto = true;
370  }
371 
373  HasDroppedStmt = true;
374  }
375 
377  HasOMPDeclareReductionCombiner = true;
378  }
379 
381  HasFallthroughStmt = true;
382  }
383 
385  setHasBranchProtectedScope();
386  FirstCXXTryLoc = TryLoc;
387  }
388 
390  setHasBranchProtectedScope();
391  FirstSEHTryLoc = TryLoc;
392  }
393 
394  bool NeedsScopeChecking() const {
395  return !HasDroppedStmt &&
396  (HasIndirectGoto ||
397  (HasBranchProtectedScope && HasBranchIntoScope));
398  }
399 
400  bool isCoroutine() const { return !FirstCoroutineStmtLoc.isInvalid(); }
401 
402  void setFirstCoroutineStmt(SourceLocation Loc, StringRef Keyword) {
403  assert(FirstCoroutineStmtLoc.isInvalid() &&
404  "first coroutine statement location already set");
405  FirstCoroutineStmtLoc = Loc;
406  FirstCoroutineStmtKind = llvm::StringSwitch<unsigned char>(Keyword)
407  .Case("co_return", 0)
408  .Case("co_await", 1)
409  .Case("co_yield", 2);
410  }
411 
412  StringRef getFirstCoroutineStmtKeyword() const {
413  assert(FirstCoroutineStmtLoc.isValid()
414  && "no coroutine statement available");
415  switch (FirstCoroutineStmtKind) {
416  case 0: return "co_return";
417  case 1: return "co_await";
418  case 2: return "co_yield";
419  default:
420  llvm_unreachable("FirstCoroutineStmtKind has an invalid value");
421  };
422  }
423 
424  void setNeedsCoroutineSuspends(bool value = true) {
425  assert((!value || CoroutineSuspends.first == nullptr) &&
426  "we already have valid suspend points");
427  NeedsCoroutineSuspends = value;
428  }
429 
431  return !NeedsCoroutineSuspends && CoroutineSuspends.first == nullptr;
432  }
433 
434  void setCoroutineSuspends(Stmt *Initial, Stmt *Final) {
435  assert(Initial && Final && "suspend points cannot be null");
436  assert(CoroutineSuspends.first == nullptr && "suspend points already set");
437  NeedsCoroutineSuspends = false;
438  CoroutineSuspends.first = Initial;
439  CoroutineSuspends.second = Final;
440  }
441 
443  : Kind(SK_Function),
444  HasBranchProtectedScope(false),
445  HasBranchIntoScope(false),
446  HasIndirectGoto(false),
447  HasDroppedStmt(false),
448  HasOMPDeclareReductionCombiner(false),
449  HasFallthroughStmt(false),
450  HasPotentialAvailabilityViolations(false),
451  ObjCShouldCallSuper(false),
452  ObjCIsDesignatedInit(false),
453  ObjCWarnForNoDesignatedInitChain(false),
454  ObjCIsSecondaryInit(false),
455  ObjCWarnForNoInitDelegation(false),
456  NeedsCoroutineSuspends(true),
457  ErrorTrap(Diag) { }
458 
459  virtual ~FunctionScopeInfo();
460 
461  /// \brief Clear out the information in this function scope, making it
462  /// suitable for reuse.
463  void Clear();
464 };
465 
467 protected:
468  CapturingScopeInfo(const CapturingScopeInfo&) = default;
469 
470 public:
472  ImpCap_None, ImpCap_LambdaByval, ImpCap_LambdaByref, ImpCap_Block,
473  ImpCap_CapturedRegion
474  };
475 
477 
478  class Capture {
479  // There are three categories of capture: capturing 'this', capturing
480  // local variables, and C++1y initialized captures (which can have an
481  // arbitrary initializer, and don't really capture in the traditional
482  // sense at all).
483  //
484  // There are three ways to capture a local variable:
485  // - capture by copy in the C++11 sense,
486  // - capture by reference in the C++11 sense, and
487  // - __block capture.
488  // Lambdas explicitly specify capture by copy or capture by reference.
489  // For blocks, __block capture applies to variables with that annotation,
490  // variables of reference type are captured by reference, and other
491  // variables are captured by copy.
492  enum CaptureKind {
493  Cap_ByCopy, Cap_ByRef, Cap_Block, Cap_VLA
494  };
495  enum {
496  IsNestedCapture = 0x1,
497  IsThisCaptured = 0x2
498  };
499  /// The variable being captured (if we are not capturing 'this') and whether
500  /// this is a nested capture, and whether we are capturing 'this'
501  llvm::PointerIntPair<VarDecl*, 2> VarAndNestedAndThis;
502  /// Expression to initialize a field of the given type, and the kind of
503  /// capture (if this is a capture and not an init-capture). The expression
504  /// is only required if we are capturing ByVal and the variable's type has
505  /// a non-trivial copy constructor.
506  llvm::PointerIntPair<void *, 2, CaptureKind> InitExprAndCaptureKind;
507 
508  /// \brief The source location at which the first capture occurred.
509  SourceLocation Loc;
510 
511  /// \brief The location of the ellipsis that expands a parameter pack.
512  SourceLocation EllipsisLoc;
513 
514  /// \brief The type as it was captured, which is in effect the type of the
515  /// non-static data member that would hold the capture.
516  QualType CaptureType;
517 
518  /// \brief Whether an explicit capture has been odr-used in the body of the
519  /// lambda.
520  bool ODRUsed;
521 
522  /// \brief Whether an explicit capture has been non-odr-used in the body of
523  /// the lambda.
524  bool NonODRUsed;
525 
526  public:
527  Capture(VarDecl *Var, bool Block, bool ByRef, bool IsNested,
528  SourceLocation Loc, SourceLocation EllipsisLoc,
529  QualType CaptureType, Expr *Cpy)
530  : VarAndNestedAndThis(Var, IsNested ? IsNestedCapture : 0),
531  InitExprAndCaptureKind(
532  Cpy, !Var ? Cap_VLA : Block ? Cap_Block : ByRef ? Cap_ByRef
533  : Cap_ByCopy),
534  Loc(Loc), EllipsisLoc(EllipsisLoc), CaptureType(CaptureType),
535  ODRUsed(false), NonODRUsed(false) {}
536 
537  enum IsThisCapture { ThisCapture };
538  Capture(IsThisCapture, bool IsNested, SourceLocation Loc,
539  QualType CaptureType, Expr *Cpy, const bool ByCopy)
540  : VarAndNestedAndThis(
541  nullptr, (IsThisCaptured | (IsNested ? IsNestedCapture : 0))),
542  InitExprAndCaptureKind(Cpy, ByCopy ? Cap_ByCopy : Cap_ByRef),
543  Loc(Loc), EllipsisLoc(), CaptureType(CaptureType), ODRUsed(false),
544  NonODRUsed(false) {}
545 
546  bool isThisCapture() const {
547  return VarAndNestedAndThis.getInt() & IsThisCaptured;
548  }
549  bool isVariableCapture() const {
550  return !isThisCapture() && !isVLATypeCapture();
551  }
552  bool isCopyCapture() const {
553  return InitExprAndCaptureKind.getInt() == Cap_ByCopy;
554  }
555  bool isReferenceCapture() const {
556  return InitExprAndCaptureKind.getInt() == Cap_ByRef;
557  }
558  bool isBlockCapture() const {
559  return InitExprAndCaptureKind.getInt() == Cap_Block;
560  }
561  bool isVLATypeCapture() const {
562  return InitExprAndCaptureKind.getInt() == Cap_VLA;
563  }
564  bool isNested() const {
565  return VarAndNestedAndThis.getInt() & IsNestedCapture;
566  }
567  bool isODRUsed() const { return ODRUsed; }
568  bool isNonODRUsed() const { return NonODRUsed; }
569  void markUsed(bool IsODRUse) { (IsODRUse ? ODRUsed : NonODRUsed) = true; }
570 
571  VarDecl *getVariable() const {
572  assert(isVariableCapture());
573  return VarAndNestedAndThis.getPointer();
574  }
575 
576  /// \brief Retrieve the location at which this variable was captured.
577  SourceLocation getLocation() const { return Loc; }
578 
579  /// \brief Retrieve the source location of the ellipsis, whose presence
580  /// indicates that the capture is a pack expansion.
581  SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
582 
583  /// \brief Retrieve the capture type for this capture, which is effectively
584  /// the type of the non-static data member in the lambda/block structure
585  /// that would store this capture.
587  assert(!isThisCapture());
588  return CaptureType;
589  }
590 
591  Expr *getInitExpr() const {
592  assert(!isVLATypeCapture() && "no init expression for type capture");
593  return static_cast<Expr *>(InitExprAndCaptureKind.getPointer());
594  }
595  };
596 
598  : FunctionScopeInfo(Diag), ImpCaptureStyle(Style), CXXThisCaptureIndex(0),
599  HasImplicitReturnType(false)
600  {}
601 
602  /// CaptureMap - A map of captured variables to (index+1) into Captures.
603  llvm::DenseMap<VarDecl*, unsigned> CaptureMap;
604 
605  /// CXXThisCaptureIndex - The (index+1) of the capture of 'this';
606  /// zero if 'this' is not captured.
608 
609  /// Captures - The captures.
611 
612  /// \brief - Whether the target type of return statements in this context
613  /// is deduced (e.g. a lambda or block with omitted return type).
615 
616  /// ReturnType - The target type of return statements in this context,
617  /// or null if unknown.
619 
620  void addCapture(VarDecl *Var, bool isBlock, bool isByref, bool isNested,
621  SourceLocation Loc, SourceLocation EllipsisLoc,
622  QualType CaptureType, Expr *Cpy) {
623  Captures.push_back(Capture(Var, isBlock, isByref, isNested, Loc,
624  EllipsisLoc, CaptureType, Cpy));
625  CaptureMap[Var] = Captures.size();
626  }
627 
628  void addVLATypeCapture(SourceLocation Loc, QualType CaptureType) {
629  Captures.push_back(Capture(/*Var*/ nullptr, /*isBlock*/ false,
630  /*isByref*/ false, /*isNested*/ false, Loc,
631  /*EllipsisLoc*/ SourceLocation(), CaptureType,
632  /*Cpy*/ nullptr));
633  }
634 
635  // Note, we do not need to add the type of 'this' since that is always
636  // retrievable from Sema::getCurrentThisType - and is also encoded within the
637  // type of the corresponding FieldDecl.
638  void addThisCapture(bool isNested, SourceLocation Loc,
639  Expr *Cpy, bool ByCopy);
640 
641  /// \brief Determine whether the C++ 'this' is captured.
642  bool isCXXThisCaptured() const { return CXXThisCaptureIndex != 0; }
643 
644  /// \brief Retrieve the capture of C++ 'this', if it has been captured.
646  assert(isCXXThisCaptured() && "this has not been captured");
647  return Captures[CXXThisCaptureIndex - 1];
648  }
649 
650  /// \brief Determine whether the given variable has been captured.
651  bool isCaptured(VarDecl *Var) const {
652  return CaptureMap.count(Var);
653  }
654 
655  /// \brief Determine whether the given variable-array type has been captured.
656  bool isVLATypeCaptured(const VariableArrayType *VAT) const;
657 
658  /// \brief Retrieve the capture of the given variable, if it has been
659  /// captured already.
661  assert(isCaptured(Var) && "Variable has not been captured");
662  return Captures[CaptureMap[Var] - 1];
663  }
664 
665  const Capture &getCapture(VarDecl *Var) const {
666  llvm::DenseMap<VarDecl*, unsigned>::const_iterator Known
667  = CaptureMap.find(Var);
668  assert(Known != CaptureMap.end() && "Variable has not been captured");
669  return Captures[Known->second - 1];
670  }
671 
672  static bool classof(const FunctionScopeInfo *FSI) {
673  return FSI->Kind == SK_Block || FSI->Kind == SK_Lambda
674  || FSI->Kind == SK_CapturedRegion;
675  }
676 };
677 
678 /// \brief Retains information about a block that is currently being parsed.
679 class BlockScopeInfo final : public CapturingScopeInfo {
680 public:
682 
683  /// TheScope - This is the scope for the block itself, which contains
684  /// arguments etc.
686 
687  /// BlockType - The function type of the block, if one was given.
688  /// Its return type may be BuiltinType::Dependent.
690 
692  : CapturingScopeInfo(Diag, ImpCap_Block), TheDecl(Block),
693  TheScope(BlockScope)
694  {
695  Kind = SK_Block;
696  }
697 
698  ~BlockScopeInfo() override;
699 
700  static bool classof(const FunctionScopeInfo *FSI) {
701  return FSI->Kind == SK_Block;
702  }
703 };
704 
705 /// \brief Retains information about a captured region.
707 public:
708  /// \brief The CapturedDecl for this statement.
710  /// \brief The captured record type.
712  /// \brief This is the enclosing scope of the captured region.
714  /// \brief The implicit parameter for the captured variables.
716  /// \brief The kind of captured region.
717  unsigned short CapRegionKind;
718  unsigned short OpenMPLevel;
719 
721  RecordDecl *RD, ImplicitParamDecl *Context,
722  CapturedRegionKind K, unsigned OpenMPLevel)
723  : CapturingScopeInfo(Diag, ImpCap_CapturedRegion),
724  TheCapturedDecl(CD), TheRecordDecl(RD), TheScope(S),
725  ContextParam(Context), CapRegionKind(K), OpenMPLevel(OpenMPLevel)
726  {
727  Kind = SK_CapturedRegion;
728  }
729 
730  ~CapturedRegionScopeInfo() override;
731 
732  /// \brief A descriptive name for the kind of captured region this is.
733  StringRef getRegionName() const {
734  switch (CapRegionKind) {
735  case CR_Default:
736  return "default captured statement";
737  case CR_OpenMP:
738  return "OpenMP region";
739  }
740  llvm_unreachable("Invalid captured region kind!");
741  }
742 
743  static bool classof(const FunctionScopeInfo *FSI) {
744  return FSI->Kind == SK_CapturedRegion;
745  }
746 };
747 
748 class LambdaScopeInfo final : public CapturingScopeInfo {
749 public:
750  /// \brief The class that describes the lambda.
752 
753  /// \brief The lambda's compiler-generated \c operator().
755 
756  /// \brief Source range covering the lambda introducer [...].
758 
759  /// \brief Source location of the '&' or '=' specifying the default capture
760  /// type, if any.
762 
763  /// \brief The number of captures in the \c Captures list that are
764  /// explicit captures.
766 
767  /// \brief Whether this is a mutable lambda.
768  bool Mutable;
769 
770  /// \brief Whether the (empty) parameter list is explicit.
772 
773  /// \brief Whether any of the capture expressions requires cleanups.
775 
776  /// \brief Whether the lambda contains an unexpanded parameter pack.
778 
779  /// \brief If this is a generic lambda, use this as the depth of
780  /// each 'auto' parameter, during initial AST construction.
782 
783  /// \brief Store the list of the auto parameters for a generic lambda.
784  /// If this is a generic lambda, store the list of the auto
785  /// parameters converted into TemplateTypeParmDecls into a vector
786  /// that can be used to construct the generic lambda's template
787  /// parameter list, during initial AST construction.
789 
790  /// If this is a generic lambda, and the template parameter
791  /// list has been created (from the AutoTemplateParams) then
792  /// store a reference to it (cache it to avoid reconstructing it).
794 
795  /// \brief Contains all variable-referring-expressions (i.e. DeclRefExprs
796  /// or MemberExprs) that refer to local variables in a generic lambda
797  /// or a lambda in a potentially-evaluated-if-used context.
798  ///
799  /// Potentially capturable variables of a nested lambda that might need
800  /// to be captured by the lambda are housed here.
801  /// This is specifically useful for generic lambdas or
802  /// lambdas within a a potentially evaluated-if-used context.
803  /// If an enclosing variable is named in an expression of a lambda nested
804  /// within a generic lambda, we don't always know know whether the variable
805  /// will truly be odr-used (i.e. need to be captured) by that nested lambda,
806  /// until its instantiation. But we still need to capture it in the
807  /// enclosing lambda if all intervening lambdas can capture the variable.
808 
810 
811  /// \brief Contains all variable-referring-expressions that refer
812  /// to local variables that are usable as constant expressions and
813  /// do not involve an odr-use (they may still need to be captured
814  /// if the enclosing full-expression is instantiation dependent).
815  llvm::SmallSet<Expr *, 8> NonODRUsedCapturingExprs;
816 
817  /// Contains all of the variables defined in this lambda that shadow variables
818  /// that were defined in parent contexts. Used to avoid warnings when the
819  /// shadowed variables are uncaptured by this lambda.
821  const VarDecl *VD;
823  };
825 
827 
829  : CapturingScopeInfo(Diag, ImpCap_None), Lambda(nullptr),
830  CallOperator(nullptr), NumExplicitCaptures(0), Mutable(false),
831  ExplicitParams(false), Cleanup{},
832  ContainsUnexpandedParameterPack(false), AutoTemplateParameterDepth(0),
833  GLTemplateParameterList(nullptr) {
834  Kind = SK_Lambda;
835  }
836 
837  /// \brief Note when all explicit captures have been added.
839  NumExplicitCaptures = Captures.size();
840  }
841 
842  static bool classof(const FunctionScopeInfo *FSI) {
843  return FSI->Kind == SK_Lambda;
844  }
845 
846  /// Is this scope known to be for a generic lambda? (This will be false until
847  /// we parse the first 'auto'-typed parameter.
848  bool isGenericLambda() const {
849  return !AutoTemplateParams.empty() || GLTemplateParameterList;
850  }
851 
852  ///
853  /// \brief Add a variable that might potentially be captured by the
854  /// lambda and therefore the enclosing lambdas.
855  ///
856  /// This is also used by enclosing lambda's to speculatively capture
857  /// variables that nested lambda's - depending on their enclosing
858  /// specialization - might need to capture.
859  /// Consider:
860  /// void f(int, int); <-- don't capture
861  /// void f(const int&, double); <-- capture
862  /// void foo() {
863  /// const int x = 10;
864  /// auto L = [=](auto a) { // capture 'x'
865  /// return [=](auto b) {
866  /// f(x, a); // we may or may not need to capture 'x'
867  /// };
868  /// };
869  /// }
870  void addPotentialCapture(Expr *VarExpr) {
871  assert(isa<DeclRefExpr>(VarExpr) || isa<MemberExpr>(VarExpr));
872  PotentiallyCapturingExprs.push_back(VarExpr);
873  }
874 
876  PotentialThisCaptureLocation = Loc;
877  }
878  bool hasPotentialThisCapture() const {
879  return PotentialThisCaptureLocation.isValid();
880  }
881 
882  /// \brief Mark a variable's reference in a lambda as non-odr using.
883  ///
884  /// For generic lambdas, if a variable is named in a potentially evaluated
885  /// expression, where the enclosing full expression is dependent then we
886  /// must capture the variable (given a default capture).
887  /// This is accomplished by recording all references to variables
888  /// (DeclRefExprs or MemberExprs) within said nested lambda in its array of
889  /// PotentialCaptures. All such variables have to be captured by that lambda,
890  /// except for as described below.
891  /// If that variable is usable as a constant expression and is named in a
892  /// manner that does not involve its odr-use (e.g. undergoes
893  /// lvalue-to-rvalue conversion, or discarded) record that it is so. Upon the
894  /// act of analyzing the enclosing full expression (ActOnFinishFullExpr)
895  /// if we can determine that the full expression is not instantiation-
896  /// dependent, then we can entirely avoid its capture.
897  ///
898  /// const int n = 0;
899  /// [&] (auto x) {
900  /// (void)+n + x;
901  /// };
902  /// Interestingly, this strategy would involve a capture of n, even though
903  /// it's obviously not odr-used here, because the full-expression is
904  /// instantiation-dependent. It could be useful to avoid capturing such
905  /// variables, even when they are referred to in an instantiation-dependent
906  /// expression, if we can unambiguously determine that they shall never be
907  /// odr-used. This would involve removal of the variable-referring-expression
908  /// from the array of PotentialCaptures during the lvalue-to-rvalue
909  /// conversions. But per the working draft N3797, (post-chicago 2013) we must
910  /// capture such variables.
911  /// Before anyone is tempted to implement a strategy for not-capturing 'n',
912  /// consider the insightful warning in:
913  /// /cfe-commits/Week-of-Mon-20131104/092596.html
914  /// "The problem is that the set of captures for a lambda is part of the ABI
915  /// (since lambda layout can be made visible through inline functions and the
916  /// like), and there are no guarantees as to which cases we'll manage to build
917  /// an lvalue-to-rvalue conversion in, when parsing a template -- some
918  /// seemingly harmless change elsewhere in Sema could cause us to start or stop
919  /// building such a node. So we need a rule that anyone can implement and get
920  /// exactly the same result".
921  ///
922  void markVariableExprAsNonODRUsed(Expr *CapturingVarExpr) {
923  assert(isa<DeclRefExpr>(CapturingVarExpr)
924  || isa<MemberExpr>(CapturingVarExpr));
925  NonODRUsedCapturingExprs.insert(CapturingVarExpr);
926  }
927  bool isVariableExprMarkedAsNonODRUsed(Expr *CapturingVarExpr) const {
928  assert(isa<DeclRefExpr>(CapturingVarExpr)
929  || isa<MemberExpr>(CapturingVarExpr));
930  return NonODRUsedCapturingExprs.count(CapturingVarExpr);
931  }
933  PotentiallyCapturingExprs.erase(
934  std::remove(PotentiallyCapturingExprs.begin(),
935  PotentiallyCapturingExprs.end(), E),
936  PotentiallyCapturingExprs.end());
937  }
939  PotentiallyCapturingExprs.clear();
940  PotentialThisCaptureLocation = SourceLocation();
941  }
943  return PotentiallyCapturingExprs.size();
944  }
945 
946  bool hasPotentialCaptures() const {
947  return getNumPotentialVariableCaptures() ||
948  PotentialThisCaptureLocation.isValid();
949  }
950 
951  // When passed the index, returns the VarDecl and Expr associated
952  // with the index.
953  void getPotentialVariableCapture(unsigned Idx, VarDecl *&VD, Expr *&E) const;
954 };
955 
956 FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy()
957  : Base(nullptr, false), Property(nullptr) {}
958 
960 FunctionScopeInfo::WeakObjectProfileTy::getSentinel() {
962  Result.Base.setInt(true);
963  return Result;
964 }
965 
966 template <typename ExprT>
967 void FunctionScopeInfo::recordUseOfWeak(const ExprT *E, bool IsRead) {
968  assert(E);
969  WeakUseVector &Uses = WeakObjectUses[WeakObjectProfileTy(E)];
970  Uses.push_back(WeakUseTy(E, IsRead));
971 }
972 
973 inline void
975  Expr *Cpy,
976  const bool ByCopy) {
977  Captures.push_back(Capture(Capture::ThisCapture, isNested, Loc, QualType(),
978  Cpy, ByCopy));
979  CXXThisCaptureIndex = Captures.size();
980 }
981 
982 } // end namespace sema
983 } // end namespace clang
984 
985 #endif
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:577
QualType getCaptureType() const
Retrieve the capture type for this capture, which is effectively the type of the non-static data memb...
Definition: ScopeInfo.h:586
SourceRange IntroducerRange
Source range covering the lambda introducer [...].
Definition: ScopeInfo.h:757
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
A (possibly-)qualified type.
Definition: Type.h:653
void addThisCapture(bool isNested, SourceLocation Loc, Expr *Cpy, bool ByCopy)
Definition: ScopeInfo.h:974
bool ExplicitParams
Whether the (empty) parameter list is explicit.
Definition: ScopeInfo.h:771
bool HasFallthroughStmt
Whether there is a fallthrough statement in this function.
Definition: ScopeInfo.h:118
TemplateParameterList * GLTemplateParameterList
If this is a generic lambda, and the template parameter list has been created (from the AutoTemplateP...
Definition: ScopeInfo.h:793
bool HasEmptyLoopBodies
Whether this compound stamement contains `for&#39; or `while&#39; loops with empty bodies.
Definition: ScopeInfo.h:63
void setNeedsCoroutineSuspends(bool value=true)
Definition: ScopeInfo.h:424
Stmt - This represents one statement.
Definition: Stmt.h:66
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
Definition: ScopeInfo.h:618
C Language Family Type Representation.
bool hasPotentialCaptures() const
Definition: ScopeInfo.h:946
bool operator==(const WeakUseTy &Other) const
Definition: ScopeInfo.h:314
const WeakObjectUseMap & getWeakObjectUses() const
Definition: ScopeInfo.h:356
StringRef getFirstCoroutineStmtKeyword() const
Definition: ScopeInfo.h:412
static unsigned getHashValue(const WeakObjectProfileTy &Val)
Definition: ScopeInfo.h:286
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
bool isVariableExprMarkedAsNonODRUsed(Expr *CapturingVarExpr) const
Definition: ScopeInfo.h:927
std::pair< Stmt *, Stmt * > CoroutineSuspends
The initial and final coroutine suspend points.
Definition: ScopeInfo.h:185
static bool classof(const FunctionScopeInfo *FSI)
Definition: ScopeInfo.h:842
Retains information about a function, method, or block that is currently being parsed.
Definition: ScopeInfo.h:87
Represents a variable declaration or definition.
Definition: Decl.h:812
static bool classof(const FunctionScopeInfo *FSI)
Definition: ScopeInfo.h:743
bool hasPotentialThisCapture() const
Definition: ScopeInfo.h:878
SmallVector< SwitchStmt *, 8 > SwitchStack
SwitchStack - This is the current set of active switch statements in the block.
Definition: ScopeInfo.h:170
static bool classof(const FunctionScopeInfo *FSI)
Definition: ScopeInfo.h:672
RAII class that determines when any errors have occurred between the time the instance was created an...
Definition: Diagnostic.h:998
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:68
llvm::SmallVector< ShadowedOuterDecl, 4 > ShadowingDecls
Definition: ScopeInfo.h:824
bool NeedsCoroutineSuspends
True only when this function has not already built, or attempted to build, the initial and final coro...
Definition: ScopeInfo.h:146
CapturedDecl * TheCapturedDecl
The CapturedDecl for this statement.
Definition: ScopeInfo.h:709
bool HasDroppedStmt
Whether a statement was dropped because it was invalid.
Definition: ScopeInfo.h:112
llvm::SmallMapVector< ParmVarDecl *, Stmt *, 4 > CoroutineParameterMoves
A mapping between the coroutine function parameters that were moved to the coroutine frame...
Definition: ScopeInfo.h:182
Represents a struct/union/class.
Definition: Decl.h:3510
unsigned char FirstCoroutineStmtKind
An enumeration represeting the kind of the first coroutine statement in the function.
Definition: ScopeInfo.h:150
SourceLocation getEllipsisLoc() const
Retrieve the source location of the ellipsis, whose presence indicates that the capture is a pack exp...
Definition: ScopeInfo.h:581
ScopeKind Kind
What kind of scope we are describing.
Definition: ScopeInfo.h:99
Scope * TheScope
This is the enclosing scope of the captured region.
Definition: ScopeInfo.h:713
llvm::SmallSet< Expr *, 8 > NonODRUsedCapturingExprs
Contains all variable-referring-expressions that refer to local variables that are usable as constant...
Definition: ScopeInfo.h:815
bool ContainsUnexpandedParameterPack
Whether the lambda contains an unexpanded parameter pack.
Definition: ScopeInfo.h:777
SourceLocation FirstSEHTryLoc
First SEH &#39;__try&#39; statement in the current function.
Definition: ScopeInfo.h:163
bool operator==(const WeakObjectProfileTy &Other) const
Definition: ScopeInfo.h:269
DiagnosticErrorTrap ErrorTrap
Used to determine if errors occurred in this function or block.
Definition: ScopeInfo.h:166
CompoundScopeInfo(bool IsStmtExpr)
Definition: ScopeInfo.h:58
WeakUseTy(const Expr *Use, bool IsRead)
Definition: ScopeInfo.h:308
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:149
QualType FunctionType
BlockType - The function type of the block, if one was given.
Definition: ScopeInfo.h:689
void finishedExplicitCaptures()
Note when all explicit captures have been added.
Definition: ScopeInfo.h:838
bool IsStmtExpr
Whether this compound statement corresponds to a GNU statement expression.
Definition: ScopeInfo.h:67
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:39
FunctionScopeInfo(DiagnosticsEngine &Diag)
Definition: ScopeInfo.h:442
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:3883
PossiblyUnreachableDiag(const PartialDiagnostic &PD, SourceLocation Loc, const Stmt *stmt)
Definition: ScopeInfo.h:80
SmallVector< TemplateTypeParmDecl *, 4 > AutoTemplateParams
Store the list of the auto parameters for a generic lambda.
Definition: ScopeInfo.h:788
SmallVector< WeakUseTy, 4 > WeakUseVector
Used to collect uses of a particular weak object in a function body.
Definition: ScopeInfo.h:322
Contains information about the compound statement currently being parsed.
Definition: ScopeInfo.h:56
SourceLocation FirstCXXTryLoc
First C++ &#39;try&#39; statement in the current function.
Definition: ScopeInfo.h:160
CleanupInfo Cleanup
Whether any of the capture expressions requires cleanups.
Definition: ScopeInfo.h:774
ImplicitCaptureStyle ImpCaptureStyle
Definition: ScopeInfo.h:476
void addPotentialCapture(Expr *VarExpr)
Add a variable that might potentially be captured by the lambda and therefore the enclosing lambdas...
Definition: ScopeInfo.h:870
void markVariableExprAsNonODRUsed(Expr *CapturingVarExpr)
Mark a variable&#39;s reference in a lambda as non-odr using.
Definition: ScopeInfo.h:922
bool Mutable
Whether this is a mutable lambda.
Definition: ScopeInfo.h:768
SmallVector< ReturnStmt *, 4 > Returns
The list of return statements that occur within the function or block, if there is any chance of appl...
Definition: ScopeInfo.h:175
Retains information about a captured region.
Definition: ScopeInfo.h:706
void recordUseOfWeak(const ExprT *E, bool IsRead=true)
Record that a weak object was accessed.
Definition: ScopeInfo.h:967
SourceLocation PotentialThisCaptureLocation
Definition: ScopeInfo.h:826
unsigned NumExplicitCaptures
The number of captures in the Captures list that are explicit captures.
Definition: ScopeInfo.h:765
CapturedRegionScopeInfo(DiagnosticsEngine &Diag, Scope *S, CapturedDecl *CD, RecordDecl *RD, ImplicitParamDecl *Context, CapturedRegionKind K, unsigned OpenMPLevel)
Definition: ScopeInfo.h:720
Retains information about a block that is currently being parsed.
Definition: ScopeInfo.h:679
CXXMethodDecl * CallOperator
The lambda&#39;s compiler-generated operator().
Definition: ScopeInfo.h:754
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:3713
Expr - This represents one expression.
Definition: Expr.h:106
void removePotentialCapture(Expr *E)
Definition: ScopeInfo.h:932
bool HasBranchProtectedScope
Whether this function contains a VLA, @try, try, C++ initializer, or anything else that can&#39;t be jump...
Definition: ScopeInfo.h:103
bool isCaptured(VarDecl *Var) const
Determine whether the given variable has been captured.
Definition: ScopeInfo.h:651
Capture & getCapture(VarDecl *Var)
Retrieve the capture of the given variable, if it has been captured already.
Definition: ScopeInfo.h:660
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:903
void setHasCXXTry(SourceLocation TryLoc)
Definition: ScopeInfo.h:384
unsigned short CapRegionKind
The kind of captured region.
Definition: ScopeInfo.h:717
llvm::SmallPtrSet< const ParmVarDecl *, 8 > ModifiedNonNullParams
A list of parameters which have the nonnull attribute and are modified in the function.
Definition: ScopeInfo.h:198
CapturingScopeInfo(DiagnosticsEngine &Diag, ImplicitCaptureStyle Style)
Definition: ScopeInfo.h:597
#define false
Definition: stdbool.h:33
Kind
void setHasSEHTry(SourceLocation TryLoc)
Definition: ScopeInfo.h:389
bool HasPotentialAvailabilityViolations
Whether we make reference to a declaration that could be unavailable.
Definition: ScopeInfo.h:122
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
Definition: ScopeInfo.h:577
Encodes a location in the source.
CXXRecordDecl * Lambda
The class that describes the lambda.
Definition: ScopeInfo.h:751
bool ObjCWarnForNoDesignatedInitChain
This starts true for a method marked as designated initializer and will be set to false if there is a...
Definition: ScopeInfo.h:134
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2019
SmallVector< Capture, 4 > Captures
Captures - The captures.
Definition: ScopeInfo.h:610
SourceLocation FirstCoroutineStmtLoc
First coroutine statement in the current function.
Definition: ScopeInfo.h:154
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:746
void addPotentialThisCapture(SourceLocation Loc)
Definition: ScopeInfo.h:875
bool ObjCIsDesignatedInit
True when this is a method marked as a designated initializer.
Definition: ScopeInfo.h:130
bool ObjCShouldCallSuper
A flag that is set when parsing a method that must call super&#39;s implementation, such as -dealloc...
Definition: ScopeInfo.h:127
SourceLocation CaptureDefaultLoc
Source location of the &#39;&&#39; or &#39;=&#39; specifying the default capture type, if any.
Definition: ScopeInfo.h:761
bool HasOMPDeclareReductionCombiner
True if current scope is for OpenMP declare reduction combiner.
Definition: ScopeInfo.h:115
llvm::SmallVector< Expr *, 4 > PotentiallyCapturingExprs
Contains all variable-referring-expressions (i.e.
Definition: ScopeInfo.h:809
bool isGenericLambda() const
Is this scope known to be for a generic lambda? (This will be false until we parse the first &#39;auto&#39;-t...
Definition: ScopeInfo.h:848
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool ObjCIsSecondaryInit
True when this is an initializer method not marked as a designated initializer within a class that ha...
Definition: ScopeInfo.h:139
llvm::SmallDenseMap< WeakObjectProfileTy, WeakUseVector, 8, WeakObjectProfileTy::DenseMapInfo > WeakObjectUseMap
Used to collect all uses of weak objects in a function body.
Definition: ScopeInfo.h:329
bool HasIndirectGoto
Whether this function contains any indirect gotos.
Definition: ScopeInfo.h:109
const Capture & getCapture(VarDecl *Var) const
Definition: ScopeInfo.h:665
unsigned CXXThisCaptureIndex
CXXThisCaptureIndex - The (index+1) of the capture of &#39;this&#39;; zero if &#39;this&#39; is not captured...
Definition: ScopeInfo.h:607
StringRef getRegionName() const
A descriptive name for the kind of captured region this is.
Definition: ScopeInfo.h:733
Represents a simple identification of a weak object.
Definition: ScopeInfo.h:223
bool ObjCWarnForNoInitDelegation
This starts true for a secondary initializer method and will be set to false if there is an invocatio...
Definition: ScopeInfo.h:142
BlockScopeInfo(DiagnosticsEngine &Diag, Scope *BlockScope, BlockDecl *Block)
Definition: ScopeInfo.h:691
LambdaScopeInfo(DiagnosticsEngine &Diag)
Definition: ScopeInfo.h:828
SourceLocation FirstReturnLoc
First &#39;return&#39; statement in the current function.
Definition: ScopeInfo.h:157
Contains all of the variables defined in this lambda that shadow variables that were defined in paren...
Definition: ScopeInfo.h:820
RecordDecl * TheRecordDecl
The captured record type.
Definition: ScopeInfo.h:711
void setFirstCoroutineStmt(SourceLocation Loc, StringRef Keyword)
Definition: ScopeInfo.h:402
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
llvm::DenseMap< VarDecl *, unsigned > CaptureMap
CaptureMap - A map of captured variables to (index+1) into Captures.
Definition: ScopeInfo.h:603
unsigned getNumPotentialVariableCaptures() const
Definition: ScopeInfo.h:942
Capture & getCXXThisCapture()
Retrieve the capture of C++ &#39;this&#39;, if it has been captured.
Definition: ScopeInfo.h:645
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:513
static bool isEqual(const WeakObjectProfileTy &LHS, const WeakObjectProfileTy &RHS)
Definition: ScopeInfo.h:292
Capture(IsThisCapture, bool IsNested, SourceLocation Loc, QualType CaptureType, Expr *Cpy, const bool ByCopy)
Definition: ScopeInfo.h:538
unsigned AutoTemplateParameterDepth
If this is a generic lambda, use this as the depth of each &#39;auto&#39; parameter, during initial AST const...
Definition: ScopeInfo.h:781
SmallVector< PossiblyUnreachableDiag, 4 > PossiblyUnreachableDiags
A list of PartialDiagnostics created but delayed within the current function scope.
Definition: ScopeInfo.h:194
Represents a C++ struct/union/class.
Definition: DeclCXX.h:299
static bool classof(const FunctionScopeInfo *FSI)
Definition: ScopeInfo.h:700
bool isCXXThisCaptured() const
Determine whether the C++ &#39;this&#39; is captured.
Definition: ScopeInfo.h:642
Capture(VarDecl *Var, bool Block, bool ByRef, bool IsNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, Expr *Cpy)
Definition: ScopeInfo.h:527
void addVLATypeCapture(SourceLocation Loc, QualType CaptureType)
Definition: ScopeInfo.h:628
Represents a single use of a weak object.
Definition: ScopeInfo.h:305
Scope * TheScope
TheScope - This is the scope for the block itself, which contains arguments etc.
Definition: ScopeInfo.h:685
bool HasImplicitReturnType
Whether the target type of return statements in this context is deduced (e.g.
Definition: ScopeInfo.h:614
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:956
CapturedRegionKind
The different kinds of captured statement.
Definition: CapturedStmt.h:17
void addCapture(VarDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, Expr *Cpy)
Definition: ScopeInfo.h:620
bool hasInvalidCoroutineSuspends() const
Definition: ScopeInfo.h:430
ImplicitParamDecl * ContextParam
The implicit parameter for the captured variables.
Definition: ScopeInfo.h:715
SmallVector< CompoundScopeInfo, 4 > CompoundScopes
The stack of currently active compound stamement scopes in the function.
Definition: ScopeInfo.h:189
bool isExactProfile() const
Returns true if the object base specifies a known object in memory, rather than, say, an instance variable or property of another object.
Definition: ScopeInfo.h:265
#define true
Definition: stdbool.h:32
A trivial tuple used to represent a source range.
This represents a decl that may have a name.
Definition: Decl.h:248
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:2723
bool HasBranchIntoScope
Whether this function contains any switches or direct gotos.
Definition: ScopeInfo.h:106
const FormatStyle & Style
void setCoroutineSuspends(Stmt *Initial, Stmt *Final)
Definition: ScopeInfo.h:434