Use early return as suggested by Cristian Draghici.

llvm-svn: 94994
This commit is contained in:
Ted Kremenek 2010-02-01 19:38:10 +00:00
parent 3c46e14137
commit fb20c4121e
1 changed files with 9 additions and 12 deletions

View File

@ -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;
}