Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions clang/lib/AST/ByteCode/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2843,6 +2843,8 @@ bool Compiler<Emitter>::VisitLambdaExpr(const LambdaExpr *E) {

assert(Initializing);
const Record *R = P.getOrCreateRecord(E->getLambdaClass());
if (!R)
return false;

auto *CaptureInitIt = E->capture_init_begin();
// Initialize all fields (which represent lambda captures) of the
Expand Down Expand Up @@ -4076,9 +4078,8 @@ bool Compiler<Emitter>::visitZeroRecordInitializer(const Record *R,
} else if (D->isRecord()) {
if (!this->visitZeroRecordInitializer(D->ElemRecord, E))
return false;
} else {
assert(false);
}
} else
return false;

if (!this->emitFinishInitPop(E))
return false;
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/AST/ByteCode/Descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,10 @@ Descriptor::Descriptor(const DeclTy &D, const Record *R, MetadataSize MD,
}

/// Dummy.
Descriptor::Descriptor(const DeclTy &D)
: Source(D), ElemSize(1), Size(1), MDSize(0), AllocSize(MDSize),
ElemRecord(nullptr), IsConst(true), IsMutable(false), IsTemporary(false),
IsDummy(true) {
Descriptor::Descriptor(const DeclTy &D, MetadataSize MD)
: Source(D), ElemSize(1), Size(1), MDSize(MD.value_or(0)),
AllocSize(MDSize), ElemRecord(nullptr), IsConst(true), IsMutable(false),
IsTemporary(false), IsDummy(true) {
assert(Source && "Missing source");
}

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/ByteCode/Descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ struct Descriptor final {
bool IsTemporary, bool IsMutable);

/// Allocates a dummy descriptor.
Descriptor(const DeclTy &D);
Descriptor(const DeclTy &D, MetadataSize MD = std::nullopt);

/// Make this descriptor a dummy descriptor.
void makeDummy() { IsDummy = true; }
Expand Down Expand Up @@ -261,7 +261,7 @@ struct Descriptor final {
bool isUnknownSizeArray() const { return Size == UnknownSizeMark; }

/// Checks if the descriptor is of a primitive.
bool isPrimitive() const { return !IsArray && !ElemRecord; }
bool isPrimitive() const { return !IsArray && !ElemRecord && !IsDummy; }

/// Checks if the descriptor is of an array.
bool isArray() const { return IsArray; }
Expand Down
7 changes: 6 additions & 1 deletion clang/lib/AST/ByteCode/Pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,12 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const {
Index = Ptr.getIndex();

QualType ElemType = Desc->getElemQualType();
Offset += (Index * ASTCtx.getTypeSizeInChars(ElemType));
if (const auto *RD = ElemType->getAsRecordDecl();
RD && !RD->getDefinition()) {
// Ignore this for the offset.
} else {
Offset += (Index * ASTCtx.getTypeSizeInChars(ElemType));
}
if (Ptr.getArray().getType()->isArrayType())
Path.push_back(APValue::LValuePathEntry::ArrayIndex(Index));
Ptr = Ptr.getArray();
Expand Down
1 change: 1 addition & 0 deletions clang/lib/AST/ByteCode/Program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ Descriptor *Program::createDescriptor(const DeclTy &D, const Type *Ty,
if (const auto *Record = getOrCreateRecord(RT->getDecl()))
return allocateDescriptor(D, Record, MDSize, IsConst, IsTemporary,
IsMutable);
return allocateDescriptor(D, MDSize);
}

// Arrays.
Expand Down
12 changes: 12 additions & 0 deletions clang/test/AST/ByteCode/records.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1747,3 +1747,15 @@ namespace CtorOfInvalidClass {
template<ReferenceOf<InvalidCtor> auto R, typename Rep> int F; // both-error {{non-type template argument is not a constant expression}}
#endif
}

namespace IncompleteTypes {
struct Incomplete;

constexpr bool foo() {
extern Incomplete bounded[10];
extern Incomplete unbounded[];
extern Incomplete IT;
return true;
}
static_assert(foo(), "");
}