[cfe-commits] r53694 - in /cfe/trunk: Driver/RewriteObjC.cpp include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp lib/Sema/SemaDecl.cpp
Steve Naroff
snaroff at apple.com
Wed Jul 16 11:22:22 PDT 2008
Author: snaroff
Date: Wed Jul 16 13:22:22 2008
New Revision: 53694
URL: http://llvm.org/viewvc/llvm-project?rev=53694&view=rev
Log:
Two fixes:
- Make sure ObjCIvarDecl propagates the bitfield width.
- RewriteObjC::SynthesizeIvarOffsetComputation(): Avoid using the __OFFSETOF__ mumbo jumbo for bitfields (since it isn't legal C). This fixes <rdar://problem/5986079> clang ObjC rewriter: bitfields and ivar access don't mix.
Modified:
cfe/trunk/Driver/RewriteObjC.cpp
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteObjC.cpp?rev=53694&r1=53693&r2=53694&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Wed Jul 16 13:22:22 2008
@@ -2779,13 +2779,19 @@
void RewriteObjC::SynthesizeIvarOffsetComputation(ObjCImplementationDecl *IDecl,
ObjCIvarDecl *ivar,
std::string &Result) {
- Result += "__OFFSETOFIVAR__(struct ";
- Result += IDecl->getName();
- if (LangOpts.Microsoft)
- Result += "_IMPL";
- Result += ", ";
- Result += ivar->getName();
- Result += ")";
+ if (ivar->isBitField()) {
+ // FIXME: The hack below doesn't work for bitfields. For now, we simply
+ // place all bitfields at offset 0.
+ Result += "0";
+ } else {
+ Result += "__OFFSETOFIVAR__(struct ";
+ Result += IDecl->getName();
+ if (LangOpts.Microsoft)
+ Result += "_IMPL";
+ Result += ", ";
+ Result += ivar->getName();
+ Result += ")";
+ }
}
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=53694&r1=53693&r2=53694&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Jul 16 13:22:22 2008
@@ -451,12 +451,12 @@
/// }
///
class ObjCIvarDecl : public FieldDecl {
- ObjCIvarDecl(SourceLocation L, IdentifierInfo *Id, QualType T)
- : FieldDecl(ObjCIvar, L, Id, T) {}
+ ObjCIvarDecl(SourceLocation L, IdentifierInfo *Id, QualType T, Expr *BW)
+ : FieldDecl(ObjCIvar, L, Id, T, BW) {}
public:
static ObjCIvarDecl *Create(ASTContext &C, SourceLocation L,
- IdentifierInfo *Id, QualType T);
-
+ IdentifierInfo *Id, QualType T, Expr *BW = NULL);
+
enum AccessControl {
None, Private, Protected, Public, Package
};
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=53694&r1=53693&r2=53694&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Wed Jul 16 13:22:22 2008
@@ -89,9 +89,9 @@
ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, SourceLocation L,
- IdentifierInfo *Id, QualType T) {
+ IdentifierInfo *Id, QualType T, Expr *BW) {
void *Mem = C.getAllocator().Allocate<ObjCIvarDecl>();
- return new (Mem) ObjCIvarDecl(L, Id, T);
+ return new (Mem) ObjCIvarDecl(L, Id, T, BW);
}
ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C,
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=53694&r1=53693&r2=53694&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jul 16 13:22:22 2008
@@ -1946,7 +1946,8 @@
InvalidDecl = true;
}
- ObjCIvarDecl *NewID = ObjCIvarDecl::Create(Context, Loc, II, T);
+ ObjCIvarDecl *NewID = ObjCIvarDecl::Create(Context, Loc, II, T,
+ (Expr *)BitfieldWidth);
ProcessDeclAttributes(NewID, D);
More information about the cfe-commits
mailing list