[cfe-commits] r78102 - in /cfe/trunk/lib/Sema: SemaChecking.cpp SemaDecl.cpp SemaDeclAttr.cpp SemaDeclCXX.cpp SemaDeclObjC.cpp SemaExpr.cpp SemaExprCXX.cpp SemaInherit.cpp SemaInit.cpp SemaOverload.cpp SemaTemplate.cpp SemaTemplateInstantiateDecl.cpp

Mike Stump mrs at apple.com
Tue Aug 4 14:03:10 PDT 2009


Author: mrs
Date: Tue Aug  4 16:02:39 2009
New Revision: 78102

URL: http://llvm.org/viewvc/llvm-project?rev=78102&view=rev
Log:
Canonicalize else.

Modified:
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaInherit.cpp
    cfe/trunk/lib/Sema/SemaInit.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=78102&r1=78101&r2=78102&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Aug  4 16:02:39 2009
@@ -751,8 +751,7 @@
 
       if (const ArrayType *AT = Context.getAsArrayType(T)) {
         isConstant = AT->getElementType().isConstant(Context);
-      }
-      else if (const PointerType *PT = T->getAs<PointerType>()) {
+      } else if (const PointerType *PT = T->getAs<PointerType>()) {
         isConstant = T.isConstant(Context) && 
                      PT->getPointeeType().isConstant(Context);
       }
@@ -1205,9 +1204,8 @@
       if (C->hasBlockDeclRefExprs())
         Diag(C->getLocStart(), diag::err_ret_local_block)
           << C->getSourceRange();
-  }
-  // Perform checking for stack values returned by reference.
-  else if (lhsType->isReferenceType()) {
+  } else if (lhsType->isReferenceType()) {
+    // Perform checking for stack values returned by reference.
     // Check for a reference to the stack
     if (DeclRefExpr *DR = EvalVal(RetValExp))
       Diag(DR->getLocStart(), diag::warn_ret_stack_ref)
@@ -1444,8 +1442,7 @@
     if (FloatingLiteral* FLL = dyn_cast<FloatingLiteral>(LeftExprSansParen)) {
       if (FLL->isExact())
         EmitWarning = false;
-    }
-    else
+    } else
       if (FloatingLiteral* FLR = dyn_cast<FloatingLiteral>(RightExprSansParen)){
         if (FLR->isExact())
           EmitWarning = false;

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=78102&r1=78101&r2=78102&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Aug  4 16:02:39 2009
@@ -3281,8 +3281,7 @@
                                 ArrayT->getElementType(),
                                 diag::err_illegal_decl_array_incomplete_type))
           IDecl->setInvalidDecl();
-      }
-      else if (IDecl->getStorageClass() == VarDecl::Static) {
+      } else if (IDecl->getStorageClass() == VarDecl::Static) {
         // C99 6.9.2p3: If the declaration of an identifier for an object is
         // a tentative definition and has internal linkage (C99 6.2.2p3), the
         // declared type shall not be an incomplete type.
@@ -3947,8 +3946,7 @@
       Name = 0;
       PrevDecl = 0;
       Invalid = true;
-    }
-    else
+    } else
       PrevDecl = R;
 
     if (!getLangOptions().CPlusPlus && TUK != TUK_Reference) {
@@ -4717,8 +4715,7 @@
     ObjCInterfaceDecl* IDecl = IMPDecl->getClassInterface();
     assert(IDecl && "No class- ActOnIvar");
     EnclosingContext = cast_or_null<DeclContext>(IDecl);
-  }
-  else
+  } else
     EnclosingContext = dyn_cast<DeclContext>(EnclosingDecl);
   assert(EnclosingContext && "null DeclContext for ivar - ActOnIvar");
   
@@ -4857,12 +4854,11 @@
       FD->setInvalidDecl();
       EnclosingDecl->setInvalidDecl();
       continue;
-    }
-    else if (getLangOptions().ObjC1 &&
-             getLangOptions().getGCMode() != LangOptions::NonGC &&
-             Record &&
-             (FD->getType()->isObjCObjectPointerType() ||
-              FD->getType().isObjCGCStrong()))
+    } else if (getLangOptions().ObjC1 &&
+               getLangOptions().getGCMode() != LangOptions::NonGC &&
+               Record &&
+               (FD->getType()->isObjCObjectPointerType() ||
+                FD->getType().isObjCGCStrong()))
       Record->setHasObjectMember(true);
     // Keep track of the number of named members.
     if (FD->getIdentifier())

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=78102&r1=78101&r2=78102&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Aug  4 16:02:39 2009
@@ -756,8 +756,7 @@
         S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
         return;
       }
