diff options
author | John McCall <rjmccall@apple.com> | 2010-11-24 05:12:34 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-11-24 05:12:34 +0000 |
commit | 7eb0a9eb0cde8444b97f9c5b713d9be7a6f1e607 (patch) | |
tree | e828a6fb6060ac7711b5209210bfd31c15de71af /lib/Sema/SemaExpr.cpp | |
parent | 834f9de3d3d76986d09f41725a70ba45a3e2aecd (diff) |
Switch a lot of call-sites over to using the new value-kind calculations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120084 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index fa7069628b..2daeed1257 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -238,8 +238,7 @@ void Sema::DefaultFunctionArrayConversion(Expr *&E) { // An lvalue or rvalue of type "array of N T" or "array of unknown bound of // T" can be converted to an rvalue of type "pointer to T". // - if (getLangOptions().C99 || getLangOptions().CPlusPlus || - E->isLvalue(Context) == Expr::LV_Valid) + if (getLangOptions().C99 || getLangOptions().CPlusPlus || E->isLValue()) ImpCastExprToType(E, Context.getArrayDecayedType(Ty), CK_ArrayToPointerDecay); } @@ -252,7 +251,7 @@ void Sema::DefaultFunctionArrayLvalueConversion(Expr *&E) { assert(!Ty.isNull() && "DefaultFunctionArrayLvalueConversion - missing type"); if (!Ty->isDependentType() && Ty.hasQualifiers() && (!getLangOptions().CPlusPlus || !Ty->isRecordType()) && - E->isLvalue(Context) == Expr::LV_Valid) { + E->isLValue()) { // C++ [conv.lval]p1: // [...] If T is a non-class type, the type of the rvalue is the // cv-unqualified version of T. Otherwise, the type of the @@ -789,10 +788,16 @@ Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, MarkDeclarationReferenced(NameInfo.getLoc(), D); - return Owned(DeclRefExpr::Create(Context, + Expr *E = DeclRefExpr::Create(Context, SS? (NestedNameSpecifier *)SS->getScopeRep() : 0, - SS? SS->getRange() : SourceRange(), - D, NameInfo, Ty, VK)); + SS? SS->getRange() : SourceRange(), + D, NameInfo, Ty, VK); + + // Just in case we're building an illegal pointer-to-member. + if (isa<FieldDecl>(D) && cast<FieldDecl>(D)->getBitWidth()) + E->setObjectKind(OK_BitField); + + return Owned(E); } static ExprResult @@ -7045,7 +7050,7 @@ static QualType CheckAddressOfOperand(Sema &S, Expr *OrigOp, // expressions here, but the result of one is always an lvalue anyway. } NamedDecl *dcl = getPrimaryDecl(op); - Expr::isLvalueResult lval = op->isLvalue(S.Context); + Expr::LValueClassification lval = op->ClassifyLValue(S.Context); if (lval == Expr::LV_ClassTemporary) { bool sfinae = S.isSFINAEContext(); @@ -7091,25 +7096,21 @@ static QualType CheckAddressOfOperand(Sema &S, Expr *OrigOp, << op->getSourceRange(); return QualType(); } - } else if (op->getBitField()) { // C99 6.5.3.2p1 + } else if (op->getObjectKind() == OK_BitField) { // C99 6.5.3.2p1 // The operand cannot be a bit-field S.Diag(OpLoc, diag::err_typecheck_address_of) << "bit-field" << op->getSourceRange(); return QualType(); - } else if (op->refersToVectorElement()) { + } else if (op->getObjectKind() == OK_VectorComponent) { // The operand cannot be an element of a vector S.Diag(OpLoc, diag::err_typecheck_address_of) << "vector element" << op->getSourceRange(); return QualType(); - } else if (isa<ObjCPropertyRefExpr>(op)) { + } else if (op->getObjectKind() == OK_ObjCProperty) { // cannot take address of a property expression. S.Diag(OpLoc, diag::err_typecheck_address_of) << "property expression" << op->getSourceRange(); return QualType(); - } else if (ConditionalOperator *CO = dyn_cast<ConditionalOperator>(op)) { - // FIXME: Can LHS ever be null here? - if (!CheckAddressOfOperand(S, CO->getTrueExpr(), OpLoc).isNull()) - return CheckAddressOfOperand(S, CO->getFalseExpr(), OpLoc); } else if (dcl) { // C99 6.5.3.2p1 // We have an lvalue with a decl. Make sure the decl is not declared // with the register storage-class specifier. |