aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-02-01 19:38:10 +0000
committerTed Kremenek <kremenek@apple.com>2010-02-01 19:38:10 +0000
commit105d41c0a4bf4dc4b210647ac704e245749a981d (patch)
treeea035ddcb62aa3e1e5830f6690fdd6a6ddf0c076 /lib/Sema/SemaChecking.cpp
parent180f2840d1d8bcb2139bfb53e2d88eda280e939e (diff)
Use early return as suggested by Cristian Draghici.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94994 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r--lib/Sema/SemaChecking.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 5db7038405..399979fc1e 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -1286,19 +1286,16 @@ CheckPrintfHandler::HandleFormatSpecifier(const analyze_printf::FormatSpecifier
// Check if we didn't match because of an implicit cast from a 'char'
// or 'short' to an 'int'. This is done because printf is a varargs
// function.
- bool hasError = true;
if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Ex))
- if (ICE->getType() == S.Context.IntTy) {
- Ex = ICE->getSubExpr();
- hasError = !MatchType(*T, Ex->getType(), true);
- }
-
- if (hasError)
- S.Diag(getLocationOfByte(CS.getStart()),
- diag::warn_printf_conversion_argument_type_mismatch)
- << *T << Ex->getType()
- << getFormatSpecifierRange(startSpecifier, specifierLen)
- << Ex->getSourceRange();
+ if (ICE->getType() == S.Context.IntTy)
+ if (MatchType(*T, ICE->getSubExpr()->getType(), true))
+ return true;
+
+ S.Diag(getLocationOfByte(CS.getStart()),
+ diag::warn_printf_conversion_argument_type_mismatch)
+ << *T << Ex->getType()
+ << getFormatSpecifierRange(startSpecifier, specifierLen)
+ << Ex->getSourceRange();
}
return true;
}