Skip to content

Commit 9cc06ce

Browse files
committed
make clang format happy
1 parent 121f2a9 commit 9cc06ce

File tree

7 files changed

+66
-63
lines changed

7 files changed

+66
-63
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6360,7 +6360,8 @@ LValue CodeGenFunction::EmitPseudoObjectLValue(const PseudoObjectExpr *E) {
63606360
return emitPseudoObjectExpr(*this, E, true, AggValueSlot::ignored()).LV;
63616361
}
63626362

6363-
llvm::Value* CodeGenFunction::PerformLoad(std::pair<Address, llvm::Value *> &GEP) {
6363+
llvm::Value *
6364+
CodeGenFunction::PerformLoad(std::pair<Address, llvm::Value *> &GEP) {
63646365
Address GEPAddress = GEP.first;
63656366
llvm::Value *Idx = GEP.second;
63666367
llvm::Value *V = Builder.CreateLoad(GEPAddress, "load");
@@ -6370,8 +6371,9 @@ llvm::Value* CodeGenFunction::PerformLoad(std::pair<Address, llvm::Value *> &GEP
63706371
return V;
63716372
}
63726373

6373-
llvm::Value* CodeGenFunction::PerformStore(std::pair<Address, llvm::Value *> &GEP,
6374-
llvm::Value *Val) {
6374+
llvm::Value *
6375+
CodeGenFunction::PerformStore(std::pair<Address, llvm::Value *> &GEP,
6376+
llvm::Value *Val) {
63756377
Address GEPAddress = GEP.first;
63766378
llvm::Value *Idx = GEP.second;
63776379
if (Idx) {
@@ -6382,20 +6384,21 @@ llvm::Value* CodeGenFunction::PerformStore(std::pair<Address, llvm::Value *> &GE
63826384
}
63836385
}
63846386

6385-
void CodeGenFunction::FlattenAccessAndType(Address Val, QualType SrcTy,
6386-
SmallVector<llvm::Value *, 4> &IdxList,
6387-
SmallVector<std::pair<Address, llvm::Value *>, 16> &GEPList,
6388-
SmallVector<QualType> &FlatTypes) {
6389-
llvm::IntegerType *IdxTy = llvm::IntegerType::get(getLLVMContext(),32);
6387+
void CodeGenFunction::FlattenAccessAndType(
6388+
Address Val, QualType SrcTy, SmallVector<llvm::Value *, 4> &IdxList,
6389+
SmallVector<std::pair<Address, llvm::Value *>, 16> &GEPList,
6390+
SmallVector<QualType> &FlatTypes) {
6391+
llvm::IntegerType *IdxTy = llvm::IntegerType::get(getLLVMContext(), 32);
63906392
if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(SrcTy)) {
63916393
uint64_t Size = CAT->getZExtSize();
6392-
for(unsigned i = 0; i < Size; i ++) {
6394+
for (unsigned i = 0; i < Size; i++) {
63936395
// flatten each member of the array
63946396
// add index of this element to index list
63956397
llvm::Value *Idx = llvm::ConstantInt::get(IdxTy, i);
63966398
IdxList.push_back(Idx);
63976399
// recur on this object
6398-
FlattenAccessAndType(Val, CAT->getElementType(), IdxList, GEPList, FlatTypes);
6400+
FlattenAccessAndType(Val, CAT->getElementType(), IdxList, GEPList,
6401+
FlatTypes);
63996402
// remove index of this element from index list
64006403
IdxList.pop_back();
64016404
}
@@ -6405,7 +6408,7 @@ void CodeGenFunction::FlattenAccessAndType(Address Val, QualType SrcTy,
64056408
// do I need to check if its a cxx record decl?
64066409

64076410
for (auto fieldIter = Record->field_begin(), fieldEnd = Record->field_end();
6408-
fieldIter != fieldEnd; ++fieldIter) {
6411+
fieldIter != fieldEnd; ++fieldIter) {
64096412
// get the field number
64106413
unsigned FieldNum = RL.getLLVMFieldNo(*fieldIter);
64116414
// can we just do *fieldIter->getFieldIndex();
@@ -6414,16 +6417,16 @@ void CodeGenFunction::FlattenAccessAndType(Address Val, QualType SrcTy,
64146417
IdxList.push_back(Idx);
64156418
// recur on the field
64166419
FlattenAccessAndType(Val, fieldIter->getType(), IdxList, GEPList,
6417-
FlatTypes);
6420+
FlatTypes);
64186421
// remove index of this element from index list
64196422
IdxList.pop_back();
64206423
}
64216424
} else if (const VectorType *VT = SrcTy->getAs<VectorType>()) {
64226425
llvm::Type *VTy = ConvertTypeForMem(SrcTy);
64236426
CharUnits Align = getContext().getTypeAlignInChars(SrcTy);
6424-
Address GEP = Builder.CreateInBoundsGEP(Val, IdxList,
6425-
VTy, Align, "vector.gep");
6426-
for(unsigned i = 0; i < VT->getNumElements(); i ++) {
6427+
Address GEP =
6428+
Builder.CreateInBoundsGEP(Val, IdxList, VTy, Align, "vector.gep");
6429+
for (unsigned i = 0; i < VT->getNumElements(); i++) {
64276430
// add index to the list
64286431
llvm::Value *Idx = llvm::ConstantInt::get(IdxTy, i);
64296432
// create gep. no need to recur since its always a scalar
@@ -6435,8 +6438,7 @@ void CodeGenFunction::FlattenAccessAndType(Address Val, QualType SrcTy,
64356438
// create a gep
64366439
llvm::Type *Ty = ConvertTypeForMem(SrcTy);
64376440
CharUnits Align = getContext().getTypeAlignInChars(SrcTy);
6438-
Address GEP = Builder.CreateInBoundsGEP(Val, IdxList,
6439-
Ty, Align, "gep");
6441+
Address GEP = Builder.CreateInBoundsGEP(Val, IdxList, Ty, Align, "gep");
64406442
GEPList.push_back({GEP, NULL});
64416443
FlatTypes.push_back(SrcTy);
64426444
}

clang/lib/CodeGen/CGExprAgg.cpp

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -491,50 +491,45 @@ static bool isTrivialFiller(Expr *E) {
491491
return false;
492492
}
493493

494-
495-
496494
// emit a flat cast where the RHS is a scalar, including vector
497495
static void EmitHLSLScalarFlatCast(CodeGenFunction &CGF, Address DestVal,
498-
QualType DestTy, llvm::Value *SrcVal,
499-
QualType SrcTy, SourceLocation Loc) {
496+
QualType DestTy, llvm::Value *SrcVal,
497+
QualType SrcTy, SourceLocation Loc) {
500498
// Flatten our destination
501499
SmallVector<QualType> DestTypes; // Flattened type
502500
SmallVector<llvm::Value *, 4> IdxList;
503501
SmallVector<std::pair<Address, llvm::Value *>, 16> StoreGEPList;
504502
// ^^ Flattened accesses to DestVal we want to store into
505-
CGF.FlattenAccessAndType(DestVal, DestTy, IdxList, StoreGEPList,
506-
DestTypes);
503+
CGF.FlattenAccessAndType(DestVal, DestTy, IdxList, StoreGEPList, DestTypes);
507504

508505
if (const VectorType *VT = SrcTy->getAs<VectorType>()) {
509506
SrcTy = VT->getElementType();
510507
assert(StoreGEPList.size() <= VT->getNumElements() &&
511-
"Cannot perform HLSL flat cast when vector source \
508+
"Cannot perform HLSL flat cast when vector source \
512509
object has less elements than flattened destination \
513510
object.");
514-
for(unsigned i = 0; i < StoreGEPList.size(); i ++) {
515-
llvm::Value *Load = CGF.Builder.CreateExtractElement(SrcVal, i,
516-
"vec.load");
517-
llvm::Value *Cast = CGF.EmitScalarConversion(Load, SrcTy,
518-
DestTypes[i],
519-
Loc);
520-
CGF.PerformStore(StoreGEPList[i], Cast);
521-
}
522-
return;
511+
for (unsigned i = 0; i < StoreGEPList.size(); i++) {
512+
llvm::Value *Load =
513+
CGF.Builder.CreateExtractElement(SrcVal, i, "vec.load");
514+
llvm::Value *Cast =
515+
CGF.EmitScalarConversion(Load, SrcTy, DestTypes[i], Loc);
516+
CGF.PerformStore(StoreGEPList[i], Cast);
517+
}
518+
return;
523519
}
524520
llvm_unreachable("HLSL Flat cast doesn't handle splatting.");
525521
}
526522

527523
// emit a flat cast where the RHS is an aggregate
528524
static void EmitHLSLAggregateFlatCast(CodeGenFunction &CGF, Address DestVal,
529-
QualType DestTy, Address SrcVal,
530-
QualType SrcTy, SourceLocation Loc) {
525+
QualType DestTy, Address SrcVal,
526+
QualType SrcTy, SourceLocation Loc) {
531527
// Flatten our destination
532528
SmallVector<QualType> DestTypes; // Flattened type
533529
SmallVector<llvm::Value *, 4> IdxList;
534530
SmallVector<std::pair<Address, llvm::Value *>, 16> StoreGEPList;
535531
// ^^ Flattened accesses to DestVal we want to store into
536-
CGF.FlattenAccessAndType(DestVal, DestTy, IdxList, StoreGEPList,
537-
DestTypes);
532+
CGF.FlattenAccessAndType(DestVal, DestTy, IdxList, StoreGEPList, DestTypes);
538533
// Flatten our src
539534
SmallVector<QualType> SrcTypes; // Flattened type
540535
SmallVector<std::pair<Address, llvm::Value *>, 16> LoadGEPList;
@@ -543,14 +538,14 @@ static void EmitHLSLAggregateFlatCast(CodeGenFunction &CGF, Address DestVal,
543538
CGF.FlattenAccessAndType(SrcVal, SrcTy, IdxList, LoadGEPList, SrcTypes);
544539

545540
assert(StoreGEPList.size() <= LoadGEPList.size() &&
546-
"Cannot perform HLSL flat cast when flattened source object \
541+
"Cannot perform HLSL flat cast when flattened source object \
547542
has less elements than flattened destination object.");
548543
// apply casts to what we load from LoadGEPList
549544
// and store result in Dest
550-
for(unsigned i = 0; i < StoreGEPList.size(); i ++) {
545+
for (unsigned i = 0; i < StoreGEPList.size(); i++) {
551546
llvm::Value *Load = CGF.PerformLoad(LoadGEPList[i]);
552-
llvm::Value *Cast = CGF.EmitScalarConversion(Load, SrcTypes[i],
553-
DestTypes[i], Loc);
547+
llvm::Value *Cast =
548+
CGF.EmitScalarConversion(Load, SrcTypes[i], DestTypes[i], Loc);
554549
CGF.PerformStore(StoreGEPList[i], Cast);
555550
}
556551
}
@@ -967,11 +962,12 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) {
967962
EmitHLSLScalarFlatCast(CGF, DestVal, DestTy, SrcVal, SrcTy, Loc);
968963
} else { // RHS is an aggregate
969964
assert(RV.isAggregate() &&
970-
"Can't perform HLSL Aggregate cast on a complex type.");
965+
"Can't perform HLSL Aggregate cast on a complex type.");
971966
Address SrcVal = RV.getAggregateAddress();
972967
EmitHLSLAggregateFlatCast(CGF, DestVal, DestTy, SrcVal, SrcTy, Loc);
973968
}
974-
break; }
969+
break;
970+
}
975971
case CK_NoOp:
976972
case CK_UserDefinedConversion:
977973
case CK_ConstructorConversion:

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,31 +2264,32 @@ bool CodeGenFunction::ShouldNullCheckClassCastValue(const CastExpr *CE) {
22642264

22652265
// RHS is an aggregate type
22662266
static Value *EmitHLSLAggregateFlatCast(CodeGenFunction &CGF, Address RHSVal,
2267-
QualType RHSTy, QualType LHSTy,
2268-
SourceLocation Loc) {
2267+
QualType RHSTy, QualType LHSTy,
2268+
SourceLocation Loc) {
22692269
SmallVector<llvm::Value *, 4> IdxList;
22702270
SmallVector<std::pair<Address, llvm::Value *>, 16> LoadGEPList;
22712271
SmallVector<QualType> SrcTypes; // Flattened type
22722272
CGF.FlattenAccessAndType(RHSVal, RHSTy, IdxList, LoadGEPList, SrcTypes);
22732273
// LHS is either a vector or a builtin?
22742274
// if its a vector create a temp alloca to store into and return that
22752275
if (auto *VecTy = LHSTy->getAs<VectorType>()) {
2276-
llvm::Value *V = CGF.Builder.CreateLoad(CGF.CreateIRTemp(LHSTy, "flatcast.tmp"));
2276+
llvm::Value *V =
2277+
CGF.Builder.CreateLoad(CGF.CreateIRTemp(LHSTy, "flatcast.tmp"));
22772278
// write to V.
2278-
for(unsigned i = 0; i < VecTy->getNumElements(); i ++) {
2279+
for (unsigned i = 0; i < VecTy->getNumElements(); i++) {
22792280
llvm::Value *Load = CGF.PerformLoad(LoadGEPList[i]);
2280-
llvm::Value *Cast = CGF.EmitScalarConversion(Load, SrcTypes[i],
2281-
VecTy->getElementType(), Loc);
2281+
llvm::Value *Cast = CGF.EmitScalarConversion(
2282+
Load, SrcTypes[i], VecTy->getElementType(), Loc);
22822283
V = CGF.Builder.CreateInsertElement(V, Cast, i);
22832284
}
22842285
return V;
22852286
}
22862287
// i its a builtin just do an extract element or load.
22872288
assert(LHSTy->isBuiltinType() &&
2288-
"Destination type must be a vector or builtin type.");
2289+
"Destination type must be a vector or builtin type.");
22892290
// TODO add asserts about things being long enough
2290-
return CGF.EmitScalarConversion(CGF.PerformLoad(LoadGEPList[0]),
2291-
LHSTy, SrcTypes[0], Loc);
2291+
return CGF.EmitScalarConversion(CGF.PerformLoad(LoadGEPList[0]), LHSTy,
2292+
SrcTypes[0], Loc);
22922293
}
22932294

22942295
// VisitCastExpr - Emit code for an explicit or implicit cast. Implicit casts

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4360,11 +4360,12 @@ class CodeGenFunction : public CodeGenTypeCache {
43604360
LValue EmitPseudoObjectLValue(const PseudoObjectExpr *e);
43614361

43624362
llvm::Value *PerformLoad(std::pair<Address, llvm::Value *> &GEP);
4363-
llvm::Value *PerformStore(std::pair<Address, llvm::Value *> &GEP, llvm::Value *Val);
4364-
void FlattenAccessAndType(Address Val, QualType SrcTy,
4365-
SmallVector<llvm::Value *, 4> &IdxList,
4366-
SmallVector<std::pair<Address, llvm::Value *>, 16> &GEPList,
4367-
SmallVector<QualType> &FlatTypes);
4363+
llvm::Value *PerformStore(std::pair<Address, llvm::Value *> &GEP,
4364+
llvm::Value *Val);
4365+
void FlattenAccessAndType(
4366+
Address Val, QualType SrcTy, SmallVector<llvm::Value *, 4> &IdxList,
4367+
SmallVector<std::pair<Address, llvm::Value *>, 16> &GEPList,
4368+
SmallVector<QualType> &FlatTypes);
43684369

43694370
llvm::Value *EmitIvarOffset(const ObjCInterfaceDecl *Interface,
43704371
const ObjCIvarDecl *Ivar);

clang/lib/Sema/SemaCast.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
#include "clang/Basic/TargetInfo.h"
2424
#include "clang/Lex/Preprocessor.h"
2525
#include "clang/Sema/Initialization.h"
26+
#include "clang/Sema/SemaHLSL.h"
2627
#include "clang/Sema/SemaObjC.h"
2728
#include "clang/Sema/SemaRISCV.h"
28-
#include "clang/Sema/SemaHLSL.h"
2929
#include "llvm/ADT/SmallVector.h"
3030
#include "llvm/ADT/StringExtras.h"
3131
#include <set>
@@ -2780,7 +2780,9 @@ void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle,
27802780
if (Self.getLangOpts().HLSL &&
27812781
Self.HLSL().CanPerformAggregateCast(SrcExpr.get(), DestType)) {
27822782
if (SrcTy->isConstantArrayType())
2783-
SrcExpr = Self.ImpCastExprToType(SrcExpr.get(), Self.Context.getArrayParameterType(SrcTy), CK_HLSLArrayRValue, VK_PRValue, nullptr, CCK);
2783+
SrcExpr = Self.ImpCastExprToType(
2784+
SrcExpr.get(), Self.Context.getArrayParameterType(SrcTy),
2785+
CK_HLSLArrayRValue, VK_PRValue, nullptr, CCK);
27842786
Kind = CK_HLSLAggregateCast;
27852787
return;
27862788
}

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,7 +2530,7 @@ bool SemaHLSL::CanPerformAggregateCast(Expr *Src, QualType DestTy) {
25302530
QualType SrcTy = Src->getType();
25312531
if (SrcTy->isScalarType()) // always a splat and this cast doesn't handle that
25322532
return false;
2533-
2533+
25342534
if ((DestTy->isScalarType() || DestTy->isVectorType()) &&
25352535
(SrcTy->isScalarType() || SrcTy->isVectorType()))
25362536
return false;
@@ -2540,11 +2540,12 @@ bool SemaHLSL::CanPerformAggregateCast(Expr *Src, QualType DestTy) {
25402540
llvm::SmallVector<QualType> SrcTypes;
25412541
BuildFlattenedTypeList(SrcTy, SrcTypes);
25422542

2543-
// Usually the size of SrcTypes must be greater than or equal to the size of DestTypes.
2543+
// Usually the size of SrcTypes must be greater than or equal to the size of
2544+
// DestTypes.
25442545
if (SrcTypes.size() >= DestTypes.size()) {
25452546

25462547
unsigned i;
2547-
for(i = 0; i < DestTypes.size() && i < SrcTypes.size(); i ++) {
2548+
for (i = 0; i < DestTypes.size() && i < SrcTypes.size(); i++) {
25482549
if (!CanPerformScalarCast(SrcTypes[i], DestTypes[i])) {
25492550
return false;
25502551
}

clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex,
522522
case CK_ToUnion:
523523
case CK_MatrixCast:
524524
case CK_VectorSplat:
525-
case CK_HLSLAggregateCast:
525+
case CK_HLSLAggregateCast:
526526
case CK_HLSLVectorTruncation: {
527527
QualType resultType = CastE->getType();
528528
if (CastE->isGLValue())

0 commit comments

Comments
 (0)