manmanren retitled this revision from "FixIt: correctly set DeclSpec's range end for a type name annotation." to "FixIt: use getLocForEndOfToken to insert fix-it after a type name.". manmanren updated the summary for this revision. manmanren updated this revision to Diff 59296. manmanren added a comment.
Use getLocForEndOfToken to insert fix-it after a type name instead of setting DeclSpec's range end. http://reviews.llvm.org/D20844 Files: lib/Parse/ParseObjc.cpp lib/Sema/SemaDecl.cpp test/FixIt/fixit-interface-as-param.m Index: test/FixIt/fixit-interface-as-param.m =================================================================== --- test/FixIt/fixit-interface-as-param.m +++ test/FixIt/fixit-interface-as-param.m @@ -5,7 +5,16 @@ @interface INTF - (void) drawRect : inView:(NSView)view; +- (void)test:(NSView )a; +- (void)foo; @end // CHECK: {7:35-7:35}:"*" - +// CHECK: {8:21-8:21}:"*" +@implementation INTF +-(void)foo { + ^(NSView view) { + }; +} +@end +// CHECK: {16:11-16:11}:"*" Index: lib/Sema/SemaDecl.cpp =================================================================== --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -10954,7 +10954,8 @@ // Parameter declarators cannot be interface types. All ObjC objects are // passed by reference. if (T->isObjCObjectType()) { - SourceLocation TypeEndLoc = TSInfo->getTypeLoc().getLocEnd(); + SourceLocation TypeEndLoc = + getLocForEndOfToken(TSInfo->getTypeLoc().getLocEnd()); Diag(NameLoc, diag::err_object_cannot_be_passed_returned_by_value) << 1 << T << FixItHint::CreateInsertion(TypeEndLoc, "*"); Index: lib/Parse/ParseObjc.cpp =================================================================== --- lib/Parse/ParseObjc.cpp +++ lib/Parse/ParseObjc.cpp @@ -1277,7 +1277,6 @@ if (context == Declarator::ObjCResultContext) dsContext = DSC_objc_method_result; ParseSpecifierQualifierList(declSpec, AS_none, dsContext); - declSpec.SetRangeEnd(Tok.getLocation()); Declarator declarator(declSpec, context); ParseDeclarator(declarator);
Index: test/FixIt/fixit-interface-as-param.m =================================================================== --- test/FixIt/fixit-interface-as-param.m +++ test/FixIt/fixit-interface-as-param.m @@ -5,7 +5,16 @@ @interface INTF - (void) drawRect : inView:(NSView)view; +- (void)test:(NSView )a; +- (void)foo; @end // CHECK: {7:35-7:35}:"*" - +// CHECK: {8:21-8:21}:"*" +@implementation INTF +-(void)foo { + ^(NSView view) { + }; +} +@end +// CHECK: {16:11-16:11}:"*" Index: lib/Sema/SemaDecl.cpp =================================================================== --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -10954,7 +10954,8 @@ // Parameter declarators cannot be interface types. All ObjC objects are // passed by reference. if (T->isObjCObjectType()) { - SourceLocation TypeEndLoc = TSInfo->getTypeLoc().getLocEnd(); + SourceLocation TypeEndLoc = + getLocForEndOfToken(TSInfo->getTypeLoc().getLocEnd()); Diag(NameLoc, diag::err_object_cannot_be_passed_returned_by_value) << 1 << T << FixItHint::CreateInsertion(TypeEndLoc, "*"); Index: lib/Parse/ParseObjc.cpp =================================================================== --- lib/Parse/ParseObjc.cpp +++ lib/Parse/ParseObjc.cpp @@ -1277,7 +1277,6 @@ if (context == Declarator::ObjCResultContext) dsContext = DSC_objc_method_result; ParseSpecifierQualifierList(declSpec, AS_none, dsContext); - declSpec.SetRangeEnd(Tok.getLocation()); Declarator declarator(declSpec, context); ParseDeclarator(declarator);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits