Test case? (I know we don't rigorously test the ranges specified in a diagnostic, but if we're fixing a bug in it, it might be worthwhile - I think they're sometimes tested with the machine readable diagnostic format)
On Mon, Aug 4, 2014 at 8:17 AM, Aaron Ballman <[email protected]> wrote: > Author: aaronballman > Date: Mon Aug 4 10:17:29 2014 > New Revision: 214722 > > URL: http://llvm.org/viewvc/llvm-project?rev=214722&view=rev > Log: > Highlight the offending function parameter when the format_arg argument > refers to an invalid function parameter type. > > Modified: > cfe/trunk/lib/Sema/SemaDeclAttr.cpp > > Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=214722&r1=214721&r2=214722&view=diff > ============================================================================== > --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) > +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Aug 4 10:17:29 2014 > @@ -2362,10 +2362,9 @@ static void handleFormatArgAttr(Sema &S, > !isCFStringType(Ty, S.Context) && > (!Ty->isPointerType() || > !Ty->getAs<PointerType>()->getPointeeType()->isCharType())) { > - // FIXME: Should highlight the actual expression that has the wrong type. > S.Diag(Attr.getLoc(), diag::err_format_attribute_not) > - << (not_nsstring_type ? "a string type" : "an NSString") > - << IdxExpr->getSourceRange(); > + << (not_nsstring_type ? "a string type" : "an NSString") > + << IdxExpr->getSourceRange() << getFunctionOrMethodParamRange(D, 0); > return; > } > Ty = getFunctionOrMethodResultType(D); > @@ -2373,10 +2372,9 @@ static void handleFormatArgAttr(Sema &S, > !isCFStringType(Ty, S.Context) && > (!Ty->isPointerType() || > !Ty->getAs<PointerType>()->getPointeeType()->isCharType())) { > - // FIXME: Should highlight the actual expression that has the wrong type. > S.Diag(Attr.getLoc(), diag::err_format_attribute_result_not) > - << (not_nsstring_type ? "string type" : "NSString") > - << IdxExpr->getSourceRange(); > + << (not_nsstring_type ? "string type" : "NSString") > + << IdxExpr->getSourceRange() << getFunctionOrMethodParamRange(D, 0); > return; > } > > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
