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
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 24172a5..b548756 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1775,6 +1775,16 @@
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 @@
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 @@
}
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()) {