clang 20.0.0git
|
Defines the result of an evaluation. More...
Public Types | |
enum | ResultKind { Empty , LValue , RValue , Invalid , Valid } |
using | DeclTy = llvm::PointerUnion< const Decl *, const Expr * > |
Public Member Functions | |
EvaluationResult (const Context *Ctx) | |
bool | empty () const |
bool | isInvalid () const |
bool | isLValue () const |
bool | isRValue () const |
APValue | toAPValue () const |
Returns an APValue for the evaluation result. | |
std::optional< APValue > | toRValue () const |
If the result is an LValue, convert that to an RValue and return it. | |
bool | checkFullyInitialized (InterpState &S, const Pointer &Ptr) const |
Check that all subobjects of the given pointer have been initialized. | |
bool | checkReturnValue (InterpState &S, const Context &Ctx, const Pointer &Ptr, const SourceInfo &Info) |
Check that none of the blocks the given pointer (transitively) points to are dynamically allocated. | |
QualType | getSourceType () const |
void | dump () const |
Dump to stderr. | |
Friends | |
class | EvalEmitter |
class | InterpState |
Defines the result of an evaluation.
The result might be in different forms–one of the pointer types, an APValue, or nothing.
We use this class to inspect and diagnose the result, as well as convert it to the requested form.
Definition at line 32 of file EvaluationResult.h.
using clang::interp::EvaluationResult::DeclTy = llvm::PointerUnion<const Decl *, const Expr *> |
Definition at line 42 of file EvaluationResult.h.
Enumerator | |
---|---|
Empty | |
LValue | |
RValue | |
Invalid | |
Valid |
Definition at line 34 of file EvaluationResult.h.
|
inline |
Definition at line 85 of file EvaluationResult.h.
bool clang::interp::EvaluationResult::checkFullyInitialized | ( | InterpState & | S, |
const Pointer & | Ptr | ||
) | const |
Check that all subobjects of the given pointer have been initialized.
Definition at line 149 of file EvaluationResult.cpp.
References clang::interp::CheckArrayInitialized(), clang::interp::CheckFieldsInitialized(), D, E, empty(), clang::Type::getAsArrayTypeUnsafe(), clang::interp::Pointer::getRecord(), clang::interp::Pointer::getType(), clang::interp::Pointer::isLive(), and clang::interp::Pointer::isZero().
bool clang::interp::EvaluationResult::checkReturnValue | ( | InterpState & | S, |
const Context & | Ctx, | ||
const Pointer & | Ptr, | ||
const SourceInfo & | Info | ||
) |
Check that none of the blocks the given pointer (transitively) points to are dynamically allocated.
Definition at line 219 of file EvaluationResult.cpp.
References clang::interp::collectBlocks(), clang::interp::Pointer::getType(), clang::Type::isReferenceType(), and clang::interp::Pointer::isRoot().
LLVM_DUMP_METHOD void EvaluationResult::dump | ( | ) | const |
Dump to stderr.
Definition at line 352 of file Disasm.cpp.
References D, E, Empty, clang::interp::Context::getASTContext(), clang::Expr::getType(), Invalid, LValue, P, RValue, and Valid.
|
inline |
Definition at line 87 of file EvaluationResult.h.
References Empty.
Referenced by checkFullyInitialized(), and toAPValue().
|
inline |
|
inline |
Definition at line 88 of file EvaluationResult.h.
References Invalid.
|
inline |
Definition at line 89 of file EvaluationResult.h.
References LValue.
|
inline |
Definition at line 90 of file EvaluationResult.h.
References RValue.
APValue clang::interp::EvaluationResult::toAPValue | ( | ) | const |
Returns an APValue for the evaluation result.
The returned APValue might be an LValue or RValue.
Definition at line 20 of file EvaluationResult.cpp.
References empty(), clang::interp::Context::getASTContext(), LValue, P, RValue, and Valid.
Referenced by toRValue().
std::optional< APValue > clang::interp::EvaluationResult::toRValue | ( | ) | const |
If the result is an LValue, convert that to an RValue and return it.
This may fail, e.g. if the result is an LValue and we can't read from it.
Definition at line 41 of file EvaluationResult.cpp.
References clang::interp::Context::getASTContext(), getSourceType(), LValue, P, RValue, and toAPValue().
|
friend |
Definition at line 120 of file EvaluationResult.h.
|
friend |
Definition at line 121 of file EvaluationResult.h.