Canonicalize else spacing.

llvm-svn: 77629
This commit is contained in:
Mike Stump 2009-07-30 22:28:39 +00:00
parent 59a2ab9720
commit 658fe02d17
10 changed files with 33 additions and 70 deletions

View File

@ -609,8 +609,7 @@ CodeGenFunction::GenerateBlockFunction(const BlockExpr *BExpr,
dyn_cast<FunctionProtoType>(BlockFunctionType)) { dyn_cast<FunctionProtoType>(BlockFunctionType)) {
ResultType = FTy->getResultType(); ResultType = FTy->getResultType();
IsVariadic = FTy->isVariadic(); IsVariadic = FTy->isVariadic();
} } else {
else {
// K&R style block. // K&R style block.
ResultType = BlockFunctionType->getResultType(); ResultType = BlockFunctionType->getResultType();
IsVariadic = false; IsVariadic = false;

View File

@ -515,8 +515,7 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD) {
Ctor_Complete, V, Ctor_Complete, V,
Member->const_arg_begin(), Member->const_arg_begin(),
Member->const_arg_end()); Member->const_arg_end());
} } else {
else {
// non-static data member initilaizers. // non-static data member initilaizers.
FieldDecl *Field = Member->getMember(); FieldDecl *Field = Member->getMember();
QualType FieldType = getContext().getCanonicalType((Field)->getType()); QualType FieldType = getContext().getCanonicalType((Field)->getType());
@ -572,8 +571,7 @@ void CodeGenFunction::EmitDtorEpilogue(const CXXDestructorDecl *DD) {
LValue LHS = EmitLValueForField(LoadOfThis, FD, false, 0); LValue LHS = EmitLValueForField(LoadOfThis, FD, false, 0);
EmitCXXDestructorCall(FieldClassDecl->getDestructor(getContext()), EmitCXXDestructorCall(FieldClassDecl->getDestructor(getContext()),
Dtor_Complete, LHS.getAddress()); Dtor_Complete, LHS.getAddress());
} } else {
else {
const RecordType *RT = const RecordType *RT =
DD->getAnyBaseClassToDestroy(BaseOrMember)->getAs<RecordType>(); DD->getAnyBaseClassToDestroy(BaseOrMember)->getAs<RecordType>();
CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(RT->getDecl()); CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(RT->getDecl());

View File

@ -329,8 +329,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
DI->setLocation(D.getLocation()); DI->setLocation(D.getLocation());
if (Target.useGlobalsForAutomaticVariables()) { if (Target.useGlobalsForAutomaticVariables()) {
DI->EmitGlobalVariable(static_cast<llvm::GlobalVariable *>(DeclPtr), &D); DI->EmitGlobalVariable(static_cast<llvm::GlobalVariable *>(DeclPtr), &D);
} } else if (isByRef) {
else if (isByRef) {
llvm::Value *Loc; llvm::Value *Loc;
bool needsCopyDispose = BlockRequiresCopying(Ty); bool needsCopyDispose = BlockRequiresCopying(Ty);
Loc = Builder.CreateStructGEP(DeclPtr, 1, "forwarding"); Loc = Builder.CreateStructGEP(DeclPtr, 1, "forwarding");

View File

@ -619,8 +619,7 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src,
Vec = Builder.CreateShuffleVector(SrcVal, Vec = Builder.CreateShuffleVector(SrcVal,
VMContext.getUndef(Vec->getType()), VMContext.getUndef(Vec->getType()),
MaskV, "tmp"); MaskV, "tmp");
} } else if (NumDstElts > NumSrcElts) {
else if (NumDstElts > NumSrcElts) {
// Extended the source vector to the same length and then shuffle it // Extended the source vector to the same length and then shuffle it
// into the destination. // into the destination.
// FIXME: since we're shuffling with undef, can we just use the indices // 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()); llvm::Value *MaskV = llvm::ConstantVector::get(&Mask[0], Mask.size());
Vec = Builder.CreateShuffleVector(Vec, ExtSrcVal, MaskV, "tmp"); Vec = Builder.CreateShuffleVector(Vec, ExtSrcVal, MaskV, "tmp");
} } else {
else {
// We should never shorten the vector // We should never shorten the vector
assert(0 && "unexpected shorten vector length"); assert(0 && "unexpected shorten vector length");
} }
@ -679,8 +677,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
LV = LValue::MakeAddr(V, E->getType().getCVRQualifiers(), LV = LValue::MakeAddr(V, E->getType().getCVRQualifiers(),
getContext().getObjCGCAttrKind(E->getType()), getContext().getObjCGCAttrKind(E->getType()),
E->getType().getAddressSpace()); E->getType().getAddressSpace());
} } else {
else {
llvm::Value *V = LocalDeclMap[VD]; llvm::Value *V = LocalDeclMap[VD];
assert(V && "DeclRefExpr not entered in LocalDeclMap?"); assert(V && "DeclRefExpr not entered in LocalDeclMap?");
// local variables do not get their gc attribute set. // 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(), return LValue::MakeAddr(V, E->getType().getCVRQualifiers(),
getContext().getObjCGCAttrKind(E->getType()), getContext().getObjCGCAttrKind(E->getType()),
E->getType().getAddressSpace()); E->getType().getAddressSpace());
} } else if (const ImplicitParamDecl *IPD =
else if (const ImplicitParamDecl *IPD =
dyn_cast<ImplicitParamDecl>(E->getDecl())) { dyn_cast<ImplicitParamDecl>(E->getDecl())) {
llvm::Value *V = LocalDeclMap[IPD]; llvm::Value *V = LocalDeclMap[IPD];
assert(V && "BlockVarDecl not entered in LocalDeclMap?"); assert(V && "BlockVarDecl not entered in LocalDeclMap?");
@ -1083,8 +1079,7 @@ LValue CodeGenFunction::EmitLValueForField(llvm::Value* BaseValue,
// __weak attribute on a field is ignored. // __weak attribute on a field is ignored.
if (attr == QualType::Weak) if (attr == QualType::Weak)
attr = QualType::GCNone; attr = QualType::GCNone;
} } else if (Ty->isObjCObjectPointerType())
else if (Ty->isObjCObjectPointerType())
attr = QualType::Strong; attr = QualType::Strong;
} }
LValue LV = LValue LV =

