r178680 - Objective-C modern rewriter. Fixes a bug
Fariborz Jahanian
fjahanian at apple.com
Wed Apr 3 12:11:21 PDT 2013
Author: fjahanian
Date: Wed Apr 3 14:11:21 2013
New Revision: 178680
URL: http://llvm.org/viewvc/llvm-project?rev=178680&view=rev
Log:
Objective-C modern rewriter. Fixes a bug
rewriting typedef for a qualified object type
and also when two declarations happen to be on the
same line. // rdar://13562505
Added:
cfe/trunk/test/Rewriter/rewrite-modern-qualified-type.mm
Modified:
cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp
Modified: cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp?rev=178680&r1=178679&r2=178680&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp Wed Apr 3 14:11:21 2013
@@ -1149,7 +1149,7 @@ void RewriteModernObjC::RewriteCategoryD
// Lastly, comment out the @end.
ReplaceText(CatDecl->getAtEndRange().getBegin(),
- strlen("@end"), "/* @end */");
+ strlen("@end"), "/* @end */\n");
}
void RewriteModernObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) {
@@ -1174,7 +1174,7 @@ void RewriteModernObjC::RewriteProtocolD
// Lastly, comment out the @end.
SourceLocation LocEnd = PDecl->getAtEndRange().getBegin();
- ReplaceText(LocEnd, strlen("@end"), "/* @end */");
+ ReplaceText(LocEnd, strlen("@end"), "/* @end */\n");
// Must comment out @optional/@required
const char *startBuf = SM->getCharacterData(LocStart);
@@ -1442,7 +1442,7 @@ void RewriteModernObjC::RewriteInterface
// Lastly, comment out the @end.
ReplaceText(ClassDecl->getAtEndRange().getBegin(), strlen("@end"),
- "/* @end */");
+ "/* @end */\n");
}
}
@@ -2259,6 +2259,10 @@ void RewriteModernObjC::RewriteObjCQuali
Loc = FD->getLocation();
Type = FD->getType();
}
+ else if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(Dcl)) {
+ Loc = TD->getLocation();
+ Type = TD->getUnderlyingType();
+ }
else
return;
@@ -5996,6 +6000,8 @@ void RewriteModernObjC::HandleDeclInMain
RewriteBlockPointerDecl(TD);
else if (TD->getUnderlyingType()->isFunctionPointerType())
CheckFunctionPointerDecl(TD->getUnderlyingType(), TD);
+ else
+ RewriteObjCQualifiedInterfaceTypes(TD);
}
break;
}
Added: cfe/trunk/test/Rewriter/rewrite-modern-qualified-type.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-modern-qualified-type.mm?rev=178680&view=auto
==============================================================================
--- cfe/trunk/test/Rewriter/rewrite-modern-qualified-type.mm (added)
+++ cfe/trunk/test/Rewriter/rewrite-modern-qualified-type.mm Wed Apr 3 14:11:21 2013
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D_Bool=bool -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// rdar://13562505
+
+ at protocol OS_dispatch_object @end
+
+ at interface NSObject @end
+
+ at protocol OS_dispatch_queue <OS_dispatch_object> @end typedef NSObject<OS_dispatch_queue> *dispatch_queue_t;
+
+typedef id<OS_dispatch_queue> dispatch_queue_i;
More information about the cfe-commits
mailing list