clang  15.0.0git
ConstructionContext.h
Go to the documentation of this file.
1 //===- ConstructionContext.h - CFG constructor information ------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the ConstructionContext class and its sub-classes,
10 // which represent various different ways of constructing C++ objects
11 // with the additional information the users may want to know about
12 // the constructor.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_CLANG_ANALYSIS_CONSTRUCTIONCONTEXT_H
17 #define LLVM_CLANG_ANALYSIS_CONSTRUCTIONCONTEXT_H
18 
20 #include "clang/AST/ExprCXX.h"
21 #include "clang/AST/ExprObjC.h"
22 
23 namespace clang {
24 
25 /// Represents a single point (AST node) in the program that requires attention
26 /// during construction of an object. ConstructionContext would be represented
27 /// as a list of such items.
29 public:
30  enum ItemKind {
46  };
47 
48  LLVM_DUMP_METHOD static StringRef getKindAsString(ItemKind K) {
49  switch (K) {
50  case VariableKind: return "construct into local variable";
51  case NewAllocatorKind: return "construct into new-allocator";
52  case ReturnKind: return "construct into return address";
53  case MaterializationKind: return "materialize temporary";
54  case TemporaryDestructorKind: return "destroy temporary";
55  case ElidedDestructorKind: return "elide destructor";
56  case ElidableConstructorKind: return "elide constructor";
57  case ArgumentKind: return "construct into argument";
58  case InitializerKind: return "construct into member variable";
59  };
60  llvm_unreachable("Unknown ItemKind");
61  }
62 
63 private:
64  const void *const Data;
65  const ItemKind Kind;
66  const unsigned Index = 0;
67 
68  bool hasStatement() const {
69  return Kind >= STATEMENT_KIND_BEGIN &&
70  Kind <= STATEMENT_KIND_END;
71  }
72 
73  bool hasIndex() const {
74  return Kind >= STATEMENT_WITH_INDEX_KIND_BEGIN &&
76  }
77 
78  bool hasInitializer() const {
79  return Kind >= INITIALIZER_KIND_BEGIN &&
81  }
82 
83 public:
84  // ConstructionContextItem should be simple enough so that it was easy to
85  // re-construct it from the AST node it captures. For that reason we provide
86  // simple implicit conversions from all sorts of supported AST nodes.
88  : Data(DS), Kind(VariableKind) {}
89 
91  : Data(NE), Kind(NewAllocatorKind) {}
92 
94  : Data(RS), Kind(ReturnKind) {}
95 
97  : Data(MTE), Kind(MaterializationKind) {}
98 
100  bool IsElided = false)
101  : Data(BTE),
102  Kind(IsElided ? ElidedDestructorKind : TemporaryDestructorKind) {}
103 
105  : Data(CE), Kind(ElidableConstructorKind) {}
106 
107  ConstructionContextItem(const CallExpr *CE, unsigned Index)
108  : Data(CE), Kind(ArgumentKind), Index(Index) {}
109 
110  ConstructionContextItem(const CXXConstructExpr *CE, unsigned Index)
111  : Data(CE), Kind(ArgumentKind), Index(Index) {}
112 
114  : Data(CE), Kind(ArgumentKind), Index(Index) {}
115 
116  ConstructionContextItem(const ObjCMessageExpr *ME, unsigned Index)
117  : Data(ME), Kind(ArgumentKind), Index(Index) {}
118 
119  // A polymorphic version of the previous calls with dynamic type check.
120  ConstructionContextItem(const Expr *E, unsigned Index)
121  : Data(E), Kind(ArgumentKind), Index(Index) {
122  assert(isa<CallExpr>(E) || isa<CXXConstructExpr>(E) ||
123  isa<CXXDeleteExpr>(E) || isa<CXXInheritedCtorInitExpr>(E) ||
124  isa<ObjCMessageExpr>(E));
125  }
126 
128  : Data(Init), Kind(InitializerKind), Index(0) {}
129 
130  ItemKind getKind() const { return Kind; }
131 
132  LLVM_DUMP_METHOD StringRef getKindAsString() const {
133  return getKindAsString(getKind());
134  }
135 
136  /// The construction site - the statement that triggered the construction
137  /// for one of its parts. For instance, stack variable declaration statement
138  /// triggers construction of itself or its elements if it's an array,
139  /// new-expression triggers construction of the newly allocated object(s).
140  const Stmt *getStmt() const {
141  assert(hasStatement());
142  return static_cast<const Stmt *>(Data);
143  }
144 
145  const Stmt *getStmtOrNull() const {
146  return hasStatement() ? getStmt() : nullptr;
147  }
148 
149  /// The construction site is not necessarily a statement. It may also be a
150  /// CXXCtorInitializer, which means that a member variable is being
151  /// constructed during initialization of the object that contains it.
153  assert(hasInitializer());
154  return static_cast<const CXXCtorInitializer *>(Data);
155  }
156 
157  /// If a single trigger statement triggers multiple constructors, they are
158  /// usually being enumerated. This covers function argument constructors
159  /// triggered by a call-expression and items in an initializer list triggered
160  /// by an init-list-expression.
161  unsigned getIndex() const {
162  // This is a fairly specific request. Let's make sure the user knows
163  // what he's doing.
164  assert(hasIndex());
165  return Index;
166  }
167 
168  void Profile(llvm::FoldingSetNodeID &ID) const {
169  ID.AddPointer(Data);
170  ID.AddInteger(Kind);
171  ID.AddInteger(Index);
172  }
173 
174  bool operator==(const ConstructionContextItem &Other) const {
175  // For most kinds the Index comparison is trivially true, but
176  // checking kind separately doesn't seem to be less expensive
177  // than checking Index. Same in operator<().
178  return std::make_tuple(Data, Kind, Index) ==
179  std::make_tuple(Other.Data, Other.Kind, Other.Index);
180  }
181 
182  bool operator<(const ConstructionContextItem &Other) const {
183  return std::make_tuple(Data, Kind, Index) <
184  std::make_tuple(Other.Data, Other.Kind, Other.Index);
185  }
186 };
187 
188 /// Construction context can be seen as a linked list of multiple layers.
189 /// Sometimes a single trigger is not enough to describe the construction
190 /// site. That's what causing us to have a chain of "partial" construction
191 /// context layers. Some examples:
192 /// - A constructor within in an aggregate initializer list within a variable
193 /// would have a construction context of the initializer list with
194 /// the parent construction context of a variable.
195 /// - A constructor for a temporary that needs to be both destroyed
196 /// and materialized into an elidable copy constructor would have a
197 /// construction context of a CXXBindTemporaryExpr with the parent
198 /// construction context of a MaterializeTemproraryExpr.
199 /// Not all of these are currently supported.
200 /// Layers are created gradually while traversing the AST, and layers that
201 /// represent the outmost AST nodes are built first, while the node that
202 /// immediately contains the constructor would be built last and capture the
203 /// previous layers as its parents. Construction context captures the last layer
204 /// (which has links to the previous layers) and classifies the seemingly
205 /// arbitrary chain of layers into one of the possible ways of constructing
206 /// an object in C++ for user-friendly experience.
208  const ConstructionContextLayer *Parent = nullptr;
210 
213  : Parent(Parent), Item(Item) {}
214 
215 public:
216  static const ConstructionContextLayer *
218  const ConstructionContextLayer *Parent = nullptr);
219 
220  const ConstructionContextItem &getItem() const { return Item; }
221  const ConstructionContextLayer *getParent() const { return Parent; }
222  bool isLast() const { return !Parent; }
223 
224  /// See if Other is a proper initial segment of this construction context
225  /// in terms of the parent chain - i.e. a few first parents coincide and
226  /// then the other context terminates but our context goes further - i.e.,
227  /// we are providing the same context that the other context provides,
228  /// and a bit more above that.
229  bool isStrictlyMoreSpecificThan(const ConstructionContextLayer *Other) const;
230 };
231 
232 
233 /// ConstructionContext's subclasses describe different ways of constructing
234 /// an object in C++. The context re-captures the essential parent AST nodes
235 /// of the CXXConstructExpr it is assigned to and presents these nodes
236 /// through easy-to-understand accessor methods.
238 public:
239  enum Kind {
258  };
259 
260 protected:
262 
263  // Do not make public! These need to only be constructed
264  // via createFromLayers().
265  explicit ConstructionContext(Kind K) : K(K) {}
266 
267 private:
268  // A helper function for constructing an instance into a bump vector context.
269  template <typename T, typename... ArgTypes>
270  static T *create(BumpVectorContext &C, ArgTypes... Args) {
271  auto *CC = C.getAllocator().Allocate<T>();
272  return new (CC) T(Args...);
273  }
274 
275  // A sub-routine of createFromLayers() that deals with temporary objects
276  // that need to be materialized. The BTE argument is for the situation when
277  // the object also needs to be bound for destruction.
278  static const ConstructionContext *createMaterializedTemporaryFromLayers(
279  BumpVectorContext &C, const MaterializeTemporaryExpr *MTE,
280  const CXXBindTemporaryExpr *BTE,
281  const ConstructionContextLayer *ParentLayer);
282 
283  // A sub-routine of createFromLayers() that deals with temporary objects
284  // that need to be bound for destruction. Automatically finds out if the
285  // object also needs to be materialized and delegates to
286  // createMaterializedTemporaryFromLayers() if necessary.
287  static const ConstructionContext *
288  createBoundTemporaryFromLayers(
289  BumpVectorContext &C, const CXXBindTemporaryExpr *BTE,
290  const ConstructionContextLayer *ParentLayer);
291 
292 public:
293  /// Consume the construction context layer, together with its parent layers,
294  /// and wrap it up into a complete construction context. May return null
295  /// if layers do not form any supported construction context.
296  static const ConstructionContext *
297  createFromLayers(BumpVectorContext &C,
298  const ConstructionContextLayer *TopLayer);
299 
300  Kind getKind() const { return K; }
301 };
302 
303 /// An abstract base class for local variable constructors.
305  const DeclStmt *DS;
306 
307 protected:
309  : ConstructionContext(K), DS(DS) {
310  assert(classof(this));
311  assert(DS);
312  }
313 
314 public:
315  const DeclStmt *getDeclStmt() const { return DS; }
316 
317  static bool classof(const ConstructionContext *CC) {
318  return CC->getKind() >= VARIABLE_BEGIN &&
319  CC->getKind() <= VARIABLE_END;
320  }
321 };
322 
323 /// Represents construction into a simple local variable, eg. T var(123);.
324 /// If a variable has an initializer, eg. T var = makeT();, then the final
325 /// elidable copy-constructor from makeT() into var would also be a simple
326 /// variable constructor handled by this class.
328  friend class ConstructionContext; // Allows to create<>() itself.
329 
330  explicit SimpleVariableConstructionContext(const DeclStmt *DS)
332  DS) {}
333 
334 public:
335  static bool classof(const ConstructionContext *CC) {
336  return CC->getKind() == SimpleVariableKind;
337  }
338 };
339 
340 /// Represents construction into a simple variable with an initializer syntax,
341 /// with a single constructor, eg. T var = makeT();. Such construction context
342 /// may only appear in C++17 because previously it was split into a temporary
343 /// object constructor and an elidable simple variable copy-constructor and
344 /// we were producing separate construction contexts for these constructors.
345 /// In C++17 we have a single construction context that combines both.
346 /// Note that if the object has trivial destructor, then this code is
347 /// indistinguishable from a simple variable constructor on the AST level;
348 /// in this case we provide a simple variable construction context.
350  : public VariableConstructionContext {
351  const CXXBindTemporaryExpr *BTE;
352 
353  friend class ConstructionContext; // Allows to create<>() itself.
354 
356  const DeclStmt *DS, const CXXBindTemporaryExpr *BTE)
358  assert(BTE);
359  }
360 
361 public:
362  const CXXBindTemporaryExpr *getCXXBindTemporaryExpr() const { return BTE; }
363 
364  static bool classof(const ConstructionContext *CC) {
365  return CC->getKind() == CXX17ElidedCopyVariableKind;
366  }
367 };
368 
369 // An abstract base class for constructor-initializer-based constructors.
371  const CXXCtorInitializer *I;
372 
373 protected:
376  : ConstructionContext(K), I(I) {
377  assert(classof(this));
378  assert(I);
379  }
380 
381 public:
382  const CXXCtorInitializer *getCXXCtorInitializer() const { return I; }
383 
384  static bool classof(const ConstructionContext *CC) {
385  return CC->getKind() >= INITIALIZER_BEGIN &&
386  CC->getKind() <= INITIALIZER_END;
387  }
388 };
389 
390 /// Represents construction into a field or a base class within a bigger object
391 /// via a constructor initializer, eg. T(): field(123) { ... }.
394  friend class ConstructionContext; // Allows to create<>() itself.
395 
397  const CXXCtorInitializer *I)
400 
401 public:
402  static bool classof(const ConstructionContext *CC) {
404  }
405 };
406 
407 /// Represents construction into a field or a base class within a bigger object
408 /// via a constructor initializer, with a single constructor, eg.
409 /// T(): field(Field(123)) { ... }. Such construction context may only appear
410 /// in C++17 because previously it was split into a temporary object constructor
411 /// and an elidable simple constructor-initializer copy-constructor and we were
412 /// producing separate construction contexts for these constructors. In C++17
413 /// we have a single construction context that combines both. Note that if the
414 /// object has trivial destructor, then this code is indistinguishable from
415 /// a simple constructor-initializer constructor on the AST level; in this case
416 /// we provide a simple constructor-initializer construction context.
419  const CXXBindTemporaryExpr *BTE;
420 
421  friend class ConstructionContext; // Allows to create<>() itself.
422 
424  const CXXCtorInitializer *I, const CXXBindTemporaryExpr *BTE)
427  BTE(BTE) {
428  assert(BTE);
429  }
430 
431 public:
432  const CXXBindTemporaryExpr *getCXXBindTemporaryExpr() const { return BTE; }
433 
434  static bool classof(const ConstructionContext *CC) {
436  }
437 };
438 
439 /// Represents immediate initialization of memory allocated by operator new,
440 /// eg. new T(123);.
442  const CXXNewExpr *NE;
443 
444  friend class ConstructionContext; // Allows to create<>() itself.
445 
448  NE(NE) {
449  assert(NE);
450  }
451 
452 public:
453  const CXXNewExpr *getCXXNewExpr() const { return NE; }
454 
455  static bool classof(const ConstructionContext *CC) {
456  return CC->getKind() == NewAllocatedObjectKind;
457  }
458 };
459 
460 /// Represents a temporary object, eg. T(123), that does not immediately cross
461 /// function boundaries "by value"; constructors that construct function
462 /// value-type arguments or values that are immediately returned from the
463 /// function that returns a value receive separate construction context kinds.
465  const CXXBindTemporaryExpr *BTE;
466  const MaterializeTemporaryExpr *MTE;
467 
468 protected:
471  const MaterializeTemporaryExpr *MTE)
472  : ConstructionContext(K), BTE(BTE), MTE(MTE) {
473  // Both BTE and MTE can be null here, all combinations possible.
474  // Even though for now at least one should be non-null, we simply haven't
475  // implemented the other case yet (this would be a temporary in the middle
476  // of nowhere that doesn't have a non-trivial destructor).
477  }
478 
479 public:
480  /// CXXBindTemporaryExpr here is non-null as long as the temporary has
481  /// a non-trivial destructor.
483  return BTE;
484  }
485 
486  /// MaterializeTemporaryExpr is non-null as long as the temporary is actually
487  /// used after construction, eg. by binding to a reference (lifetime
488  /// extension), accessing a field, calling a method, or passing it into
489  /// a function (an elidable copy or move constructor would be a common
490  /// example) by reference.
492  return MTE;
493  }
494 
495  static bool classof(const ConstructionContext *CC) {
496  return CC->getKind() >= TEMPORARY_BEGIN && CC->getKind() <= TEMPORARY_END;
497  }
498 };
499 
500 /// Represents a temporary object that is not constructed for the purpose of
501 /// being immediately copied/moved by an elidable copy/move-constructor.
502 /// This includes temporary objects "in the middle of nowhere" like T(123) and
503 /// lifetime-extended temporaries.
506  friend class ConstructionContext; // Allows to create<>() itself.
507 
509  const CXXBindTemporaryExpr *BTE, const MaterializeTemporaryExpr *MTE)
512 
513 public:
514  static bool classof(const ConstructionContext *CC) {
515  return CC->getKind() == SimpleTemporaryObjectKind;
516  }
517 };
518 
519 /// Represents a temporary object that is constructed for the sole purpose
520 /// of being immediately copied by an elidable copy/move constructor.
521 /// For example, T t = T(123); includes a temporary T(123) that is immediately
522 /// copied to variable t. In such cases the elidable copy can (but not
523 /// necessarily should) be omitted ("elided") accodring to the rules of the
524 /// language; the constructor would then construct variable t directly.
525 /// This construction context contains information of the elidable constructor
526 /// and its respective construction context.
529  const CXXConstructExpr *ElidedCE;
530  const ConstructionContext *ElidedCC;
531 
532  friend class ConstructionContext; // Allows to create<>() itself.
533 
535  const CXXBindTemporaryExpr *BTE, const MaterializeTemporaryExpr *MTE,
536  const CXXConstructExpr *ElidedCE, const ConstructionContext *ElidedCC)
539  ElidedCE(ElidedCE), ElidedCC(ElidedCC) {
540  // Elided constructor and its context should be either both specified
541  // or both unspecified. In the former case, the constructor must be
542  // elidable.
543  assert(ElidedCE && ElidedCE->isElidable() && ElidedCC);
544  }
545 
546 public:
548  return ElidedCE;
549  }
550 
552  return ElidedCC;
553  }
554 
555  static bool classof(const ConstructionContext *CC) {
556  return CC->getKind() == ElidedTemporaryObjectKind;
557  }
558 };
559 
561  const ReturnStmt *RS;
562 
563 protected:
565  const ReturnStmt *RS)
566  : ConstructionContext(K), RS(RS) {
567  assert(classof(this));
568  assert(RS);
569  }
570 
571 public:
572  const ReturnStmt *getReturnStmt() const { return RS; }
573 
574  static bool classof(const ConstructionContext *CC) {
575  return CC->getKind() >= RETURNED_VALUE_BEGIN &&
576  CC->getKind() <= RETURNED_VALUE_END;
577  }
578 };
579 
580 /// Represents a temporary object that is being immediately returned from a
581 /// function by value, eg. return t; or return T(123);. In this case there is
582 /// always going to be a constructor at the return site. However, the usual
583 /// temporary-related bureaucracy (CXXBindTemporaryExpr,
584 /// MaterializeTemporaryExpr) is normally located in the caller function's AST.
587  friend class ConstructionContext; // Allows to create<>() itself.
588 
592 
593 public:
594  static bool classof(const ConstructionContext *CC) {
595  return CC->getKind() == SimpleReturnedValueKind;
596  }
597 };
598 
599 /// Represents a temporary object that is being immediately returned from a
600 /// function by value, eg. return t; or return T(123); in C++17.
601 /// In C++17 there is not going to be an elidable copy constructor at the
602 /// return site. However, the usual temporary-related bureaucracy (CXXBindTemporaryExpr,
603 /// MaterializeTemporaryExpr) is normally located in the caller function's AST.
604 /// Note that if the object has trivial destructor, then this code is
605 /// indistinguishable from a simple returned value constructor on the AST level;
606 /// in this case we provide a simple returned value construction context.
609  const CXXBindTemporaryExpr *BTE;
610 
611  friend class ConstructionContext; // Allows to create<>() itself.
612 
614  const ReturnStmt *RS, const CXXBindTemporaryExpr *BTE)
617  BTE(BTE) {
618  assert(BTE);
619  }
620 
621 public:
622  const CXXBindTemporaryExpr *getCXXBindTemporaryExpr() const { return BTE; }
623 
624  static bool classof(const ConstructionContext *CC) {
626  }
627 };
628 
630  // The call of which the context is an argument.
631  const Expr *CE;
632 
633  // Which argument we're constructing. Note that when numbering between
634  // arguments and parameters is inconsistent (eg., operator calls),
635  // this is the index of the argument, not of the parameter.
636  unsigned Index;
637 
638  // Whether the object needs to be destroyed.
639  const CXXBindTemporaryExpr *BTE;
640 
641  friend class ConstructionContext; // Allows to create<>() itself.
642 
643  explicit ArgumentConstructionContext(const Expr *CE, unsigned Index,
644  const CXXBindTemporaryExpr *BTE)
646  Index(Index), BTE(BTE) {
647  assert(isa<CallExpr>(CE) || isa<CXXConstructExpr>(CE) ||
648  isa<ObjCMessageExpr>(CE));
649  // BTE is optional.
650  }
651 
652 public:
653  const Expr *getCallLikeExpr() const { return CE; }
654  unsigned getIndex() const { return Index; }
655  const CXXBindTemporaryExpr *getCXXBindTemporaryExpr() const { return BTE; }
656 
657  static bool classof(const ConstructionContext *CC) {
658  return CC->getKind() == ArgumentKind;
659  }
660 };
661 
662 } // end namespace clang
663 
664 #endif // LLVM_CLANG_ANALYSIS_CONSTRUCTIONCONTEXT_H
clang::ConstructionContext::TEMPORARY_BEGIN
@ TEMPORARY_BEGIN
Definition: ConstructionContext.h:251
clang::ConstructorInitializerConstructionContext::getCXXCtorInitializer
const CXXCtorInitializer * getCXXCtorInitializer() const
Definition: ConstructionContext.h:382
clang::TemporaryObjectConstructionContext::TemporaryObjectConstructionContext
TemporaryObjectConstructionContext(ConstructionContext::Kind K, const CXXBindTemporaryExpr *BTE, const MaterializeTemporaryExpr *MTE)
Definition: ConstructionContext.h:469
clang::ConstructionContext::INITIALIZER_BEGIN
@ INITIALIZER_BEGIN
Definition: ConstructionContext.h:246
clang::ConstructionContext::NewAllocatedObjectKind
@ NewAllocatedObjectKind
Definition: ConstructionContext.h:248
clang::ElidedTemporaryObjectConstructionContext::getConstructionContextAfterElision
const ConstructionContext * getConstructionContextAfterElision() const
Definition: ConstructionContext.h:551
clang::SimpleTemporaryObjectConstructionContext::classof
static bool classof(const ConstructionContext *CC)
Definition: ConstructionContext.h:514
clang::ConstructionContextItem::getKind
ItemKind getKind() const
Definition: ConstructionContext.h:130
clang::ConstructionContextLayer::isLast
bool isLast() const
Definition: ConstructionContext.h:222
clang::ConstructionContextItem::ConstructionContextItem
ConstructionContextItem(const DeclStmt *DS)
Definition: ConstructionContext.h:87
clang::ConstructionContextItem::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: ConstructionContext.h:168
clang::SimpleVariableConstructionContext::classof
static bool classof(const ConstructionContext *CC)
Definition: ConstructionContext.h:335
clang::ConstructionContextItem::ConstructionContextItem
ConstructionContextItem(const CXXInheritedCtorInitExpr *CE, unsigned Index)
Definition: ConstructionContext.h:113
clang::TemporaryObjectConstructionContext::classof
static bool classof(const ConstructionContext *CC)
Definition: ConstructionContext.h:495
clang::ConstructionContextItem::STATEMENT_KIND_END
@ STATEMENT_KIND_END
Definition: ConstructionContext.h:42
clang::ReturnedValueConstructionContext::ReturnedValueConstructionContext
ReturnedValueConstructionContext(ConstructionContext::Kind K, const ReturnStmt *RS)
Definition: ConstructionContext.h:564
clang::ArgumentConstructionContext::getCXXBindTemporaryExpr
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
Definition: ConstructionContext.h:655
clang::ConstructionContextItem::TemporaryDestructorKind
@ TemporaryDestructorKind
Definition: ConstructionContext.h:35
clang::ConstructionContextItem::getCXXCtorInitializer
const CXXCtorInitializer * getCXXCtorInitializer() const
The construction site is not necessarily a statement.
Definition: ConstructionContext.h:152
clang::ConstructionContextItem::ConstructionContextItem
ConstructionContextItem(const CXXConstructExpr *CE)
Definition: ConstructionContext.h:104
clang::ConstructionContext::CXX17ElidedCopyConstructorInitializerKind
@ CXX17ElidedCopyConstructorInitializerKind
Definition: ConstructionContext.h:245
clang::ConstructionContext
ConstructionContext's subclasses describe different ways of constructing an object in C++.
Definition: ConstructionContext.h:237
clang::ConstructionContextItem::getStmtOrNull
const Stmt * getStmtOrNull() const
Definition: ConstructionContext.h:145
clang::CXXNewExpr
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition: ExprCXX.h:2139
clang::ConstructionContext::SimpleReturnedValueKind
@ SimpleReturnedValueKind
Definition: ConstructionContext.h:253
clang::ConstructorInitializerConstructionContext::ConstructorInitializerConstructionContext
ConstructorInitializerConstructionContext(ConstructionContext::Kind K, const CXXCtorInitializer *I)
Definition: ConstructionContext.h:374
clang::ConstructionContext::CXX17ElidedCopyVariableKind
@ CXX17ElidedCopyVariableKind
Definition: ConstructionContext.h:241
clang::ConstructionContext::INITIALIZER_END
@ INITIALIZER_END
Definition: ConstructionContext.h:247
clang::VariableConstructionContext::classof
static bool classof(const ConstructionContext *CC)
Definition: ConstructionContext.h:317
clang::ConstructionContextItem::ConstructionContextItem
ConstructionContextItem(const CXXConstructExpr *CE, unsigned Index)
Definition: ConstructionContext.h:110
clang::ConstructionContextItem::ConstructionContextItem
ConstructionContextItem(const CXXNewExpr *NE)
Definition: ConstructionContext.h:90
clang::VariableConstructionContext::getDeclStmt
const DeclStmt * getDeclStmt() const
Definition: ConstructionContext.h:315
clang::SimpleConstructorInitializerConstructionContext
Represents construction into a field or a base class within a bigger object via a constructor initial...
Definition: ConstructionContext.h:392
clang::ConstructionContextLayer::getItem
const ConstructionContextItem & getItem() const
Definition: ConstructionContext.h:220
clang::ConstructionContextItem::INITIALIZER_KIND_BEGIN
@ INITIALIZER_KIND_BEGIN
Definition: ConstructionContext.h:44
clang::ArgumentConstructionContext
Definition: ConstructionContext.h:629
clang::ConstructionContextItem::ItemKind
ItemKind
Definition: ConstructionContext.h:30
clang::ConstructionContextItem::getKindAsString
LLVM_DUMP_METHOD StringRef getKindAsString() const
Definition: ConstructionContext.h:132
clang::ConstructionContextItem
Represents a single point (AST node) in the program that requires attention during construction of an...
Definition: ConstructionContext.h:28
clang::ConstructionContextLayer::create
static const ConstructionContextLayer * create(BumpVectorContext &C, const ConstructionContextItem &Item, const ConstructionContextLayer *Parent=nullptr)
Definition: ConstructionContext.cpp:22
clang::CXX17ElidedCopyConstructorInitializerConstructionContext
Represents construction into a field or a base class within a bigger object via a constructor initial...
Definition: ConstructionContext.h:417
clang::CXX17ElidedCopyReturnedValueConstructionContext
Represents a temporary object that is being immediately returned from a function by value,...
Definition: ConstructionContext.h:607
clang::ConstructionContext::TEMPORARY_END
@ TEMPORARY_END
Definition: ConstructionContext.h:252
clang::ConstructionContext::Kind
Kind
Definition: ConstructionContext.h:239
clang::ConstructionContextItem::INITIALIZER_KIND_END
@ INITIALIZER_KIND_END
Definition: ConstructionContext.h:45
clang::SimpleConstructorInitializerConstructionContext::classof
static bool classof(const ConstructionContext *CC)
Definition: ConstructionContext.h:402
clang::TemporaryObjectConstructionContext::getMaterializedTemporaryExpr
const MaterializeTemporaryExpr * getMaterializedTemporaryExpr() const
MaterializeTemporaryExpr is non-null as long as the temporary is actually used after construction,...
Definition: ConstructionContext.h:491
clang::ConstructionContextItem::getIndex
unsigned getIndex() const
If a single trigger statement triggers multiple constructors, they are usually being enumerated.
Definition: ConstructionContext.h:161
clang::TemporaryObjectConstructionContext::getCXXBindTemporaryExpr
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
CXXBindTemporaryExpr here is non-null as long as the temporary has a non-trivial destructor.
Definition: ConstructionContext.h:482
clang::ArgumentConstructionContext::getIndex
unsigned getIndex() const
Definition: ConstructionContext.h:654
clang::ConstructionContextItem::STATEMENT_KIND_BEGIN
@ STATEMENT_KIND_BEGIN
Definition: ConstructionContext.h:41
clang::ConstructionContext::VARIABLE_BEGIN
@ VARIABLE_BEGIN
Definition: ConstructionContext.h:242
clang::ConstructionContextItem::ElidedDestructorKind
@ ElidedDestructorKind
Definition: ConstructionContext.h:36
clang::ConstructionContextItem::operator==
bool operator==(const ConstructionContextItem &Other) const
Definition: ConstructionContext.h:174
clang::NewAllocatedObjectConstructionContext::getCXXNewExpr
const CXXNewExpr * getCXXNewExpr() const
Definition: ConstructionContext.h:453
clang::ReturnedValueConstructionContext::classof
static bool classof(const ConstructionContext *CC)
Definition: ConstructionContext.h:574
clang::ConstructorInitializerConstructionContext
Definition: ConstructionContext.h:370
clang::ConstructionContextItem::NewAllocatorKind
@ NewAllocatorKind
Definition: ConstructionContext.h:32
clang::ConstructionContextItem::ReturnKind
@ ReturnKind
Definition: ConstructionContext.h:33
clang::CXXBindTemporaryExpr
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1412
clang::NewAllocatedObjectConstructionContext::classof
static bool classof(const ConstructionContext *CC)
Definition: ConstructionContext.h:455
clang::MaterializeTemporaryExpr
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4479
clang::ConstructionContextItem::getKindAsString
static LLVM_DUMP_METHOD StringRef getKindAsString(ItemKind K)
Definition: ConstructionContext.h:48
clang::CXX17ElidedCopyReturnedValueConstructionContext::classof
static bool classof(const ConstructionContext *CC)
Definition: ConstructionContext.h:624
clang::ElidedTemporaryObjectConstructionContext
Represents a temporary object that is constructed for the sole purpose of being immediately copied by...
Definition: ConstructionContext.h:527
clang::CXX17ElidedCopyConstructorInitializerConstructionContext::getCXXBindTemporaryExpr
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
Definition: ConstructionContext.h:432
clang::ConstructionContext::SimpleConstructorInitializerKind
@ SimpleConstructorInitializerKind
Definition: ConstructionContext.h:244
clang::ReturnedValueConstructionContext
Definition: ConstructionContext.h:560
clang::ConstructionContextItem::InitializerKind
@ InitializerKind
Definition: ConstructionContext.h:43
clang::CXX17ElidedCopyVariableConstructionContext::classof
static bool classof(const ConstructionContext *CC)
Definition: ConstructionContext.h:364
clang::ConstructorInitializerConstructionContext::classof
static bool classof(const ConstructionContext *CC)
Definition: ConstructionContext.h:384
BumpVector.h
ExprObjC.h
ExprCXX.h
clang::ConstructionContextItem::ConstructionContextItem
ConstructionContextItem(const CXXCtorInitializer *Init)
Definition: ConstructionContext.h:127
clang::CXXInheritedCtorInitExpr
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1651
clang::ReturnedValueConstructionContext::getReturnStmt
const ReturnStmt * getReturnStmt() const
Definition: ConstructionContext.h:572
clang::SimpleReturnedValueConstructionContext::classof
static bool classof(const ConstructionContext *CC)
Definition: ConstructionContext.h:594
clang::VariableConstructionContext
An abstract base class for local variable constructors.
Definition: ConstructionContext.h:304
clang::ObjCMessageExpr
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:940
clang::ConstructionContext::ConstructionContext
ConstructionContext(Kind K)
Definition: ConstructionContext.h:265
clang::ConstructionContextItem::getStmt
const Stmt * getStmt() const
The construction site - the statement that triggered the construction for one of its parts.
Definition: ConstructionContext.h:140
clang::ElidedTemporaryObjectConstructionContext::classof
static bool classof(const ConstructionContext *CC)
Definition: ConstructionContext.h:555
clang::ConstructionContext::SimpleVariableKind
@ SimpleVariableKind
Definition: ConstructionContext.h:240
clang::ArgumentConstructionContext::getCallLikeExpr
const Expr * getCallLikeExpr() const
Definition: ConstructionContext.h:653
clang::ConstructionContextItem::STATEMENT_WITH_INDEX_KIND_BEGIN
@ STATEMENT_WITH_INDEX_KIND_BEGIN
Definition: ConstructionContext.h:39
clang::SimpleTemporaryObjectConstructionContext
Represents a temporary object that is not constructed for the purpose of being immediately copied/mov...
Definition: ConstructionContext.h:504
clang::NewAllocatedObjectConstructionContext
Represents immediate initialization of memory allocated by operator new, eg.
Definition: ConstructionContext.h:441
clang::ConstructionContextItem::VariableKind
@ VariableKind
Definition: ConstructionContext.h:31
clang::ConstructionContextLayer
Construction context can be seen as a linked list of multiple layers.
Definition: ConstructionContext.h:207
clang::ConstructionContextItem::ArgumentKind
@ ArgumentKind
Definition: ConstructionContext.h:38
clang::ConstructionContextItem::ElidableConstructorKind
@ ElidableConstructorKind
Definition: ConstructionContext.h:37
clang::ConstructionContextLayer::isStrictlyMoreSpecificThan
bool isStrictlyMoreSpecificThan(const ConstructionContextLayer *Other) const
See if Other is a proper initial segment of this construction context in terms of the parent chain - ...
Definition: ConstructionContext.cpp:30
clang::ConstructionContextItem::MaterializationKind
@ MaterializationKind
Definition: ConstructionContext.h:34
clang::SimpleVariableConstructionContext
Represents construction into a simple local variable, eg.
Definition: ConstructionContext.h:327
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::DeclStmt
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition: Stmt.h:1294
clang::ConstructionContext::K
Kind K
Definition: ConstructionContext.h:261
clang::interp::NE
bool NE(InterpState &S, CodePtr OpPC)
Definition: Interp.h:225
clang::Builtin::ID
ID
Definition: Builtins.h:52
clang::ConstructionContextItem::ConstructionContextItem
ConstructionContextItem(const Expr *E, unsigned Index)
Definition: ConstructionContext.h:120
clang::ConstructionContext::RETURNED_VALUE_BEGIN
@ RETURNED_VALUE_BEGIN
Definition: ConstructionContext.h:255
clang
Definition: CalledOnceCheck.h:17
clang::ConstructionContext::SimpleTemporaryObjectKind
@ SimpleTemporaryObjectKind
Definition: ConstructionContext.h:249
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:69
clang::SimpleReturnedValueConstructionContext
Represents a temporary object that is being immediately returned from a function by value,...
Definition: ConstructionContext.h:585
clang::ConstructionContextItem::ConstructionContextItem
ConstructionContextItem(const ObjCMessageExpr *ME, unsigned Index)
Definition: ConstructionContext.h:116
clang::ConstructionContextItem::ConstructionContextItem
ConstructionContextItem(const CallExpr *CE, unsigned Index)
Definition: ConstructionContext.h:107
clang::ArgumentConstructionContext::classof
static bool classof(const ConstructionContext *CC)
Definition: ConstructionContext.h:657
clang::ConstructionContext::getKind
Kind getKind() const
Definition: ConstructionContext.h:300
clang::ConstructionContextItem::ConstructionContextItem
ConstructionContextItem(const ReturnStmt *RS)
Definition: ConstructionContext.h:93
clang::ConstructionContextItem::STATEMENT_WITH_INDEX_KIND_END
@ STATEMENT_WITH_INDEX_KIND_END
Definition: ConstructionContext.h:40
clang::ConstructionContextItem::ConstructionContextItem
ConstructionContextItem(const CXXBindTemporaryExpr *BTE, bool IsElided=false)
Definition: ConstructionContext.h:99
clang::ConstructionContext::ElidedTemporaryObjectKind
@ ElidedTemporaryObjectKind
Definition: ConstructionContext.h:250
clang::ConstructionContext::RETURNED_VALUE_END
@ RETURNED_VALUE_END
Definition: ConstructionContext.h:256
Parent
NodeId Parent
Definition: ASTDiff.cpp:192
clang::TemporaryObjectConstructionContext
Represents a temporary object, eg.
Definition: ConstructionContext.h:464
clang::CXX17ElidedCopyVariableConstructionContext::getCXXBindTemporaryExpr
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
Definition: ConstructionContext.h:362
clang::CXX17ElidedCopyReturnedValueConstructionContext::getCXXBindTemporaryExpr
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
Definition: ConstructionContext.h:622
clang::BumpVectorContext
Definition: BumpVector.h:32
clang::ConstructionContext::CXX17ElidedCopyReturnedValueKind
@ CXX17ElidedCopyReturnedValueKind
Definition: ConstructionContext.h:254
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::VariableConstructionContext::VariableConstructionContext
VariableConstructionContext(ConstructionContext::Kind K, const DeclStmt *DS)
Definition: ConstructionContext.h:308
clang::ConstructionContextLayer::getParent
const ConstructionContextLayer * getParent() const
Definition: ConstructionContext.h:221
clang::ConstructionContext::ArgumentKind
@ ArgumentKind
Definition: ConstructionContext.h:257
clang::ElidedTemporaryObjectConstructionContext::getConstructorAfterElision
const CXXConstructExpr * getConstructorAfterElision() const
Definition: ConstructionContext.h:547
clang::CXXCtorInitializer
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2205
clang::ConstructionContext::createFromLayers
static const ConstructionContext * createFromLayers(BumpVectorContext &C, const ConstructionContextLayer *TopLayer)
Consume the construction context layer, together with its parent layers, and wrap it up into a comple...
Definition: ConstructionContext.cpp:164
clang::CallExpr
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2801
clang::ConstructionContextItem::ConstructionContextItem
ConstructionContextItem(const MaterializeTemporaryExpr *MTE)
Definition: ConstructionContext.h:96
clang::CXXConstructExpr
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1460
clang::CXX17ElidedCopyConstructorInitializerConstructionContext::classof
static bool classof(const ConstructionContext *CC)
Definition: ConstructionContext.h:434
clang::ConstructionContextItem::operator<
bool operator<(const ConstructionContextItem &Other) const
Definition: ConstructionContext.h:182
clang::CXXConstructExpr::isElidable
bool isElidable() const
Whether this construction is elidable.
Definition: ExprCXX.h:1538
clang::ConstructionContext::VARIABLE_END
@ VARIABLE_END
Definition: ConstructionContext.h:243
clang::CXX17ElidedCopyVariableConstructionContext
Represents construction into a simple variable with an initializer syntax, with a single constructor,...
Definition: ConstructionContext.h:349
clang::ReturnStmt
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition: Stmt.h:2764