Skip to content

Commit

Permalink
Revert "[clang][Interp] Basic support for bit fields"
Browse files Browse the repository at this point in the history
This reverts commit 8065b1c.

This breaks builders. I forgot this depends
on https://reviews.llvm.org/D155548
  • Loading branch information
tbaederr committed Aug 10, 2023
1 parent ac2af81 commit b56ab41
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 73 deletions.
15 changes: 4 additions & 11 deletions clang/lib/AST/Interp/ByteCodeExprGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,8 @@ bool ByteCodeExprGen<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
return Discard(this->emitDiv(*T, BO));
case BO_Assign:
if (DiscardResult)
return LHS->refersToBitField() ? this->emitStoreBitFieldPop(*T, BO)
: this->emitStorePop(*T, BO);
return LHS->refersToBitField() ? this->emitStoreBitField(*T, BO)
: this->emitStore(*T, BO);
return this->emitStorePop(*T, BO);
return this->emitStore(*T, BO);
case BO_And:
return Discard(this->emitBitAnd(*T, BO));
case BO_Or:
Expand Down Expand Up @@ -1592,13 +1590,8 @@ bool ByteCodeExprGen<Emitter>::visitRecordInitializer(const Expr *Initializer) {
if (!this->visit(Init))
return false;

if (FieldToInit->isBitField()) {
if (!this->emitInitBitField(*T, FieldToInit, Initializer))
return false;
} else {
if (!this->emitInitField(*T, FieldToInit->Offset, Initializer))
return false;
}
if (!this->emitInitField(*T, FieldToInit->Offset, Initializer))
return false;

if (!this->emitPopPtr(Initializer))
return false;
Expand Down
9 changes: 2 additions & 7 deletions clang/lib/AST/Interp/ByteCodeStmtGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,8 @@ bool ByteCodeStmtGen<Emitter>::visitFunc(const FunctionDecl *F) {
if (!this->visit(InitExpr))
return false;

if (F->isBitField()) {
if (!this->emitInitThisBitField(*T, F, InitExpr))
return false;
} else {
if (!this->emitInitThisField(*T, F->Offset, InitExpr))
return false;
}
if (!this->emitInitThisField(*T, F->Offset, InitExpr))
return false;
} else {
// Non-primitive case. Get a pointer to the field-to-initialize
// on the stack and call visitInitialzer() for it.
Expand Down
14 changes: 7 additions & 7 deletions clang/lib/AST/Interp/Interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,6 @@ bool InitThisField(InterpState &S, CodePtr OpPC, uint32_t I) {

template <PrimType Name, class T = typename PrimConv<Name>::T>
bool InitThisBitField(InterpState &S, CodePtr OpPC, const Record::Field *F) {
assert(F->isBitField());
if (S.checkingPotentialConstantExpression())
return false;
const Pointer &This = S.Current->getThis();
Expand Down Expand Up @@ -1049,9 +1048,8 @@ bool InitField(InterpState &S, CodePtr OpPC, uint32_t I) {

template <PrimType Name, class T = typename PrimConv<Name>::T>
bool InitBitField(InterpState &S, CodePtr OpPC, const Record::Field *F) {
assert(F->isBitField());
const T &Value = S.Stk.pop<T>();
const Pointer &Field = S.Stk.peek<Pointer>().atField(F->Offset);
const Pointer &Field = S.Stk.pop<Pointer>().atField(F->Offset);
Field.deref<T>() = Value.truncate(F->Decl->getBitWidthValue(S.getCtx()));
Field.activate();
Field.initialize();
Expand Down Expand Up @@ -1249,10 +1247,11 @@ bool StoreBitField(InterpState &S, CodePtr OpPC) {
return false;
if (!Ptr.isRoot())
Ptr.initialize();
if (const auto *FD = Ptr.getField())
if (auto *FD = Ptr.getField()) {
Ptr.deref<T>() = Value.truncate(FD->getBitWidthValue(S.getCtx()));
else
} else {
Ptr.deref<T>() = Value;
}
return true;
}

Expand All @@ -1264,10 +1263,11 @@ bool StoreBitFieldPop(InterpState &S, CodePtr OpPC) {
return false;
if (!Ptr.isRoot())
Ptr.initialize();
if (const auto *FD = Ptr.getField())
if (auto *FD = Ptr.getField()) {
Ptr.deref<T>() = Value.truncate(FD->getBitWidthValue(S.getCtx()));
else
} else {
Ptr.deref<T>() = Value;
}
return true;
}

Expand Down
1 change: 0 additions & 1 deletion clang/lib/AST/Interp/Record.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class Record final {
const FieldDecl *Decl;
unsigned Offset;
Descriptor *Desc;
bool isBitField() const { return Decl->isBitField(); }
};

/// Describes a base class.
Expand Down
47 changes: 0 additions & 47 deletions clang/test/AST/Interp/bitfields.cpp

This file was deleted.

0 comments on commit b56ab41

Please sign in to comment.