aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-01-13 01:18:13 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-01-13 01:18:13 +0000
commit8b4bf90eb6d3d08cf3bfb86705f0fdb20b9c5875 (patch)
tree28901d68b1e6bd88d1155a9908e4a7f2dd9b1921 /lib/AST/ASTContext.cpp
parente3a46b08f879771b9445c2a3cb717bf843f48f07 (diff)
Patch to fix encoding of Enum bitfields in ObjC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62135 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r--lib/AST/ASTContext.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 24172a5ddb..b5487565ae 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1775,6 +1775,16 @@ void ASTContext::getObjCEncodingForType(QualType T, std::string& S,
true /* outermost type */);
}
+static void EncodeBitField(const ASTContext *Context, std::string& S,
+ FieldDecl *FD) {
+ const Expr *E = FD->getBitWidth();
+ assert(E && "bitfield width not there - getObjCEncodingForTypeImpl");
+ ASTContext *Ctx = const_cast<ASTContext*>(Context);
+ unsigned N = E->getIntegerConstantExprValue(*Ctx).getZExtValue();
+ S += 'b';
+ S += llvm::utostr(N);
+}
+
void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
bool ExpandPointedToStructures,
bool ExpandStructures,
@@ -1782,12 +1792,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
bool OutermostType) const {
if (const BuiltinType *BT = T->getAsBuiltinType()) {
if (FD && FD->isBitField()) {
- const Expr *E = FD->getBitWidth();
- assert(E && "bitfield width not there - getObjCEncodingForTypeImpl");
- ASTContext *Ctx = const_cast<ASTContext*>(this);
- unsigned N = E->getIntegerConstantExprValue(*Ctx).getZExtValue();
- S += 'b';
- S += llvm::utostr(N);
+ EncodeBitField(this, S, FD);
}
else {
char encoding;
@@ -1949,7 +1954,10 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
}
S += RDecl->isUnion() ? ')' : '}';
} else if (T->isEnumeralType()) {
- S += 'i';
+ if (FD && FD->isBitField())
+ EncodeBitField(this, S, FD);
+ else
+ S += 'i';
} else if (T->isBlockPointerType()) {
S += '^'; // This type string is the same as general pointers.
} else if (T->isObjCInterfaceType()) {