23 if (
const auto *
P = std::get_if<Pointer>(&
Value))
24 return P->toAPValue();
25 else if (
const auto *FP = std::get_if<FunctionPointer>(&
Value))
26 return FP->toAPValue();
28 llvm_unreachable(
"Unhandled LValue type");
31 return std::get<APValue>(
Value);
35 llvm_unreachable(
"Unhandled result kind?");
46 if (
const auto *
P = std::get_if<Pointer>(&
Value))
47 return P->toRValue(*Ctx);
48 else if (
const auto *FP = std::get_if<FunctionPointer>(&
Value))
49 return FP->toAPValue();
50 llvm_unreachable(
"Unhandled lvalue kind");
55 assert(SubObjDecl &&
"Subobject declaration does not exist");
56 S.FFDiag(Loc, diag::note_constexpr_uninitialized)
59 diag::note_constexpr_subobject_declared_here);
63 const Pointer &BasePtr,
const Record *R);
74 for (
size_t I = 0; I != NumElems; ++I) {
78 }
else if (
const auto *ElemCAT = dyn_cast<ConstantArrayType>(ElemType)) {
79 for (
size_t I = 0; I != NumElems; ++I) {
84 for (
size_t I = 0; I != NumElems; ++I) {
100 for (
const Record::Field &F : R->
fields()) {
102 QualType FieldType = F.Decl->getType();
108 }
else if (F.Decl->isUnnamedBitField()) {
121 for (
const Record::Base &B : R->
bases()) {
123 if (!
P.isInitialized()) {
125 diag::note_constexpr_uninitialized_base)
126 << B.Desc->getType();
143 const Decl *SourceDecl = Source.dyn_cast<
const Decl *>();
145 const auto *VD = cast<VarDecl>(SourceDecl);
146 assert(VD->getType()->isRecordType() || VD->getType()->isArrayType());
160 auto &OS = llvm::errs();
169 std::get<APValue>(
Value).dump(OS, ASTCtx);
174 if (
const auto *D = Source.dyn_cast<
const Decl *>()) {
175 if (
const auto *VD = dyn_cast<ValueDecl>(D))
176 SourceType = VD->getType();
177 }
else if (
const auto *E = Source.dyn_cast<
const Expr *>()) {
178 SourceType = E->getType();
182 if (
const auto *
P = std::get_if<Pointer>(&
Value))
183 P->toAPValue().printPretty(OS, ASTCtx, SourceType);
184 else if (
const auto *FP = std::get_if<FunctionPointer>(&
Value))
185 FP->toAPValue().printPretty(OS, ASTCtx, SourceType);
Defines the clang::Expr interface and subclasses for C++ expressions.
llvm::MachO::Record Record
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getElementType() const
Represents the canonical version of C arrays with a specified constant size.
uint64_t getZExtSize() const
Return the size zero-extended as a uint64_t.
Decl - This represents one declaration (or definition), e.g.
SourceLocation getLocation() const
This represents one expression.
Represents a member of a struct/union/class.
A (possibly-)qualified type.
Encodes a location in the source.
bool isIncompleteArrayType() const
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isRecordType() const
ASTContext & getASTContext() const
Returns the AST context.
void dump() const
Dump to stderr.
std::optional< APValue > toRValue() const
If the result is an LValue, convert that to an RValue and return it.
APValue toAPValue() const
Returns an APValue for the evaluation result.
bool checkFullyInitialized(InterpState &S, const Pointer &Ptr) const
A pointer to a memory block, live or dead.
Pointer narrow() const
Restricts the scope of an array element pointer.
bool isInitialized() const
Checks if an object was initialized.
Pointer atIndex(uint64_t Idx) const
Offsets a pointer inside an array.
Pointer atField(unsigned Off) const
Creates a pointer to a field.
QualType getType() const
Returns the type of the innermost field.
bool isZero() const
Checks if the pointer is null.
const Descriptor * getDeclDesc() const
Accessor for information about the declaration site.
const Record * getElemRecord() const
Returns the element record type, if this is a non-primive array.
const FieldDecl * getField() const
Returns the field information.
const Record * getRecord() const
Returns the record descriptor of a class.
Structure/Class descriptor.
llvm::iterator_range< const_base_iter > bases() const
llvm::iterator_range< const_field_iter > fields() const
static bool CheckFieldsInitialized(InterpState &S, SourceLocation Loc, const Pointer &BasePtr, const Record *R)
static void DiagnoseUninitializedSubobject(InterpState &S, SourceLocation Loc, const FieldDecl *SubObjDecl)
static bool CheckArrayInitialized(InterpState &S, SourceLocation Loc, const Pointer &BasePtr, const ConstantArrayType *CAT)
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
const Decl * asDecl() const