Go to the documentation of this file.
16 #ifndef LLVM_CLANG_ANALYSIS_CONSTRUCTIONCONTEXT_H
17 #define LLVM_CLANG_ANALYSIS_CONSTRUCTIONCONTEXT_H
50 case VariableKind:
return "construct into local variable";
52 case ReturnKind:
return "construct into return address";
60 llvm_unreachable(
"Unknown ItemKind");
64 const void *
const Data;
66 const unsigned Index = 0;
68 bool hasStatement()
const {
73 bool hasIndex()
const {
78 bool hasInitializer()
const {
100 bool IsElided =
false)
122 assert(isa<CallExpr>(E) || isa<CXXConstructExpr>(E) ||
123 isa<CXXDeleteExpr>(E) || isa<CXXInheritedCtorInitExpr>(E) ||
124 isa<ObjCMessageExpr>(E));
141 assert(hasStatement());
142 return static_cast<const Stmt *
>(Data);
146 return hasStatement() ?
getStmt() :
nullptr;
153 assert(hasInitializer());
171 ID.AddInteger(Index);
178 return std::make_tuple(Data, Kind, Index) ==
179 std::make_tuple(Other.Data, Other.Kind, Other.Index);
183 return std::make_tuple(Data, Kind, Index) <
184 std::make_tuple(Other.Data, Other.Kind, Other.Index);
269 template <
typename T,
typename... ArgTypes>
271 auto *CC = C.getAllocator().Allocate<T>();
272 return new (CC) T(Args...);
279 BumpVectorContext &C,
const MaterializeTemporaryExpr *MTE,
280 const CXXBindTemporaryExpr *BTE,
281 const ConstructionContextLayer *ParentLayer);
288 createBoundTemporaryFromLayers(
289 BumpVectorContext &C,
const CXXBindTemporaryExpr *BTE,
290 const ConstructionContextLayer *ParentLayer);
298 const ConstructionContextLayer *TopLayer);
539 ElidedCE(ElidedCE), ElidedCC(ElidedCC) {
543 assert(ElidedCE && ElidedCE->
isElidable() && ElidedCC);
646 Index(Index), BTE(BTE) {
647 assert(isa<CallExpr>(CE) || isa<CXXConstructExpr>(CE) ||
648 isa<ObjCMessageExpr>(CE));
664 #endif // LLVM_CLANG_ANALYSIS_CONSTRUCTIONCONTEXT_H
const CXXCtorInitializer * getCXXCtorInitializer() const
TemporaryObjectConstructionContext(ConstructionContext::Kind K, const CXXBindTemporaryExpr *BTE, const MaterializeTemporaryExpr *MTE)
const ConstructionContext * getConstructionContextAfterElision() const
static bool classof(const ConstructionContext *CC)
ConstructionContextItem(const DeclStmt *DS)
void Profile(llvm::FoldingSetNodeID &ID) const
static bool classof(const ConstructionContext *CC)
ConstructionContextItem(const CXXInheritedCtorInitExpr *CE, unsigned Index)
static bool classof(const ConstructionContext *CC)
ReturnedValueConstructionContext(ConstructionContext::Kind K, const ReturnStmt *RS)
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
@ TemporaryDestructorKind
const CXXCtorInitializer * getCXXCtorInitializer() const
The construction site is not necessarily a statement.
ConstructionContextItem(const CXXConstructExpr *CE)
@ CXX17ElidedCopyConstructorInitializerKind
ConstructionContext's subclasses describe different ways of constructing an object in C++.
const Stmt * getStmtOrNull() const
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
@ SimpleReturnedValueKind
ConstructorInitializerConstructionContext(ConstructionContext::Kind K, const CXXCtorInitializer *I)
@ CXX17ElidedCopyVariableKind
static bool classof(const ConstructionContext *CC)
ConstructionContextItem(const CXXConstructExpr *CE, unsigned Index)
ConstructionContextItem(const CXXNewExpr *NE)
const DeclStmt * getDeclStmt() const
Represents construction into a field or a base class within a bigger object via a constructor initial...
const ConstructionContextItem & getItem() const
LLVM_DUMP_METHOD StringRef getKindAsString() const
Represents a single point (AST node) in the program that requires attention during construction of an...
static const ConstructionContextLayer * create(BumpVectorContext &C, const ConstructionContextItem &Item, const ConstructionContextLayer *Parent=nullptr)
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 MaterializeTemporaryExpr * getMaterializedTemporaryExpr() const
MaterializeTemporaryExpr is non-null as long as the temporary is actually used after construction,...
unsigned getIndex() const
If a single trigger statement triggers multiple constructors, they are usually being enumerated.
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
CXXBindTemporaryExpr here is non-null as long as the temporary has a non-trivial destructor.
unsigned getIndex() const
bool operator==(const ConstructionContextItem &Other) const
const CXXNewExpr * getCXXNewExpr() const
static bool classof(const ConstructionContext *CC)
Represents binding an expression to a temporary.
static bool classof(const ConstructionContext *CC)
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
static LLVM_DUMP_METHOD StringRef getKindAsString(ItemKind K)
static bool classof(const ConstructionContext *CC)
Represents a temporary object that is constructed for the sole purpose of being immediately copied by...
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
@ SimpleConstructorInitializerKind
static bool classof(const ConstructionContext *CC)
static bool classof(const ConstructionContext *CC)
ConstructionContextItem(const CXXCtorInitializer *Init)
Represents a call to an inherited base class constructor from an inheriting constructor.
const ReturnStmt * getReturnStmt() const
static bool classof(const ConstructionContext *CC)
An abstract base class for local variable constructors.
An expression that sends a message to the given Objective-C object or class.
ConstructionContext(Kind K)
const Stmt * getStmt() const
The construction site - the statement that triggered the construction for one of its parts.
static bool classof(const ConstructionContext *CC)
const Expr * getCallLikeExpr() const
@ STATEMENT_WITH_INDEX_KIND_BEGIN
Represents a temporary object that is not constructed for the purpose of being immediately copied/mov...
Represents immediate initialization of memory allocated by operator new, eg.
Construction context can be seen as a linked list of multiple layers.
@ ElidableConstructorKind
bool isStrictlyMoreSpecificThan(const ConstructionContextLayer *Other) const
See if Other is a proper initial segment of this construction context in terms of the parent chain - ...
Represents construction into a simple local variable, eg.
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
bool NE(InterpState &S, CodePtr OpPC)
ConstructionContextItem(const Expr *E, unsigned Index)
@ SimpleTemporaryObjectKind
Stmt - This represents one statement.
Represents a temporary object that is being immediately returned from a function by value,...
ConstructionContextItem(const ObjCMessageExpr *ME, unsigned Index)
ConstructionContextItem(const CallExpr *CE, unsigned Index)
static bool classof(const ConstructionContext *CC)
ConstructionContextItem(const ReturnStmt *RS)
@ STATEMENT_WITH_INDEX_KIND_END
ConstructionContextItem(const CXXBindTemporaryExpr *BTE, bool IsElided=false)
@ ElidedTemporaryObjectKind
Represents a temporary object, eg.
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
@ CXX17ElidedCopyReturnedValueKind
This represents one expression.
VariableConstructionContext(ConstructionContext::Kind K, const DeclStmt *DS)
const ConstructionContextLayer * getParent() const
const CXXConstructExpr * getConstructorAfterElision() const
Represents a C++ base or member initializer.
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...
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
ConstructionContextItem(const MaterializeTemporaryExpr *MTE)
Represents a call to a C++ constructor.
static bool classof(const ConstructionContext *CC)
bool operator<(const ConstructionContextItem &Other) const
bool isElidable() const
Whether this construction is elidable.
Represents construction into a simple variable with an initializer syntax, with a single constructor,...
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.