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