Objective-C. provide legacy encoding of *id and *Class types

instead of crashing.  // rdar://15824769.

llvm-svn: 200338
This commit is contained in:
Fariborz Jahanian 2014-01-28 20:41:15 +00:00
parent 559b63cbb9
commit 33fa962441
2 changed files with 21 additions and 1 deletions

View File

@ -5440,7 +5440,19 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
return;
}
case Type::ObjCObject:
case Type::ObjCObject: {
// hack to match legacy encoding of *id and *Class
QualType Ty = getObjCObjectPointerType(CT);
if (Ty->isObjCIdType()) {
S += "{objc_object=}";
return;
}
else if (Ty->isObjCClassType()) {
S += "{objc_class=}";
return;
}
}
case Type::ObjCInterface: {
// Ignore protocol qualifiers when mangling at this level.
T = T->castAs<ObjCObjectType>()->getBaseType();

View File

@ -169,3 +169,11 @@ const char g11[] = @encode(void);
// PR14628
// CHECK: @g12 = constant [3 x i8] c"Ai\00"
const char g12[] = @encode(_Atomic(int));
// rdar://15824769
id test_id = 0;
Class test_class = 0;
const char g13[] = @encode(__typeof__(*test_class));
const char g14[] = @encode(__typeof__(*test_id));
// CHECK: constant [14 x i8] c"{objc_class=}\00"
// CHECK: constant [15 x i8] c"{objc_object=}\00"