summaryrefslogtreecommitdiffstats
path: root/clang
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
commitfb20c4121eafb3eae7c98f4651c51e71a01e44d3 (patch)
tree163b5ee4450126cdfc1057881e3d6f5500c84667 /clang
parent3c46e141378ddbb9b8f6dc41c646dc7c5b7610b2 (diff)
downloadbcm5719-llvm-fb20c4121eafb3eae7c98f4651c51e71a01e44d3.tar.gz
bcm5719-llvm-fb20c4121eafb3eae7c98f4651c51e71a01e44d3.zip
Use early return as suggested by Cristian Draghici.
llvm-svn: 94994
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 5db7038405c..399979fc1ea 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/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;
}
OpenPOWER on IntegriCloud