-    }
-    else {
+    } else {
       S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
       << Attr.getName() << 6 /*function, method or block */;
       return;

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=78102&r1=78101&r2=78102&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Aug  4 16:02:39 2009
@@ -986,8 +986,7 @@
           Diag(PrevMember->getSourceLocation(),
                diag::warn_base_initialized) 
                 << BaseClass->getDesugaredType(true);
-        }
-        else {
+        } else {
           FieldDecl *Field = PrevMember->getMember();
           Diag(PrevMember->getSourceLocation(),
                diag::warn_field_initialized) 
@@ -2165,14 +2164,12 @@
           err = true;
         }
       }
-    }
-    else if (FieldType->isReferenceType()) {
+    } else if (FieldType->isReferenceType()) {
       Diag(CurrentLocation, diag::err_unintialized_member) 
         << Context.getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
       Diag((*Field)->getLocation(), diag::note_declared_at);
       err = true;
-    }
-    else if (FieldType.isConstQualified()) {
+    } else if (FieldType.isConstQualified()) {
       Diag(CurrentLocation, diag::err_unintialized_member) 
         << Context.getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
        Diag((*Field)->getLocation(), diag::note_declared_at);
@@ -2269,15 +2266,13 @@
       if (CXXMethodDecl *FieldAssignOpMethod = 
           getAssignOperatorMethod(MethodDecl->getParamDecl(0), FieldClassDecl))
         MarkDeclarationReferenced(CurrentLocation, FieldAssignOpMethod);
-    }
-    else if (FieldType->isReferenceType()) {
+    } else if (FieldType->isReferenceType()) {
       Diag(ClassDecl->getLocation(), diag::err_uninitialized_member_for_assign) 
       << Context.getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
       Diag(Field->getLocation(), diag::note_declared_at);
       Diag(CurrentLocation, diag::note_first_required_here);
       err = true;
-    }
-    else if (FieldType.isConstQualified()) {
+    } else if (FieldType.isConstQualified()) {
       Diag(ClassDecl->getLocation(), diag::err_uninitialized_member_for_assign) 
       << Context.getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
       Diag(Field->getLocation(), diag::note_declared_at);

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=78102&r1=78101&r2=78102&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Aug  4 16:02:39 2009
@@ -128,8 +128,7 @@
       Diag(SuperLoc, diag::err_recursive_superclass)
         << SuperName << ClassName << SourceRange(AtInterfaceLoc, ClassLoc);
       IDecl->setLocEnd(ClassLoc);
-    }
-    else {
+    } else {
       ObjCInterfaceDecl *SuperClassDecl = 
                                 dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
 
@@ -862,9 +861,8 @@
         dyn_cast<ObjCImplementationDecl>(OMD->getDeclContext())) {
       if (IMD->getInstanceMethod(PDecl->getSetterName()))
         return false;
-    }
-    else if (ObjCCategoryImplDecl *CIMD = 
-             dyn_cast<ObjCCategoryImplDecl>(OMD->getDeclContext())) {
+    } else if (ObjCCategoryImplDecl *CIMD = 
+               dyn_cast<ObjCCategoryImplDecl>(OMD->getDeclContext())) {
       if (CIMD->getInstanceMethod(PDecl->getSetterName()))
         return false;
     }
@@ -974,8 +972,7 @@
       if (ImmediateClass)
         WarnUndefinedMethod(IMPDecl->getLocation(), *I, IncompleteImpl);
       continue;
