Skip to content

Commit

Permalink
[clang][NFC] Fix FieldDecl::isUnnamedBitfield() capitalization (llvm#…
Browse files Browse the repository at this point in the history
…89048)

We always capitalize bitfield as "BitField".
  • Loading branch information
tbaederr authored Apr 18, 2024
1 parent fbca90b commit 3d56ea0
Show file tree
Hide file tree
Showing 29 changed files with 74 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ void ProTypeMemberInitCheck::checkMissingMemberInitializer(
if (!F->hasInClassInitializer() &&
utils::type_traits::isTriviallyDefaultConstructible(F->getType(),
Context) &&
!isEmpty(Context, F->getType()) && !F->isUnnamedBitfield() &&
!isEmpty(Context, F->getType()) && !F->isUnnamedBitField() &&
!AnyMemberHasInitPerUnion)
FieldsToInit.insert(F);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ getAllNamedFields(const CXXRecordDecl *Record) {
std::set<const FieldDecl *> Result;
for (const auto *Field : Record->fields()) {
// Static data members are not in this range.
if (Field->isUnnamedBitfield())
if (Field->isUnnamedBitField())
continue;
Result.insert(Field);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ ExceptionSpecAnalyzer::analyzeRecord(const CXXRecordDecl *RecordDecl,
}

for (const auto *FDecl : RecordDecl->fields())
if (!FDecl->isInvalidDecl() && !FDecl->isUnnamedBitfield()) {
if (!FDecl->isInvalidDecl() && !FDecl->isUnnamedBitField()) {
State Result = analyzeFieldDecl(FDecl, Kind);
if (Result == State::Throwing || Result == State::Unknown)
return Result;
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3149,7 +3149,7 @@ class FieldDecl : public DeclaratorDecl, public Mergeable<FieldDecl> {
bool isBitField() const { return BitField; }

/// Determines whether this is an unnamed bitfield.
bool isUnnamedBitfield() const { return isBitField() && !getDeclName(); }
bool isUnnamedBitField() const { return isBitField() && !getDeclName(); }

/// Determines whether this field is a
/// representative for an anonymous struct or union. Such fields are
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/AST/APValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,8 @@ void APValue::printPretty(raw_ostream &Out, const PrintingPolicy &Policy,
for (const auto *FI : RD->fields()) {
if (!First)
Out << ", ";
if (FI->isUnnamedBitfield()) continue;
if (FI->isUnnamedBitField())
continue;
getStructField(FI->getFieldIndex()).
printPretty(Out, Policy, FI->getType(), Ctx);
First = false;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2684,7 +2684,7 @@ getSubobjectSizeInBits(const FieldDecl *Field, const ASTContext &Context,
if (Field->isBitField()) {
// If we have explicit padding bits, they don't contribute bits
// to the actual object representation, so return 0.
if (Field->isUnnamedBitfield())
if (Field->isUnnamedBitField())
return 0;

int64_t BitfieldSize = Field->getBitWidthValue(Context);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4597,7 +4597,7 @@ unsigned FieldDecl::getBitWidthValue(const ASTContext &Ctx) const {
}

bool FieldDecl::isZeroLengthBitField(const ASTContext &Ctx) const {
return isUnnamedBitfield() && !getBitWidth()->isValueDependent() &&
return isUnnamedBitField() && !getBitWidth()->isValueDependent() &&
getBitWidthValue(Ctx) == 0;
}

Expand Down
7 changes: 4 additions & 3 deletions clang/lib/AST/DeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ bool CXXRecordDecl::hasSubobjectAtOffsetZeroOfEmptyBaseType(
for (auto *FD : X->fields()) {
// FIXME: Should we really care about the type of the first non-static
// data member of a non-union if there are preceding unnamed bit-fields?
if (FD->isUnnamedBitfield())
if (FD->isUnnamedBitField())
continue;

if (!IsFirstField && !FD->isZeroSize(Ctx))
Expand Down Expand Up @@ -947,7 +947,7 @@ void CXXRecordDecl::addedMember(Decl *D) {
// A declaration for a bit-field that omits the identifier declares an
// unnamed bit-field. Unnamed bit-fields are not members and cannot be
// initialized.
if (Field->isUnnamedBitfield()) {
if (Field->isUnnamedBitField()) {
// C++ [meta.unary.prop]p4: [LWG2358]
// T is a class type [...] with [...] no unnamed bit-fields of non-zero
// length
Expand Down Expand Up @@ -3469,7 +3469,8 @@ static bool isValidStructGUID(ASTContext &Ctx, QualType T) {
return false;
auto MatcherIt = Fields.begin();
for (const FieldDecl *FD : RD->fields()) {
if (FD->isUnnamedBitfield()) continue;
if (FD->isUnnamedBitField())
continue;
if (FD->isBitField() || MatcherIt == Fields.end() ||
!(*MatcherIt)(FD->getType()))
return false;
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2044,7 +2044,7 @@ const FieldDecl *CastExpr::getTargetFieldForToUnionCast(const RecordDecl *RD,
for (Field = RD->field_begin(), FieldEnd = RD->field_end();
Field != FieldEnd; ++Field) {
if (Ctx.hasSameUnqualifiedType(Field->getType(), OpType) &&
!Field->isUnnamedBitfield()) {
!Field->isUnnamedBitField()) {
return *Field;
}
}
Expand Down Expand Up @@ -3393,7 +3393,7 @@ bool Expr::isConstantInitializer(ASTContext &Ctx, bool IsForRef,
continue;

// Don't emit anonymous bitfields, they just affect layout.
if (Field->isUnnamedBitfield())
if (Field->isUnnamedBitField())
continue;

if (ElementNo < ILE->getNumInits()) {
Expand Down
18 changes: 9 additions & 9 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2492,7 +2492,7 @@ static bool CheckEvaluationResult(CheckEvaluationResultKind CERK,
}
}
for (const auto *I : RD->fields()) {
if (I->isUnnamedBitfield())
if (I->isUnnamedBitField())
continue;

if (!CheckEvaluationResult(CERK, Info, DiagLoc, I->getType(),
Expand Down Expand Up @@ -3529,7 +3529,7 @@ static bool isReadByLvalueToRvalueConversion(const CXXRecordDecl *RD) {
return false;

for (auto *Field : RD->fields())
if (!Field->isUnnamedBitfield() &&
if (!Field->isUnnamedBitField() &&
isReadByLvalueToRvalueConversion(Field->getType()))
return true;

Expand Down Expand Up @@ -4898,7 +4898,7 @@ static bool handleDefaultInitValue(QualType T, APValue &Result) {
handleDefaultInitValue(I->getType(), Result.getStructBase(Index));

for (const auto *I : RD->fields()) {
if (I->isUnnamedBitfield())
if (I->isUnnamedBitField())
continue;
Success &= handleDefaultInitValue(
I->getType(), Result.getStructField(I->getFieldIndex()));
Expand Down Expand Up @@ -6436,7 +6436,7 @@ static bool HandleConstructorCall(const Expr *E, const LValue &This,
// Default-initialize any fields with no explicit initializer.
for (; !declaresSameEntity(*FieldIt, FD); ++FieldIt) {
assert(FieldIt != RD->field_end() && "missing field?");
if (!FieldIt->isUnnamedBitfield())
if (!FieldIt->isUnnamedBitField())
Success &= handleDefaultInitValue(
FieldIt->getType(),
Result.getStructField(FieldIt->getFieldIndex()));
Expand Down Expand Up @@ -6546,7 +6546,7 @@ static bool HandleConstructorCall(const Expr *E, const LValue &This,
// Default-initialize any remaining fields.
if (!RD->isUnion()) {
for (; FieldIt != RD->field_end(); ++FieldIt) {
if (!FieldIt->isUnnamedBitfield())
if (!FieldIt->isUnnamedBitField())
Success &= handleDefaultInitValue(
FieldIt->getType(),
Result.getStructField(FieldIt->getFieldIndex()));
Expand Down Expand Up @@ -6708,7 +6708,7 @@ static bool HandleDestructionImpl(EvalInfo &Info, SourceRange CallRange,
// fields first and then walk them backwards.
SmallVector<FieldDecl*, 16> Fields(RD->fields());
for (const FieldDecl *FD : llvm::reverse(Fields)) {
if (FD->isUnnamedBitfield())
if (FD->isUnnamedBitField())
continue;

LValue Subobject = This;
Expand Down Expand Up @@ -10220,7 +10220,7 @@ static bool HandleClassZeroInitialization(EvalInfo &Info, const Expr *E,

for (const auto *I : RD->fields()) {
// -- if T is a reference type, no initialization is performed.
if (I->isUnnamedBitfield() || I->getType()->isReferenceType())
if (I->isUnnamedBitField() || I->getType()->isReferenceType())
continue;

LValue Subobject = This;
Expand All @@ -10243,7 +10243,7 @@ bool RecordExprEvaluator::ZeroInitialization(const Expr *E, QualType T) {
// C++11 [dcl.init]p5: If T is a (possibly cv-qualified) union type, the
// object's first non-static named data member is zero-initialized
RecordDecl::field_iterator I = RD->field_begin();
while (I != RD->field_end() && (*I)->isUnnamedBitfield())
while (I != RD->field_end() && (*I)->isUnnamedBitField())
++I;
if (I == RD->field_end()) {
Result = APValue((const FieldDecl*)nullptr);
Expand Down Expand Up @@ -10390,7 +10390,7 @@ bool RecordExprEvaluator::VisitCXXParenListOrInitListExpr(
for (const auto *Field : RD->fields()) {
// Anonymous bit-fields are not considered members of the class for
// purposes of aggregate initialization.
if (Field->isUnnamedBitfield())
if (Field->isUnnamedBitField())
continue;

LValue Subobject = This;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/Interp/EvaluationResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static bool CheckFieldsInitialized(InterpState &S, SourceLocation Loc,
Result &= CheckFieldsInitialized(S, Loc, FieldPtr, FieldPtr.getRecord());
} else if (FieldType->isIncompleteArrayType()) {
// Nothing to do here.
} else if (F.Decl->isUnnamedBitfield()) {
} else if (F.Decl->isUnnamedBitField()) {
// Nothing do do here.
} else if (FieldType->isArrayType()) {
const auto *CAT =
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/AST/ItaniumMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6176,7 +6176,7 @@ static bool isZeroInitialized(QualType T, const APValue &V) {
}
I = 0;
for (const FieldDecl *FD : RD->fields()) {
if (!FD->isUnnamedBitfield() &&
if (!FD->isUnnamedBitField() &&
!isZeroInitialized(FD->getType(), V.getStructField(I)))
return false;
++I;
Expand All @@ -6189,7 +6189,7 @@ static bool isZeroInitialized(QualType T, const APValue &V) {
assert(RD && "unexpected type for union value");
// Zero-initialization zeroes the first non-unnamed-bitfield field, if any.
for (const FieldDecl *FD : RD->fields()) {
if (!FD->isUnnamedBitfield())
if (!FD->isUnnamedBitField())
return V.getUnionField() && declaresSameEntity(FD, V.getUnionField()) &&
isZeroInitialized(FD->getType(), V.getUnionValue());
}
Expand Down Expand Up @@ -6331,7 +6331,7 @@ void CXXNameMangler::mangleValueInTemplateArg(QualType T, const APValue &V,
llvm::SmallVector<const FieldDecl *, 16> Fields(RD->fields());
while (
!Fields.empty() &&
(Fields.back()->isUnnamedBitfield() ||
(Fields.back()->isUnnamedBitField() ||
isZeroInitialized(Fields.back()->getType(),
V.getStructField(Fields.back()->getFieldIndex())))) {
Fields.pop_back();
Expand All @@ -6351,7 +6351,7 @@ void CXXNameMangler::mangleValueInTemplateArg(QualType T, const APValue &V,
for (unsigned I = 0, N = Bases.size(); I != N; ++I)
mangleValueInTemplateArg(Bases[I].getType(), V.getStructBase(I), false);
for (unsigned I = 0, N = Fields.size(); I != N; ++I) {
if (Fields[I]->isUnnamedBitfield())
if (Fields[I]->isUnnamedBitField())
continue;
mangleValueInTemplateArg(Fields[I]->getType(),
V.getStructField(Fields[I]->getFieldIndex()),
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/MicrosoftMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1933,7 +1933,7 @@ void MicrosoftCXXNameMangler::mangleTemplateArgValue(QualType T,
for (const CXXBaseSpecifier &B : RD->bases())
mangleTemplateArgValue(B.getType(), V.getStructBase(BaseIndex++), TAK);
for (const FieldDecl *FD : RD->fields())
if (!FD->isUnnamedBitfield())
if (!FD->isUnnamedBitField())
mangleTemplateArgValue(FD->getType(),
V.getStructField(FD->getFieldIndex()), TAK,
/*WithScalarType*/ true);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Analysis/FlowSensitive/ASTOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ getFieldsForInitListExpr(const InitListExpr *InitList) {
// fields to avoid mapping inits to the wrongs fields.
llvm::copy_if(
RD->fields(), std::back_inserter(Fields),
[](const FieldDecl *Field) { return !Field->isUnnamedBitfield(); });
[](const FieldDecl *Field) { return !Field->isUnnamedBitField(); });
return Fields;
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Analysis/UninitializedValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static bool recordIsNotEmpty(const RecordDecl *RD) {
// We consider a record decl to be empty if it contains only unnamed bit-
// fields, zero-width fields, and fields of empty record type.
for (const auto *FD : RD->fields()) {
if (FD->isUnnamedBitfield())
if (FD->isUnnamedBitField())
continue;
if (FD->isZeroSize(FD->getASTContext()))
continue;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/ABIInfoImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ Address CodeGen::emitMergePHI(CodeGenFunction &CGF, Address Addr1,

bool CodeGen::isEmptyField(ASTContext &Context, const FieldDecl *FD,
bool AllowArrays, bool AsIfNoUniqueAddr) {
if (FD->isUnnamedBitfield())
if (FD->isUnnamedBitField())
return true;

QualType FT = FD->getType();
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3665,7 +3665,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(Context) ||
F->getType()->isIncompleteArrayType())
continue;

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4704,7 +4704,7 @@ unsigned CodeGenFunction::getDebugInfoFIndex(const RecordDecl *Rec,
for (auto *F : Rec->getDefinition()->fields()) {
if (I == FieldIndex)
break;
if (F->isUnnamedBitfield())
if (F->isUnnamedBitField())
Skipped++;
I++;
}
Expand Down
8 changes: 5 additions & 3 deletions clang/lib/CodeGen/CGExprAgg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1755,7 +1755,9 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr(
// Make sure that it's really an empty and not a failure of
// semantic analysis.
for (const auto *Field : record->fields())
assert((Field->isUnnamedBitfield() || Field->isAnonymousStructOrUnion()) && "Only unnamed bitfields or ananymous class allowed");
assert(
(Field->isUnnamedBitField() || Field->isAnonymousStructOrUnion()) &&
"Only unnamed bitfields or ananymous class allowed");
#endif
return;
}
Expand Down Expand Up @@ -1783,7 +1785,7 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr(
break;

// Always skip anonymous bitfields.
if (field->isUnnamedBitfield())
if (field->isUnnamedBitField())
continue;

// We're done if we reach the end of the explicit initializers, we
Expand Down Expand Up @@ -1988,7 +1990,7 @@ static CharUnits GetNumNonZeroBytesInInit(const Expr *E, CodeGenFunction &CGF) {
if (Field->getType()->isIncompleteArrayType() ||
ILEElement == ILE->getNumInits())
break;
if (Field->isUnnamedBitfield())
if (Field->isUnnamedBitField())
continue;

const Expr *E = ILE->getInit(ILEElement++);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ void CodeGenFunction::EmitNewArrayInitializer(
if (auto *CXXRD = dyn_cast<CXXRecordDecl>(RType->getDecl()))
NumElements = CXXRD->getNumBases();
for (auto *Field : RType->getDecl()->fields())
if (!Field->isUnnamedBitfield())
if (!Field->isUnnamedBitField())
++NumElements;
// FIXME: Recurse into nested InitListExprs.
if (ILE->getNumInits() == NumElements)
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/CGExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ bool ConstStructBuilder::Build(InitListExpr *ILE, bool AllowOverwrite) {
continue;

// Don't emit anonymous bitfields.
if (Field->isUnnamedBitfield())
if (Field->isUnnamedBitField())
continue;

// Get the initializer. A struct can include fields without initializers,
Expand Down Expand Up @@ -840,7 +840,7 @@ bool ConstStructBuilder::Build(const APValue &Val, const RecordDecl *RD,
continue;

// Don't emit anonymous bitfields or zero-sized fields.
if (Field->isUnnamedBitfield() || Field->isZeroSize(CGM.getContext()))
if (Field->isUnnamedBitField() || Field->isZeroSize(CGM.getContext()))
continue;

// Emit the value of the initializer.
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CodeGenTBAA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ llvm::MDNode *CodeGenTBAA::getBaseTypeInfoHelper(const Type *Ty) {
});
}
for (FieldDecl *Field : RD->fields()) {
if (Field->isZeroSize(Context) || Field->isUnnamedBitfield())
if (Field->isZeroSize(Context) || Field->isUnnamedBitField())
continue;
QualType FieldQTy = Field->getType();
llvm::MDNode *TypeNode = isValidBaseType(FieldQTy)
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/Targets/X86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2087,7 +2087,7 @@ void X86_64ABIInfo::classify(QualType Ty, uint64_t OffsetBase, Class &Lo,
bool BitField = i->isBitField();

// Ignore padding bit-fields.
if (BitField && i->isUnnamedBitfield())
if (BitField && i->isUnnamedBitField())
continue;

// AMD64-ABI 3.2.3p2: Rule 1. If the size of an object is larger than
Expand Down Expand Up @@ -2128,7 +2128,7 @@ void X86_64ABIInfo::classify(QualType Ty, uint64_t OffsetBase, Class &Lo,
// structure to be passed in memory even if unaligned, and
// therefore they can straddle an eightbyte.
if (BitField) {
assert(!i->isUnnamedBitfield());
assert(!i->isUnnamedBitField());
uint64_t Offset = OffsetBase + Layout.getFieldOffset(idx);
uint64_t Size = i->getBitWidthValue(getContext());

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaChecking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ struct BuiltinDumpStructGenerator {
for (auto *D : RD->decls()) {
auto *IFD = dyn_cast<IndirectFieldDecl>(D);
auto *FD = IFD ? IFD->getAnonField() : dyn_cast<FieldDecl>(D);
if (!FD || FD->isUnnamedBitfield() || FD->isAnonymousStructOrUnion())
if (!FD || FD->isUnnamedBitField() || FD->isAnonymousStructOrUnion())
continue;

llvm::SmallString<20> Format = llvm::StringRef("%s%s %s ");
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19683,7 +19683,7 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl,
E = Record->field_end();
(NonBitFields == 0 || ZeroSize) && I != E; ++I) {
IsEmpty = false;
if (I->isUnnamedBitfield()) {
if (I->isUnnamedBitField()) {
if (!I->isZeroLengthBitField(Context))
ZeroSize = false;
} else {
Expand Down
Loading

0 comments on commit 3d56ea0

Please sign in to comment.