diff options
| author | Aaron Ballman <aaron@aaronballman.com> | 2014-08-04 15:26:33 +0000 |
|---|---|---|
| committer | Aaron Ballman <aaron@aaronballman.com> | 2014-08-04 15:26:33 +0000 |
| commit | dfe8cc51c2c0816c71c0ba2f2ebbe38049d1f7f6 (patch) | |
| tree | 5e9e980b1a5086c22318da283d9be1a935db0ca7 /clang/lib/Sema | |
| parent | 2f9e88b9f2b597dc48ffd69356a9d9f45c9e5102 (diff) | |
| download | bcm5719-llvm-dfe8cc51c2c0816c71c0ba2f2ebbe38049d1f7f6.tar.gz bcm5719-llvm-dfe8cc51c2c0816c71c0ba2f2ebbe38049d1f7f6.zip | |
Highlight the offending function parameter when the format argument refers to an invalid function parameter type.
llvm-svn: 214723
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 4408abb7d8c..a1afbdba7aa 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2545,23 +2545,24 @@ static void handleFormatAttr(Sema &S, Decl *D, const AttributeList &Attr) { if (Kind == CFStringFormat) { if (!isCFStringType(Ty, S.Context)) { S.Diag(Attr.getLoc(), diag::err_format_attribute_not) - << "a CFString" << IdxExpr->getSourceRange(); + << "a CFString" << IdxExpr->getSourceRange() + << getFunctionOrMethodParamRange(D, ArgIdx); return; } } else if (Kind == NSStringFormat) { // FIXME: do we need to check if the type is NSString*? What are the // semantics? if (!isNSStringType(Ty, S.Context)) { - // FIXME: Should highlight the actual expression that has the wrong type. S.Diag(Attr.getLoc(), diag::err_format_attribute_not) - << "an NSString" << IdxExpr->getSourceRange(); + << "an NSString" << IdxExpr->getSourceRange() + << getFunctionOrMethodParamRange(D, ArgIdx); return; } } else if (!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) - << "a string type" << IdxExpr->getSourceRange(); + << "a string type" << IdxExpr->getSourceRange() + << getFunctionOrMethodParamRange(D, ArgIdx); return; } |

