diff options
author | Matt Beaumont-Gay <matthewbg@google.com> | 2012-05-17 00:03:16 +0000 |
---|---|---|
committer | Matt Beaumont-Gay <matthewbg@google.com> | 2012-05-17 00:03:16 +0000 |
commit | abf145ab57fc56bfb9c48333fcc65b49a564dc60 (patch) | |
tree | 12ef72dca38656c435346122f7a58a586c83a08a /lib/Sema/SemaChecking.cpp | |
parent | 5641b0d02563840c51c33b93dc663c55306093f3 (diff) |
Use the argument location instead of the format string location when warning
about argument type mismatch.
This gives a nicer diagnostic in cases like
printf(fmt,
i);
where previously the snippet just pointed at 'fmt' (with a note at the
definition of fmt).
It's a wash for cases like
printf("%f",
i);
where previously we snippeted the offending portion of the format string,
but didn't indicate which argument was at fault.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156968 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 62f45f5c91..769705419e 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -2423,8 +2423,8 @@ CheckPrintfHandler::HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier S.PDiag(diag::warn_printf_conversion_argument_type_mismatch) << ATR.getRepresentativeTypeName(S.Context) << Ex->getType() << Ex->getSourceRange(), - getLocationOfByte(CS.getStart()), - /*IsStringLocation*/true, + Ex->getLocStart(), + /*IsStringLocation*/false, getSpecifierRange(startSpecifier, specifierLen), FixItHint::CreateReplacement( getSpecifierRange(startSpecifier, specifierLen), @@ -2436,8 +2436,8 @@ CheckPrintfHandler::HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier << ATR.getRepresentativeTypeName(S.Context) << Ex->getType() << getSpecifierRange(startSpecifier, specifierLen) << Ex->getSourceRange(), - getLocationOfByte(CS.getStart()), - true, + Ex->getLocStart(), + /*IsStringLocation*/false, getSpecifierRange(startSpecifier, specifierLen)); } } @@ -2591,8 +2591,8 @@ bool CheckScanfHandler::HandleScanfSpecifier( S.PDiag(diag::warn_printf_conversion_argument_type_mismatch) << ATR.getRepresentativeTypeName(S.Context) << Ex->getType() << Ex->getSourceRange(), - getLocationOfByte(CS.getStart()), - /*IsStringLocation*/true, + Ex->getLocStart(), + /*IsStringLocation*/false, getSpecifierRange(startSpecifier, specifierLen), FixItHint::CreateReplacement( getSpecifierRange(startSpecifier, specifierLen), @@ -2602,8 +2602,8 @@ bool CheckScanfHandler::HandleScanfSpecifier( S.PDiag(diag::warn_printf_conversion_argument_type_mismatch) << ATR.getRepresentativeTypeName(S.Context) << Ex->getType() << Ex->getSourceRange(), - getLocationOfByte(CS.getStart()), - /*IsStringLocation*/true, + Ex->getLocStart(), + /*IsStringLocation*/false, getSpecifierRange(startSpecifier, specifierLen)); } } |