diff options
author | Richard Trieu <rtrieu@google.com> | 2011-09-09 01:45:06 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2011-09-09 01:45:06 +0000 |
commit | ccd891ae75e9678f1138868e50508c8083d021fa (patch) | |
tree | 3fbce3520b2f0bbc9bc20caf0ea5c12d037369f1 /lib/Sema/SemaExpr.cpp | |
parent | 69ff26bd1e7a2faffec0c3b9740cfb0c6bb354c5 (diff) |
Capitialize paramater names in SemaExpr.cpp and resolve any parameter name conflicts between declarations and definitions from this and previous refactorings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139346 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 690 |
1 files changed, 345 insertions, 345 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 3d00537b81..aab24175a1 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -262,9 +262,8 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, Diag(D->getLocation(), diag::note_sentinel_here) << isMethod; } -SourceRange Sema::getExprRange(ExprTy *E) const { - Expr *Ex = (Expr *)E; - return Ex? Ex->getSourceRange() : SourceRange(); +SourceRange Sema::getExprRange(Expr *E) const { + return E ? E->getSourceRange() : SourceRange(); } //===----------------------------------------------------------------------===// @@ -546,21 +545,21 @@ ExprResult Sema::DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, /// /// \return false if the integer expression is an integer type and is /// successfully converted to the complex type. -static bool handleIntegerToComplexFloatConversion(Sema &S, ExprResult &intExpr, - ExprResult &complexExpr, - QualType intTy, - QualType complexTy, - bool skipCast) { - if (intTy->isComplexType() || intTy->isRealFloatingType()) return true; - if (skipCast) return false; - if (intTy->isIntegerType()) { - QualType fpTy = cast<ComplexType>(complexTy)->getElementType(); - intExpr = S.ImpCastExprToType(intExpr.take(), fpTy, CK_IntegralToFloating); - intExpr = S.ImpCastExprToType(intExpr.take(), complexTy, +static bool handleIntegerToComplexFloatConversion(Sema &S, ExprResult &IntExpr, + ExprResult &ComplexExpr, + QualType IntTy, + QualType ComplexTy, + bool SkipCast) { + if (IntTy->isComplexType() || IntTy->isRealFloatingType()) return true; + if (SkipCast) return false; + if (IntTy->isIntegerType()) { + QualType fpTy = cast<ComplexType>(ComplexTy)->getElementType(); + IntExpr = S.ImpCastExprToType(IntExpr.take(), fpTy, CK_IntegralToFloating); + IntExpr = S.ImpCastExprToType(IntExpr.take(), ComplexTy, CK_FloatingRealToComplex); } else { - assert(intTy->isComplexIntegerType()); - intExpr = S.ImpCastExprToType(intExpr.take(), complexTy, + assert(IntTy->isComplexIntegerType()); + IntExpr = S.ImpCastExprToType(IntExpr.take(), ComplexTy, CK_IntegralComplexToFloatingComplex); } return false; @@ -572,12 +571,12 @@ static QualType handleComplexFloatToComplexFloatConverstion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, - bool isCompAssign) { + bool IsCompAssign) { int order = S.Context.getFloatingTypeOrder(LHSType, RHSType); if (order < 0) { // _Complex float -> _Complex double - if (!isCompAssign) + if (!IsCompAssign) LHS = S.ImpCastExprToType(LHS.take(), RHSType, CK_FloatingComplexCast); return RHSType; } @@ -590,39 +589,39 @@ handleComplexFloatToComplexFloatConverstion(Sema &S, ExprResult &LHS, /// \brief Converts otherExpr to complex float and promotes complexExpr if /// necessary. Helper function of UsualArithmeticConversions() static QualType handleOtherComplexFloatConversion(Sema &S, - ExprResult &complexExpr, - ExprResult &otherExpr, - QualType complexTy, - QualType otherTy, - bool convertComplexExpr, - bool convertOtherExpr) { - int order = S.Context.getFloatingTypeOrder(complexTy, otherTy); + ExprResult &ComplexExpr, + ExprResult &OtherExpr, + QualType ComplexTy, + QualType OtherTy, + bool ConvertComplexExpr, + bool ConvertOtherExpr) { + int order = S.Context.getFloatingTypeOrder(ComplexTy, OtherTy); // If just the complexExpr is complex, the otherExpr needs to be converted, // and the complexExpr might need to be promoted. if (order > 0) { // complexExpr is wider // float -> _Complex double - if (convertOtherExpr) { - QualType fp = cast<ComplexType>(complexTy)->getElementType(); - otherExpr = S.ImpCastExprToType(otherExpr.take(), fp, CK_FloatingCast); - otherExpr = S.ImpCastExprToType(otherExpr.take(), complexTy, + if (ConvertOtherExpr) { + QualType fp = cast<ComplexType>(ComplexTy)->getElementType(); + OtherExpr = S.ImpCastExprToType(OtherExpr.take(), fp, CK_FloatingCast); + OtherExpr = S.ImpCastExprToType(OtherExpr.take(), ComplexTy, CK_FloatingRealToComplex); } - return complexTy; + return ComplexTy; } // otherTy is at least as wide. Find its corresponding complex type. - QualType result = (order == 0 ? complexTy : - S.Context.getComplexType(otherTy)); + QualType result = (order == 0 ? ComplexTy : + S.Context.getComplexType(OtherTy)); // double -> _Complex double - if (convertOtherExpr) - otherExpr = S.ImpCastExprToType(otherExpr.take(), result, + if (ConvertOtherExpr) + OtherExpr = S.ImpCastExprToType(OtherExpr.take(), result, CK_FloatingRealToComplex); // _Complex float -> _Complex double - if (convertComplexExpr && order < 0) - complexExpr = S.ImpCastExprToType(complexExpr.take(), result, + if (ConvertComplexExpr && order < 0) + ComplexExpr = S.ImpCastExprToType(ComplexExpr.take(), result, CK_FloatingComplexCast); return result; @@ -633,13 +632,13 @@ static QualType handleOtherComplexFloatConversion(Sema &S, static QualType handleComplexFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, - bool isCompAssign) { + bool IsCompAssign) { // if we have an integer operand, the result is the complex type. if (!handleIntegerToComplexFloatConversion(S, RHS, LHS, RHSType, LHSType, /*skipCast*/false)) return LHSType; if (!handleIntegerToComplexFloatConversion(S, LHS, RHS, LHSType, RHSType, - /*skipCast*/isCompAssign)) + /*skipCast*/IsCompAssign)) return RHSType; // This handles complex/complex, complex/float, or float/complex. @@ -660,47 +659,47 @@ static QualType handleComplexFloatConversion(Sema &S, ExprResult &LHS, if (LHSComplexFloat && RHSComplexFloat) return handleComplexFloatToComplexFloatConverstion(S, LHS, RHS, LHSType, RHSType, - isCompAssign); + IsCompAssign); // If only one operand is complex, promote it if necessary and convert the // other operand to complex. if (LHSComplexFloat) return handleOtherComplexFloatConversion( - S, LHS, RHS, LHSType, RHSType, /*convertComplexExpr*/!isCompAssign, + S, LHS, RHS, LHSType, RHSType, /*convertComplexExpr*/!IsCompAssign, /*convertOtherExpr*/ true); assert(RHSComplexFloat); return handleOtherComplexFloatConversion( S, RHS, LHS, RHSType, LHSType, /*convertComplexExpr*/true, - /*convertOtherExpr*/ !isCompAssign); + /*convertOtherExpr*/ !IsCompAssign); } /// \brief Hande arithmetic conversion from integer to float. Helper function /// of UsualArithmeticConversions() -static QualType handleIntToFloatConversion(Sema &S, ExprResult &floatExpr, - ExprResult &intExpr, - QualType floatTy, QualType intTy, - bool convertFloat, bool convertInt) { - if (intTy->isIntegerType()) { - if (convertInt) +static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr, + ExprResult &IntExpr, + QualType FloatTy, QualType IntTy, + bool ConvertFloat, bool ConvertInt) { + if (IntTy->isIntegerType()) { + if (ConvertInt) // Convert intExpr to the lhs floating point type. - intExpr = S.ImpCastExprToType(intExpr.take(), floatTy, + IntExpr = S.ImpCastExprToType(IntExpr.take(), FloatTy, CK_IntegralToFloating); - return floatTy; + return FloatTy; } // Convert both sides to the appropriate complex float. - assert(intTy->isComplexIntegerType()); - QualType result = S.Context.getComplexType(floatTy); + assert(IntTy->isComplexIntegerType()); + QualType result = S.Context.getComplexType(FloatTy); // _Complex int -> _Complex float - if (convertInt) - intExpr = S.ImpCastExprToType(intExpr.take(), result, + if (ConvertInt) + IntExpr = S.ImpCastExprToType(IntExpr.take(), result, CK_IntegralComplexToFloatingComplex); // float -> _Complex float - if (convertFloat) - floatExpr = S.ImpCastExprToType(floatExpr.take(), result, + if (ConvertFloat) + FloatExpr = S.ImpCastExprToType(FloatExpr.take(), result, CK_FloatingRealToComplex); return result; @@ -710,7 +709,7 @@ static QualType handleIntToFloatConversion(Sema &S, ExprResult &floatExpr, /// function of UsualArithmeticConversions() static QualType handleFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, - QualType RHSType, bool isCompAssign) { + QualType RHSType, bool IsCompAssign) { bool LHSFloat = LHSType->isRealFloatingType(); bool RHSFloat = RHSType->isRealFloatingType(); @@ -724,19 +723,19 @@ static QualType handleFloatConversion(Sema &S, ExprResult &LHS, } assert(order < 0 && "illegal float comparison"); - if (!isCompAssign) + if (!IsCompAssign) LHS = S.ImpCastExprToType(LHS.take(), RHSType, CK_FloatingCast); return RHSType; } if (LHSFloat) return handleIntToFloatConversion(S, LHS, RHS, LHSType, RHSType, - /*convertFloat=*/!isCompAssign, + /*convertFloat=*/!IsCompAssign, /*convertInt=*/ true); assert(RHSFloat); return handleIntToFloatConversion(S, RHS, LHS, RHSType, LHSType, /*convertInt=*/ true, - /*convertFloat=*/!isCompAssign); + /*convertFloat=*/!IsCompAssign); } /// \brief Handle conversions with GCC complex int extension. Helper function @@ -746,7 +745,7 @@ static QualType handleFloatConversion(Sema &S, ExprResult &LHS, static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, - bool isCompAssign) { + bool IsCompAssign) { const ComplexType *LHSComplexInt = LHSType->getAsComplexIntegerType(); const ComplexType *RHSComplexInt = RHSType->getAsComplexIntegerType(); @@ -760,7 +759,7 @@ static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS, return LHSType; } - if (!isCompAssign) + if (!IsCompAssign) LHS = S.ImpCastExprToType(LHS.take(), RHSType, CK_IntegralComplexCast); return RHSType; } @@ -773,7 +772,7 @@ static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS, assert(RHSComplexInt); // int -> _Complex int - if (!isCompAssign) + if (!IsCompAssign) LHS = S.ImpCastExprToType(LHS.take(), RHSType, CK_IntegralRealToComplex); return RHSType; } @@ -782,7 +781,7 @@ static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS, /// UsualArithmeticConversions() static QualType handleIntegerConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, - QualType RHSType, bool isCompAssign) { + QualType RHSType, bool IsCompAssign) { // The rules for this case are in C99 6.3.1.8 int order = S.Context.getIntegerTypeOrder(LHSType, RHSType); bool LHSSigned = LHSType->hasSignedIntegerRepresentation(); @@ -792,7 +791,7 @@ static QualType handleIntegerConversion(Sema &S, ExprResult &LHS, if (order >= 0) { RHS = S.ImpCastExprToType(RHS.take(), LHSType, CK_IntegralCast); return LHSType; - } else if (!isCompAssign) + } else if (!IsCompAssign) LHS = S.ImpCastExprToType(LHS.take(), RHSType, CK_IntegralCast); return RHSType; } else if (order != (LHSSigned ? 1 : -1)) { @@ -801,7 +800,7 @@ static QualType handleIntegerConversion(Sema &S, ExprResult &LHS, if (RHSSigned) { RHS = S.ImpCastExprToType(RHS.take(), LHSType, CK_IntegralCast); return LHSType; - } else if (!isCompAssign) + } else if (!IsCompAssign) LHS = S.ImpCastExprToType(LHS.take(), RHSType, CK_IntegralCast); return RHSType; } else if (S.Context.getIntWidth(LHSType) != S.Context.getIntWidth(RHSType)) { @@ -811,7 +810,7 @@ static QualType handleIntegerConversion(Sema &S, ExprResult &LHS, if (LHSSigned) { RHS = S.ImpCastExprToType(RHS.take(), LHSType, CK_IntegralCast); return LHSType; - } else if (!isCompAssign) + } else if (!IsCompAssign) LHS = S.ImpCastExprToType(LHS.take(), RHSType, CK_IntegralCast); return RHSType; } else { @@ -822,7 +821,7 @@ static QualType handleIntegerConversion(Sema &S, ExprResult &LHS, QualType result = S.Context.getCorrespondingUnsignedType(LHSSigned ? LHSType : RHSType); RHS = S.ImpCastExprToType(RHS.take(), result, CK_IntegralCast); - if (!isCompAssign) + if (!IsCompAssign) LHS = S.ImpCastExprToType(LHS.take(), result, CK_IntegralCast); return result; } @@ -835,8 +834,8 @@ static QualType handleIntegerConversion(Sema &S, ExprResult &LHS, /// FIXME: verify the conversion rules for "complex int" are consistent with /// GCC. QualType Sema::UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, - bool isCompAssign) { - if (!isCompAssign) { + bool IsCompAssign) { + if (!IsCompAssign) { LHS = UsualUnaryConversions(LHS.take()); if (LHS.isInvalid()) return QualType(); @@ -869,7 +868,7 @@ QualType Sema::UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, QualType LHSBitfieldPromoteTy = Context.isPromotableBitField(LHS.get()); if (!LHSBitfieldPromoteTy.isNull()) LHSType = LHSBitfieldPromoteTy; - if (LHSType != LHSUnpromotedType && !isCompAssign) + if (LHSType != LHSUnpromotedType && !IsCompAssign) LHS = ImpCastExprToType(LHS.take(), LHSType, CK_IntegralCast); // If both types are identical, no conversion is needed. @@ -881,21 +880,21 @@ QualType Sema::UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, // Handle complex types first (C99 6.3.1.8p1). if (LHSType->isComplexType() || RHSType->isComplexType()) return handleComplexFloatConversion(*this, LHS, RHS, LHSType, RHSType, - isCompAssign); + IsCompAssign); // Now handle "real" floating types (i.e. float, double, long double). if (LHSType->isRealFloatingType() || RHSType->isRealFloatingType()) return handleFloatConversion(*this, LHS, RHS, LHSType, RHSType, - isCompAssign); + IsCompAssign); // Handle GCC complex int extension. if (LHSType->isComplexIntegerType() || RHSType->isComplexIntegerType()) return handleComplexIntConversion(*this, LHS, RHS, LHSType, RHSType, - isCompAssign); + IsCompAssign); // Finally, we have two differing integer types. return handleIntegerConversion(*this, LHS, RHS, LHSType, RHSType, - isCompAssign); + IsCompAssign); } //===----------------------------------------------------------------------===// @@ -908,13 +907,13 @@ Sema::ActOnGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, - MultiTypeArg types, - MultiExprArg exprs) { - unsigned NumAssocs = types.size(); - assert(NumAssocs == exprs.size()); + MultiTypeArg ArgTypes, + MultiExprArg ArgExprs) { + unsigned NumAssocs = ArgTypes.size(); + assert(NumAssocs == ArgExprs.size()); - ParsedType *ParsedTypes = types.release(); - Expr **Exprs = exprs.release(); + ParsedType *ParsedTypes = ArgTypes.release(); + Expr **Exprs = ArgExprs.release(); TypeSourceInfo **Types = new TypeSourceInfo*[NumAssocs]; for (unsigned i = 0; i < NumAssocs; ++i) { @@ -1186,21 +1185,21 @@ diagnoseUncapturableValueReference(Sema &S, SourceLocation loc, /// There is a well-formed capture at a particular scope level; /// propagate it through all the nested blocks. -static CaptureResult propagateCapture(Sema &S, unsigned validScopeIndex, - const BlockDecl::Capture &capture) { - VarDecl *var = capture.getVariable(); +static CaptureResult propagateCapture(Sema &S, unsigned ValidScopeIndex, + const BlockDecl::Capture &Capture) { + VarDecl *var = Capture.getVariable(); // Update all the inner blocks with the capture information. - for (unsigned i = validScopeIndex + 1, e = S.FunctionScopes.size(); + for (unsigned i = ValidScopeIndex + 1, e = S.FunctionScopes.size(); i != e; ++i) { BlockScopeInfo *innerBlock = cast<BlockScopeInfo>(S.FunctionScopes[i]); innerBlock->Captures.push_back( - BlockDecl::Capture(capture.getVariable(), capture.isByRef(), - /*nested*/ true, capture.getCopyExpr())); + BlockDecl::Capture(Capture.getVariable(), Capture.isByRef(), + /*nested*/ true, Capture.getCopyExpr())); innerBlock->CaptureMap[var] = innerBlock->Captures.size(); // +1 } - return capture.isByRef() ? CR_CaptureByRef : CR_Capture; + return Capture.isByRef() ? CR_CaptureByRef : CR_Capture; } /// shouldCaptureValueReference - Determine if a reference to the @@ -1209,9 +1208,9 @@ static CaptureResult propagateCapture(Sema &S, unsigned validScopeIndex, /// This also keeps the captures set in the BlockScopeInfo records /// up-to-date. static CaptureResult shouldCaptureValueReference(Sema &S, SourceLocation loc, - ValueDecl *value) { + ValueDecl *Value) { // Only variables ever require capture. - VarDecl *var = dyn_cast<VarDecl>(value); + VarDecl *var = dyn_cast<VarDecl>(Value); if (!var) return CR_NoCapture; // Fast path: variables from the current context never require capture. @@ -1320,19 +1319,19 @@ static CaptureResult shouldCaptureValueReference(Sema &S, SourceLocation loc, blockScope->Captures.back()); } -static ExprResult BuildBlockDeclRefExpr(Sema &S, ValueDecl *vd, +static ExprResult BuildBlockDeclRefExpr(Sema &S, ValueDecl *VD, const DeclarationNameInfo &NameInfo, - bool byRef) { - assert(isa<VarDecl>(vd) && "capturing non-variable"); + bool ByRef) { + assert(isa<VarDecl>(VD) && "capturing non-variable"); - VarDecl *var = cast<VarDecl>(vd); + VarDecl *var = cast<VarDecl>(VD); assert(var->hasLocalStorage() && "capturing non-local"); - assert(byRef == var->hasAttr<BlocksAttr>() && "byref set wrong"); + assert(ByRef == var->hasAttr<BlocksAttr>() && "byref set wrong"); QualType exprType = var->getType().getNonReferenceType(); BlockDeclRefExpr *BDRE; - if (!byRef) { + if (!ByRef) { // The variable will be bound by copy; make it const within the // closure, but record that this was done in the expression. bool constAdded = !exprType.isConstQualified(); @@ -1597,8 +1596,8 @@ ExprResult Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS, UnqualifiedId &Id, bool HasTrailingLParen, - bool isAddressOfOperand) { - assert(!(isAddressOfOperand && HasTrailingLParen) && + bool IsAddressOfOperand) { + assert(!(IsAddressOfOperand && HasTrailingLParen) && "cannot be direct & operand and have a trailing lparen"); if (SS.isInvalid()) @@ -1640,7 +1639,7 @@ ExprResult Sema::ActOnIdExpression(Scope *S, } if (DependentID) - return ActOnDependentIdExpression(SS, NameInfo, isAddressOfOperand, + return ActOnDependentIdExpression(SS, NameInfo, IsAddressOfOperand, TemplateArgs); bool IvarLookupFollowUp = false; @@ -1660,7 +1659,7 @@ ExprResult Sema::ActOnIdExpression(Scope *S, if (MemberOfUnknownSpecialization || (R.getResultKind() == LookupResult::NotFoundInCurrentInstantiation)) - return ActOnDependentIdExpression(SS, NameInfo, isAddressOfOperand, + return ActOnDependentIdExpression(SS, NameInfo, IsAddressOfOperand, TemplateArgs); } else { IvarLookupFollowUp = (!SS.isSet() && II && getCurMethodDecl()); @@ -1669,7 +1668,7 @@ ExprResult Sema::ActOnIdExpression(Scope *S, // If the result might be in a dependent base class, this is a dependent // id-expression. if (R.getResultKind() == LookupResult::NotFoundInCurrentInstantiation) - return ActOnDependentIdExpression(SS, NameInfo, isAddressOfOperand, + return ActOnDependentIdExpression(SS, NameInfo, IsAddressOfOperand, TemplateArgs); // If this reference is in an Objective-C method, then we need to do @@ -1752,7 +1751,7 @@ ExprResult Sema::ActOnIdExpression(Scope *S, // instance method. if (!R.empty() && (*R.begin())->isCXXClassMember()) { bool MightBeImplicitMember; - if (!isAddressOfOperand) + if (!IsAddressOfOperand) MightBeImplicitMember = true; else if (!SS.isEmpty()) MightBeImplicitMember = false; @@ -2646,8 +2645,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok) { return Owned(Res); } -ExprResult Sema::ActOnParenExpr(SourceLocation L, - SourceLocation R, Expr *E) { +ExprResult Sema::ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E) { assert((E != 0) && "ActOnParenExpr() missing expr"); return Owned(new (Context) ParenExpr(L, R, E)); } @@ -2713,9 +2711,9 @@ static bool CheckObjCTraitOperandConstraints(Sema &S, QualType T, /// expression. The logic mostly mirrors the type-based overload, but may modify /// the expression as it completes the type for that expression through template /// instantiation, etc. -bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *Op, +bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind) { - QualType ExprTy = Op->getType(); + QualType ExprTy = E->getType(); // C++ [expr.sizeof]p2: "When applied to a reference or a reference type, // the result is the size of the referenced type." @@ -2725,36 +2723,36 @@ bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *Op, ExprTy = Ref->getPointeeType(); if (ExprKind == UETT_VecStep) - return CheckVecStepTraitOperandType(*this, ExprTy, Op->getExprLoc(), - Op->getSourceRange()); + return CheckVecStepTraitOperandType(*this, ExprTy, E->getExprLoc(), + E->getSourceRange()); // Whitelist some types as extensions - if (!CheckExtensionTraitOperandType(*this, ExprTy, Op->getExprLoc(), - Op->getSourceRange(), ExprKind)) + if (!CheckExtensionTraitOperandType(*this, ExprTy, E->getExprLoc(), + E->getSourceRange(), ExprKind)) return false; - if (RequireCompleteExprType(Op, + if (RequireCompleteExprType(E, PDiag(diag::err_sizeof_alignof_incomplete_type) - << ExprKind << Op->getSourceRange(), + << ExprKind << E->getSourceRange(), std::make_pair(SourceLocation(), PDiag(0)))) return true; // Completeing the expression's type may have changed it. - ExprTy = Op->getType(); + ExprTy = E->getType(); if (const ReferenceType *Ref = ExprTy->getAs<ReferenceType>()) ExprTy = Ref->getPointeeType(); - if (CheckObjCTraitOperandConstraints(*this, ExprTy, Op->getExprLoc(), - Op->getSourceRange(), ExprKind)) + if (CheckObjCTraitOperandConstraints(*this, ExprTy, E->getExprLoc(), + E->getSourceRange(), ExprKind)) return true; if (ExprKind == UETT_SizeOf) { - if (DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(Op->IgnoreParens())) { + if (DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E->IgnoreParens())) { if (ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) { QualType OType = PVD->getOriginalType(); QualType Type = PVD->getType(); if (Type->isPointerType() && OType->isArrayType()) { - Diag(Op->getExprLoc(), diag::warn_sizeof_array_param) + Diag(E->getExprLoc(), diag::warn_sizeof_array_param) << Type << OType; Diag(PVD->getLocation(), diag::note_declared_at); } @@ -2780,34 +2778,34 @@ bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *Op, /// standard conversions are not applied to the operand of sizeof. /// /// This policy is followed for all of the unary trait expressions. -bool Sema::CheckUnaryExprOrTypeTraitOperand(QualType exprType, +bool Sema::CheckUnaryExprOrTypeTraitOperand(QualType ExprType, SourceLocation OpLoc, SourceRange ExprRange, UnaryExprOrTypeTrait ExprKind) { - if (exprType->isDependentType()) + if (ExprType->isDependentType()) return false; // C++ [expr.sizeof]p2: "When applied to a reference or a reference type, // the result is the size of the referenced type." // C++ [expr.alignof]p3: "When alignof is applied to a reference type, the // result shall be the alignment of the referenced type." - if (const ReferenceType *Ref = exprType->getAs<ReferenceType>()) - exprType = Ref->getPointeeType(); + if (const ReferenceType *Ref = ExprType->getAs<ReferenceType>()) + ExprType = Ref->getPointeeType(); if (ExprKind == UETT_VecStep) - return CheckVecStepTraitOperandType(*this, exprType, OpLoc, ExprRange); + return CheckVecStepTraitOperandType(*this, ExprType, OpLoc, ExprRange); // Whitelist some types as extensions - if (!CheckExtensionTraitOperandType(*this, exprType, OpLoc, ExprRange, + if (!CheckExtensionTraitOperandType(*this, ExprType, OpLoc, ExprRange, ExprKind)) return false; - if (RequireCompleteType(OpLoc, exprType, + if (RequireCompleteType(OpLoc, ExprType, PDiag(diag::err_sizeof_alignof_incomplete_type) << ExprKind << ExprRange)) return true; - if (CheckObjCTraitOperandConstraints(*this, exprType, OpLoc, ExprRange, + if (CheckObjCTraitOperandConstraints(*this, ExprType, OpLoc, ExprRange, ExprKind)) return true; @@ -2911,12 +2909,12 @@ Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc, /// Note that the ArgRange is invalid if isType is false. ExprResult Sema::ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, - UnaryExprOrTypeTrait ExprKind, bool isType, + UnaryExprOrTypeTrait ExprKind, bool IsType, void *TyOrEx, const SourceRange &ArgRange) { // If error parsing type, ignore. if (TyOrEx == 0) return ExprError(); - if (isType) { + if (IsType) { TypeSourceInfo *TInfo; (void) GetTypeFromParser(ParsedType::getFromOpaquePtr(TyOrEx), &TInfo); return CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, ArgRange); @@ -2928,7 +2926,7 @@ Sema::ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, } static QualType CheckRealImagOperand(Sema &S, ExprResult &V, SourceLocation Loc, - bool isReal) { + bool IsReal) { if (V.get()->isTypeDependent()) return S.Context.DependentTy; @@ -2952,12 +2950,12 @@ static QualType CheckRealImagOperand(Sema &S, ExprResult &V, SourceLocation Loc, if (PR.isInvalid()) return QualType(); if (PR.get() != V.get()) { V = move(PR); - return CheckRealImagOperand(S, V, Loc, isReal); + return CheckRealImagOperand(S, V, Loc, IsReal); } // Reject anything else. S.Diag(Loc, diag::err_realimag_invalid_type) << V.get()->getType() - << (isReal ? "__real" : "__imag"); + << (IsReal ? "__real" : "__imag"); return QualType(); } @@ -3008,7 +3006,7 @@ Sema::ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, ExprResult Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, - Expr *Idx, SourceLocation RLoc) { + Expr *Idx, SourceLocation RLoc) { Expr *LHSExp = Base; Expr *RHSExp = Idx; @@ -3403,16 +3401,16 @@ static ExprResult rebuildUnknownAnyFunction(Sema &S, Expr *fn); /// locations. ExprResult Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, - MultiExprArg args, SourceLocation RParenLoc, + MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig) { - unsigned NumArgs = args.size(); + unsigned NumArgs = ArgExprs.size(); // Since this might be a postfix expression, get rid of ParenListExprs. ExprResult Result = MaybeConvertParenListExprToParenExpr(S, Fn); if (Result.isInvalid()) return ExprError(); Fn = Result.take(); - Expr **Args = args.release(); + Expr **Args = ArgExprs.release(); if (getLangOptions().CPlusPlus) { // If this is a pseudo-destructor expression, build the call immediately. @@ -3508,7 +3506,7 @@ Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, ExprResult Sema::ActOnCUDAExecConfigExpr(Scope *S, SourceLocation LLLLoc, - MultiExprArg execConfig, SourceLocation GGGLoc) { + MultiExprArg ExecConfig, SourceLocation GGGLoc) { FunctionDecl *ConfigDecl = Context.getcudaConfigureCallDecl(); if (!ConfigDecl) return ExprError(Diag(LLLLoc, diag::err_undeclared_var_use) @@ -3518,27 +3516,27 @@ Sema::ActOnCUDAExecConfigExpr(Scope *S, SourceLocation LLLLoc, DeclRefExpr *ConfigDR = new (Context) DeclRefExpr( ConfigDecl, ConfigQTy, VK_LValue, LLLLoc); - return ActOnCallExpr(S, ConfigDR, LLLLoc, execConfig, GGGLoc, 0); + return ActOnCallExpr(S, ConfigDR, LLLLoc, ExecConfig, GGGLoc, 0); } /// ActOnAsTypeExpr - create a new asType (bitcast) from the arguments. /// /// __builtin_astype( value, dst type ) /// -ExprResult Sema::ActOnAsTypeExpr(Expr *expr, ParsedType destty, +ExprResult Sema::ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc) { ExprValueKind VK = VK_RValue; ExprObjectKind OK = OK_Ordinary; - QualType DstTy = GetTypeFromParser(destty); - QualType SrcTy = expr->getType(); + QualType DstTy = GetTypeFromParser(ParsedDestTy); + QualType SrcTy = E->getType(); if (Context.getTypeSize(DstTy) != Context.getTypeSize(SrcTy)) return ExprError(Diag(BuiltinLoc, diag::err_invalid_astype_of_different_size) << DstTy << SrcTy - << expr->getSourceRange()); - return Owned(new (Context) AsTypeExpr(expr, DstTy, VK, OK, BuiltinLoc, + << E->getSourceRange()); + return Owned(new (Context) AsTypeExpr(E, DstTy, VK, OK, BuiltinLoc, RParenLoc)); } @@ -3738,23 +3736,23 @@ Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, ExprResult Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, - SourceLocation RParenLoc, Expr *literalExpr) { + SourceLocation RParenLoc, Expr *LiteralExpr) { QualType literalType = TInfo->getType(); if (literalType->isArrayType()) { if (RequireCompleteType(LParenLoc, Context.getBaseElementType(literalType), PDiag(diag::err_illegal_decl_array_incomplete_type) << SourceRange(LParenLoc, - literalExpr->getSourceRange().getEnd()))) + LiteralExpr->getSourceRange().getEnd()))) return ExprError(); if (literalType->isVariableArrayType()) return ExprError(Diag(LParenLoc, diag::err_variable_object_no_init) - << SourceRange(LParenLoc, literalExpr->getSourceRange().getEnd())); + << SourceRange(LParenLoc, LiteralExpr->getSourceRange().getEnd())); } else if (!literalType->isDependentType() && RequireCompleteType(LParenLoc, literalType, PDiag(diag::err_typecheck_decl_incomplete_type) << SourceRange(LParenLoc, - literalExpr->getSourceRange().getEnd()))) + LiteralExpr->getSourceRange().getEnd()))) return ExprError(); InitializedEntity Entity @@ -3762,17 +3760,17 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, InitializationKind Kind = InitializationKind::CreateCStyleCast(LParenLoc, SourceRange(LParenLoc, RParenLoc)); - InitializationSequence InitSeq(*this, Entity, Kind, &literalExpr, 1); + InitializationSequence InitSeq(*this, Entity, Kind, &LiteralExpr, 1); ExprResult Result = InitSeq.Perform(*this, Entity, Kind, - MultiExprArg(*this, &literalExpr, 1), + MultiExprArg(*this, &LiteralExpr, 1), &literalType); if (Result.isInvalid()) return ExprError(); - literalExpr = Result.get(); + LiteralExpr = Result.get(); bool isFileScope = getCurFunctionOrMethodDecl() == 0; if (isFileScope) { // 6.5.2.5p3 - if (CheckForConstantInitializer(literalExpr, literalType)) + if (CheckForConstantInitializer(LiteralExpr, literalType)) return ExprError(); } @@ -3781,14 +3779,14 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, return MaybeBindToTemporary( new (Context) CompoundLiteralExpr(LParenLoc, TInfo, literalType, - VK, literalExpr, isFileScope)); + VK, LiteralExpr, isFileScope)); } ExprResult -Sema::ActOnInitList(SourceLocation LBraceLoc, MultiExprArg initlist, +Sema::ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc) { - unsigned NumInit = initlist.size(); - Expr **InitList = initlist.release(); + unsigned NumInit = InitArgList.size(); + Expr **InitList = InitArgList.release(); // Semantic analysis for initializers is done by ActOnDeclarator() and // CheckInitializer() - it requires knowledge of the object being intialized. @@ -3946,118 +3944,121 @@ static CastKind PrepareScalarCast(Sema &S, ExprResult &Src, QualType DestTy) { } /// CheckCastTypes - Check type constraints for casting between types. -ExprResult Sema::CheckCastTypes(SourceLocation CastStartLoc, SourceRange TyR, - QualType castType, Expr *castExpr, - CastKind& Kind, ExprValueKind &VK, - CXXCastPath &BasePath, bool FunctionalStyle) { - if (castExpr->getType() == Context.UnknownAnyTy) - return checkUnknownAnyCast(TyR, castType, castExpr, Kind, VK, BasePath); +ExprResult Sema::CheckCastTypes(SourceLocation CastStartLoc, + SourceRange TypeRange, QualType CastType, + Expr *CastExpr, CastKind &Kind, + ExprValueKind &VK, CXXCastPath &BasePath, + bool FunctionalStyle) { + if (CastExpr->getType() == Context.UnknownAnyTy) + return checkUnknownAnyCast(TypeRange, CastType, CastExpr, Kind, VK, + BasePath); if (getLangOptions().CPlusPlus) return CXXCheckCStyleCast(SourceRange(CastStartLoc, - castExpr->getLocEnd()), - castType, VK, castExpr, Kind, BasePath, + CastExpr->getLocEnd()), + CastType, VK, CastExpr, Kind, BasePath, FunctionalStyle); - assert(!castExpr->getType()->isPlaceholderType()); + assert(!CastExpr->getType()->isPlaceholderType()); // We only support r-value casts in C. VK = VK_RValue; |