aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-10-21 04:00:58 +0000
committerTed Kremenek <kremenek@apple.com>2010-10-21 04:00:58 +0000
commit4d8ae4d57ed18d60da4d3786fb740607aa7c3688 (patch)
tree417e4e11d6a2f8b488e22f6b86d8fe1b6f654864 /lib/Sema/SemaChecking.cpp
parent5cca53e5beeb6ec14e03327f0fd4e5ff318834d6 (diff)
Previously, the printf warnings would say your arguments type was 'int' when it was really a 'char'
or a 'short'. This fixes that and allows the hints to suggest 'h' modifiers for small ints. Patch by Justin Bogner! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116996 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r--lib/Sema/SemaChecking.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 1a07a86f80..fccbe92d6f 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -1603,9 +1603,12 @@ CheckPrintfHandler::HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier
// or 'short' to an 'int'. This is done because printf is a varargs
// function.
if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Ex))
- if (ICE->getType() == S.Context.IntTy)
- if (ATR.matchesType(S.Context, ICE->getSubExpr()->getType()))
+ if (ICE->getType() == S.Context.IntTy) {
+ // All further checking is done on the subexpression.
+ Ex = ICE->getSubExpr();
+ if (ATR.matchesType(S.Context, Ex->getType()))
return true;
+ }
// We may be able to offer a FixItHint if it is a supported type.
PrintfSpecifier fixedFS = FS;