Skip to content

Commit 01f21ad

Browse files
committed
Rebuild builtin_id * as an ObjCObjectPointerType, where builtin_id is the
magic type that 'id' is a pointer to. llvm-svn: 103708
1 parent 6e8417c commit 01f21ad

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

clang/lib/Sema/TreeTransform.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2445,16 +2445,24 @@ QualType TreeTransform<Derived>::TransformPointerType(TypeLocBuilder &TLB,
24452445
return QualType();
24462446

24472447
QualType Result = TL.getType();
2448-
if (PointeeType->isObjCInterfaceType()) {
2448+
if (PointeeType->isObjCInterfaceType() ||
2449+
PointeeType->isSpecificBuiltinType(BuiltinType::ObjCId)) {
24492450
// A dependent pointer type 'T *' has is being transformed such
24502451
// that an Objective-C class type is being replaced for 'T'. The
24512452
// resulting pointer type is an ObjCObjectPointerType, not a
24522453
// PointerType.
2453-
const ObjCInterfaceType *IFace = PointeeType->getAs<ObjCInterfaceType>();
2454+
ObjCProtocolDecl **Protocols = 0;
2455+
unsigned NumProtocols = 0;
2456+
2457+
if (const ObjCInterfaceType *IFace
2458+
= PointeeType->getAs<ObjCInterfaceType>()) {
2459+
Protocols = const_cast<ObjCProtocolDecl**>(IFace->qual_begin());
2460+
NumProtocols = IFace->getNumProtocols();
2461+
}
2462+
24542463
Result = SemaRef.Context.getObjCObjectPointerType(PointeeType,
2455-
const_cast<ObjCProtocolDecl **>(
2456-
IFace->qual_begin()),
2457-
IFace->getNumProtocols());
2464+
Protocols,
2465+
NumProtocols);
24582466

24592467
ObjCObjectPointerTypeLoc NewT = TLB.push<ObjCObjectPointerTypeLoc>(Result);
24602468
NewT.setStarLoc(TL.getSigilLoc());

clang/test/SemaObjCXX/deduction.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@
2121
void test(NSString *S) {
2222
RetainPtr<NSString*> ptr(S);
2323
}
24+
25+
void test(id S) {
26+
RetainPtr<id> ptr(S);
27+
}
2428
}

0 commit comments

Comments
 (0)