Author: mren Date: Wed Jun 1 19:11:03 2016 New Revision: 271448 URL: http://llvm.org/viewvc/llvm-project?rev=271448&view=rev Log: FixIt: use getLocForEndOfToken to insert fix-it after a type name.
Instead of setting DeclSpec's range end to point to the next token after the DeclSpec, we use getLocForEndOfToken to insert fix-it after a type name. Before this fix, fix-it will change ^(NSView view) to ^(*NSView view) This commit correctly updates the source to ^(NSView* view). rdar://21042144 Differential Revision: http://reviews.llvm.org/D20844 Modified: cfe/trunk/lib/Parse/ParseObjc.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/FixIt/fixit-interface-as-param.m Modified: cfe/trunk/lib/Parse/ParseObjc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=271448&r1=271447&r2=271448&view=diff ============================================================================== --- cfe/trunk/lib/Parse/ParseObjc.cpp (original) +++ cfe/trunk/lib/Parse/ParseObjc.cpp Wed Jun 1 19:11:03 2016 @@ -1277,7 +1277,6 @@ ParsedType Parser::ParseObjCTypeName(Obj if (context == Declarator::ObjCResultContext) dsContext = DSC_objc_method_result; ParseSpecifierQualifierList(declSpec, AS_none, dsContext); - declSpec.SetRangeEnd(Tok.getLocation()); Declarator declarator(declSpec, context); ParseDeclarator(declarator); Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=271448&r1=271447&r2=271448&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jun 1 19:11:03 2016 @@ -10954,7 +10954,8 @@ ParmVarDecl *Sema::CheckParameter(DeclCo // 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, "*"); Modified: cfe/trunk/test/FixIt/fixit-interface-as-param.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-interface-as-param.m?rev=271448&r1=271447&r2=271448&view=diff ============================================================================== --- cfe/trunk/test/FixIt/fixit-interface-as-param.m (original) +++ cfe/trunk/test/FixIt/fixit-interface-as-param.m Wed Jun 1 19:11:03 2016 @@ -1,11 +1,20 @@ -// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s // rdar://11311333 @interface NSView @end @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}:"*" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits