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);
}
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)
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;
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.
Name = 0;
PrevDecl = 0;
Invalid = true;
- }
- else
+ } else
PrevDecl = R;
if (!getLangOptions().CPlusPlus && TUK != TUK_Reference) {
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");
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())
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;
Diag(PrevMember->getSourceLocation(),
diag::warn_base_initialized)
<< BaseClass->getDesugaredType(true);
- }
- else {
+ } else {
FieldDecl *Field = PrevMember->getMember();
Diag(PrevMember->getSourceLocation(),
diag::warn_field_initialized)
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);
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);
Diag(SuperLoc, diag::err_recursive_superclass)
<< SuperName << ClassName << SourceRange(AtInterfaceLoc, ClassLoc);
IDecl->setLocEnd(ClassLoc);
- }
- else {
+ } else {
ObjCInterfaceDecl *SuperClassDecl =
dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
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;
}
if (ImmediateClass)
WarnUndefinedMethod(IMPDecl->getLocation(), *I, IncompleteImpl);
continue;
- }
- else {
+ } else {
ObjCMethodDecl *ImpMethodDecl =
IMPDecl->getInstanceMethod((*I)->getSelector());
ObjCMethodDecl *IntfMethodDecl =
if (!ClsMap.count((*I)->getSelector())) {
if (ImmediateClass)
WarnUndefinedMethod(IMPDecl->getLocation(), *I, IncompleteImpl);
- }
- else {
+ } else {
ObjCMethodDecl *ImpMethodDecl =
IMPDecl->getClassMethod((*I)->getSelector());
ObjCMethodDecl *IntfMethodDecl =
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();
// 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)
}
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);
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;
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();
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();
return DeclPtrTy();
}
IC->addPropertyImplementation(PIDecl);
- }
- else {
+ } else {
if (Synthesize)
if (ObjCPropertyImplDecl *PPIDecl =
CatImplClass->FindPropertyImplIvarDecl(PropertyIvar)) {
}
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) {
++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()) {
}
if (Ty->isBlockPointerType())
isMethod = 2;
- }
- else
+ } else
return;
- }
- else
+ } else
return;
if (warnNotEnoughArgs) {
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;
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();
}
!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;
}
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);
}
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,
// 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;
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);
}
}
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.
// 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
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,
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;
}
// 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.
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
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() &&
PreviousDefaultArgLoc = NewNonTypeParm->getDefaultArgumentLoc();
} else if (SawDefaultArgument)
MissingDefaultArg = true;
- }
+ } else {
// Merge default arguments for template template parameters
- else {
TemplateTemplateParmDecl *NewTemplateParm
= cast<TemplateTemplateParmDecl>(*NewParam);
TemplateTemplateParmDecl *OldTemplateParm
Converted.getFlatArguments(),
Converted.flatSize(),
Context);
- }
- else
+ } else
ClassTemplateSpecializationDecl::Profile(ID,
Converted.getFlatArguments(),
Converted.flatSize(),
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);