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)
119 assert(isa<CallExpr>(E) || isa<CXXConstructExpr>(E) ||
120 isa<ObjCMessageExpr>(E));
137 assert(hasStatement());
138 return static_cast<const Stmt *
>(Data);
142 return hasStatement() ?
getStmt() :
nullptr;
149 assert(hasInitializer());
167 ID.AddInteger(Index);
174 return std::make_tuple(Data, Kind, Index) ==
175 std::make_tuple(Other.Data, Other.Kind, Other.Index);
179 return std::make_tuple(Data, Kind, Index) <
180 std::make_tuple(Other.Data, Other.Kind, Other.Index);
209 :
Parent(Parent), Item(Item) {}
238 VARIABLE_BEGIN = SimpleVariableKind,
239 VARIABLE_END = CXX17ElidedCopyVariableKind,
242 INITIALIZER_BEGIN = SimpleConstructorInitializerKind,
243 INITIALIZER_END = CXX17ElidedCopyConstructorInitializerKind,
247 TEMPORARY_BEGIN = SimpleTemporaryObjectKind,
248 TEMPORARY_END = ElidedTemporaryObjectKind,
251 RETURNED_VALUE_BEGIN = SimpleReturnedValueKind,
252 RETURNED_VALUE_END = CXX17ElidedCopyReturnedValueKind,
265 template <
typename T,
typename... ArgTypes>
268 return new (CC) T(Args...);
284 createBoundTemporaryFromLayers(
314 return CC->
getKind() >= VARIABLE_BEGIN &&
332 return CC->
getKind() == SimpleVariableKind;
361 return CC->
getKind() == CXX17ElidedCopyVariableKind;
381 return CC->
getKind() >= INITIALIZER_BEGIN &&
382 CC->
getKind() <= INITIALIZER_END;
399 return CC->
getKind() == SimpleConstructorInitializerKind;
422 CXX17ElidedCopyConstructorInitializerKind, I),
431 return CC->
getKind() == CXX17ElidedCopyConstructorInitializerKind;
452 return CC->
getKind() == NewAllocatedObjectKind;
492 return CC->
getKind() >= TEMPORARY_BEGIN && CC->
getKind() <= TEMPORARY_END;
511 return CC->
getKind() == SimpleTemporaryObjectKind;
535 ElidedCE(ElidedCE), ElidedCC(ElidedCC) {
539 assert(ElidedCE && ElidedCE->
isElidable() && ElidedCC);
552 return CC->
getKind() == ElidedTemporaryObjectKind;
571 return CC->
getKind() >= RETURNED_VALUE_BEGIN &&
572 CC->
getKind() <= RETURNED_VALUE_END;
591 return CC->
getKind() == SimpleReturnedValueKind;
621 return CC->
getKind() == CXX17ElidedCopyReturnedValueKind;
642 Index(Index), BTE(BTE) {
643 assert(isa<CallExpr>(CE) || isa<CXXConstructExpr>(CE) ||
644 isa<ObjCMessageExpr>(CE));
660 #endif // LLVM_CLANG_ANALYSIS_CONSTRUCTIONCONTEXT_H static bool classof(const ConstructionContext *CC)
const DeclStmt * getDeclStmt() const
Stmt - This represents one statement.
VariableConstructionContext(ConstructionContext::Kind K, const DeclStmt *DS)
bool operator==(const ConstructionContextItem &Other) const
const ConstructionContext * getConstructionContextAfterElision() const
ConstructionContextItem(const Expr *E, unsigned Index)
Represents a call to a C++ constructor.
const Expr * getCallLikeExpr() const
static bool classof(const ConstructionContext *CC)
static bool classof(const ConstructionContext *CC)
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
llvm::BumpPtrAllocator & getAllocator()
ConstructionContextItem(const CXXConstructExpr *CE, unsigned Index)
Defines the clang::Expr interface and subclasses for C++ expressions.
ConstructionContext(Kind K)
ReturnedValueConstructionContext(ConstructionContext::Kind K, const ReturnStmt *RS)
Represents construction into a field or a base class within a bigger object via a constructor initial...
static LLVM_DUMP_METHOD StringRef getKindAsString(ItemKind K)
const Stmt * getStmtOrNull() const
bool isElidable() const
Whether this construction is elidable.
static bool classof(const ConstructionContext *CC)
ConstructionContextItem(const ObjCMessageExpr *ME, unsigned Index)
const ConstructionContextLayer * getParent() const
void Profile(llvm::FoldingSetNodeID &ID) const
Represents binding an expression to a temporary.
An abstract base class for local variable constructors.
unsigned getIndex() const
const CXXNewExpr * getCXXNewExpr() const
LLVM_DUMP_METHOD StringRef getKindAsString() const
static bool classof(const ConstructionContext *CC)
const MaterializeTemporaryExpr * getMaterializedTemporaryExpr() const
MaterializeTemporaryExpr is non-null as long as the temporary is actually used after construction...
static bool classof(const ConstructionContext *CC)
This represents one expression.
static bool classof(const ConstructionContext *CC)
const ReturnStmt * getReturnStmt() const
ConstructionContextItem(const CXXBindTemporaryExpr *BTE, bool IsElided=false)
static bool classof(const ConstructionContext *CC)
Represents a temporary object that is being immediately returned from a function by value...
const CXXConstructExpr * getConstructorAfterElision() const
ConstructionContextItem(const DeclStmt *DS)
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
An expression that sends a message to the given Objective-C object or class.
bool operator<(const ConstructionContextItem &Other) const
ConstructionContextItem(const CXXCtorInitializer *Init)
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
CXXBindTemporaryExpr here is non-null as long as the temporary has a non-trivial destructor.
ConstructorInitializerConstructionContext(ConstructionContext::Kind K, const CXXCtorInitializer *I)
const CXXCtorInitializer * getCXXCtorInitializer() const
Construction context can be seen as a linked list of multiple layers.
ConstructionContextItem(const CallExpr *CE, unsigned Index)
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
ConstructionContextItem(const MaterializeTemporaryExpr *MTE)
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
const CXXCtorInitializer * getCXXCtorInitializer() const
The construction site is not necessarily a statement.
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
ConstructionContextItem(const ReturnStmt *RS)
static bool classof(const ConstructionContext *CC)
unsigned getIndex() const
If a single trigger statement triggers multiple constructors, they are usually being enumerated...
Represents a temporary object that is constructed for the sole purpose of being immediately copied by...
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
const CXXBindTemporaryExpr * getCXXBindTemporaryExpr() const
Dataflow Directional Tag Classes.
bool NE(InterpState &S, CodePtr OpPC)
Represents immediate initialization of memory allocated by operator new, eg.
std::unique_ptr< DiagnosticConsumer > create(StringRef OutputFile, DiagnosticOptions *Diags, bool MergeChildRecords=false)
Returns a DiagnosticConsumer that serializes diagnostics to a bitcode file.
Represents a single point (AST node) in the program that requires attention during construction of an...
Represents a temporary object that is being immediately returned from a function by value...
static bool classof(const OMPClause *T)
Represents a temporary object that is not constructed for the purpose of being immediately copied/mov...
Represents a C++ base or member initializer.
const ConstructionContextItem & getItem() const
Represents a temporary object, eg.
static bool classof(const ConstructionContext *CC)
const Stmt * getStmt() const
The construction site - the statement that triggered the construction for one of its parts...
ConstructionContextItem(const CXXConstructExpr *CE)
ConstructionContext's subclasses describe different ways of constructing an object in C++...
Represents construction into a field or a base class within a bigger object via a constructor initial...
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static bool classof(const ConstructionContext *CC)
Represents construction into a simple local variable, eg.
TemporaryObjectConstructionContext(ConstructionContext::Kind K, const CXXBindTemporaryExpr *BTE, const MaterializeTemporaryExpr *MTE)
static bool classof(const ConstructionContext *CC)
ConstructionContextItem(const CXXNewExpr *NE)
Represents construction into a simple variable with an initializer syntax, with a single constructor...
static bool classof(const ConstructionContext *CC)
static bool classof(const ConstructionContext *CC)