-    }
-    else {
+    } else {
       ObjCMethodDecl *ImpMethodDecl = 
       IMPDecl->getInstanceMethod((*I)->getSelector());
       ObjCMethodDecl *IntfMethodDecl = 
@@ -998,8 +995,7 @@
     if (!ClsMap.count((*I)->getSelector())) {
       if (ImmediateClass)
         WarnUndefinedMethod(IMPDecl->getLocation(), *I, IncompleteImpl);
-    }
-    else {
+    } else {
       ObjCMethodDecl *ImpMethodDecl =
         IMPDecl->getClassMethod((*I)->getSelector());
       ObjCMethodDecl *IntfMethodDecl = 
@@ -1136,10 +1132,9 @@
       if (!TDD || !isa<ObjCInterfaceType>(TDD->getUnderlyingType())) {
         Diag(AtClassLoc, diag::err_redefinition_different_kind) << IdentList[i];
         Diag(PrevDecl->getLocation(), diag::note_previous_definition);
-      }
-      else if (TDD) {
-        // a forward class declaration matching a typedef name of a class
-        // refers to the underlying class.
+      } else if (TDD) {
+        // a forward class declaration matching a typedef name of a class refers
+        // to the underlying class.
         if (ObjCInterfaceType * OI = 
               dyn_cast<ObjCInterfaceType>(TDD->getUnderlyingType()))
           PrevDecl = OI->getDecl();
@@ -1550,8 +1545,7 @@
         // parent methods if it shadows one.
         CompareMethodParamsInBaseAndSuper(ClassDecl, Method, true);
       }
-    }
-    else {
+    } else {
       /// Check for class method of the same name with incompatible types
       const ObjCMethodDecl *&PrevMethod = ClsMap[Method->getSelector()];
       bool match = PrevMethod ? MatchTwoMethodDeclarations(Method, PrevMethod) 
@@ -1758,9 +1752,8 @@
     }
     if (AttrList)
       Diag(EndLoc, diag::warn_attribute_method_def);
-  } 
-  else if (ObjCCategoryImplDecl *CatImpDecl = 
-            dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) {
+  } else if (ObjCCategoryImplDecl *CatImpDecl = 
+             dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) {
     if (MethodType == tok::minus) {
       PrevMethod = CatImpDecl->getInstanceMethod(Sel);
       CatImpDecl->addInstanceMethod(ObjCMethod);
@@ -1913,8 +1906,7 @@
             if (Attributes & ObjCDeclSpec::DQ_PR_copy)
               PIDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_copy);
             PIDecl->setSetterName(SetterSel);
-          }
-          else
+          } else
             Diag(AtLoc, diag::err_use_continuation_class) 
               << CCPrimary->getDeclName();
           *isOverridingProperty = true;
@@ -2024,8 +2016,7 @@
       Diag(PropertyLoc, diag::error_bad_property_decl) << IDecl->getDeclName();
       return DeclPtrTy();
     }
-  }
-  else if ((CatImplClass = dyn_cast<ObjCCategoryImplDecl>(ClassImpDecl))) {
+  } else if ((CatImplClass = dyn_cast<ObjCCategoryImplDecl>(ClassImpDecl))) {
     if (Synthesize) {
       Diag(AtLoc, diag::error_synthesize_category_decl);
       return DeclPtrTy();
@@ -2078,9 +2069,8 @@
         Diag(PropertyLoc, diag::error_missing_property_ivar_decl) << PropertyId;
         // Note! I deliberately want it to fall thru so, we have a 
         // a property implementation and to avoid future warnings.
-    }
-    else if (getLangOptions().ObjCNonFragileABI &&
-             ClassDeclared != IDecl) {
+    } else if (getLangOptions().ObjCNonFragileABI &&
+               ClassDeclared != IDecl) {
       Diag(PropertyLoc, diag::error_ivar_in_superclass_use)
         << property->getDeclName() << Ivar->getDeclName() 
         << ClassDeclared->getDeclName();
@@ -2153,8 +2143,7 @@
       return DeclPtrTy();
     }
     IC->addPropertyImplementation(PIDecl);
-  }
-  else {
+  } else {
     if (Synthesize)
       if (ObjCPropertyImplDecl *PPIDecl = 
           CatImplClass->FindPropertyImplIvarDecl(PropertyIvar)) {

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=78102&r1=78101&r2=78102&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug  4 16:02:39 2009
@@ -116,8 +116,7 @@
     }
     warnNotEnoughArgs = (P != E || i >= NumArgs);
     isMethod = 1;
-  }
-  else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+  } else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
     // skip over named parameters.
     ObjCMethodDecl::param_iterator P, E = FD->param_end();
     for (P = FD->param_begin(); (P != E && i < NumArgs); ++P) {
@@ -127,8 +126,7 @@
         ++i;
     }
     warnNotEnoughArgs = (P != E || i >= NumArgs);
