diff options
author | John McCall <rjmccall@apple.com> | 2013-05-06 21:39:12 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2013-05-06 21:39:12 +0000 |
commit | 993f43f24d7a45a5cd4678a3316b0852261fc5d4 (patch) | |
tree | bf54fbd0ff497973e08eb9c0667daaaa43804fb0 /include/clang/AST | |
parent | 009735db957ac4bcca8f5ad1a5c01354b1b57fbd (diff) |
Grab-bag of bit-field fixes:
- References to ObjC bit-field ivars are bit-field lvalues;
fixes rdar://13794269, which got me started down this.
- Introduce Expr::refersToBitField, switch a couple users to
it where semantically important, and comment the difference
between this and the existing API.
- Discourage Expr::getBitField by making it a bit longer and
less general-sounding.
- Lock down on const_casts of bit-field gl-values until we
hear back from the committee as to whether they're allowed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181252 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST')
-rw-r--r-- | include/clang/AST/Expr.h | 20 | ||||
-rw-r--r-- | include/clang/AST/ExprObjC.h | 3 |
2 files changed, 18 insertions, 5 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 2e66df33ee..4ff1257b7d 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -427,12 +427,24 @@ private: public: + /// \brief Returns true if this expression is a gl-value that + /// potentially refers to a bit-field. + /// + /// In C++, whether a gl-value refers to a bitfield is essentially + /// an aspect of the value-kind type system. + bool refersToBitField() const { return getObjectKind() == OK_BitField; } + /// \brief If this expression refers to a bit-field, retrieve the /// declaration of that bit-field. - FieldDecl *getBitField(); - - const FieldDecl *getBitField() const { - return const_cast<Expr*>(this)->getBitField(); + /// + /// Note that this returns a non-null pointer in subtly different + /// places than refersToBitField returns true. In particular, this can + /// return a non-null pointer even for r-values loaded from + /// bit-fields, but it will return null for a conditional bit-field. + FieldDecl *getSourceBitField(); + + const FieldDecl *getSourceBitField() const { + return const_cast<Expr*>(this)->getSourceBitField(); } /// \brief If this expression is an l-value for an Objective C diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h index dfd45279dd..a94c69a115 100644 --- a/include/clang/AST/ExprObjC.h +++ b/include/clang/AST/ExprObjC.h @@ -476,7 +476,8 @@ public: SourceLocation l, SourceLocation oploc, Expr *base, bool arrow = false, bool freeIvar = false) : - Expr(ObjCIvarRefExprClass, t, VK_LValue, OK_Ordinary, + Expr(ObjCIvarRefExprClass, t, VK_LValue, + d->isBitField() ? OK_BitField : OK_Ordinary, /*TypeDependent=*/false, base->isValueDependent(), base->isInstantiationDependent(), base->containsUnexpandedParameterPack()), |