Skip to content

Commit 58ad6c6

Browse files
committed
clang-format ...
1 parent caeeebf commit 58ad6c6

File tree

9 files changed

+63
-62
lines changed

9 files changed

+63
-62
lines changed

clang/include/clang/CIR/Dialect/IR/CIRTypes.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ class StructType
8686
/// Create a identified and complete struct type.
8787
static StructType get(mlir::MLIRContext *context,
8888
llvm::ArrayRef<mlir::Type> members,
89-
mlir::StringAttr name, bool packed, bool padded, RecordKind kind,
90-
ASTRecordDeclInterface ast = {});
89+
mlir::StringAttr name, bool packed, bool padded,
90+
RecordKind kind, ASTRecordDeclInterface ast = {});
9191
static StructType
9292
getChecked(llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
9393
mlir::MLIRContext *context, llvm::ArrayRef<mlir::Type> members,
@@ -104,19 +104,21 @@ class StructType
104104

105105
/// Create a anonymous struct type (always complete).
106106
static StructType get(mlir::MLIRContext *context,
107-
llvm::ArrayRef<mlir::Type> members, bool packed,
108-
bool padded, RecordKind kind, ASTRecordDeclInterface ast = {});
107+
llvm::ArrayRef<mlir::Type> members, bool packed,
108+
bool padded, RecordKind kind,
109+
ASTRecordDeclInterface ast = {});
109110
static StructType
110111
getChecked(llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
111112
mlir::MLIRContext *context, llvm::ArrayRef<mlir::Type> members,
112-
bool packed, bool padded, RecordKind kind, ASTRecordDeclInterface ast = {});
113+
bool packed, bool padded, RecordKind kind,
114+
ASTRecordDeclInterface ast = {});
113115

114116
/// Validate the struct about to be constructed.
115117
static llvm::LogicalResult
116118
verifyInvariants(llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
117119
llvm::ArrayRef<mlir::Type> members, mlir::StringAttr name,
118-
bool incomplete, bool packed, bool padded, StructType::RecordKind kind,
119-
ASTRecordDeclInterface ast);
120+
bool incomplete, bool packed, bool padded,
121+
StructType::RecordKind kind, ASTRecordDeclInterface ast);
120122

121123
// Parse/print methods.
122124
static constexpr llvm::StringLiteral getMnemonic() { return {"struct"}; }
@@ -178,8 +180,8 @@ class StructType
178180
// FIXME: currently opaque because there's a cycle if CIRTypes.types include
179181
// from CIRAttrs.h. The implementation operates in terms of StructLayoutAttr
180182
// instead.
181-
mutable mlir::Attribute layoutInfo;
182-
//bool isPadded(const mlir::DataLayout &dataLayout) const;
183+
mutable mlir::Attribute layoutInfo;
184+
// bool isPadded(const mlir::DataLayout &dataLayout) const;
183185
void computeSizeAndAlignment(const mlir::DataLayout &dataLayout) const;
184186
};
185187

