clang 20.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
23namespace 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.
29public:
30 enum ItemKind {
47 };
48
49 LLVM_DUMP_METHOD static StringRef getKindAsString(ItemKind K) {
50 switch (K) {
51 case VariableKind: return "construct into local variable";
52 case NewAllocatorKind: return "construct into new-allocator";
53 case ReturnKind: return "construct into return address";
54 case MaterializationKind: return "materialize temporary";
55 case TemporaryDestructorKind: return "destroy temporary";
56 case ElidedDestructorKind: return "elide destructor";
57 case ElidableConstructorKind: return "elide constructor";
58 case ArgumentKind: return "construct into argument";
60 return "construct into lambda captured variable";
61 case InitializerKind: return "construct into member variable";
62 };
63 llvm_unreachable("Unknown ItemKind");
64 }
65
66private:
67 const void *const Data;
68 const ItemKind Kind;
69 const unsigned Index = 0;
70
71 bool hasStatement() const {
72 return Kind >= STATEMENT_KIND_BEGIN &&
73 Kind <= STATEMENT_KIND_END;
74 }
75
76 bool hasIndex() const {
77 return Kind >= STATEMENT_WITH_INDEX_KIND_BEGIN &&
79 }
80
81 bool hasInitializer() const {
82 return Kind >= INITIALIZER_KIND_BEGIN &&
84 }
85
86public:
87 // ConstructionContextItem should be simple enough so that it was easy to
88 // re-construct it from the AST node it captures. For that reason we provide
89 // simple implicit conversions from all sorts of supported AST nodes.
91 : Data(DS), Kind(VariableKind) {}
92
94 : Data(NE), Kind(NewAllocatorKind) {}
95
97 : Data(RS), Kind(ReturnKind) {}
98
100 : Data(MTE), Kind(MaterializationKind) {}
101
103 bool IsElided = false)
104 : Data(BTE),
106
108 : Data(CE), Kind(ElidableConstructorKind) {}
109
110 ConstructionContextItem(const CallExpr *CE, unsigned Index)
111 : Data(CE), Kind(ArgumentKind), Index(Index) {}
112
113 ConstructionContextItem(const CXXConstructExpr *CE, unsigned Index)
114 : Data(CE), Kind(ArgumentKind), Index(Index) {}
115
117 : Data(CE), Kind(ArgumentKind), Index(Index) {}
118
119 ConstructionContextItem(const ObjCMessageExpr *ME, unsigned Index)
120 : Data(ME), Kind(ArgumentKind), Index(Index) {}
121
122 // A polymorphic version of the previous calls with dynamic type check.
123 ConstructionContextItem(const Expr *E, unsigned Index)
124 : Data(E), Kind(ArgumentKind), Index(Index) {
125 assert(isa<CallExpr>(E) || isa<CXXConstructExpr>(E) ||
126 isa<CXXDeleteExpr>(E) || isa<CXXInheritedCtorInitExpr>(E) ||
127 isa<ObjCMessageExpr>(E));
128 }
129
131 : Data(Init), Kind(InitializerKind), Index(0) {}
132
133 ConstructionContextItem(const LambdaExpr *LE, unsigned Index)
134 : Data(LE), Kind(LambdaCaptureKind), Index(Index) {}
135
136 ItemKind getKind() const { return Kind; }
137
138 LLVM_DUMP_METHOD StringRef getKindAsString() const {
139 return getKindAsString(getKind());
140 }
141
142 /// The construction site - the statement that triggered the construction
143 /// for one of its parts. For instance, stack variable declaration statement
144 /// triggers construction of itself or its elements if it's an array,
145 /// new-expression triggers construction of the newly allocated object(s).
146 const Stmt *getStmt() const {
147 assert(hasStatement());
148 return static_cast<const Stmt *>(Data);
149 }
150
151 const Stmt *getStmtOrNull() const {
152 return hasStatement() ? getStmt() : nullptr;
153 }
154
155 /// The construction site is not necessarily a statement. It may also be a
156 /// CXXCtorInitializer, which means that a member variable is being
157 /// constructed during initialization of the object that contains it.
159 assert(hasInitializer());
160 return static_cast<const CXXCtorInitializer *>(Data);
161 }
162
163 /// If a single trigger statement triggers multiple constructors, they are
164 /// usually being enumerated. This covers function argument constructors
165 /// triggered by a call-expression and items in an initializer list triggered
166 /// by an init-list-expression.
167 unsigned getIndex() const {
168 // This is a fairly specific request. Let's make sure the user knows
169 // what he's doing.
170 assert(hasIndex());
171 return Index;
172 }
173
174 void Profile(llvm::FoldingSetNodeID &ID) const {
175 ID.AddPointer(Data);
176 ID.AddInteger(Kind);
177 ID.AddInteger(Index);
178 }
179
181 // For most kinds the Index comparison is trivially true, but
182 // checking kind separately doesn't seem to be less expensive
183 // than checking Index. Same in operator<().
184 return std::make_tuple(Data, Kind, Index) ==
185 std::make_tuple(Other.Data, Other.Kind, Other.Index);
186 }
187
189 return std::make_tuple(Data, Kind, Index) <
190 std::make_tuple(Other.Data, Other.Kind, Other.Index);
191 }
192};
193
194/// Construction context can be seen as a linked list of multiple layers.
195/// Sometimes a single trigger is not enough to describe the construction
196/// site. That's what causing us to have a chain of "partial" construction
197/// context layers. Some examples:
198/// - A constructor within in an aggregate initializer list within a variable
199/// would have a construction context of the initializer list with
200/// the parent construction context of a variable.
201/// - A constructor for a temporary that needs to be both destroyed
202/// and materialized into an elidable copy constructor would have a
203/// construction context of a CXXBindTemporaryExpr with the parent
204/// construction context of a MaterializeTemproraryExpr.
205/// Not all of these are currently supported.
206/// Layers are created gradually while traversing the AST, and layers that
207/// represent the outmost AST nodes are built first, while the node that
208/// immediately contains the constructor would be built last and capture the
209/// previous layers as its parents. Construction context captures the last layer
210/// (which has links to the previous layers) and classifies the seemingly
211/// arbitrary chain of layers into one of the possible ways of constructing
212/// an object in C++ for user-friendly experience.
214 const ConstructionContextLayer *Parent = nullptr;
216
219 : Parent(Parent), Item(Item) {}
220
221public:
222 static const ConstructionContextLayer *
224 const ConstructionContextLayer *Parent = nullptr);
225
226 const ConstructionContextItem &getItem() const { return Item; }
227 const ConstructionContextLayer *getParent() const { return Parent; }
228 bool isLast() const { return !Parent; }
229
230 /// See if Other is a proper initial segment of this construction context
231 /// in terms of the parent chain - i.e. a few first parents coincide and
232 /// then the other context terminates but our context goes further - i.e.,
233 /// we are providing the same context that the other context provides,
234 /// and a bit more above that.
236};
237
238
239/// ConstructionContext's subclasses describe different ways of constructing
240/// an object in C++. The context re-captures the essential parent AST nodes
241/// of the CXXConstructExpr it is assigned to and presents these nodes
242/// through easy-to-understand accessor methods.
244public:
245 enum Kind {
265 };
266
267protected:
269
270 // Do not make public! These need to only be constructed
271 // via createFromLayers().
272 explicit ConstructionContext(Kind K) : K(K) {}
273
274private:
275 // A helper function for constructing an instance into a bump vector context.
276 template <typename T, typename... ArgTypes>
277 static T *create(BumpVectorContext &C, ArgTypes... Args) {
278 auto *CC = C.getAllocator().Allocate<T>();
279 return new (CC) T(Args...);
280 }
281
282 // A sub-routine of createFromLayers() that deals with temporary objects
283 // that need to be materialized. The BTE argument is for the situation when
284 // the object also needs to be bound for destruction.
285 static const ConstructionContext *createMaterializedTemporaryFromLayers(
286 BumpVectorContext &C, const MaterializeTemporaryExpr *MTE,
287 const CXXBindTemporaryExpr *BTE,
288 const ConstructionContextLayer *ParentLayer);
289
290 // A sub-routine of createFromLayers() that deals with temporary objects
291 // that need to be bound for destruction. Automatically finds out if the
292 // object also needs to be materialized and delegates to
293 // createMaterializedTemporaryFromLayers() if necessary.
294 static const ConstructionContext *
295 createBoundTemporaryFromLayers(
296 BumpVectorContext &C, const CXXBindTemporaryExpr *BTE,
297 const ConstructionContextLayer *ParentLayer);
298
299public:
300 /// Consume the construction context layer, together with its parent layers,
301 /// and wrap it up into a complete construction context. May return null
302 /// if layers do not form any supported construction context.
303 static const ConstructionContext *
304 createFromLayers(BumpVectorContext &C,
305 const ConstructionContextLayer *TopLayer);
306
307 Kind getKind() const { return K; }
308
309 virtual const ArrayInitLoopExpr *getArrayInitLoop() const { return nullptr; }
310
311 // Only declared to silence -Wnon-virtual-dtor warnings.
312 virtual ~ConstructionContext() = default;
313};
314
315/// An abstract base class for local variable constructors.
317 const DeclStmt *DS;
318
319protected:
321 : ConstructionContext(K), DS(DS) {
322 assert(classof(this));
323 assert(DS);
324 }
325
326public:
327 const DeclStmt *getDeclStmt() const { return DS; }
328
329 const ArrayInitLoopExpr *getArrayInitLoop() const override {
330 const auto *Var = cast<VarDecl>(DS->getSingleDecl());
331
332 return dyn_cast<ArrayInitLoopExpr>(Var->getInit());
333 }
334
335 static bool classof(const ConstructionContext *CC) {
336 return CC->getKind() >= VARIABLE_BEGIN &&
337 CC->getKind() <= VARIABLE_END;
338 }
339};
340
341/// Represents construction into a simple local variable, eg. T var(123);.
342/// If a variable has an initializer, eg. T var = makeT();, then the final
343/// elidable copy-constructor from makeT() into var would also be a simple
344/// variable constructor handled by this class.
346 friend class ConstructionContext; // Allows to create<>() itself.
347
350 DS) {}
351
352public:
353 static bool classof(const ConstructionContext *CC) {
354 return CC->getKind() == SimpleVariableKind;
355 }
356};
357
358/// Represents construction into a simple variable with an initializer syntax,
359/// with a single constructor, eg. T var = makeT();. Such construction context
360/// may only appear in C++17 because previously it was split into a temporary
361/// object constructor and an elidable simple variable copy-constructor and
362/// we were producing separate construction contexts for these constructors.
363/// In C++17 we have a single construction context that combines both.
364/// Note that if the object has trivial destructor, then this code is
365/// indistinguishable from a simple variable constructor on the AST level;
366/// in this case we provide a simple variable construction context.
369 const CXXBindTemporaryExpr *BTE;
370
371 friend class ConstructionContext; // Allows to create<>() itself.
372
374 const DeclStmt *DS, const CXXBindTemporaryExpr *BTE)
376 assert(BTE);
377 }
378
379public:
380 const CXXBindTemporaryExpr *getCXXBindTemporaryExpr() const { return BTE; }
381
382 static bool classof(const ConstructionContext *CC) {
383 return CC->getKind() == CXX17ElidedCopyVariableKind;
384 }
385};
386
387// An abstract base class for constructor-initializer-based constructors.
389 const CXXCtorInitializer *I;
390
391protected:
394 : ConstructionContext(K), I(I) {
395 assert(classof(this));
396 assert(I);
397 }
398
399public:
400 const CXXCtorInitializer *getCXXCtorInitializer() const { return I; }
401
402 const ArrayInitLoopExpr *getArrayInitLoop() const override {
403 return dyn_cast<ArrayInitLoopExpr>(I->getInit());
404 }
405
406 static bool classof(const ConstructionContext *CC) {
407 return CC->getKind() >= INITIALIZER_BEGIN &&
408 CC->getKind() <= INITIALIZER_END;
409 }
410};
411
412/// Represents construction into a field or a base class within a bigger object
413/// via a constructor initializer, eg. T(): field(123) { ... }.
416 friend class ConstructionContext; // Allows to create<>() itself.
417
419 const CXXCtorInitializer *I)
422
423public:
424 static bool classof(const ConstructionContext *CC) {
426 }
427};
428
429/// Represents construction into a field or a base class within a bigger object
430/// via a constructor initializer, with a single constructor, eg.
431/// T(): field(Field(123)) { ... }. Such construction context may only appear
432/// in C++17 because previously it was split into a temporary object constructor
433/// and an elidable simple constructor-initializer copy-constructor and we were
434/// producing separate construction contexts for these constructors. In C++17
435/// we have a single construction context that combines both. Note that if the
436/// object has trivial destructor, then this code is indistinguishable from
437/// a simple constructor-initializer constructor on the AST level; in this case
438/// we provide a simple constructor-initializer construction context.
441 const CXXBindTemporaryExpr *BTE;
442
443 friend class ConstructionContext; // Allows to create<>() itself.
444
446 const CXXCtorInitializer *I, const CXXBindTemporaryExpr *BTE)
449 BTE(BTE) {
450 assert(BTE);
451 }
452
453public:
454 const CXXBindTemporaryExpr *getCXXBindTemporaryExpr() const { return BTE; }
455
456 static bool classof(const ConstructionContext *CC) {
458 }
459};
460
461/// Represents immediate initialization of memory allocated by operator new,
462/// eg. new T(123);.
464 const CXXNewExpr *NE;
465
466 friend class ConstructionContext; // Allows to create<>() itself.
467
470 NE(NE) {
471 assert(NE);
472 }
473
474public:
475 const CXXNewExpr *getCXXNewExpr() const { return NE; }
476
477 static bool classof(const ConstructionContext *CC) {
478 return CC->getKind() == NewAllocatedObjectKind;
479 }
480};
481
482/// Represents a temporary object, eg. T(123), that does not immediately cross
483/// function boundaries "by value"; constructors that construct function
484/// value-type arguments or values that are immediately returned from the
485/// function that returns a value receive separate construction context kinds.
487 const CXXBindTemporaryExpr *BTE;
488 const MaterializeTemporaryExpr *MTE;
489
490protected:
493 const MaterializeTemporaryExpr *MTE)
494 : ConstructionContext(K), BTE(BTE), MTE(MTE) {
495 // Both BTE and MTE can be null here, all combinations possible.
496 // Even though for now at least one should be non-null, we simply haven't
497 // implemented the other case yet (this would be a temporary in the middle
498 // of nowhere that doesn't have a non-trivial destructor).
499 }
500
501public:
502 /// CXXBindTemporaryExpr here is non-null as long as the temporary has
503 /// a non-trivial destructor.
505 return BTE;
506 }
507
508 /// MaterializeTemporaryExpr is non-null as long as the temporary is actually
509 /// used after construction, eg. by binding to a reference (lifetime
510 /// extension), accessing a field, calling a method, or passing it into
511 /// a function (an elidable copy or move constructor would be a common
512 /// example) by reference.
514 return MTE;
515 }
516
517 static bool classof(const ConstructionContext *CC) {
518 return CC->getKind() >= TEMPORARY_BEGIN && CC->getKind() <= TEMPORARY_END;
519 }
520};
521
522/// Represents a temporary object that is not constructed for the purpose of
523/// being immediately copied/moved by an elidable copy/move-constructor.
524/// This includes temporary objects "in the middle of nowhere" like T(123) and
525/// lifetime-extended temporaries.
528 friend class ConstructionContext; // Allows to create<>() itself.
529
531 const CXXBindTemporaryExpr *BTE, const MaterializeTemporaryExpr *MTE)
534
535public:
536 static bool classof(const ConstructionContext *CC) {
537 return CC->getKind() == SimpleTemporaryObjectKind;
538 }
539};
540
541/// Represents a temporary object that is constructed for the sole purpose
542/// of being immediately copied by an elidable copy/move constructor.
543/// For example, T t = T(123); includes a temporary T(123) that is immediately
544/// copied to variable t. In such cases the elidable copy can (but not
545/// necessarily should) be omitted ("elided") according to the rules of the
546/// language; the constructor would then construct variable t directly.
547/// This construction context contains information of the elidable constructor
548/// and its respective construction context.
551 const CXXConstructExpr *ElidedCE;
552 const ConstructionContext *ElidedCC;
553
554 friend class ConstructionContext; // Allows to create<>() itself.
555
557 const CXXBindTemporaryExpr *BTE, const MaterializeTemporaryExpr *MTE,
558 const CXXConstructExpr *ElidedCE, const ConstructionContext *ElidedCC)
561 ElidedCE(ElidedCE), ElidedCC(ElidedCC) {
562 // Elided constructor and its context should be either both specified
563 // or both unspecified. In the former case, the constructor must be
564 // elidable.
565 assert(ElidedCE && ElidedCE->isElidable() && ElidedCC);
566 }
567
568public:
570 return ElidedCE;
571 }
572
574 return ElidedCC;
575 }
576
577 static bool classof(const ConstructionContext *CC) {
578 return CC->getKind() == ElidedTemporaryObjectKind;
579 }
580};
581
583 const ReturnStmt *RS;
584
585protected:
587 const ReturnStmt *RS)
588 : ConstructionContext(K), RS(RS) {
589 assert(classof(this));
590 assert(RS);
591 }
592
593public:
594 const ReturnStmt *getReturnStmt() const { return RS; }
595
596 static bool classof(const ConstructionContext *CC) {
597 return CC->getKind() >= RETURNED_VALUE_BEGIN &&
599 }
600};
601
602/// Represents a temporary object that is being immediately returned from a
603/// function by value, eg. return t; or return T(123);. In this case there is
604/// always going to be a constructor at the return site. However, the usual
605/// temporary-related bureaucracy (CXXBindTemporaryExpr,
606/// MaterializeTemporaryExpr) is normally located in the caller function's AST.
609 friend class ConstructionContext; // Allows to create<>() itself.
610
614
615public:
616 static bool classof(const ConstructionContext *CC) {
617 return CC->getKind() == SimpleReturnedValueKind;
618 }
619};
620
621/// Represents a temporary object that is being immediately returned from a
622/// function by value, eg. return t; or return T(123); in C++17.
623/// In C++17 there is not going to be an elidable copy constructor at the
624/// return site. However, the usual temporary-related bureaucracy (CXXBindTemporaryExpr,
625/// MaterializeTemporaryExpr) is normally located in the caller function's AST.
626/// Note that if the object has trivial destructor, then this code is
627/// indistinguishable from a simple returned value constructor on the AST level;
628/// in this case we provide a simple returned value construction context.
631 const CXXBindTemporaryExpr *BTE;
632
633 friend class ConstructionContext; // Allows to create<>() itself.
634
636 const ReturnStmt *RS, const CXXBindTemporaryExpr *BTE)
639 BTE(BTE) {
640 assert(BTE);
641 }
642
643public:
644 const CXXBindTemporaryExpr *getCXXBindTemporaryExpr() const { return BTE; }
645
646 static bool classof(const ConstructionContext *CC) {
648 }
649};
650
652 // The call of which the context is an argument.
653 const Expr *CE;
654
655 // Which argument we're constructing. Note that when numbering between
656 // arguments and parameters is inconsistent (eg., operator calls),
657 // this is the index of the argument, not of the parameter.
658 unsigned Index;
659
660 // Whether the object needs to be destroyed.
661 const CXXBindTemporaryExpr *BTE;
662
663 friend class ConstructionContext; // Allows to create<>() itself.
664
665 explicit ArgumentConstructionContext(const Expr *CE, unsigned Index,
666 const CXXBindTemporaryExpr *BTE)
668 Index(Index), BTE(BTE) {
669 assert(isa<CallExpr>(CE) || isa<CXXConstructExpr>(CE) ||
670 isa<ObjCMessageExpr>(CE));
671 // BTE is optional.
672 }
673
674public:
675 const Expr *getCallLikeExpr() const { return CE; }
676 unsigned getIndex() const { return Index; }
677 const CXXBindTemporaryExpr *getCXXBindTemporaryExpr() const { return BTE; }
678
679 static bool classof(const ConstructionContext *CC) {
680 return CC->getKind() == ArgumentKind;
681 }
682};
683
685 // The lambda of which the initializer we capture.
686 const LambdaExpr *LE;
687
688 // Index of the captured element in the captured list.
689 unsigned Index;
690
691 friend class ConstructionContext; // Allows to create<>() itself.
692
694 unsigned Index)
695 : ConstructionContext(LambdaCaptureKind), LE(LE), Index(Index) {}
696
697public:
698 const LambdaExpr *getLambdaExpr() const { return LE; }
699 unsigned getIndex() const { return Index; }
700
701 const Expr *getInitializer() const {
702 return *(LE->capture_init_begin() + Index);
703 }
704
705 const FieldDecl *getFieldDecl() const {
706 auto It = LE->getLambdaClass()->field_begin();
707 std::advance(It, Index);
708 return *It;
709 }
710
711 const ArrayInitLoopExpr *getArrayInitLoop() const override {
712 return dyn_cast_or_null<ArrayInitLoopExpr>(getInitializer());
713 }
714
715 static bool classof(const ConstructionContext *CC) {
716 return CC->getKind() == LambdaCaptureKind;
717 }
718};
719
720} // end namespace clang
721
722#endif // LLVM_CLANG_ANALYSIS_CONSTRUCTIONCONTEXT_H
NodeId Parent
Definition: ASTDiff.cpp:191
static char ID
Definition: Arena.cpp:183
Expr * E
Defines the clang::Expr interface and subclasses for C++ expressions.
const char * Data
static bool classof(const ConstructionContext *CC)
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
Represents a loop initializing the elements of an array.
Definition: Expr.h:5703
Represents construction into a field or a base class within a bigger object via a constructor initial...
Represents a temporary object that is being immediately returned from a function by value,...
static bool classof(const ConstructionContext *CC)
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
Represents construction into a simple variable with an initializer syntax, with a single constructor,...
static bool classof(const ConstructionContext *CC)
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1491
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1546
bool isElidable() const
Whether this construction is elidable.
Definition: ExprCXX.h:1615
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2304
Expr * getInit() const
Get the initializer.
Definition: DeclCXX.h:2506
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1737
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition: ExprCXX.h:2241
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2830
Represents a single point (AST node) in the program that requires attention during construction of an...
ConstructionContextItem(const ReturnStmt *RS)
ConstructionContextItem(const CXXInheritedCtorInitExpr *CE, unsigned Index)
ConstructionContextItem(const CallExpr *CE, unsigned Index)
ConstructionContextItem(const CXXCtorInitializer *Init)
ConstructionContextItem(const LambdaExpr *LE, unsigned Index)
unsigned getIndex() const
If a single trigger statement triggers multiple constructors, they are usually being enumerated.
bool operator==(const ConstructionContextItem &Other) const
bool operator<(const ConstructionContextItem &Other) const
const CXXCtorInitializer * getCXXCtorInitializer() const
The construction site is not necessarily a statement.
void Profile(llvm::FoldingSetNodeID &ID) const
ConstructionContextItem(const MaterializeTemporaryExpr *MTE)
ConstructionContextItem(const CXXConstructExpr *CE, unsigned Index)
ConstructionContextItem(const ObjCMessageExpr *ME, unsigned Index)
ConstructionContextItem(const CXXConstructExpr *CE)
ConstructionContextItem(const DeclStmt *DS)
ConstructionContextItem(const CXXNewExpr *NE)
LLVM_DUMP_METHOD StringRef getKindAsString() const
static LLVM_DUMP_METHOD StringRef getKindAsString(ItemKind K)
ConstructionContextItem(const Expr *E, unsigned Index)
ConstructionContextItem(const CXXBindTemporaryExpr *BTE, bool IsElided=false)
const Stmt * getStmt() const
The construction site - the statement that triggered the construction for one of its parts.
Construction context can be seen as a linked list of multiple layers.
static const ConstructionContextLayer * create(BumpVectorContext &C, const ConstructionContextItem &Item, const ConstructionContextLayer *Parent=nullptr)
const ConstructionContextItem & getItem() const
const ConstructionContextLayer * getParent() const
bool isStrictlyMoreSpecificThan(const ConstructionContextLayer *Other) const
See if Other is a proper initial segment of this construction context in terms of the parent chain - ...
ConstructionContext's subclasses describe different ways of constructing an object in C++.
virtual const ArrayInitLoopExpr * getArrayInitLoop() const
virtual ~ConstructionContext()=default
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...
const CXXCtorInitializer * getCXXCtorInitializer() const
ConstructorInitializerConstructionContext(ConstructionContext::Kind K, const CXXCtorInitializer *I)
const ArrayInitLoopExpr * getArrayInitLoop() const override
static bool classof(const ConstructionContext *CC)
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition: Stmt.h:1502
const Decl * getSingleDecl() const
Definition: Stmt.h:1517
Represents a temporary object that is constructed for the sole purpose of being immediately copied by...
static bool classof(const ConstructionContext *CC)
const ConstructionContext * getConstructionContextAfterElision() const
const CXXConstructExpr * getConstructorAfterElision() const
This represents one expression.
Definition: Expr.h:110
Represents a member of a struct/union/class.
Definition: Decl.h:3030
const ArrayInitLoopExpr * getArrayInitLoop() const override
static bool classof(const ConstructionContext *CC)
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1954
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4728
Represents immediate initialization of memory allocated by operator new, eg.
static bool classof(const ConstructionContext *CC)
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:945
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition: Stmt.h:3029
ReturnedValueConstructionContext(ConstructionContext::Kind K, const ReturnStmt *RS)
static bool classof(const ConstructionContext *CC)
Represents construction into a field or a base class within a bigger object via a constructor initial...
static bool classof(const ConstructionContext *CC)
Represents a temporary object that is being immediately returned from a function by value,...
static bool classof(const ConstructionContext *CC)
Represents a temporary object that is not constructed for the purpose of being immediately copied/mov...
static bool classof(const ConstructionContext *CC)
Represents construction into a simple local variable, eg.
static bool classof(const ConstructionContext *CC)
Stmt - This represents one statement.
Definition: Stmt.h:84
Represents a temporary object, eg.
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
CXXBindTemporaryExpr here is non-null as long as the temporary has a non-trivial destructor.
const MaterializeTemporaryExpr * getMaterializedTemporaryExpr() const
MaterializeTemporaryExpr is non-null as long as the temporary is actually used after construction,...
static bool classof(const ConstructionContext *CC)
TemporaryObjectConstructionContext(ConstructionContext::Kind K, const CXXBindTemporaryExpr *BTE, const MaterializeTemporaryExpr *MTE)
An abstract base class for local variable constructors.
static bool classof(const ConstructionContext *CC)
const ArrayInitLoopExpr * getArrayInitLoop() const override
VariableConstructionContext(ConstructionContext::Kind K, const DeclStmt *DS)
const DeclStmt * getDeclStmt() const
The JSON file list parser is used to communicate input to InstallAPI.
LambdaCaptureKind
The different capture forms in a lambda introducer.
Definition: Lambda.h:33
const FunctionProtoType * T
@ Other
Other implicit parameter.