From b3589f44c5d295cd41de2c83f3475116835eeebd Mon Sep 17 00:00:00 2001 From: Mike Stump Date: Thu, 30 Jul 2009 22:28:39 +0000 Subject: [PATCH] Canonicalize else spacing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77629 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGBlocks.cpp | 3 +-- lib/CodeGen/CGCXX.cpp | 6 ++--- lib/CodeGen/CGDecl.cpp | 3 +-- lib/CodeGen/CGExpr.cpp | 15 ++++------- lib/CodeGen/CGExprAgg.cpp | 3 +-- lib/CodeGen/CGExprComplex.cpp | 1 - lib/CodeGen/CGExprScalar.cpp | 3 +-- lib/CodeGen/CGObjC.cpp | 21 ++++++---------- lib/CodeGen/CGObjCMac.cpp | 47 +++++++++++------------------------ lib/CodeGen/CGStmt.cpp | 1 - 10 files changed, 33 insertions(+), 70 deletions(-) diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index c7d900cf48..2eafef949a 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -609,8 +609,7 @@ CodeGenFunction::GenerateBlockFunction(const BlockExpr *BExpr, dyn_cast(BlockFunctionType)) { ResultType = FTy->getResultType(); IsVariadic = FTy->isVariadic(); - } - else { + } else { // K&R style block. ResultType = BlockFunctionType->getResultType(); IsVariadic = false; diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index 215ee4c026..b8b774f7f0 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -515,8 +515,7 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD) { Ctor_Complete, V, Member->const_arg_begin(), Member->const_arg_end()); - } - else { + } else { // non-static data member initilaizers. FieldDecl *Field = Member->getMember(); QualType FieldType = getContext().getCanonicalType((Field)->getType()); @@ -572,8 +571,7 @@ void CodeGenFunction::EmitDtorEpilogue(const CXXDestructorDecl *DD) { LValue LHS = EmitLValueForField(LoadOfThis, FD, false, 0); EmitCXXDestructorCall(FieldClassDecl->getDestructor(getContext()), Dtor_Complete, LHS.getAddress()); - } - else { + } else { const RecordType *RT = DD->getAnyBaseClassToDestroy(BaseOrMember)->getAs(); CXXRecordDecl *BaseClassDecl = cast(RT->getDecl()); diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 3c3814c70d..b552da679e 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -329,8 +329,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { DI->setLocation(D.getLocation()); if (Target.useGlobalsForAutomaticVariables()) { DI->EmitGlobalVariable(static_cast(DeclPtr), &D); - } - else if (isByRef) { + } else if (isByRef) { llvm::Value *Loc; bool needsCopyDispose = BlockRequiresCopying(Ty); Loc = Builder.CreateStructGEP(DeclPtr, 1, "forwarding"); diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 4065758617..8367c27fa1 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -619,8 +619,7 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src, Vec = Builder.CreateShuffleVector(SrcVal, VMContext.getUndef(Vec->getType()), MaskV, "tmp"); - } - else if (NumDstElts > NumSrcElts) { + } else if (NumDstElts > NumSrcElts) { // Extended the source vector to the same length and then shuffle it // into the destination. // FIXME: since we're shuffling with undef, can we just use the indices @@ -649,8 +648,7 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src, } llvm::Value *MaskV = llvm::ConstantVector::get(&Mask[0], Mask.size()); Vec = Builder.CreateShuffleVector(Vec, ExtSrcVal, MaskV, "tmp"); - } - else { + } else { // We should never shorten the vector assert(0 && "unexpected shorten vector length"); } @@ -679,8 +677,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { LV = LValue::MakeAddr(V, E->getType().getCVRQualifiers(), getContext().getObjCGCAttrKind(E->getType()), E->getType().getAddressSpace()); - } - else { + } else { llvm::Value *V = LocalDeclMap[VD]; assert(V && "DeclRefExpr not entered in LocalDeclMap?"); // local variables do not get their gc attribute set. @@ -733,8 +730,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { return LValue::MakeAddr(V, E->getType().getCVRQualifiers(), getContext().getObjCGCAttrKind(E->getType()), E->getType().getAddressSpace()); - } - else if (const ImplicitParamDecl *IPD = + } else if (const ImplicitParamDecl *IPD = dyn_cast(E->getDecl())) { llvm::Value *V = LocalDeclMap[IPD]; assert(V && "BlockVarDecl not entered in LocalDeclMap?"); @@ -1083,8 +1079,7 @@ LValue CodeGenFunction::EmitLValueForField(llvm::Value* BaseValue, // __weak attribute on a field is ignored. if (attr == QualType::Weak) attr = QualType::GCNone; - } - else if (Ty->isObjCObjectPointerType()) + } else if (Ty->isObjCObjectPointerType()) attr = QualType::Strong; } LValue LV = diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index a711f49ef7..d3dc9c809c 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -243,8 +243,7 @@ void AggExprEmitter::VisitBinAssign(const BinaryOperator *E) { CGF.EmitAggExpr(E->getRHS(), AggLoc, VolatileDest); CGF.EmitObjCPropertySet(LHS.getPropertyRefExpr(), RValue::getAggregate(AggLoc, VolatileDest)); - } - else if (LHS.isKVCRef()) { + } else if (LHS.isKVCRef()) { llvm::Value *AggLoc = DestPtr; if (!AggLoc) AggLoc = CGF.CreateTempAlloca(CGF.ConvertType(E->getRHS()->getType())); diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp index 87b45d3af9..36771dd083 100644 --- a/lib/CodeGen/CGExprComplex.cpp +++ b/lib/CodeGen/CGExprComplex.cpp @@ -378,7 +378,6 @@ ComplexPairTy ComplexExprEmitter::VisitPrePostIncDec(const UnaryOperator *E, // Add the inc/dec to the real part. NextVal = Builder.CreateAdd(InVal.first, NextVal, isInc ? "inc" : "dec"); - } else { QualType ElemTy = E->getType()->getAsComplexType()->getElementType(); llvm::APFloat FVal(CGF.getContext().getFloatTypeSemantics(ElemTy), 1); diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 64261dde6f..59f5c83e30 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -714,8 +714,7 @@ Value *ScalarExprEmitter::VisitPrePostIncDec(const UnaryOperator *E, lhs = Builder.CreateBitCast(lhs, llvm::PointerType::getUnqual(i8Ty)); LV = LValue::MakeAddr(lhs, ValTy.getCVRQualifiers(), CGF.getContext().getObjCGCAttrKind(ValTy)); - } - else + } else NextVal = Builder.CreateGEP(InVal, Inc, "ptrincdec"); } else { const llvm::Type *i8Ty = diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index 1bf07bfe9e..3999b80c9a 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -199,8 +199,7 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP, LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(), Ivar, 0); if (hasAggregateLLVMType(Ivar->getType())) { EmitAggregateCopy(ReturnValue, LV.getAddress(), Ivar->getType()); - } - else { + } else { CodeGenTypes &Types = CGM.getTypes(); RValue RV = EmitLoadOfLValue(LV, Ivar->getType()); RV = RValue::get(Builder.CreateBitCast(RV.getScalarVal(), @@ -337,16 +336,14 @@ RValue CodeGenFunction::EmitObjCPropertyGet(const Expr *Exp) { GenerateMessageSend(*this, Exp->getType(), S, EmitScalarExpr(E->getBase()), false, CallArgList()); - } - else { + } else { const ObjCKVCRefExpr *KE = cast(Exp); Selector S = KE->getGetterMethod()->getSelector(); llvm::Value *Receiver; if (KE->getClassProp()) { const ObjCInterfaceDecl *OID = KE->getClassProp(); Receiver = CGM.getObjCRuntime().GetClass(Builder, OID); - } - else if (isa(KE->getBase())) + } else if (isa(KE->getBase())) return EmitObjCSuperPropertyGet(KE, S); else Receiver = EmitScalarExpr(KE->getBase()); @@ -391,27 +388,23 @@ void CodeGenFunction::EmitObjCPropertySet(const Expr *Exp, CGM.getObjCRuntime().GenerateMessageSend(*this, getContext().VoidTy, S, EmitScalarExpr(E->getBase()), false, Args); - } - else if (const ObjCKVCRefExpr *E = dyn_cast(Exp)) { + } else if (const ObjCKVCRefExpr *E = dyn_cast(Exp)) { Selector S = E->getSetterMethod()->getSelector(); CallArgList Args; llvm::Value *Receiver; if (E->getClassProp()) { const ObjCInterfaceDecl *OID = E->getClassProp(); Receiver = CGM.getObjCRuntime().GetClass(Builder, OID); - } - else if (isa(E->getBase())) { + } else if (isa(E->getBase())) { EmitObjCSuperPropertySet(E, S, Src); return; - } - else + } else Receiver = EmitScalarExpr(E->getBase()); Args.push_back(std::make_pair(Src, E->getType())); CGM.getObjCRuntime().GenerateMessageSend(*this, getContext().VoidTy, S, Receiver, E->getClassProp() != 0, Args); - } - else + } else assert (0 && "bad expression node in EmitObjCPropertySet"); } diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 3ad2befd1a..f759e4a93e 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -1468,8 +1468,7 @@ CGObjCMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF, Target = EmitClassRef(CGF.Builder, Class->getSuperClass()); Target = CGF.Builder.CreateStructGEP(Target, 0); Target = CGF.Builder.CreateLoad(Target); - } - else { + } else { llvm::Value *MetaClassPtr = EmitMetaClassRef(Class); llvm::Value *SuperPtr = CGF.Builder.CreateStructGEP(MetaClassPtr, 1); llvm::Value *Super = CGF.Builder.CreateLoad(SuperPtr); @@ -1541,8 +1540,7 @@ CodeGen::RValue CGObjCCommonMac::EmitLegacyMessageSend( } else { Fn = ObjCTypes.getSendFn2(IsSuper); } - } - else + } else // FIXME. This currently matches gcc's API for x86-32. May need to change // for others if we have their API. Fn = ObjCTypes.getSendFpretFn(IsSuper); @@ -2509,10 +2507,8 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, CGF.Builder.CreateStore(Caught, RethrowPtr); CGF.Builder.CreateStore(VMContext.getFalse(), CallTryExitPtr); CGF.EmitBranchThroughCleanup(FinallyRethrow); - } - else if (const ObjCAtCatchStmt* CatchStmt = - cast(S).getCatchStmts()) - { + } else if (const ObjCAtCatchStmt* CatchStmt = + cast(S).getCatchStmts()) { // Enter a new exception try block (in case a @catch block throws // an exception). CGF.Builder.CreateCall(ObjCTypes.getExceptionTryEnterFn(), ExceptionData); @@ -4527,8 +4523,7 @@ void CGObjCNonFragileABIMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) { Values[5] = EmitPropertyList(std::string("\01l_OBJC_$_PROP_LIST_") + ExtName, OCD, Category, ObjCTypes); - } - else { + } else { Values[4] = VMContext.getNullValue(ObjCTypes.ProtocolListnfABIPtrTy); Values[5] = VMContext.getNullValue(ObjCTypes.PropertyListPtrTy); } @@ -5003,44 +4998,35 @@ CodeGen::RValue CGObjCNonFragileABIMac::EmitMessageSend( // FIXME. Is there a better way of getting these names. // They are available in RuntimeFunctions vector pair. Name += "objc_msgSendId_stret_fixup"; - } - else + } else #endif if (IsSuper) { Fn = ObjCTypes.getMessageSendSuper2StretFixupFn(); Name += "objc_msgSendSuper2_stret_fixup"; - } - else - { + } else { Fn = ObjCTypes.getMessageSendStretFixupFn(); Name += "objc_msgSend_stret_fixup"; } - } - else if (!IsSuper && ResultType->isFloatingType()) { + } else if (!IsSuper && ResultType->isFloatingType()) { if (ResultType->isSpecificBuiltinType(BuiltinType::LongDouble)) { Fn = ObjCTypes.getMessageSendFpretFixupFn(); Name += "objc_msgSend_fpret_fixup"; - } - else { + } else { Fn = ObjCTypes.getMessageSendFixupFn(); Name += "objc_msgSend_fixup"; } - } - else { + } else { #if 0 // unlike what is documented. gcc never generates this API!! if (Receiver->getType() == ObjCTypes.ObjectPtrTy) { Fn = ObjCTypes.getMessageSendIdFixupFn(); Name += "objc_msgSendId_fixup"; - } - else + } else #endif if (IsSuper) { Fn = ObjCTypes.getMessageSendSuper2FixupFn(); Name += "objc_msgSendSuper2_fixup"; - } - else - { + } else { Fn = ObjCTypes.getMessageSendFixupFn(); Name += "objc_msgSend_fixup"; } @@ -5225,11 +5211,9 @@ CGObjCNonFragileABIMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF, Target = EmitClassRef(CGF.Builder, Class); Target = CGF.Builder.CreateStructGEP(Target, 0); Target = CGF.Builder.CreateLoad(Target); - } - else + } else Target = EmitMetaClassRef(CGF.Builder, Class); - } - else + } else Target = EmitSuperClassRef(CGF.Builder, Class); // FIXME: We shouldn't need to do this cast, rectify the ASTContext and @@ -5463,8 +5447,7 @@ CGObjCNonFragileABIMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, llvm::GlobalValue::ExternalLinkage, 0, "OBJC_EHTYPE_id"); SelectorArgs.push_back(IDEHType); - } - else { + } else { // All other types should be Objective-C interface pointer types. const ObjCObjectPointerType *PT = CatchDecl->getType()->getAsObjCObjectPointerType(); diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 5370483ba5..5b17b7b900 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -899,7 +899,6 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) { ResultRegTypes.back() = llvm::IntegerType::get((unsigned)InputSize); } } - } else { ArgTypes.push_back(Dest.getAddress()->getType()); Args.push_back(Dest.getAddress());