View File

@ -243,8 +243,7 @@ void AggExprEmitter::VisitBinAssign(const BinaryOperator *E) {
CGF.EmitAggExpr(E->getRHS(), AggLoc, VolatileDest); CGF.EmitAggExpr(E->getRHS(), AggLoc, VolatileDest);
CGF.EmitObjCPropertySet(LHS.getPropertyRefExpr(), CGF.EmitObjCPropertySet(LHS.getPropertyRefExpr(),
RValue::getAggregate(AggLoc, VolatileDest)); RValue::getAggregate(AggLoc, VolatileDest));
} } else if (LHS.isKVCRef()) {
else if (LHS.isKVCRef()) {
llvm::Value *AggLoc = DestPtr; llvm::Value *AggLoc = DestPtr;
if (!AggLoc) if (!AggLoc)
AggLoc = CGF.CreateTempAlloca(CGF.ConvertType(E->getRHS()->getType())); AggLoc = CGF.CreateTempAlloca(CGF.ConvertType(E->getRHS()->getType()));

View File

@ -378,7 +378,6 @@ ComplexPairTy ComplexExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
// Add the inc/dec to the real part. // Add the inc/dec to the real part.
NextVal = Builder.CreateAdd(InVal.first, NextVal, isInc ? "inc" : "dec"); NextVal = Builder.CreateAdd(InVal.first, NextVal, isInc ? "inc" : "dec");
} else { } else {
QualType ElemTy = E->getType()->getAsComplexType()->getElementType(); QualType ElemTy = E->getType()->getAsComplexType()->getElementType();
llvm::APFloat FVal(CGF.getContext().getFloatTypeSemantics(ElemTy), 1); llvm::APFloat FVal(CGF.getContext().getFloatTypeSemantics(ElemTy), 1);

View File

@ -714,8 +714,7 @@ Value *ScalarExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
lhs = Builder.CreateBitCast(lhs, llvm::PointerType::getUnqual(i8Ty)); lhs = Builder.CreateBitCast(lhs, llvm::PointerType::getUnqual(i8Ty));
LV = LValue::MakeAddr(lhs, ValTy.getCVRQualifiers(), LV = LValue::MakeAddr(lhs, ValTy.getCVRQualifiers(),
CGF.getContext().getObjCGCAttrKind(ValTy)); CGF.getContext().getObjCGCAttrKind(ValTy));
} } else
else
NextVal = Builder.CreateGEP(InVal, Inc, "ptrincdec"); NextVal = Builder.CreateGEP(InVal, Inc, "ptrincdec");
} else { } else {
const llvm::Type *i8Ty = const llvm::Type *i8Ty =

View File

@ -199,8 +199,7 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP,
LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(), Ivar, 0); LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(), Ivar, 0);
if (hasAggregateLLVMType(Ivar->getType())) { if (hasAggregateLLVMType(Ivar->getType())) {
EmitAggregateCopy(ReturnValue, LV.getAddress(), Ivar->getType()); EmitAggregateCopy(ReturnValue, LV.getAddress(), Ivar->getType());
} } else {
else {
CodeGenTypes &Types = CGM.getTypes(); CodeGenTypes &Types = CGM.getTypes();
RValue RV = EmitLoadOfLValue(LV, Ivar->getType()); RValue RV = EmitLoadOfLValue(LV, Ivar->getType());
RV = RValue::get(Builder.CreateBitCast(RV.getScalarVal(), RV = RValue::get(Builder.CreateBitCast(RV.getScalarVal(),
@ -337,16 +336,14 @@ RValue CodeGenFunction::EmitObjCPropertyGet(const Expr *Exp) {
GenerateMessageSend(*this, Exp->getType(), S, GenerateMessageSend(*this, Exp->getType(), S,
EmitScalarExpr(E->getBase()), EmitScalarExpr(E->getBase()),
false, CallArgList()); false, CallArgList());
} } else {
else {
const ObjCKVCRefExpr *KE = cast<ObjCKVCRefExpr>(Exp); const ObjCKVCRefExpr *KE = cast<ObjCKVCRefExpr>(Exp);
Selector S = KE->getGetterMethod()->getSelector(); Selector S = KE->getGetterMethod()->getSelector();
llvm::Value *Receiver; llvm::Value *Receiver;
if (KE->getClassProp()) { if (KE->getClassProp()) {
const ObjCInterfaceDecl *OID = KE->getClassProp(); const ObjCInterfaceDecl *OID = KE->getClassProp();
Receiver = CGM.getObjCRuntime().GetClass(Builder, OID); Receiver = CGM.getObjCRuntime().GetClass(Builder, OID);
} } else if (isa<ObjCSuperExpr>(KE->getBase()))
else if (isa<ObjCSuperExpr>(KE->getBase()))
return EmitObjCSuperPropertyGet(KE, S); return EmitObjCSuperPropertyGet(KE, S);
else else
Receiver = EmitScalarExpr(KE->getBase()); Receiver = EmitScalarExpr(KE->getBase());
@ -391,27 +388,23 @@ void CodeGenFunction::EmitObjCPropertySet(const Expr *Exp,
CGM.getObjCRuntime().GenerateMessageSend(*this, getContext().VoidTy, S, CGM.getObjCRuntime().GenerateMessageSend(*this, getContext().VoidTy, S,
EmitScalarExpr(E->getBase()), EmitScalarExpr(E->getBase()),
false, Args); false, Args);
} } else if (const ObjCKVCRefExpr *E = dyn_cast<ObjCKVCRefExpr>(Exp)) {
else if (const ObjCKVCRefExpr *E = dyn_cast<ObjCKVCRefExpr>(Exp)) {
Selector S = E->getSetterMethod()->getSelector(); Selector S = E->getSetterMethod()->getSelector();
CallArgList Args; CallArgList Args;
llvm::Value *Receiver; llvm::Value *Receiver;
if (E->getClassProp()) { if (E->getClassProp()) {
const ObjCInterfaceDecl *OID = E->getClassProp(); const ObjCInterfaceDecl *OID = E->getClassProp();
Receiver = CGM.getObjCRuntime().GetClass(Builder, OID); Receiver = CGM.getObjCRuntime().GetClass(Builder, OID);
} } else if (isa<ObjCSuperExpr>(E->getBase())) {
else if (isa<ObjCSuperExpr>(E->getBase())) {
EmitObjCSuperPropertySet(E, S, Src); EmitObjCSuperPropertySet(E, S, Src);
return; return;
} } else
else
Receiver = EmitScalarExpr(E->getBase()); Receiver = EmitScalarExpr(E->getBase());
Args.push_back(std::make_pair(Src, E->getType())); Args.push_back(std::make_pair(Src, E->getType()));
CGM.getObjCRuntime().GenerateMessageSend(*this, getContext().VoidTy, S, CGM.getObjCRuntime().GenerateMessageSend(*this, getContext().VoidTy, S,
Receiver, Receiver,
E->getClassProp() != 0, Args); E->getClassProp() != 0, Args);
} } else
else
assert (0 && "bad expression node in EmitObjCPropertySet"); assert (0 && "bad expression node in EmitObjCPropertySet");
} }

View File

@ -1468,8 +1468,7 @@ CGObjCMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
Target = EmitClassRef(CGF.Builder, Class->getSuperClass()); Target = EmitClassRef(CGF.Builder, Class->getSuperClass());
Target = CGF.Builder.CreateStructGEP(Target, 0); Target = CGF.Builder.CreateStructGEP(Target, 0);
Target = CGF.Builder.CreateLoad(Target); Target = CGF.Builder.CreateLoad(Target);
} } else {
else {
llvm::Value *MetaClassPtr = EmitMetaClassRef(Class); llvm::Value *MetaClassPtr = EmitMetaClassRef(Class);
llvm::Value *SuperPtr = CGF.Builder.CreateStructGEP(MetaClassPtr, 1); llvm::Value *SuperPtr = CGF.Builder.CreateStructGEP(MetaClassPtr, 1);
llvm::Value *Super = CGF.Builder.CreateLoad(SuperPtr); llvm::Value *Super = CGF.Builder.CreateLoad(SuperPtr);
@ -1541,8 +1540,7 @@ CodeGen::RValue CGObjCCommonMac::EmitLegacyMessageSend(
} else { } else {
Fn = ObjCTypes.getSendFn2(IsSuper); Fn = ObjCTypes.getSendFn2(IsSuper);
} }
} } else
else
// FIXME. This currently matches gcc's API for x86-32. May need to change // FIXME. This currently matches gcc's API for x86-32. May need to change
// for others if we have their API. // for others if we have their API.
Fn = ObjCTypes.getSendFpretFn(IsSuper); Fn = ObjCTypes.getSendFpretFn(IsSuper);
@ -2509,10 +2507,8 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
CGF.Builder.CreateStore(Caught, RethrowPtr); CGF.Builder.CreateStore(Caught, RethrowPtr);
CGF.Builder.CreateStore(VMContext.getFalse(), CallTryExitPtr); CGF.Builder.CreateStore(VMContext.getFalse(), CallTryExitPtr);
CGF.EmitBranchThroughCleanup(FinallyRethrow); CGF.EmitBranchThroughCleanup(FinallyRethrow);
} } else if (const ObjCAtCatchStmt* CatchStmt =
else if (const ObjCAtCatchStmt* CatchStmt = cast<ObjCAtTryStmt>(S).getCatchStmts()) {
cast<ObjCAtTryStmt>(S).getCatchStmts())
{
// Enter a new exception try block (in case a @catch block throws // Enter a new exception try block (in case a @catch block throws
// an exception). // an exception).
CGF.Builder.CreateCall(ObjCTypes.getExceptionTryEnterFn(), ExceptionData); CGF.Builder.CreateCall(ObjCTypes.getExceptionTryEnterFn(), ExceptionData);
@ -4527,8 +4523,7 @@ void CGObjCNonFragileABIMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
Values[5] = Values[5] =
EmitPropertyList(std::string("\01l_OBJC_$_PROP_LIST_") + ExtName, EmitPropertyList(std::string("\01l_OBJC_$_PROP_LIST_") + ExtName,
OCD, Category, ObjCTypes); OCD, Category, ObjCTypes);
} } else {
else {
Values[4] = VMContext.getNullValue(ObjCTypes.ProtocolListnfABIPtrTy); Values[4] = VMContext.getNullValue(ObjCTypes.ProtocolListnfABIPtrTy);
Values[5] = VMContext.getNullValue(ObjCTypes.PropertyListPtrTy); Values[5] = VMContext.getNullValue(ObjCTypes.PropertyListPtrTy);
} }
@ -5003,44 +4998,35 @@ CodeGen::RValue CGObjCNonFragileABIMac::EmitMessageSend(
// FIXME. Is there a better way of getting these names. // FIXME. Is there a better way of getting these names.
// They are available in RuntimeFunctions vector pair. // They are available in RuntimeFunctions vector pair.
Name += "objc_msgSendId_stret_fixup"; Name += "objc_msgSendId_stret_fixup";
} } else
else
#endif #endif
if (IsSuper) { if (IsSuper) {
Fn = ObjCTypes.getMessageSendSuper2StretFixupFn(); Fn = ObjCTypes.getMessageSendSuper2StretFixupFn();
Name += "objc_msgSendSuper2_stret_fixup"; Name += "objc_msgSendSuper2_stret_fixup";
} } else {
else
{
Fn = ObjCTypes.getMessageSendStretFixupFn(); Fn = ObjCTypes.getMessageSendStretFixupFn();
Name += "objc_msgSend_stret_fixup"; Name += "objc_msgSend_stret_fixup";
} }
} } else if (!IsSuper && ResultType->isFloatingType()) {
else if (!IsSuper && ResultType->isFloatingType()) {
if (ResultType->isSpecificBuiltinType(BuiltinType::LongDouble)) { if (ResultType->isSpecificBuiltinType(BuiltinType::LongDouble)) {
Fn = ObjCTypes.getMessageSendFpretFixupFn(); Fn = ObjCTypes.getMessageSendFpretFixupFn();
Name += "objc_msgSend_fpret_fixup"; Name += "objc_msgSend_fpret_fixup";
} } else {
else {
Fn = ObjCTypes.getMessageSendFixupFn(); Fn = ObjCTypes.getMessageSendFixupFn();
Name += "objc_msgSend_fixup"; Name += "objc_msgSend_fixup";
} }
} } else {
else {
#if 0 #if 0
// unlike what is documented. gcc never generates this API!! // unlike what is documented. gcc never generates this API!!
if (Receiver->getType() == ObjCTypes.ObjectPtrTy) { if (Receiver->getType() == ObjCTypes.ObjectPtrTy) {
Fn = ObjCTypes.getMessageSendIdFixupFn(); Fn = ObjCTypes.getMessageSendIdFixupFn();
Name += "objc_msgSendId_fixup"; Name += "objc_msgSendId_fixup";
} } else
else
#endif #endif
if (IsSuper) { if (IsSuper) {
Fn = ObjCTypes.getMessageSendSuper2FixupFn(); Fn = ObjCTypes.getMessageSendSuper2FixupFn();
Name += "objc_msgSendSuper2_fixup"; Name += "objc_msgSendSuper2_fixup";
} } else {
else
{
Fn = ObjCTypes.getMessageSendFixupFn(); Fn = ObjCTypes.getMessageSendFixupFn();
Name += "objc_msgSend_fixup"; Name += "objc_msgSend_fixup";
} }
@ -5225,11 +5211,9 @@ CGObjCNonFragileABIMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
Target = EmitClassRef(CGF.Builder, Class); Target = EmitClassRef(CGF.Builder, Class);
Target = CGF.Builder.CreateStructGEP(Target, 0); Target = CGF.Builder.CreateStructGEP(Target, 0);
Target = CGF.Builder.CreateLoad(Target); Target = CGF.Builder.CreateLoad(Target);
} } else
else
Target = EmitMetaClassRef(CGF.Builder, Class); Target = EmitMetaClassRef(CGF.Builder, Class);
} } else
else
Target = EmitSuperClassRef(CGF.Builder, Class); Target = EmitSuperClassRef(CGF.Builder, Class);
// FIXME: We shouldn't need to do this cast, rectify the ASTContext and // 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, llvm::GlobalValue::ExternalLinkage,
0, "OBJC_EHTYPE_id"); 0, "OBJC_EHTYPE_id");
SelectorArgs.push_back(IDEHType); SelectorArgs.push_back(IDEHType);
} } else {
else {
// All other types should be Objective-C interface pointer types. // All other types should be Objective-C interface pointer types.
const ObjCObjectPointerType *PT = const ObjCObjectPointerType *PT =
CatchDecl->getType()->getAsObjCObjectPointerType(); CatchDecl->getType()->getAsObjCObjectPointerType();

View File

@ -899,7 +899,6 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
ResultRegTypes.back() = llvm::IntegerType::get((unsigned)InputSize); ResultRegTypes.back() = llvm::IntegerType::get((unsigned)InputSize);
} }
} }
} else { } else {
ArgTypes.push_back(Dest.getAddress()->getType()); ArgTypes.push_back(Dest.getAddress()->getType());
Args.push_back(Dest.getAddress()); Args.push_back(Dest.getAddress());