-  }
-  else if (VarDecl *V = dyn_cast<VarDecl>(D)) {
+  } else if (VarDecl *V = dyn_cast<VarDecl>(D)) {
     // block or function pointer call.
     QualType Ty = V->getType();
     if (Ty->isBlockPointerType() || Ty->isFunctionPointerType()) {
@@ -148,11 +146,9 @@
       }
       if (Ty->isBlockPointerType())
         isMethod = 2;
-    }
-    else
+    } else
       return;
-  }
-  else
+  } else
     return;
 
   if (warnNotEnoughArgs) {
@@ -913,8 +909,7 @@
                                        SelfExpr.takeAs<Expr>(), true, true));
         }
       }
-    }
-    else if (getCurMethodDecl()->isInstanceMethod()) {
+    } else if (getCurMethodDecl()->isInstanceMethod()) {
       // We should warn if a local variable hides an ivar.
       ObjCInterfaceDecl *IFace = getCurMethodDecl()->getClassInterface();
       ObjCInterfaceDecl *ClassDeclared;
@@ -2355,9 +2350,8 @@
                 ClassOfMethodDecl != ClassDeclared)
               Diag(MemberLoc, diag::error_private_ivar_access) 
                 << IV->getDeclName();
-          }
-          // @protected
-          else if (!IDecl->isSuperClassOf(ClassOfMethodDecl))
+          } else if (!IDecl->isSuperClassOf(ClassOfMethodDecl))
+            // @protected
             Diag(MemberLoc, diag::error_protected_ivar_access) 
               << IV->getDeclName();
         }
@@ -4154,10 +4148,9 @@
         !RHSStripped->isNullPointerConstant(Context)) {
       literalString = lex;
       literalStringStripped = LHSStripped;
-    }
-    else if ((isa<StringLiteral>(RHSStripped) ||
-              isa<ObjCEncodeExpr>(RHSStripped)) &&
-             !LHSStripped->isNullPointerConstant(Context)) {
+    } else if ((isa<StringLiteral>(RHSStripped) ||
+                isa<ObjCEncodeExpr>(RHSStripped)) &&
+               !LHSStripped->isNullPointerConstant(Context)) {
       literalString = rex;
       literalStringStripped = RHSStripped;
     }
@@ -5804,9 +5797,8 @@
     if (Constructor->isImplicit() && Constructor->isDefaultConstructor()) {
         if (!Constructor->isUsed())
           DefineImplicitDefaultConstructor(Loc, Constructor);
-    }
-    else if (Constructor->isImplicit() && 
-             Constructor->isCopyConstructor(Context, TypeQuals)) {
+    } else if (Constructor->isImplicit() && 
+               Constructor->isCopyConstructor(Context, TypeQuals)) {
       if (!Constructor->isUsed())
         DefineImplicitCopyConstructor(Loc, Constructor, TypeQuals);
     }

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=78102&r1=78101&r2=78102&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Aug  4 16:02:39 2009
@@ -414,9 +414,8 @@
   unsigned NumConsArgs = ConstructorArgs.size();
   if (AllocType->isDependentType()) {
     // Skip all the checks.
-  }
-  else if ((RT = AllocType->getAs<RecordType>()) &&
-            !AllocType->isAggregateType()) {
+  } else if ((RT = AllocType->getAs<RecordType>()) &&
+             !AllocType->isAggregateType()) {
     Constructor = PerformInitializationByConstructor(
                       AllocType, ConsArgs, NumConsArgs,
                       TypeLoc,

Modified: cfe/trunk/lib/Sema/SemaInherit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInherit.cpp?rev=78102&r1=78101&r2=78102&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaInherit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInherit.cpp Tue Aug  4 16:02:39 2009
@@ -227,13 +227,13 @@
         // return immediately.
         return FoundPath;
       }
-    } 
-    // C++ [class.member.lookup]p2:
-    //   A member name f in one sub-object B hides a member name f in
-    //   a sub-object A if A is a base class sub-object of B. Any
-    //   declarations that are so hidden are eliminated from
-    //   consideration.
-    else if (VisitBase && LookupInBases(BaseRecord, Criteria, Paths)) {
+    } else if (VisitBase && LookupInBases(BaseRecord, Criteria, Paths)) {
+      // C++ [class.member.lookup]p2:
+      //   A member name f in one sub-object B hides a member name f in
+      //   a sub-object A if A is a base class sub-object of B. Any
+      //   declarations that are so hidden are eliminated from
+      //   consideration.
+
       // There is a path to a base class that meets the criteria. If we're not
       // collecting paths or finding ambiguities, we're done.
       FoundPath = true;

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=78102&r1=78101&r2=78102&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Aug  4 16:02:39 2009
@@ -414,8 +414,8 @@
       if (Init < NumInits && !hadError)
         ILE->setInit(Init, 
                      new (SemaRef.Context) ImplicitValueInitExpr(ElementType));
-    }
-    else if (InitListExpr *InnerILE =dyn_cast<InitListExpr>(ILE->getInit(Init)))
+    } else if (InitListExpr *InnerILE
+               = dyn_cast<InitListExpr>(ILE->getInit(Init)))
       FillInValueInitializations(InnerILE);
   }
 }
