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

llvm-svn: 178680
This commit is contained in:
Fariborz Jahanian 2013-04-03 19:11:21 +00:00
parent 9cad53cfec
commit 3a65ce3a56
2 changed files with 20 additions and 3 deletions
clang

View File

@ -1149,7 +1149,7 @@ void RewriteModernObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) {
// 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::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) {
// 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::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) {
// Lastly, comment out the @end.
ReplaceText(ClassDecl->getAtEndRange().getBegin(), strlen("@end"),
"/* @end */");
"/* @end */\n");
}
}
@ -2259,6 +2259,10 @@ void RewriteModernObjC::RewriteObjCQualifiedInterfaceTypes(Decl *Dcl) {
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::HandleDeclInMainFile(Decl *D) {
RewriteBlockPointerDecl(TD);
else if (TD->getUnderlyingType()->isFunctionPointerType())
CheckFunctionPointerDecl(TD->getUnderlyingType(), TD);
else
RewriteObjCQualifiedInterfaceTypes(TD);
}
break;
}

View File

@ -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
@protocol OS_dispatch_object @end
@interface NSObject @end
@protocol OS_dispatch_queue <OS_dispatch_object> @end typedef NSObject<OS_dispatch_queue> *dispatch_queue_t;
typedef id<OS_dispatch_queue> dispatch_queue_i;