[Lldb-commits] [clang] [clang-tools-extra] [lldb] Reapply "[clang] Avoid re-evaluating field bitwidth" (PR #122289)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Jan 9 07:06:08 PST 2025
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/122289 at github.com>
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-static-analyzer-1
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
---
Patch is 43.47 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/122289.diff
40 Files Affected:
- (modified) clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp (+1-1)
- (modified) clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp (+1-1)
- (modified) clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp (+1-1)
- (modified) clang-tools-extra/clangd/Hover.cpp (+1-1)
- (modified) clang/include/clang/AST/Decl.h (+4-2)
- (modified) clang/include/clang/ASTMatchers/ASTMatchers.h (+1-2)
- (modified) clang/lib/AST/ASTContext.cpp (+5-5)
- (modified) clang/lib/AST/ByteCode/Interp.h (+4-6)
- (modified) clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp (+4-4)
- (modified) clang/lib/AST/Decl.cpp (+11-5)
- (modified) clang/lib/AST/DeclCXX.cpp (+1-1)
- (modified) clang/lib/AST/Expr.cpp (+1-2)
- (modified) clang/lib/AST/ExprConstant.cpp (+1-1)
- (modified) clang/lib/AST/Randstruct.cpp (+1-1)
- (modified) clang/lib/AST/RecordLayoutBuilder.cpp (+3-3)
- (modified) clang/lib/CodeGen/ABIInfo.cpp (+1-1)
- (modified) clang/lib/CodeGen/ABIInfoImpl.cpp (+1-1)
- (modified) clang/lib/CodeGen/CGCall.cpp (+3-3)
- (modified) clang/lib/CodeGen/CGClass.cpp (+1-1)
- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+3-5)
- (modified) clang/lib/CodeGen/CGNonTrivialStruct.cpp (+3-3)
- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+1-2)
- (modified) clang/lib/CodeGen/CGObjCRuntime.cpp (+1-1)
- (modified) clang/lib/CodeGen/CGRecordLayoutBuilder.cpp (+10-10)
- (modified) clang/lib/CodeGen/SwiftCallingConv.cpp (+1-1)
- (modified) clang/lib/CodeGen/Targets/LoongArch.cpp (+1-1)
- (modified) clang/lib/CodeGen/Targets/RISCV.cpp (+1-1)
- (modified) clang/lib/CodeGen/Targets/X86.cpp (+1-1)
- (modified) clang/lib/CodeGen/Targets/XCore.cpp (+1-1)
- (modified) clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp (+2-1)
- (modified) clang/lib/Sema/SemaChecking.cpp (+5-5)
- (modified) clang/lib/Sema/SemaDecl.cpp (+11-10)
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+3-3)
- (modified) clang/lib/Sema/SemaDeclObjC.cpp (+1-2)
- (modified) clang/lib/Sema/SemaOverload.cpp (+1-1)
- (modified) clang/lib/StaticAnalyzer/Core/RegionStore.cpp (+1-1)
- (modified) clang/tools/libclang/CXType.cpp (+1-1)
- (modified) clang/unittests/AST/ASTImporterTest.cpp (+2-2)
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+2)
- (modified) lldb/test/Shell/SymbolFile/DWARF/x86/no_unique_address-with-bitfields.cpp (+27-9)
``````````diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp
index a950704208c73b..408390ebc70b64 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp
@@ -38,7 +38,7 @@ AST_MATCHER(FieldDecl, hasIntBitwidth) {
assert(Node.isBitField());
const ASTContext &Ctx = Node.getASTContext();
unsigned IntBitWidth = Ctx.getIntWidth(Ctx.IntTy);
- unsigned CurrentBitWidth = Node.getBitWidthValue(Ctx);
+ unsigned CurrentBitWidth = Node.getBitWidthValue();
return IntBitWidth == CurrentBitWidth;
}
diff --git a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
index a73d46f01d9b2d..4ceeefb78ee824 100644
--- a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
@@ -124,7 +124,7 @@ static MagnitudeBits calcMagnitudeBits(const ASTContext &Context,
unsigned SignedBits = IntExprType->isUnsignedIntegerType() ? 0U : 1U;
if (const auto *BitField = IntExpr->getSourceBitField()) {
- unsigned BitFieldWidth = BitField->getBitWidthValue(Context);
+ unsigned BitFieldWidth = BitField->getBitWidthValue();
return {BitFieldWidth - SignedBits, BitFieldWidth};
}
diff --git a/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp b/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
index 47dafca2d03ff0..7028c3958f103e 100644
--- a/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
+++ b/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
@@ -160,7 +160,7 @@ void MultiwayPathsCoveredCheck::handleSwitchWithoutDefault(
}
if (const auto *BitfieldDecl =
Result.Nodes.getNodeAs<FieldDecl>("bitfield")) {
- return twoPow(BitfieldDecl->getBitWidthValue(*Result.Context));
+ return twoPow(BitfieldDecl->getBitWidthValue());
}
return static_cast<std::size_t>(0);
diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp
index 298fa79e3fd0ba..5e136d0e76ece7 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -1018,7 +1018,7 @@ void addLayoutInfo(const NamedDecl &ND, HoverInfo &HI) {
const ASTRecordLayout &Layout = Ctx.getASTRecordLayout(Record);
HI.Offset = Layout.getFieldOffset(FD->getFieldIndex());
if (FD->isBitField())
- HI.Size = FD->getBitWidthValue(Ctx);
+ HI.Size = FD->getBitWidthValue();
else if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType()))
HI.Size = FD->isZeroSize(Ctx) ? 0 : Size->getQuantity() * 8;
if (HI.Size) {
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 67ee0bb412692a..5670072ab4a76f 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -3142,7 +3142,9 @@ class FieldDecl : public DeclaratorDecl, public Mergeable<FieldDecl> {
/// Computes the bit width of this field, if this is a bit field.
/// May not be called on non-bitfields.
- unsigned getBitWidthValue(const ASTContext &Ctx) const;
+ /// Note that in order to successfully use this function, the bitwidth
+ /// expression must be a ConstantExpr with a valid integer result set.
+ unsigned getBitWidthValue() const;
/// Set the bit-field width for this member.
// Note: used by some clients (i.e., do not remove it).
@@ -3173,7 +3175,7 @@ class FieldDecl : public DeclaratorDecl, public Mergeable<FieldDecl> {
/// Is this a zero-length bit-field? Such bit-fields aren't really bit-fields
/// at all and instead act as a separator between contiguous runs of other
/// bit-fields.
- bool isZeroLengthBitField(const ASTContext &Ctx) const;
+ bool isZeroLengthBitField() const;
/// Determine if this field is a subobject of zero size, that is, either a
/// zero-length bit-field or a field of empty class type with the
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index f32170c93bee26..239fcba4e5e057 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -708,8 +708,7 @@ AST_MATCHER(FieldDecl, isBitField) {
/// fieldDecl(hasBitWidth(2))
/// matches 'int a;' and 'int c;' but not 'int b;'.
AST_MATCHER_P(FieldDecl, hasBitWidth, unsigned, Width) {
- return Node.isBitField() &&
- Node.getBitWidthValue(Finder->getASTContext()) == Width;
+ return Node.isBitField() && Node.getBitWidthValue() == Width;
}
/// Matches non-static data members that have an in-class initializer.
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index b10513f49a8d16..46431634d91025 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -2795,7 +2795,7 @@ getSubobjectSizeInBits(const FieldDecl *Field, const ASTContext &Context,
if (Field->isUnnamedBitField())
return 0;
- int64_t BitfieldSize = Field->getBitWidthValue(Context);
+ int64_t BitfieldSize = Field->getBitWidthValue();
if (IsBitIntType) {
if ((unsigned)BitfieldSize >
cast<BitIntType>(Field->getType())->getNumBits())
@@ -7769,7 +7769,7 @@ QualType ASTContext::isPromotableBitField(Expr *E) const {
QualType FT = Field->getType();
- uint64_t BitWidth = Field->getBitWidthValue(*this);
+ uint64_t BitWidth = Field->getBitWidthValue();
uint64_t IntSize = getTypeSize(IntTy);
// C++ [conv.prom]p5:
// A prvalue for an integral bit-field can be converted to a prvalue of type
@@ -8797,7 +8797,7 @@ static void EncodeBitField(const ASTContext *Ctx, std::string& S,
S += getObjCEncodingForPrimitiveType(Ctx, BT);
}
}
- S += llvm::utostr(FD->getBitWidthValue(*Ctx));
+ S += llvm::utostr(FD->getBitWidthValue());
}
// Helper function for determining whether the encoded type string would include
@@ -9223,7 +9223,7 @@ void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
}
for (FieldDecl *Field : RDecl->fields()) {
- if (!Field->isZeroLengthBitField(*this) && Field->isZeroSize(*this))
+ if (!Field->isZeroLengthBitField() && Field->isZeroSize(*this))
continue;
uint64_t offs = layout.getFieldOffset(Field->getFieldIndex());
FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
@@ -9320,7 +9320,7 @@ void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
if (field->isBitField()) {
EncodeBitField(this, S, field->getType(), field);
#ifndef NDEBUG
- CurOffs += field->getBitWidthValue(*this);
+ CurOffs += field->getBitWidthValue();
#endif
} else {
QualType qt = field->getType();
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index d2aec69072e04f..93a91976a31bf1 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -1471,8 +1471,7 @@ bool InitThisBitField(InterpState &S, CodePtr OpPC, const Record::Field *F,
return false;
const Pointer &Field = This.atField(FieldOffset);
const auto &Value = S.Stk.pop<T>();
- Field.deref<T>() =
- Value.truncate(F->Decl->getBitWidthValue(S.getASTContext()));
+ Field.deref<T>() = Value.truncate(F->Decl->getBitWidthValue());
Field.initialize();
return true;
}
@@ -1495,8 +1494,7 @@ 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);
- Field.deref<T>() =
- Value.truncate(F->Decl->getBitWidthValue(S.getASTContext()));
+ Field.deref<T>() = Value.truncate(F->Decl->getBitWidthValue());
Field.activate();
Field.initialize();
return true;
@@ -1750,7 +1748,7 @@ bool StoreBitField(InterpState &S, CodePtr OpPC) {
if (Ptr.canBeInitialized())
Ptr.initialize();
if (const auto *FD = Ptr.getField())
- Ptr.deref<T>() = Value.truncate(FD->getBitWidthValue(S.getASTContext()));
+ Ptr.deref<T>() = Value.truncate(FD->getBitWidthValue());
else
Ptr.deref<T>() = Value;
return true;
@@ -1765,7 +1763,7 @@ bool StoreBitFieldPop(InterpState &S, CodePtr OpPC) {
if (Ptr.canBeInitialized())
Ptr.initialize();
if (const auto *FD = Ptr.getField())
- Ptr.deref<T>() = Value.truncate(FD->getBitWidthValue(S.getASTContext()));
+ Ptr.deref<T>() = Value.truncate(FD->getBitWidthValue());
else
Ptr.deref<T>() = Value;
return true;
diff --git a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
index 57c1fab5d6ab43..f4c54551a9a603 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
@@ -269,7 +269,7 @@ bool clang::interp::readPointerToBuffer(const Context &Ctx,
Bits BitWidth = FullBitWidth;
if (const FieldDecl *FD = P.getField(); FD && FD->isBitField())
- BitWidth = Bits(std::min(FD->getBitWidthValue(ASTCtx),
+ BitWidth = Bits(std::min(FD->getBitWidthValue(),
(unsigned)FullBitWidth.getQuantity()));
else if (T == PT_Bool && PackedBools)
BitWidth = Bits(1);
@@ -301,8 +301,8 @@ bool clang::interp::readPointerToBuffer(const Context &Ctx,
assert(NumBits.isFullByte());
assert(NumBits.getQuantity() <= FullBitWidth.getQuantity());
F.bitcastToMemory(Buff.get());
- // Now, only (maybe) swap the actual size of the float, excluding the
- // padding bits.
+ // Now, only (maybe) swap the actual size of the float, excluding
+ // the padding bits.
if (llvm::sys::IsBigEndianHost)
swapBytes(Buff.get(), NumBits.roundToBytes());
@@ -406,7 +406,7 @@ bool clang::interp::DoBitCastPtr(InterpState &S, CodePtr OpPC,
Bits BitWidth;
if (const FieldDecl *FD = P.getField(); FD && FD->isBitField())
- BitWidth = Bits(std::min(FD->getBitWidthValue(ASTCtx),
+ BitWidth = Bits(std::min(FD->getBitWidthValue(),
(unsigned)FullBitWidth.getQuantity()));
else if (T == PT_Bool && PackedBools)
BitWidth = Bits(1);
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 741e908cf9bc56..37baf06cc55dd1 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -4599,18 +4599,24 @@ void FieldDecl::setLazyInClassInitializer(LazyDeclStmtPtr NewInit) {
Init = NewInit;
}
-unsigned FieldDecl::getBitWidthValue(const ASTContext &Ctx) const {
+unsigned FieldDecl::getBitWidthValue() const {
assert(isBitField() && "not a bitfield");
- return getBitWidth()->EvaluateKnownConstInt(Ctx).getZExtValue();
+ assert(isa<ConstantExpr>(getBitWidth()));
+ assert(cast<ConstantExpr>(getBitWidth())->hasAPValueResult());
+ assert(cast<ConstantExpr>(getBitWidth())->getAPValueResult().isInt());
+ return cast<ConstantExpr>(getBitWidth())
+ ->getAPValueResult()
+ .getInt()
+ .getZExtValue();
}
-bool FieldDecl::isZeroLengthBitField(const ASTContext &Ctx) const {
+bool FieldDecl::isZeroLengthBitField() const {
return isUnnamedBitField() && !getBitWidth()->isValueDependent() &&
- getBitWidthValue(Ctx) == 0;
+ getBitWidthValue() == 0;
}
bool FieldDecl::isZeroSize(const ASTContext &Ctx) const {
- if (isZeroLengthBitField(Ctx))
+ if (isZeroLengthBitField())
return true;
// C++2a [intro.object]p7:
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 8989e46e4847cb..4163342118c2dc 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -993,7 +993,7 @@ void CXXRecordDecl::addedMember(Decl *D) {
// C++ [meta.unary.prop]p4: [LWG2358]
// T is a class type [...] with [...] no unnamed bit-fields of non-zero
// length
- if (data().Empty && !Field->isZeroLengthBitField(Context) &&
+ if (data().Empty && !Field->isZeroLengthBitField() &&
Context.getLangOpts().getClangABICompat() >
LangOptions::ClangABI::Ver6)
data().Empty = false;
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index ba66d362785674..5331357b5d1fef 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -196,8 +196,7 @@ bool Expr::isKnownToHaveBooleanValue(bool Semantic) const {
if (const FieldDecl *FD = E->getSourceBitField())
if (!Semantic && FD->getType()->isUnsignedIntegerType() &&
- !FD->getBitWidth()->isValueDependent() &&
- FD->getBitWidthValue(FD->getASTContext()) == 1)
+ !FD->getBitWidth()->isValueDependent() && FD->getBitWidthValue() == 1)
return true;
return false;
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 5768bb12ee38e8..2e680d1569f60f 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2875,7 +2875,7 @@ static bool truncateBitfieldValue(EvalInfo &Info, const Expr *E,
APSInt &Int = Value.getInt();
unsigned OldBitWidth = Int.getBitWidth();
- unsigned NewBitWidth = FD->getBitWidthValue(Info.Ctx);
+ unsigned NewBitWidth = FD->getBitWidthValue();
if (NewBitWidth < OldBitWidth)
Int = Int.trunc(NewBitWidth).extend(OldBitWidth);
return true;
diff --git a/clang/lib/AST/Randstruct.cpp b/clang/lib/AST/Randstruct.cpp
index b484afa4997bbc..4537ba5309e0bc 100644
--- a/clang/lib/AST/Randstruct.cpp
+++ b/clang/lib/AST/Randstruct.cpp
@@ -91,7 +91,7 @@ void randomizeStructureLayoutImpl(const ASTContext &Context,
auto FieldIter = FieldsOut.begin();
FieldDecl *FD = *FieldIter;
- if (FD->isBitField() && !FD->isZeroLengthBitField(Context)) {
+ if (FD->isBitField() && !FD->isZeroLengthBitField()) {
// Start a bitfield run if this is the first bitfield we have found.
if (!CurrentBitfieldRun)
CurrentBitfieldRun = std::make_unique<BitfieldRunBucket>();
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp
index f749d3a705fc99..e6af27e8c96772 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1542,7 +1542,7 @@ static bool isAIXLayout(const ASTContext &Context) {
void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
bool FieldPacked = Packed || D->hasAttr<PackedAttr>();
- uint64_t FieldSize = D->getBitWidthValue(Context);
+ uint64_t FieldSize = D->getBitWidthValue();
TypeInfo FieldInfo = Context.getTypeInfo(D->getType());
uint64_t StorageUnitSize = FieldInfo.Width;
unsigned FieldAlign = FieldInfo.Align;
@@ -3022,7 +3022,7 @@ void MicrosoftRecordLayoutBuilder::layoutField(const FieldDecl *FD) {
}
void MicrosoftRecordLayoutBuilder::layoutBitField(const FieldDecl *FD) {
- unsigned Width = FD->getBitWidthValue(Context);
+ unsigned Width = FD->getBitWidthValue();
if (Width == 0) {
layoutZeroWidthBitField(FD);
return;
@@ -3692,7 +3692,7 @@ static void DumpRecordLayout(raw_ostream &OS, const RecordDecl *RD,
if (Field.isBitField()) {
uint64_t LocalFieldByteOffsetInBits = C.toBits(FieldOffset - Offset);
unsigned Begin = LocalFieldOffsetInBits - LocalFieldByteOffsetInBits;
- unsigned Width = Field.getBitWidthValue(C);
+ unsigned Width = Field.getBitWidthValue();
PrintBitFieldOffset(OS, FieldOffset, Begin, Width, IndentLevel);
} else {
PrintOffset(OS, FieldOffset, IndentLevel);
diff --git a/clang/lib/CodeGen/ABIInfo.cpp b/clang/lib/CodeGen/ABIInfo.cpp
index 8e76cf15b642c6..642bca9e8b76da 100644
--- a/clang/lib/CodeGen/ABIInfo.cpp
+++ b/clang/lib/CodeGen/ABIInfo.cpp
@@ -106,7 +106,7 @@ bool ABIInfo::isHomogeneousAggregate(QualType Ty, const Type *&Base,
continue;
if (isZeroLengthBitfieldPermittedInHomogeneousAggregate() &&
- FD->isZeroLengthBitField(getContext()))
+ FD->isZeroLengthBitField())
continue;
uint64_t FldMembers;
diff --git a/clang/lib/CodeGen/ABIInfoImpl.cpp b/clang/lib/CodeGen/ABIInfoImpl.cpp
index 79300df15d0e29..795874059bda71 100644
--- a/clang/lib/CodeGen/ABIInfoImpl.cpp
+++ b/clang/lib/CodeGen/ABIInfoImpl.cpp
@@ -303,7 +303,7 @@ bool CodeGen::isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays,
bool CodeGen::isEmptyFieldForLayout(const ASTContext &Context,
const FieldDecl *FD) {
- if (FD->isZeroLengthBitField(Context))
+ if (FD->isZeroLengthBitField())
return true;
if (FD->isUnnamedBitField())
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 7b0ef4be986193..d497fcff37f87b 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -954,7 +954,7 @@ getTypeExpansion(QualType Ty, const ASTContext &Context) {
CharUnits UnionSize = CharUnits::Zero();
for (const auto *FD : RD->fields()) {
- if (FD->isZeroLengthBitField(Context))
+ if (FD->isZeroLengthBitField())
continue;
assert(!FD->isBitField() &&
"Cannot expand structure with bit-field members.");
@@ -974,7 +974,7 @@ getTypeExpansion(QualType Ty, const ASTContext &Context) {
}
for (const auto *FD : RD->fields()) {
- if (FD->isZeroLengthBitField(Context))
+ if (FD->isZeroLengthBitField())
continue;
assert(!FD->isBitField() &&
"Cannot expand structure with bit-field members.");
@@ -3682,7 +3682,7 @@ static void setUsedBits(CodeGenModule &CGM, const RecordType *RTy, int Offset,
for (auto I = RD->field_begin(), E = RD->field_end(); I != E; ++I, ++Idx) {
const FieldDecl *F = *I;
- if (F->isUnnamedBitField() || F->isZeroLengthBitField(Context) ||
+ if (F->isUnnamedBitField() || F->isZeroLengthBitField() ||
F->getType()->isIncompleteArrayType())
continue;
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index c45688bd1ed3ce..8c190732c8cdcf 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -945,7 +945,7 @@ namespace {
ASTContext &Ctx = CGF.getContext();
unsigned LastFieldSize =
LastField->isBitField()
- ? LastField->getBitWidthValue(Ctx)
+ ? LastField->getBitWidthValue()
: Ctx.toBits(
Ctx.getTypeInfoDataSizeInChars(LastField->getType()).Width);
uint64_t MemcpySizeBits = LastFieldOffset + LastFieldSize -
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 560d4ce293365e..d7e5e95b7873a0 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1721,8 +1721,7 @@ llvm::DIDerivedType *CGDebugInfo::createBitFieldSeparatorIfNeeded(
assert(PreviousBitfield->isBitField());
- ASTContext &Context = CGM.getContext();
- if (!PreviousBitfield->isZeroLengthBitField(Context))
+ if (!PreviousBitfield->isZeroLengthBitField())
return nullptr;
QualType Ty = PreviousBitfield->getType();
@@ -3214,9 +3213,8 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty,
if (!FType->isIncompleteArrayType()) {
// Bit size, align and offset of the type.
- FieldSize = Field->isBitField()
- ? Field->getBitWidthValue(CGM.getContext())
- : CGM.getContext().getTypeSize(FType);
+ FieldSize = Field->isBitField() ? Field->getBitWidthValue()
+ : CGM.getContext().getTypeSize(FType);
FieldAlign = getTypeAlignIfRequired(FType, CGM.getContext());
}
diff --git a/clang/lib/CodeGen/CGNonTrivialStruct.cpp b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
index 6a02e4dbf84d14..d90c44d770d14b 100644
--- a/clang/lib/CodeGen/CGNonTrivialStruct.cpp
+++ b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
@@ -25,7 +25,7 @@ using namespace CodeGen;
static uint64_t getFieldSize(const FieldDecl *FD, QualType FT,
ASTContext &Ctx) {
if (FD && FD->isBitField())
- return FD->getBitWidthValue(Ctx);
+ return FD->getBitWidthValue();
return Ctx.getTypeSize(FT);
}
@@ -255,7 +255,7 @@ struct GenBinaryFuncName : CopyStructVisitor<GenBinaryFuncName<IsMove>, IsMove>,
...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/122289
More information about the lldb-commits
mailing list