Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/AST/Expr.cpp
Show First 20 Lines • Show All 2,400 Lines • ▼ Show 20 Lines | |||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// Generic Expression Routines | // Generic Expression Routines | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
bool Expr::isReadIfDiscardedInCPlusPlus11() const { | bool Expr::isReadIfDiscardedInCPlusPlus11() const { | ||||
// In C++11, discarded-value expressions of a certain form are special, | // In C++11, discarded-value expressions of a certain form are special, | ||||
// according to [expr]p10: | // according to [expr]p10: | ||||
// The lvalue-to-rvalue conversion (4.1) is applied only if the | // The lvalue-to-rvalue conversion (4.1) is applied only if the | ||||
// expression is an lvalue of volatile-qualified type and it has | // expression is a glvalue of volatile-qualified type and it has | ||||
// one of the following forms: | // one of the following forms: | ||||
if (!isGLValue() || !getType().isVolatileQualified()) | if (!isGLValue() || !getType().isVolatileQualified()) | ||||
return false; | return false; | ||||
const Expr *E = IgnoreParens(); | const Expr *E = IgnoreParens(); | ||||
// - id-expression (5.1.1), | // - id-expression (5.1.1), | ||||
if (isa<DeclRefExpr>(E)) | if (isa<DeclRefExpr>(E)) | ||||
▲ Show 20 Lines • Show All 1,451 Lines • ▼ Show 20 Lines | Expr::isNullPointerConstant(ASTContext &Ctx, | ||||
return NPCK_ZeroExpression; | return NPCK_ZeroExpression; | ||||
} | } | ||||
/// If this expression is an l-value for an Objective C | /// If this expression is an l-value for an Objective C | ||||
/// property, find the underlying property reference expression. | /// property, find the underlying property reference expression. | ||||
const ObjCPropertyRefExpr *Expr::getObjCProperty() const { | const ObjCPropertyRefExpr *Expr::getObjCProperty() const { | ||||
const Expr *E = this; | const Expr *E = this; | ||||
while (true) { | while (true) { | ||||
assert((E->getValueKind() == VK_LValue && | assert((E->isLValue() && E->getObjectKind() == OK_ObjCProperty) && | ||||
E->getObjectKind() == OK_ObjCProperty) && | |||||
"expression is not a property reference"); | "expression is not a property reference"); | ||||
E = E->IgnoreParenCasts(); | E = E->IgnoreParenCasts(); | ||||
if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) { | if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) { | ||||
if (BO->getOpcode() == BO_Comma) { | if (BO->getOpcode() == BO_Comma) { | ||||
E = BO->getRHS(); | E = BO->getRHS(); | ||||
continue; | continue; | ||||
} | } | ||||
} | } | ||||
Show All 22 Lines | bool Expr::isObjCSelfExpr() const { | ||||
return M->getSelfDecl() == Param; | return M->getSelfDecl() == Param; | ||||
} | } | ||||
FieldDecl *Expr::getSourceBitField() { | FieldDecl *Expr::getSourceBitField() { | ||||
Expr *E = this->IgnoreParens(); | Expr *E = this->IgnoreParens(); | ||||
while (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) { | while (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) { | ||||
if (ICE->getCastKind() == CK_LValueToRValue || | if (ICE->getCastKind() == CK_LValueToRValue || | ||||
(ICE->getValueKind() != VK_PRValue && ICE->getCastKind() == CK_NoOp)) | (ICE->isGLValue() && ICE->getCastKind() == CK_NoOp)) | ||||
E = ICE->getSubExpr()->IgnoreParens(); | E = ICE->getSubExpr()->IgnoreParens(); | ||||
else | else | ||||
break; | break; | ||||
} | } | ||||
if (MemberExpr *MemRef = dyn_cast<MemberExpr>(E)) | if (MemberExpr *MemRef = dyn_cast<MemberExpr>(E)) | ||||
if (FieldDecl *Field = dyn_cast<FieldDecl>(MemRef->getMemberDecl())) | if (FieldDecl *Field = dyn_cast<FieldDecl>(MemRef->getMemberDecl())) | ||||
if (Field->isBitField()) | if (Field->isBitField()) | ||||
Show All 30 Lines | FieldDecl *Expr::getSourceBitField() { | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
bool Expr::refersToVectorElement() const { | bool Expr::refersToVectorElement() const { | ||||
// FIXME: Why do we not just look at the ObjectKind here? | // FIXME: Why do we not just look at the ObjectKind here? | ||||
const Expr *E = this->IgnoreParens(); | const Expr *E = this->IgnoreParens(); | ||||
while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) { | while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) { | ||||
if (ICE->getValueKind() != VK_PRValue && ICE->getCastKind() == CK_NoOp) | if (ICE->isGLValue() && ICE->getCastKind() == CK_NoOp) | ||||
E = ICE->getSubExpr()->IgnoreParens(); | E = ICE->getSubExpr()->IgnoreParens(); | ||||
else | else | ||||
break; | break; | ||||
} | } | ||||
if (const ArraySubscriptExpr *ASE = dyn_cast<ArraySubscriptExpr>(E)) | if (const ArraySubscriptExpr *ASE = dyn_cast<ArraySubscriptExpr>(E)) | ||||
return ASE->getBase()->getType()->isVectorType(); | return ASE->getBase()->getType()->isVectorType(); | ||||
▲ Show 20 Lines • Show All 1,022 Lines • Show Last 20 Lines |