clang/include/clang/CIR/Dialect/IR/CIRTypesDetails.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct StructTypeStorage : public mlir::TypeStorage {
5252
ASTRecordDeclInterface ast;
5353

5454
StructTypeStorage(llvm::ArrayRef<mlir::Type> members, mlir::StringAttr name,
55-
bool incomplete, bool packed, bool padded,
55+
bool incomplete, bool packed, bool padded,
5656
StructType::RecordKind kind, ASTRecordDeclInterface ast)
5757
: members(members), name(name), incomplete(incomplete), packed(packed),
5858
padded(padded), kind(kind), ast(ast) {}
@@ -72,16 +72,15 @@ struct StructTypeStorage : public mlir::TypeStorage {
7272
static llvm::hash_code hashKey(const KeyTy &key) {
7373
if (key.name)
7474
return llvm::hash_combine(key.name, key.kind);
75-
return llvm::hash_combine(key.members, key.incomplete, key.packed,
75+
return llvm::hash_combine(key.members, key.incomplete, key.packed,
7676
key.padded, key.kind, key.ast);
7777
}
7878

7979
static StructTypeStorage *construct(mlir::TypeStorageAllocator &allocator,
8080
const KeyTy &key) {
81-
return new (allocator.allocate<StructTypeStorage>())
82-
StructTypeStorage(allocator.copyInto(key.members), key.name,
83-
key.incomplete, key.packed, key.padded,
84-
key.kind, key.ast);
81+
return new (allocator.allocate<StructTypeStorage>()) StructTypeStorage(
82+
allocator.copyInto(key.members), key.name, key.incomplete, key.packed,
83+
key.padded, key.kind, key.ast);
8584
}
8685

8786
/// Mutates the members and attributes an identified struct.
@@ -100,8 +99,8 @@ struct StructTypeStorage : public mlir::TypeStorage {
10099
// Mutation of complete structs are allowed if they change nothing.
101100
if (!incomplete)
102101
return mlir::success((this->members == members) &&
103-
(this->packed == packed) && (this->padded == padded) &&
104-
(this->ast == ast));
102+
(this->packed == packed) &&
103+
(this->padded == padded) && (this->ast == ast));
105104

106105
// Mutate incomplete struct.
107106
this->members = allocator.copyInto(members);

clang/lib/CIR/CodeGen/CIRAsm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,8 @@ mlir::LogicalResult CIRGenFunction::emitAsmStmt(const AsmStmt &S) {
619619
ResultType = ResultRegTypes[0];
620620
else if (ResultRegTypes.size() > 1) {
621621
auto sname = builder.getUniqueAnonRecordName();
622-
ResultType =
623-
builder.getCompleteStructTy(ResultRegTypes, sname, false, false, nullptr);
622+
ResultType = builder.getCompleteStructTy(ResultRegTypes, sname, false,
623+
false, nullptr);
624624
}
625625

626626
bool HasSideEffect = S.isVolatile() || S.getNumOutputs() == 0;

clang/lib/CIR/CodeGen/CIRGenBuilder.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
194194

195195
// Struct type not specified: create anon struct type from members.
196196
if (!structTy)
197-
structTy =
198-
getType<cir::StructType>(members, packed, padded, cir::StructType::Struct,
199-
/*ast=*/nullptr);
197+
structTy = getType<cir::StructType>(members, packed, padded,
198+
cir::StructType::Struct,
199+
/*ast=*/nullptr);
200200

201201
// Return zero or anonymous constant struct.
202202
if (isZero)
@@ -436,8 +436,7 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
436436

437437
/// Get a CIR anonymous struct type.
438438
cir::StructType getAnonStructTy(llvm::ArrayRef<mlir::Type> members,
439-
bool packed = false,
440-
bool padded = false,
439+
bool packed = false, bool padded = false,
441440
const clang::RecordDecl *ast = nullptr) {
442441
cir::ASTRecordDeclAttr astAttr = nullptr;
443442
auto kind = cir::StructType::RecordKind::Struct;
@@ -491,8 +490,8 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
491490
}
492491

493492
// Create or get the struct.
494-
auto type =
495-
getType<cir::StructType>(members, nameAttr, packed, padded, kind, astAttr);
493+
auto type = getType<cir::StructType>(members, nameAttr, packed, padded,
494+
kind, astAttr);
496495

497496
// Complete an incomplete struct or ensure the existing complete struct
498497
// matches the requested attributes.
@@ -503,8 +502,7 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
503502

504503
cir::StructType
505504
getCompleteStructType(mlir::ArrayAttr fields, bool packed = false,
506-
bool padded = false,
507-
llvm::StringRef name = "",
505+
bool padded = false, llvm::StringRef name = "",
508506
const clang::RecordDecl *ast = nullptr) {
509507
llvm::SmallVector<mlir::Type, 8> members;
510508
for (auto &attr : fields) {

clang/lib/CIR/CodeGen/CIRGenExprConst.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ mlir::Attribute ConstantAggregateBuilder::buildFrom(
436436
auto &builder = CGM.getBuilder();
437437
auto arrAttr = mlir::ArrayAttr::get(builder.getContext(),
438438
Packed ? PackedElems : UnpackedElems);
439-
439+
440440
auto strType = builder.getCompleteStructType(arrAttr, Packed);
441441
if (auto desired = dyn_cast<cir::StructType>(DesiredTy))
442442
if (desired.isLayoutIdentical(strType))
@@ -446,7 +446,7 @@ mlir::Attribute ConstantAggregateBuilder::buildFrom(
446446
}
447447

448448
void ConstantAggregateBuilder::condense(CharUnits Offset,
449-
mlir::Type DesiredTy) {
449+
mlir::Type DesiredTy) {
450450
CharUnits Size = getSize(DesiredTy);
451451

452452
std::optional<size_t> FirstElemToReplace = splitAt(Offset);
@@ -719,10 +719,10 @@ bool ConstStructBuilder::Build(InitListExpr *ILE, bool AllowOverwrite) {
719719
}
720720
}
721721

722-
if (ZeroInitPadding && !ApplyZeroInitPadding(Layout, AllowOverwrite, SizeSoFar))
722+
if (ZeroInitPadding &&
723+
!ApplyZeroInitPadding(Layout, AllowOverwrite, SizeSoFar))
723724
return false;
724725

725-
726726
return true;
727727
}
728728

@@ -862,11 +862,11 @@ bool ConstStructBuilder::ApplyZeroInitPadding(
862862
}
863863

864864
bool ConstStructBuilder::ApplyZeroInitPadding(const ASTRecordLayout &Layout,
865-
bool AllowOverwrite,
866-
CharUnits SizeSoFar) {
865+
bool AllowOverwrite,
866+
CharUnits SizeSoFar) {
867867
CharUnits TotalSize = Layout.getSize();
868868
if (SizeSoFar < TotalSize) {
869-
if (!AppendBytes(SizeSoFar, computePadding(CGM, TotalSize - SizeSoFar),
869+
if (!AppendBytes(SizeSoFar, computePadding(CGM, TotalSize - SizeSoFar),
870870
AllowOverwrite))
871871
return false;
872872
}

clang/lib/CIR/CodeGen/CIRRecordLayoutBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ struct CIRRecordLowering final {
199199
void appendPaddingBytes(CharUnits Size) {
200200
if (!Size.isZero()) {
201201
fieldTypes.push_back(getByteArrayType(Size));
202-
isPadded = 1;
202+
isPadded = 1;
203203
}
204204
}
205205

@@ -709,9 +709,9 @@ CIRGenTypes::computeRecordLayout(const RecordDecl *D, cir::StructType *Ty) {
709709
CIRRecordLowering baseBuilder(*this, D, /*Packed=*/builder.isPacked);
710710
baseBuilder.lower(/*NonVirtualBaseType=*/true);
711711
auto baseIdentifier = getRecordTypeName(D, ".base");
712-
BaseTy = Builder.getCompleteStructTy(
713-
baseBuilder.fieldTypes, baseIdentifier, baseBuilder.isPacked, baseBuilder.isPadded,
714-
D);
712+
BaseTy = Builder.getCompleteStructTy(baseBuilder.fieldTypes,
713+
baseIdentifier, baseBuilder.isPacked,
714+
baseBuilder.isPadded, D);
715715
// TODO(cir): add something like addRecordTypeName
716716

717717
// BaseTy and Ty must agree on their packedness for getCIRFieldNo to work

clang/lib/CIR/Dialect/IR/CIRDataLayout.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,16 +214,17 @@ llvm::TypeSize CIRDataLayout::getTypeSizeInBits(mlir::Type Ty) const {
214214
// of handling unions particularities. We should have a separate union type.
215215
// if (structTy.isUnion()) {
216216
// auto largestMember = structTy.getLargestMember(layout);
217-
// return llvm::TypeSize::getFixed(layout.getTypeSizeInBits(largestMember));
217+
// return
218+
// llvm::TypeSize::getFixed(layout.getTypeSizeInBits(largestMember));
218219
// }
219220

220221
// FIXME(cir): We should be able to query the size of a struct directly to
221222
// its data layout implementation instead of requiring a separate
222223
// StructLayout object.
223224
// Get the layout annotation... which is lazily created on demand.
224225
return structTy.getTypeSizeInBits(layout, {});
225-
226-
//return getStructLayout(structTy)->getSizeInBits();
226+
227+
// return getStructLayout(structTy)->getSizeInBits();
227228
}
228229

229230
// FIXME(cir): This does not account for different address spaces, and relies

clang/lib/CIR/Dialect/IR/CIRTypes.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ Type StructType::parse(mlir::AsmParser &parser) {
173173

174174
if (parser.parseOptionalKeyword("packed").succeeded())
175175
packed = true;
176-
176+
177177
if (parser.parseOptionalKeyword("padded").succeeded())
178178
padded = true;
179179

@@ -273,7 +273,8 @@ void StructType::print(mlir::AsmPrinter &printer) const {
273273
mlir::LogicalResult StructType::verifyInvariants(
274274
llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
275275
llvm::ArrayRef<mlir::Type> members, mlir::StringAttr name, bool incomplete,
276-
bool packed, bool padded, cir::StructType::RecordKind kind, ASTRecordDeclInterface ast) {
276+
bool packed, bool padded, cir::StructType::RecordKind kind,
277+
ASTRecordDeclInterface ast) {
277278
if (name && name.getValue().empty()) {
278279
emitError() << "identified structs cannot have an empty name";
279280
return mlir::failure();
@@ -283,10 +284,10 @@ mlir::LogicalResult StructType::verifyInvariants(
283284

284285
void StructType::dropAst() { getImpl()->ast = nullptr; }
285286
StructType StructType::get(::mlir::MLIRContext *context, ArrayRef<Type> members,
286-
StringAttr name, bool packed, bool padded, RecordKind kind,
287-
ASTRecordDeclInterface ast) {
288-
return Base::get(context, members, name, /*incomplete=*/false, packed, padded, kind,
289-
ast);
287+
StringAttr name, bool packed, bool padded,
288+
RecordKind kind, ASTRecordDeclInterface ast) {
289+
return Base::get(context, members, name, /*incomplete=*/false, packed, padded,
290+
kind, ast);
290291
}
291292

292293
StructType StructType::getChecked(
@@ -300,16 +301,17 @@ StructType StructType::getChecked(
300301
StructType StructType::get(::mlir::MLIRContext *context, StringAttr name,
301302
RecordKind kind) {
302303
return Base::get(context, /*members=*/ArrayRef<Type>{}, name,
303-
/*incomplete=*/true, /*packed=*/false, /*padded=*/false, kind,
304+
/*incomplete=*/true, /*packed=*/false, /*padded=*/false,
305+
kind,
304306
/*ast=*/ASTRecordDeclInterface{});
305307
}
306308

307309
StructType StructType::getChecked(
308310
::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError,
309311
::mlir::MLIRContext *context, StringAttr name, RecordKind kind) {
310312
return Base::getChecked(emitError, context, ArrayRef<Type>{}, name,
311-
/*incomplete=*/true, /*packed=*/false, /*padded=*/false, kind,
312-
ASTRecordDeclInterface{});
313+
/*incomplete=*/true, /*packed=*/false,
314+
/*padded=*/false, kind, ASTRecordDeclInterface{});
313315
}
314316

315317
StructType StructType::get(::mlir::MLIRContext *context, ArrayRef<Type> members,
@@ -324,8 +326,7 @@ StructType StructType::getChecked(
324326
::mlir::MLIRContext *context, ArrayRef<Type> members, bool packed,
325327
bool padded, RecordKind kind, ASTRecordDeclInterface ast) {
326328
return Base::getChecked(emitError, context, members, StringAttr{},
327-
/*incomplete=*/false, packed, padded,
328-
kind, ast);
329+
/*incomplete=*/false, packed, padded, kind, ast);
329330
}
330331

331332
::llvm::ArrayRef<mlir::Type> StructType::getMembers() const {
@@ -527,10 +528,10 @@ void StructType::computeSizeAndAlignment(
527528
bool dontCountLastElt = isUnion() && getPadded();
528529
if (dontCountLastElt)
529530
numElements--;
530-
531+
531532
// Loop over each of the elements, placing them in memory.
532533
memberOffsets.reserve(numElements);
533-
534+
534535
for (unsigned i = 0, e = numElements; i != e; ++i) {
535536
auto ty = members[i];
536537

@@ -571,7 +572,7 @@ void StructType::computeSizeAndAlignment(
571572
structSize = largestMemberSize;
572573
if (getPadded()) {
573574
memberOffsets.push_back(mlir::IntegerAttr::get(
574-
mlir::IntegerType::get(getContext(), 32), structSize));
575+
mlir::IntegerType::get(getContext(), 32), structSize));
575576
auto ty = getMembers()[numElements];
576577
structSize += dataLayout.getTypeSize(ty);
577578
isPadded = true;
@@ -1067,9 +1068,8 @@ static mlir::Type getMethodLayoutType(mlir::MLIRContext *ctx) {
10671068
// TODO: consider member function pointer layout in other ABIs
10681069
auto voidPtrTy = cir::PointerType::get(cir::VoidType::get(ctx));
10691070
mlir::Type fields[2]{voidPtrTy, voidPtrTy};
1070-
return cir::StructType::get(ctx, fields, /*packed=*/false,
1071-
/*padded=*/false,
1072-
cir::StructType::Struct);
1071+
return cir::StructType::get(ctx, fields, /*packed=*/false,
1072+
/*padded=*/false, cir::StructType::Struct);
10731073
}
10741074

10751075
llvm::TypeSize

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4343,19 +4343,20 @@ void prepareTypeConverter(mlir::LLVMTypeConverter &converter,
43434343
switch (type.getKind()) {
43444344
case cir::StructType::Class:
43454345
// TODO(cir): This should be properly validated.
4346-
case cir::StructType::Struct:
4346+
case cir::StructType::Struct:
43474347
for (auto ty : type.getMembers())
43484348
llvmMembers.push_back(convertTypeForMemory(converter, dataLayout, ty));
43494349
break;
43504350
// Unions are lowered as only the largest member.
4351-
case cir::StructType::Union: {
4351+
case cir::StructType::Union: {
43524352
auto largestMember = type.getLargestMember(dataLayout);
43534353
if (largestMember)
43544354
llvmMembers.push_back(
43554355
convertTypeForMemory(converter, dataLayout, largestMember));
43564356
if (type.getPadded()) {
43574357
auto last = *type.getMembers().rbegin();
4358-
llvmMembers.push_back(convertTypeForMemory(converter, dataLayout, last));
4358+
llvmMembers.push_back(
4359+
convertTypeForMemory(converter, dataLayout, last));
43594360
}
43604361
break;
43614362
}

0 commit comments

Comments
 (0)