@@ -595,8 +595,7 @@
                       false);
       CheckArrayType(IList, DeclType, Zero, SubobjectIsDesignatorContext, Index,
                      StructuredList, StructuredIndex);
-    }
-    else
+    } else
       assert(0 && "Aggregate that isn't a structure or array?!");
   } else if (DeclType->isVoidType() || DeclType->isFunctionType()) {
     // This type is invalid, issue a diagnostic.

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=78102&r1=78101&r2=78102&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Aug  4 16:02:39 2009
@@ -509,9 +509,8 @@
 
     // FIXME: Doesn't see through to qualifiers behind a typedef!
     FromType = FromType.getUnqualifiedType();
-  }
-  // Array-to-pointer conversion (C++ 4.2)
-  else if (FromType->isArrayType()) {
+  } else if (FromType->isArrayType()) {
+    // Array-to-pointer conversion (C++ 4.2)
     SCS.First = ICK_Array_To_Pointer;
 
     // An lvalue or rvalue of type "array of N T" or "array of unknown
@@ -532,19 +531,17 @@
       SCS.ToTypePtr = ToType.getAsOpaquePtr();
       return true;
     }
-  }
-  // Function-to-pointer conversion (C++ 4.3).
-  else if (FromType->isFunctionType() && argIsLvalue == Expr::LV_Valid) {
+  } else if (FromType->isFunctionType() && argIsLvalue == Expr::LV_Valid) {
+    // Function-to-pointer conversion (C++ 4.3).
     SCS.First = ICK_Function_To_Pointer;
 
     // An lvalue of function type T can be converted to an rvalue of
     // type "pointer to T." The result is a pointer to the
     // function. (C++ 4.3p1).
     FromType = Context.getPointerType(FromType);
-  }
-  // Address of overloaded function (C++ [over.over]).
-  else if (FunctionDecl *Fn 
+  } else if (FunctionDecl *Fn 
              = ResolveAddressOfOverloadedFunction(From, ToType, false)) {
+    // Address of overloaded function (C++ [over.over]).
     SCS.First = ICK_Function_To_Pointer;
 
     // We were able to resolve the address of the overloaded function,
@@ -566,9 +563,8 @@
                     Context.getTypeDeclType(M->getParent()).getTypePtr());
     } else
       FromType = Context.getPointerType(FromType);
-  }
-  // We don't require any conversions for the first step.
-  else {
+  } else {
+    // We don't require any conversions for the first step.
     SCS.First = ICK_Identity;
   }
 
@@ -583,79 +579,67 @@
     // The unqualified versions of the types are the same: there's no
     // conversion to do.
     SCS.Second = ICK_Identity;
