summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-05-02 02:18:30 +0000
committerDouglas Gregor <dgregor@apple.com>2009-05-02 02:18:30 +0000
commit71235ecb7fa323b597051c1f097d9b6515a41c37 (patch)
tree9c95b333941cc6bcbfe79a04931477627b33600d /clang/lib/AST
parent49805454e662e44b5b61a9520e9437fa7f374dae (diff)
downloadbcm5719-llvm-71235ecb7fa323b597051c1f097d9b6515a41c37.tar.gz
bcm5719-llvm-71235ecb7fa323b597051c1f097d9b6515a41c37.zip
When determining whether an expression refers to a bit-field, look
into the left-hand side of an assignment expression. This completes most of PR3500; the only remaining part is to deal with the GCC-specific implementation-defined behavior for "unsigned long" (and other) bit-fields. llvm-svn: 70623
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/Expr.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index d89290bbb97..19d67bb7f8a 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1379,13 +1379,19 @@ bool Expr::isNullPointerConstant(ASTContext &Ctx) const
return isIntegerConstantExpr(Result, Ctx) && Result == 0;
}
-/// isBitField - Return true if this expression is a bit-field.
-bool Expr::isBitField() {
+FieldDecl *Expr::getBitField() {
Expr *E = this->IgnoreParenCasts();
+
if (MemberExpr *MemRef = dyn_cast<MemberExpr>(E))
if (FieldDecl *Field = dyn_cast<FieldDecl>(MemRef->getMemberDecl()))
- return Field->isBitField();
- return false;
+ if (Field->isBitField())
+ return Field;
+
+ if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(E))
+ if (BinOp->isAssignmentOp() && BinOp->getLHS())
+ return BinOp->getLHS()->getBitField();
+
+ return 0;
}
/// isArrow - Return true if the base expression is a pointer to vector,
OpenPOWER on IntegriCloud