From: Aaron Ballman Date: Mon, 4 Aug 2014 15:17:29 +0000 (+0000) Subject: Highlight the offending function parameter when the format_arg argument refers to... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a41cfc753729d2a996a024b0d7b48fec78e70ad6;p=clang Highlight the offending function parameter when the format_arg argument refers to an invalid function parameter type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214722 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index ff2594e114..4408abb7d8 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -2362,10 +2362,9 @@ static void handleFormatArgAttr(Sema &S, Decl *D, const AttributeList &Attr) { !isCFStringType(Ty, S.Context) && (!Ty->isPointerType() || !Ty->getAs()->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, Decl *D, const AttributeList &Attr) { !isCFStringType(Ty, S.Context) && (!Ty->isPointerType() || !Ty->getAs()->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; }