diff options
author | Mike Stump <mrs@apple.com> | 2009-09-09 15:08:12 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-09-09 15:08:12 +0000 |
commit | 1eb4433ac451dc16f4133a88af2d002ac26c58ef (patch) | |
tree | 07065b80cb7787bb7b9ffcb985196007a57e86f7 /lib/Sema/SemaExpr.cpp | |
parent | 79d39f92590cf2e91bf81486b02cd1156d13ca54 (diff) |
Remove tabs, and whitespace cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81346 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 697 |
1 files changed, 345 insertions, 352 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 2644c1d6f7..c2a4119c53 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -46,12 +46,12 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) { // stuff. Don't warn if we are implementing a deprecated // construct. bool isSilenced = false; - + if (NamedDecl *ND = getCurFunctionOrMethodDecl()) { // If this reference happens *in* a deprecated function or method, don't // warn. isSilenced = ND->getAttr<DeprecatedAttr>(); - + // If this is an Objective-C method implementation, check to see if the // method was deprecated on the declaration, not the definition. if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(ND)) { @@ -59,14 +59,14 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) { // ObjCImplementationDecl. if (ObjCImplementationDecl *Impl = dyn_cast<ObjCImplementationDecl>(MD->getParent())) { - + MD = Impl->getClassInterface()->getMethod(MD->getSelector(), MD->isInstanceMethod()); isSilenced |= MD && MD->getAttr<DeprecatedAttr>(); } } } - + if (!isSilenced) Diag(Loc, diag::warn_deprecated) << D->getDeclName(); } @@ -90,18 +90,17 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) { } /// DiagnoseSentinelCalls - This routine checks on method dispatch calls -/// (and other functions in future), which have been declared with sentinel +/// (and other functions in future), which have been declared with sentinel /// attribute. It warns if call does not have the sentinel argument. /// void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, - Expr **Args, unsigned NumArgs) -{ + Expr **Args, unsigned NumArgs) { const SentinelAttr *attr = D->getAttr<SentinelAttr>(); - if (!attr) + if (!attr) return; int sentinelPos = attr->getSentinel(); int nullPos = attr->getNullPos(); - + // FIXME. ObjCMethodDecl and FunctionDecl need be derived from the same common // base class. Then we won't be needing two versions of the same code. unsigned int i = 0; @@ -132,7 +131,7 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, // block or function pointer call. QualType Ty = V->getType(); if (Ty->isBlockPointerType() || Ty->isFunctionPointerType()) { - const FunctionType *FT = Ty->isFunctionPointerType() + const FunctionType *FT = Ty->isFunctionPointerType() ? Ty->getAs<PointerType>()->getPointeeType()->getAsFunctionType() : Ty->getAs<BlockPointerType>()->getPointeeType()->getAsFunctionType(); if (const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FT)) { @@ -196,7 +195,7 @@ void Sema::DefaultFunctionArrayConversion(Expr *&E) { assert(!Ty.isNull() && "DefaultFunctionArrayConversion - missing type"); if (Ty->isFunctionType()) - ImpCastExprToType(E, Context.getPointerType(Ty), + ImpCastExprToType(E, Context.getPointerType(Ty), CastExpr::CK_FunctionToPointerDecay); else if (Ty->isArrayType()) { // In C90 mode, arrays only promote to pointers if the array expression is @@ -218,14 +217,14 @@ void Sema::DefaultFunctionArrayConversion(Expr *&E) { } /// UsualUnaryConversions - Performs various conversions that are common to most -/// operators (C99 6.3). The conversions of array and function types are +/// operators (C99 6.3). The conversions of array and function types are /// sometimes surpressed. For example, the array->pointer conversion doesn't /// apply if the array is an argument to the sizeof or address (&) operators. /// In these instances, this routine should *not* be called. Expr *Sema::UsualUnaryConversions(Expr *&Expr) { QualType Ty = Expr->getType(); assert(!Ty.isNull() && "UsualUnaryConversions - missing type"); - + // C99 6.3.1.1p2: // // The following may be used in an expression wherever an int or @@ -255,17 +254,17 @@ Expr *Sema::UsualUnaryConversions(Expr *&Expr) { } /// DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that -/// do not have a prototype. Arguments that have type float are promoted to +/// do not have a prototype. Arguments that have type float are promoted to /// double. All other argument types are converted by UsualUnaryConversions(). void Sema::DefaultArgumentPromotion(Expr *&Expr) { QualType Ty = Expr->getType(); assert(!Ty.isNull() && "DefaultArgumentPromotion - missing type"); - + // If this is a 'float' (CVR qualified or typedef) promote to double. if (const BuiltinType *BT = Ty->getAsBuiltinType()) if (BT->getKind() == BuiltinType::Float) return ImpCastExprToType(Expr, Context.DoubleTy); - + UsualUnaryConversions(Expr); } @@ -275,14 +274,14 @@ void Sema::DefaultArgumentPromotion(Expr *&Expr) { /// completely illegal. bool Sema::DefaultVariadicArgumentPromotion(Expr *&Expr, VariadicCallType CT) { DefaultArgumentPromotion(Expr); - + if (Expr->getType()->isObjCInterfaceType()) { Diag(Expr->getLocStart(), diag::err_cannot_pass_objc_interface_to_vararg) << Expr->getType() << CT; return true; } - + if (!Expr->getType()->isPODType()) Diag(Expr->getLocStart(), diag::warn_cannot_pass_non_pod_arg_to_vararg) << Expr->getType() << CT; @@ -293,7 +292,7 @@ bool Sema::DefaultVariadicArgumentPromotion(Expr *&Expr, VariadicCallType CT) { /// UsualArithmeticConversions - Performs various conversions that are common to /// binary operators (C99 6.3.1.8). If both operands aren't arithmetic, this -/// routine returns the first non-arithmetic type found. The client is +/// routine returns the first non-arithmetic type found. The client is /// responsible for emitting appropriate error diagnostics. /// FIXME: verify the conversion rules for "complex int" are consistent with /// GCC. @@ -304,11 +303,11 @@ QualType Sema::UsualArithmeticConversions(Expr *&lhsExpr, Expr *&rhsExpr, UsualUnaryConversions(rhsExpr); - // For conversion purposes, we ignore any qualifiers. + // For conversion purposes, we ignore any qualifiers. // For example, "const float" and "float" are equivalent. QualType lhs = Context.getCanonicalType(lhsExpr->getType()).getUnqualifiedType(); - QualType rhs = + QualType rhs = Context.getCanonicalType(rhsExpr->getType()).getUnqualifiedType(); // If both types are identical, no conversion is needed. @@ -372,9 +371,9 @@ Sema::ActOnStringLiteral(const Token *StringToks, unsigned NumStringToks) { StrTy = Context.getConstantArrayType(StrTy, llvm::APInt(32, Literal.GetNumStringChars()+1), ArrayType::Normal, 0); - + // Pass &StringTokLocs[0], StringTokLocs.size() to factory! - return Owned(StringLiteral::Create(Context, Literal.GetString(), + return Owned(StringLiteral::Create(Context, Literal.GetString(), Literal.GetStringLength(), Literal.AnyWide, StrTy, &StringTokLocs[0], @@ -395,7 +394,7 @@ static bool ShouldSnapshotBlockValueReference(BlockSemaInfo *CurBlock, // we wanted to. if (CurBlock->TheDecl == VD->getDeclContext()) return false; - + // If this is an enum constant or function, it is constant, don't snapshot. if (isa<EnumConstantDecl>(VD) || isa<FunctionDecl>(VD)) return false; @@ -406,7 +405,7 @@ static bool ShouldSnapshotBlockValueReference(BlockSemaInfo *CurBlock, if (const VarDecl *Var = dyn_cast<VarDecl>(VD)) if (!Var->hasLocalStorage()) return false; - + // Blocks that have these can't be constant. CurBlock->hasBlockDeclRefExprs = true; @@ -420,15 +419,15 @@ static bool ShouldSnapshotBlockValueReference(BlockSemaInfo *CurBlock, // having a reference outside it. if (NextBlock->TheDecl == VD->getDeclContext()) break; - + // Otherwise, the DeclRef from the inner block causes the outer one to need // a snapshot as well. NextBlock->hasBlockDeclRefExprs = true; } - + return true; -} - +} + /// ActOnIdentifierExpr - The parser read an identifier in expression context, @@ -454,35 +453,35 @@ Sema::BuildDeclRefExpr(NamedDecl *D, QualType Ty, SourceLocation Loc, const CXXScopeSpec *SS) { if (Context.getCanonicalType(Ty) == Context.UndeducedAutoTy) { Diag(Loc, - diag::err_auto_variable_cannot_appear_in_own_initializer) + diag::err_auto_variable_cannot_appear_in_own_initializer) << D->getDeclName(); return ExprError(); } - + if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(CurContext)) { if (const FunctionDecl *FD = MD->getParent()->isLocalClass()) { if (VD->hasLocalStorage() && VD->getDeclContext() != CurContext) { - Diag(Loc, diag::err_reference_to_local_var_in_enclosing_function) + Diag(Loc, diag::err_reference_to_local_var_in_enclosing_function) << D->getIdentifier() << FD->getDeclName(); - Diag(D->getLocation(), diag::note_local_variable_declared_here) + Diag(D->getLocation(), diag::note_local_variable_declared_here) << D->getIdentifier(); return ExprError(); } } } } - + MarkDeclarationReferenced(Loc, D); - + Expr *E; if (SS && !SS->isEmpty()) { - E = new (Context) QualifiedDeclRefExpr(D, Ty, Loc, TypeDependent, + E = new (Context) QualifiedDeclRefExpr(D, Ty, Loc, TypeDependent, ValueDependent, SS->getRange(), static_cast<NestedNameSpecifier *>(SS->getScopeRep())); } else E = new (Context) DeclRefExpr(D, Ty, Loc, TypeDependent, ValueDependent); - + return Owned(E); } @@ -491,14 +490,14 @@ Sema::BuildDeclRefExpr(NamedDecl *D, QualType Ty, SourceLocation Loc, /// is Record. static Decl *getObjectForAnonymousRecordDecl(ASTContext &Context, RecordDecl *Record) { - assert(Record->isAnonymousStructOrUnion() && + assert(Record->isAnonymousStructOrUnion() && "Record must be an anonymous struct or union!"); - + // FIXME: Once Decls are directly linked together, this will be an O(1) // operation rather than a slow walk through DeclContext's vector (which // itself will be eliminated). DeclGroups might make this even better. DeclContext *Ctx = Record->getDeclContext(); - for (DeclContext::decl_iterator D = Ctx->decls_begin(), + for (DeclContext::decl_iterator D = Ctx->decls_begin(), DEnd = Ctx->decls_end(); D != DEnd; ++D) { if (*D == Record) { @@ -547,7 +546,7 @@ VarDecl *Sema::BuildAnonymousStructUnionMemberPath(FieldDecl *Field, break; } Ctx = Ctx->getParent(); - } while (Ctx->isRecord() && + } while (Ctx->isRecord() && cast<RecordDecl>(Ctx)->isAnonymousStructOrUnion()); return BaseObject; @@ -559,7 +558,7 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc, Expr *BaseObjectExpr, SourceLocation OpLoc) { llvm::SmallVector<FieldDecl *, 4> AnonFields; - VarDecl *BaseObject = BuildAnonymousStructUnionMemberPath(Field, + VarDecl *BaseObject = BuildAnonymousStructUnionMemberPath(Field, AnonFields); // Build the expression that refers to the base object, from @@ -575,7 +574,7 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc, MarkDeclarationReferenced(Loc, BaseObject); BaseObjectExpr = new (Context) DeclRefExpr(BaseObject,BaseObject->getType(), SourceLocation()); - ExtraQuals + ExtraQuals = Context.getCanonicalType(BaseObject->getType()).getCVRQualifiers(); } else if (BaseObjectExpr) { // The caller provided the base object expression. Determine @@ -593,11 +592,11 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc, // program our base object expression is "this". if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(CurContext)) { if (!MD->isStatic()) { - QualType AnonFieldType + QualType AnonFieldType = Context.getTagDeclType( cast<RecordDecl>(AnonFields.back()->getDeclContext())); QualType ThisType = Context.getTagDeclType(MD->getParent()); - if ((Context.getCanonicalType(AnonFieldType) + if ((Context.getCanonicalType(AnonFieldType) == Context.getCanonicalType(ThisType)) || IsDerivedFrom(ThisType, AnonFieldType)) { // Our base object expression is "this". @@ -612,7 +611,7 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc, ExtraQuals = MD->getTypeQualifiers(); } - if (!BaseObjectExpr) + if (!BaseObjectExpr) return ExprError(Diag(Loc, diag::err_invalid_non_static_member_use) << Field->getDeclName()); } @@ -626,7 +625,7 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc, FI != FIEnd; ++FI) { QualType MemberType = (*FI)->getType(); if (!(*FI)->isMutable()) { - unsigned combinedQualifiers + unsigned combinedQualifiers = MemberType.getCVRQualifiers() | ExtraQuals; MemberType = MemberType.getQualifiedType(combinedQualifiers); } @@ -665,7 +664,7 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc, Sema::OwningExprResult Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, DeclarationName Name, bool HasTrailingLParen, - const CXXScopeSpec *SS, + const CXXScopeSpec *SS, bool isAddressOfOperand) { // Could be enum-constant, value decl, instance variable, etc. if (SS && SS->isInvalid()) @@ -678,7 +677,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, // FIXME: Member of the current instantiation. if (SS && isDependentScopeSpecifier(*SS)) { return Owned(new (Context) UnresolvedDeclRefExpr(Name, Context.DependentTy, - Loc, SS->getRange(), + Loc, SS->getRange(), static_cast<NestedNameSpecifier *>(SS->getScopeRep()), isAddressOfOperand)); } @@ -692,7 +691,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, : SourceRange()); return ExprError(); } - + NamedDecl *D = Lookup.getAsDecl(); // If this reference is in an Objective-C method, then ivar lookup happens as @@ -701,8 +700,8 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, if (II && getCurMethodDecl()) { // There are two cases to handle here. 1) scoped lookup could have failed, // in which case we should look for an ivar. 2) scoped lookup could have - // found a decl, but that decl is outside the current instance method (i.e. - // a global variable). In these two cases, we do a lookup for an ivar with + // found a decl, but that decl is outside the current instance method (i.e. + // a global variable). In these two cases, we do a lookup for an ivar with // this name, if the lookup sucedes, we replace it our current decl. if (D == 0 || D->isDefinedOutsideFunctionOrMethod()) { ObjCInterfaceDecl *IFace = getCurMethodDecl()->getClassInterface(); @@ -711,12 +710,12 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, // Check if referencing a field with __attribute__((deprecated)). if (DiagnoseUseOfDecl(IV, Loc)) return ExprError(); - + // If we're referencing an invalid decl, just return this as a silent // error node. The error diagnostic was already emitted on the decl. if (IV->isInvalidDecl()) return ExprError(); - + bool IsClsMethod = getCurMethodDecl()->isClassMethod(); // If a class method attemps to use a free standing ivar, this is // an error. @@ -735,8 +734,8 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, OwningExprResult SelfExpr = ActOnIdentifierExpr(S, SourceLocation(), II, false); MarkDeclarationReferenced(Loc, IV); - return Owned(new (Context) - ObjCIvarRefExpr(IV, IV->getType(), Loc, + return Owned(new (Context) + ObjCIvarRefExpr(IV, IV->getType(), Loc, SelfExpr.takeAs<Expr>(), true, true)); } } @@ -753,7 +752,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, // Needed to implement property "super.method" notation. if (D == 0 && II->isStr("super")) { QualType T; - + if (getCurMethodDecl()->isInstanceMethod()) T = Context.getObjCObjectPointerType(Context.getObjCInterfaceType( getCurMethodDecl()->getClassInterface())); @@ -765,7 +764,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, // Determine whether this name might be a candidate for // argument-dependent lookup. - bool ADL = getLangOptions().CPlusPlus && (!SS || !SS->isSet()) && + bool ADL = getLangOptions().CPlusPlus && (!SS || !SS->isSet()) && HasTrailingLParen; if (ADL && D == 0) { @@ -791,7 +790,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, // If this name wasn't predeclared and if this is not a function call, // diagnose the problem. if (SS && !SS->isEmpty()) { - DiagnoseMissingMember(Loc, Name, + DiagnoseMissingMember(Loc, Name, (NestedNameSpecifier *)SS->getScopeRep(), SS->getRange()); return ExprError(); @@ -803,18 +802,18 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, return ExprError(Diag(Loc, diag::err_undeclared_var_use) << Name); } } - + if (VarDecl *Var = dyn_cast<VarDecl>(D)) { // Warn about constructs like: // if (void *X = foo()) { ... } else { X }. // In the else block, the pointer is always false. - + // FIXME: In a template instantiation, we don't have scope // information to check this property. if (Var->isDeclaredInCondition() && Var->getType()->isScalarType()) { Scope *CheckS = S; while (CheckS) { - if (CheckS->isWithinElse() && + if (CheckS->isWithinElse() && CheckS->getControlParent()->isDeclScope(DeclPtrTy::make(Var))) { if (Var->getType()->isBooleanType()) ExprError(Diag(Loc, diag::warn_value_always_false) @@ -824,7 +823,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, << Var->getDeclName()); break; } - + // Move up one more control parent to check again. CheckS = CheckS->getControlParent(); if (CheckS) @@ -848,16 +847,16 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, return BuildDeclRefExpr(Func, NoProtoType, Loc, false, false, SS); } } - + return BuildDeclarationNameExpr(Loc, D, HasTrailingLParen, SS, isAddressOfOperand); } /// \brief Cast member's object to its own class if necessary. bool Sema::PerformObjectMemberConversion(Expr *&From, NamedDecl *Member) { if (FieldDecl *FD = dyn_cast<FieldDecl>(Member)) - if (CXXRecordDecl *RD = + if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(FD->getDeclContext())) { - QualType DestType = + QualType DestType = Context.getCanonicalType(Context.getTypeDeclType(RD)); if (DestType->isDependentType() || From->getType()->isDependentType()) return false; @@ -880,17 +879,17 @@ Sema::PerformObjectMemberConversion(Expr *&From, NamedDecl *Member) { } /// \brief Build a MemberExpr AST node. -static MemberExpr *BuildMemberExpr(ASTContext &C, Expr *Base, bool isArrow, - const CXXScopeSpec *SS, NamedDecl *Member, +static MemberExpr *BuildMemberExpr(ASTContext &C, Expr *Base, bool isArrow, + const CXXScopeSpec *SS, NamedDecl *Member, SourceLocation Loc, QualType Ty) { if (SS && SS->isSet()) - return MemberExpr::Create(C, Base, isArrow, + return MemberExpr::Create(C, Base, isArrow, (NestedNameSpecifier *)SS->getScopeRep(), - SS->getRange(), Member, Loc, + SS->getRange(), Member, Loc, // FIXME: Explicit template argument lists false, SourceLocation(), 0, 0, SourceLocation(), Ty); - + return new (C) MemberExpr(Base, isArrow, Member, Loc, Ty); } @@ -898,11 +897,11 @@ static MemberExpr *BuildMemberExpr(ASTContext &C, Expr *Base, bool isArrow, Sema::OwningExprResult Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D, bool HasTrailingLParen, - const CXXScopeSpec *SS, + const CXXScopeSpec *SS, bool isAddressOfOperand) { assert(D && "Cannot refer to a NULL declaration"); DeclarationName Name = D->getDeclName(); - + // If this is an expression of the form &Class::member, don't build an // implicit member ref, because we want a pointer to the member in general, // not any specific instance's member. @@ -935,7 +934,7 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D, if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(CurContext)) { if (!MD->isStatic()) { - // C++ [class.mfct.nonstatic]p2: + // C++ [class.mfct.nonstatic]p2: // [...] if name lookup (3.4.1) resolves the name in the // id-expression to a nonstatic nontype member of class X or of // a base class of X, the id-expression is transformed into a @@ -950,7 +949,7 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D, if (const ReferenceType *RefType = MemberType->getAs<ReferenceType>()) MemberType = RefType->getPointeeType(); else if (!FD->isMutable()) { - unsigned combinedQualifiers + unsigned combinedQualifiers = MemberType.getCVRQualifiers() | MD->getTypeQualifiers(); MemberType = MemberType.getQualifiedType(combinedQualifiers); } @@ -959,25 +958,25 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D, Ctx = Method->getParent(); MemberType = Method->getType(); } - } else if (FunctionTemplateDecl *FunTmpl + } else if (FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(D)) { - if (CXXMethodDecl *Method + if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl())) { - if (!Method->isStatic()) { + if (!Method->isStatic()) { Ctx = Method->getParent(); MemberType = Context.OverloadTy; } } - } else if (OverloadedFunctionDecl *Ovl + } else if (OverloadedFunctionDecl *Ovl = dyn_cast<OverloadedFunctionDecl>(D)) { // FIXME: We need an abstraction for iterating over one or more function // templates or functions. This code is far too repetitive! - for (OverloadedFunctionDecl::function_iterator + for (OverloadedFunctionDecl::function_iterator Func = Ovl->function_begin(), FuncEnd = Ovl->function_end(); Func != FuncEnd; ++Func) { CXXMethodDecl *DMethod = 0; - if (FunctionTemplateDecl *FunTmpl + if (FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(*Func)) DMethod = dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl()); else @@ -994,7 +993,7 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D, if (Ctx && Ctx->isRecord()) { QualType CtxType = Context.getTagDeclType(cast<CXXRecordDecl>(Ctx)); QualType ThisType = Context.getTagDeclType(MD->getParent()); - if ((Context.getCanonicalType(CtxType) + if ((Context.getCanonicalType(CtxType) == Context.getCanonicalType(ThisType)) || IsDerivedFrom(ThisType, CtxType)) { // Build the implicit member access expression. @@ -1042,8 +1041,8 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D, return BuildDeclRefExpr(Template, Context.OverloadTy, Loc, false, false, SS); else if (UnresolvedUsingDecl *UD = dyn_cast<UnresolvedUsingDecl>(D)) - return BuildDeclRefExpr(UD, Context.DependentTy, Loc, - /*TypeDependent=*/true, + return BuildDeclRefExpr(UD, Context.DependentTy, Loc, + /*TypeDependent=*/true, /*ValueDependent=*/true, SS); ValueDecl *VD = cast<ValueDecl>(D); @@ -1052,7 +1051,7 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D, // this check when we're going to perform argument-dependent lookup // on this function name, because this might not be the function // that overload resolution actually selects. - bool ADL = getLangOptions().CPlusPlus && (!SS || !SS->isSet()) && + bool ADL = getLangOptions().CPlusPlus && (!SS || !SS->isSet()) && HasTrailingLParen; if (!(ADL && isa<FunctionDecl>(VD)) && DiagnoseUseOfDecl(VD, Loc)) return ExprError(); @@ -1078,9 +1077,9 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D, // This is to record that a 'const' was actually synthesize and added. bool constAdded = !ExprTy.isConstQualified(); // Variable will be bound by-copy, make it const within the closure. - + ExprTy.addConst(); - return Owned(new (Context) BlockDeclRefExpr(VD, ExprTy, Loc, false, + return Owned(new (Context) BlockDeclRefExpr(VD, ExprTy, Loc, false, constAdded)); } // If this reference is not in a block or if the referenced variable is @@ -1090,7 +1089,7 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D, bool ValueDependent = false; if (getLangOptions().CPlusPlus) { // C++ [temp.dep.expr]p3: - // An id-expression is type-dependent if it contains: + // An id-expression is type-dependent if it contains: // - an identifier that was declared with a dependent type, if (VD->getType()->isDependentType()) TypeDependent = true; @@ -1151,7 +1150,7 @@ Sema::OwningExprResult Sema::ActOnPredefinedExpr(SourceLocation Loc, // Pre-defined identifiers are of type char[x], where x is the length of the // string. - + Decl *currentDecl = getCurFunctionOrMethodDecl(); if (!currentDecl) { Diag(Loc, diag::ext_predef_outside_function); @@ -1203,7 +1202,7 @@ Action::OwningExprResult Sema::ActOnNumericConstant(const Token &Tok) { // Get the spelling of the token, which eliminates trigraphs, etc. unsigned ActualLength = PP.getSpelling(Tok, ThisTokBegin); - NumericLiteralParser Literal(ThisTokBegin, ThisTokBegin+ActualLength, + NumericLiteralParser Literal(ThisTokBegin, ThisTokBegin+ActualLength, Tok.getLocation(), PP); if (Literal.hadError) return ExprError(); @@ -1316,7 +1315,7 @@ Action::OwningExprResult Sema::ActOnNumericConstant(const Token &Tok) { // If this is an imaginary literal, create the ImaginaryLiteral wrapper. if (Literal.isImaginary) - Res = new (Context) ImaginaryLiteral(Res, + Res = new (Context) ImaginaryLiteral(Res, Context.getComplexType(Res->getType())); return Owned(Res); @@ -1345,27 +1344,27 @@ bool Sema::CheckSizeOfAlignOfOperand(QualType exprType, Diag(OpLoc, diag::ext_sizeof_function_type) << ExprRange; return false; } - + // Allow sizeof(void)/alignof(void) as an extension. if (exprType->isVoidType()) { Diag(OpLoc, diag::ext_sizeof_void_type) << (isSizeof ? "sizeof" : "__alignof") << ExprRange; return false; } - + if (RequireCompleteType(OpLoc, exprType, - isSizeof ? diag::err_sizeof_incomplete_type : + isSizeof ? diag::err_sizeof_incomplete_type : PDiag(diag::err_alignof_incomplete_type) << ExprRange)) return true; - + // Reject sizeof(interface) and sizeof(interface<proto>) in 64-bit mode. if (LangOpts.ObjCNonFragileABI && exprType->isObjCInterfaceType()) { Diag(OpLoc, diag::err_sizeof_nonfragile_interface) << exprType << isSizeof << ExprRange; return true; } - + return false; } @@ -1373,7 +1372,7 @@ bool Sema::CheckAlignOfExpr(Expr *E, SourceLocation OpLoc, const SourceRange &ExprRange) { E = E->IgnoreParens(); - // alignof decl is always ok. + // alignof decl is always ok. if (isa<DeclRefExpr>(E)) return false; @@ -1396,8 +1395,8 @@ bool Sema::CheckAlignOfExpr(Expr *E, SourceLocation OpLoc, } /// \brief Build a sizeof or alignof expression given a type operand. -Action::OwningExprResult -Sema::CreateSizeOfAlignOfExpr(QualType T, SourceLocation OpLoc, +Action::OwningExprResult +Sema::CreateSizeOfAlignOfExpr(QualType T, SourceLocation OpLoc, bool isSizeOf, SourceRange R) { if (T.isNull()) return ExprError(); @@ -1414,8 +1413,8 @@ Sema::CreateSizeOfAlignOfExpr(QualType T, SourceLocation OpLoc, /// \brief Build a sizeof or alignof expression given an expression /// operand. -Action::OwningExprResult -Sema::CreateSizeOfAlignOfExpr(Expr *E, SourceLocation OpLoc, +Action::OwningExprResult +Sema::CreateSizeOfAlignOfExpr(Expr *E, SourceLocation OpLoc, bool isSizeOf, SourceRange R) { // Verify that the operand is valid. bool isInvalid = false; @@ -1452,7 +1451,7 @@ Sema::ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType, // FIXME: Preserve type source info. QualType ArgTy = GetTypeFromParser(TyOrEx); return CreateSizeOfAlignOfExpr(ArgTy, OpLoc, isSizeof, ArgRange); - } + } // Get the end location. Expr *ArgEx = (Expr *)TyOrEx; @@ -1468,15 +1467,15 @@ Sema::ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType, QualType Sema::CheckRealImagOperand(Expr *&V, SourceLocation Loc, bool isReal) { if (V->isTypeDependent()) return Context.DependentTy; - + // These operators return the element type of a complex type. if (const ComplexType *CT = V->getType()->getAsComplexType()) return CT->getElementType(); - + // Otherwise they pass through real integer and floating point types here. if (V->getType()->isArithmeticType()) return V->getType(); - + // Reject anything else. Diag(Loc, diag::err_realimag_invalid_type) << V->getType() << (isReal ? "__real" : "__imag"); @@ -1514,9 +1513,9 @@ Sema::ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, // for objects of that type. When the postfix increment is // called as a result of using the ++ operator, the int // argument will have value zero. - Expr *Args[2] = { - Arg, - new (Context) IntegerLiteral(llvm::APInt(Context.Target.getIntWidth(), 0, + Expr *Args[2] = { + Arg, + new (Context) IntegerLiteral(llvm::APInt(Context.Target.getIntWidth(), 0, /*isSigned=*/true), Context.IntTy, SourceLocation()) }; @@ -1560,7 +1559,7 @@ Sema::ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, Input.release(); Args[0] = Arg; return Owned(new (Context) CXXOperatorCallExpr(Context, OverOp, FnExpr, - Args, 2, ResultTy, + Args, 2, ResultTy, OpLoc)); } else { // We matched a built-in operator. Convert the arguments, then @@ -1613,7 +1612,7 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc, Expr *LHSExp = static_cast<Expr*>(Base.get()), *RHSExp = static_cast<Expr*>(Idx.get()); - + if (getLangOptions().CPlusPlus && (LHSExp->isTypeDependent() || RHSExp->isTypeDependent())) { Base.release(); @@ -1622,12 +1621,12 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc, Context.DependentTy, RLoc)); } - if (getLangOptions().CPlusPlus && + if (getLangOptions().CPlusPlus && (LHSExp->getType()->isRecordType() || LHSExp->getType()->isEnumeralType() || RHSExp->getType()->isRecordType() || RHSExp->getType()->isEnumeralType())) { - // Add the appropriate overloaded operators (C++ [over.match.oper]) + // Add the appropriate overloaded operators (C++ [over.match.oper]) // to the candidate set. OverloadCandidateSet CandidateSet; Expr *Args[2] = { LHSExp, RHSExp }; @@ -1648,7 +1647,7 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc, // Convert the arguments. if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) { if (PerformObjectArgumentInitialization(LHSExp, Method) || - PerformCopyInitialization(RHSExp, + PerformCopyInitialization(RHSExp, FnDecl->getParamDecl(0)->getType(), "passing")) return ExprError(); @@ -1678,7 +1677,7 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc, Args[0] = LHSExp; Args[1] = RHSExp; return Owned(new (Context) CXXOperatorCallExpr(Context, OO_Subscript, - FnExpr, Args, 2, + FnExpr, Args, 2, ResultTy, LLoc)); } else { // We matched a built-in operator. Convert the arguments, then @@ -1745,12 +1744,12 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc, BaseExpr = RHSExp; IndexExpr = LHSExp; ResultType = PTy->getPointeeType(); - } else if (const ObjCObjectPointerType *PTy = + } else if (const ObjCObjectPointerType *PTy = LHSTy->getAsObjCObjectPointerType()) { BaseExpr = LHSExp; IndexExpr = RHSExp; ResultType = PTy->getPointeeType(); - } else if (const ObjCObjectPointerType *PTy = + } else if (const ObjCObjectPointerType *PTy = RHSTy->getAsObjCObjectPointerType()) { // Handle the uncommon case of "123[Ptr]". BaseExpr = RHSExp; @@ -1797,28 +1796,28 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc, << IndexExpr->getSourceRange()); // C99 6.5.2.1p1: "shall have type "pointer to *object* type". Similarly, - // C++ [expr.sub]p1: The type "T" shall be a completely-defined object - // type. Note that Functions are not objects, and that (in C99 parlance) + // C++ [expr.sub]p1: The type "T" shall be a completely-defined object + // type. Note that Functions are not objects, and that (in C99 parlance) // incomplete types are not object types. if (ResultType->isFunctionType()) { Diag(BaseExpr->getLocStart(), diag::err_subscript_function_type) << ResultType << BaseExpr->getSourceRange(); return ExprError(); } - + if (!ResultType->isDependentType() && - RequireCompleteType(LLoc, ResultType, + RequireCompleteType(LLoc, ResultType, PDiag(diag::err_subscript_incomplete_type) << BaseExpr->getSourceRange())) return ExprError(); - + // Diagnose bad cases where we step over interface counts. if (ResultType->isObjCInterfaceType() && LangOpts.ObjCNonFragileABI) { Diag(LLoc, diag::err_subscript_nonfragile_interface) << ResultType << BaseExpr->getSourceRange(); return ExprError(); } - + Base.release(); Idx.release(); return Owned(new (Context) ArraySubscriptExpr(LHSExp, RHSExp, @@ -1827,7 +1826,7 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc, QualType Sema:: CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc, - const IdentifierInfo *CompName, + const IdentifierInfo *CompName, SourceLocation CompLoc) { const ExtVectorType *vecType = baseType->getAsExtVectorType(); @@ -1918,15 +1917,15 @@ static Decl *FindGetterNameDeclFromProtocolList(const ObjCProtocolDecl*PDecl, IdentifierInfo *Member, const Selector &Sel, ASTContext &Context) { - + if (ObjCPropertyDecl *PD = PDecl->FindPropertyDeclaration(Member)) return PD; if (ObjCMethodDecl *OMD = PDecl->getInstanceMethod(Sel)) return OMD; - + for (ObjCProtocolDecl::protocol_iterator I = PDecl->protocol_begin(), E = PDecl->protocol_end(); I != E |