-  }
-  // Integral promotion (C++ 4.5).  
-  else if (IsIntegralPromotion(From, FromType, ToType)) {
+  } else if (IsIntegralPromotion(From, FromType, ToType)) {
+    // Integral promotion (C++ 4.5).  
     SCS.Second = ICK_Integral_Promotion;
     FromType = ToType.getUnqualifiedType();
-  } 
-  // Floating point promotion (C++ 4.6).
-  else if (IsFloatingPointPromotion(FromType, ToType)) {
+  } else if (IsFloatingPointPromotion(FromType, ToType)) {
+    // Floating point promotion (C++ 4.6).
     SCS.Second = ICK_Floating_Promotion;
     FromType = ToType.getUnqualifiedType();
-  } 
-  // Complex promotion (Clang extension)
-  else if (IsComplexPromotion(FromType, ToType)) {
+  } else if (IsComplexPromotion(FromType, ToType)) {
+    // Complex promotion (Clang extension)
     SCS.Second = ICK_Complex_Promotion;
     FromType = ToType.getUnqualifiedType();
-  }
-  // Integral conversions (C++ 4.7).
-  // FIXME: isIntegralType shouldn't be true for enums in C++.
-  else if ((FromType->isIntegralType() || FromType->isEnumeralType()) &&
+  } else if ((FromType->isIntegralType() || FromType->isEnumeralType()) &&
            (ToType->isIntegralType() && !ToType->isEnumeralType())) {
+    // Integral conversions (C++ 4.7).
+    // FIXME: isIntegralType shouldn't be true for enums in C++.
     SCS.Second = ICK_Integral_Conversion;
     FromType = ToType.getUnqualifiedType();
-  }
-  // Floating point conversions (C++ 4.8).
-  else if (FromType->isFloatingType() && ToType->isFloatingType()) {
+  } else if (FromType->isFloatingType() && ToType->isFloatingType()) {
+    // Floating point conversions (C++ 4.8).
     SCS.Second = ICK_Floating_Conversion;
     FromType = ToType.getUnqualifiedType();
-  }
-  // Complex conversions (C99 6.3.1.6)
-  else if (FromType->isComplexType() && ToType->isComplexType()) {
+  } else if (FromType->isComplexType() && ToType->isComplexType()) {
+    // Complex conversions (C99 6.3.1.6)
     SCS.Second = ICK_Complex_Conversion;
     FromType = ToType.getUnqualifiedType();
-  }
-  // Floating-integral conversions (C++ 4.9).
-  // FIXME: isIntegralType shouldn't be true for enums in C++.
-  else if ((FromType->isFloatingType() &&
-            ToType->isIntegralType() && !ToType->isBooleanType() &&
-                                        !ToType->isEnumeralType()) ||
-           ((FromType->isIntegralType() || FromType->isEnumeralType()) && 
-            ToType->isFloatingType())) {
+  } else if ((FromType->isFloatingType() &&
+              ToType->isIntegralType() && (!ToType->isBooleanType() &&
+                                           !ToType->isEnumeralType())) ||
+             ((FromType->isIntegralType() || FromType->isEnumeralType()) && 
+              ToType->isFloatingType())) {
+    // Floating-integral conversions (C++ 4.9).
+    // FIXME: isIntegralType shouldn't be true for enums in C++.
     SCS.Second = ICK_Floating_Integral;
     FromType = ToType.getUnqualifiedType();
-  }
-  // Complex-real conversions (C99 6.3.1.7)
-  else if ((FromType->isComplexType() && ToType->isArithmeticType()) ||
-           (ToType->isComplexType() && FromType->isArithmeticType())) {
+  } else if ((FromType->isComplexType() && ToType->isArithmeticType()) ||
+             (ToType->isComplexType() && FromType->isArithmeticType())) {
+    // Complex-real conversions (C99 6.3.1.7)
     SCS.Second = ICK_Complex_Real;
     FromType = ToType.getUnqualifiedType();
-  }
-  // Pointer conversions (C++ 4.10).
-  else if (IsPointerConversion(From, FromType, ToType, FromType, 
-                               IncompatibleObjC)) {
+  } else if (IsPointerConversion(From, FromType, ToType, FromType, 
+                                 IncompatibleObjC)) {
+    // Pointer conversions (C++ 4.10).
     SCS.Second = ICK_Pointer_Conversion;
     SCS.IncompatibleObjC = IncompatibleObjC;
-  }
-  // Pointer to member conversions (4.11).
-  else if (IsMemberPointerConversion(From, FromType, ToType, FromType)) {
+  } else if (IsMemberPointerConversion(From, FromType, ToType, FromType)) {
+    // Pointer to member conversions (4.11).
     SCS.Second = ICK_Pointer_Member;
-  }
-  // Boolean conversions (C++ 4.12).
-  else if (ToType->isBooleanType() &&
-           (FromType->isArithmeticType() ||
-            FromType->isEnumeralType() ||
-            FromType->isPointerType() ||
-            FromType->isBlockPointerType() ||
-            FromType->isMemberPointerType() ||
-            FromType->isNullPtrType())) {
+  } else if (ToType->isBooleanType() &&
+             (FromType->isArithmeticType() ||
+              FromType->isEnumeralType() ||
+              FromType->isPointerType() ||
+              FromType->isBlockPointerType() ||
+              FromType->isMemberPointerType() ||
+              FromType->isNullPtrType())) {
+    // Boolean conversions (C++ 4.12).
     SCS.Second = ICK_Boolean_Conversion;
     FromType = Context.BoolTy;
-  }
-  // Compatible conversions (Clang extension for C function overloading)
-  else if (!getLangOptions().CPlusPlus && 
-           Context.typesAreCompatible(ToType, FromType)) {
+  } else if (!getLangOptions().CPlusPlus && 
+             Context.typesAreCompatible(ToType, FromType)) {
+    // Compatible conversions (Clang extension for C function overloading)
     SCS.Second = ICK_Compatible_Conversion;
   } else {
     // No second conversion required.
@@ -4660,8 +4644,7 @@
       if (Method->isStatic()) {
         // Do nothing: static member functions aren't any different
         // from non-member functions.
-      }
-      else if (QualifiedDeclRefExpr *DRE 
+      } else if (QualifiedDeclRefExpr *DRE 
                  = dyn_cast<QualifiedDeclRefExpr>(UnOp->getSubExpr())) {
         // We have taken the address of a pointer to member
         // function. Perform the computation here so that we get the

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=78102&r1=78101&r2=78102&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Tue Aug  4 16:02:39 2009
@@ -681,10 +681,9 @@
         PreviousDefaultArgLoc = NewTypeParm->getDefaultArgumentLoc();
       } else if (SawDefaultArgument)
         MissingDefaultArg = true;
-    } 
-    // Merge default arguments for non-type template parameters
-    else if (NonTypeTemplateParmDecl *NewNonTypeParm
+    } else if (NonTypeTemplateParmDecl *NewNonTypeParm
                = dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
+      // Merge default arguments for non-type template parameters
       NonTypeTemplateParmDecl *OldNonTypeParm
         = OldParams? cast<NonTypeTemplateParmDecl>(*OldParam) : 0;
       if (OldNonTypeParm && OldNonTypeParm->hasDefaultArgument() && 
@@ -709,9 +708,8 @@
         PreviousDefaultArgLoc = NewNonTypeParm->getDefaultArgumentLoc();
       } else if (SawDefaultArgument)
         MissingDefaultArg = true;      
-    }
+    } else {
     // Merge default arguments for template template parameters
-    else {
       TemplateTemplateParmDecl *NewTemplateParm
         = cast<TemplateTemplateParmDecl>(*NewParam);
       TemplateTemplateParmDecl *OldTemplateParm
@@ -2487,8 +2485,7 @@
                                                    Converted.getFlatArguments(),
                                                    Converted.flatSize(),
                                                     Context);
-  }
-  else
+  } else
     ClassTemplateSpecializationDecl::Profile(ID,
                                              Converted.getFlatArguments(),
                                              Converted.flatSize(),

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=78102&r1=78101&r2=78102&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue Aug  4 16:02:39 2009
@@ -612,11 +612,10 @@
       if (PInst->getType()->isVoidType()) {
         SemaRef.Diag(PInst->getLocation(), diag::err_param_with_void_type);
         PInst->setInvalidDecl();
-      }
-      else if (SemaRef.RequireNonAbstractType(PInst->getLocation(), 
-                                              PInst->getType(),
-                                              diag::err_abstract_type_in_decl,
-                                              Sema::AbstractParamType))
+      } else if (SemaRef.RequireNonAbstractType(PInst->getLocation(), 
+                                                PInst->getType(),
+                                                diag::err_abstract_type_in_decl,
+                                                Sema::AbstractParamType))
         PInst->setInvalidDecl();
 
       Params.push_back(PInst);





More information about the cfe-commits mailing list