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