diff options
author | Hans Wennborg <hans@hanshq.net> | 2012-02-15 09:59:46 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2012-02-15 09:59:46 +0000 |
commit | be6126a2a784e1446460b8d15c2b26f880c871fc (patch) | |
tree | dcd82b29009df602ff45a73ab58053e9e883d25a /lib/Sema/SemaChecking.cpp | |
parent | 37ce0104b182c9410cf2a76fe5a63a81dac876ac (diff) |
Make -Wformat fix-its preserve original conversion specifiers.
This commit makes PrintfSpecifier::fixType() and ScanfSpecifier::fixType()
only fix a conversion specification enough that Clang wouldn't warn about it,
as opposed to always changing it to use the "canonical" conversion specifier.
(PR11975)
This preserves the user's choice of conversion specifier in cases like:
printf("%a", (long double)1);
where we previously suggested "%Lf", we now suggest "%La"
printf("%x", (long)1);
where we previously suggested "%ld", we now suggest "%lx".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150578 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 3393cf73f1..1d75ef6e6f 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -2181,7 +2181,8 @@ CheckPrintfHandler::HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier // We may be able to offer a FixItHint if it is a supported type. PrintfSpecifier fixedFS = FS; - bool success = fixedFS.fixType(Ex->getType(), S.getLangOptions()); + bool success = fixedFS.fixType(Ex->getType(), S.getLangOptions(), + S.Context, IsObjCLiteral); if (success) { // Get the fix string from the fixed format specifier @@ -2340,7 +2341,8 @@ bool CheckScanfHandler::HandleScanfSpecifier( const analyze_scanf::ScanfArgTypeResult &ATR = FS.getArgType(S.Context); if (ATR.isValid() && !ATR.matchesType(S.Context, Ex->getType())) { ScanfSpecifier fixedFS = FS; - bool success = fixedFS.fixType(Ex->getType(), S.getLangOptions()); + bool success = fixedFS.fixType(Ex->getType(), S.getLangOptions(), + S.Context); if (success) { // Get the fix string from the fixed format specifier. |