From 2f9e88b9f2b597dc48ffd69356a9d9f45c9e5102 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Mon, 4 Aug 2014 15:17:29 +0000 Subject: [PATCH] Highlight the offending function parameter when the format_arg argument refers to an invalid function parameter type. llvm-svn: 214722 --- clang/lib/Sema/SemaDeclAttr.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index ff2594e..4408abb 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/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; } -- 2.7.4