Remove duplicate checks
This commit is contained in:
parent
d4a1c0d8bd
commit
06fd390b3f
|
@ -1060,11 +1060,11 @@ void CheckIO::checkFormatString(const Token * const tok,
|
||||||
specifier += *i;
|
specifier += *i;
|
||||||
if (argInfo.typeToken->tokType() == Token::eString)
|
if (argInfo.typeToken->tokType() == Token::eString)
|
||||||
invalidPrintfArgTypeError_int(tok, numFormat, specifier, &argInfo);
|
invalidPrintfArgTypeError_int(tok, numFormat, specifier, &argInfo);
|
||||||
else if (argInfo.isKnownType()) {
|
else if (argInfo.isArrayOrPointer() && !argInfo.element) {
|
||||||
if (argInfo.isArrayOrPointer() && !argInfo.element) {
|
// use %p on pointers and arrays
|
||||||
// use %p on pointers and arrays
|
invalidPrintfArgTypeError_int(tok, numFormat, specifier, &argInfo);
|
||||||
invalidPrintfArgTypeError_int(tok, numFormat, specifier, &argInfo);
|
} else if (argInfo.isKnownType()) {
|
||||||
} else if (!Token::Match(argInfo.typeToken, "bool|short|long|int|char|wchar_t")) {
|
if (!Token::Match(argInfo.typeToken, "bool|short|long|int|char|wchar_t")) {
|
||||||
if (!(!argInfo.isArrayOrPointer() && argInfo.element))
|
if (!(!argInfo.isArrayOrPointer() && argInfo.element))
|
||||||
invalidPrintfArgTypeError_int(tok, numFormat, specifier, &argInfo);
|
invalidPrintfArgTypeError_int(tok, numFormat, specifier, &argInfo);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1118,9 +1118,6 @@ void CheckIO::checkFormatString(const Token * const tok,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (argInfo.isArrayOrPointer() && !argInfo.element) {
|
|
||||||
// use %p on pointers and arrays
|
|
||||||
invalidPrintfArgTypeError_int(tok, numFormat, specifier, &argInfo);
|
|
||||||
}
|
}
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
|
@ -1129,11 +1126,11 @@ void CheckIO::checkFormatString(const Token * const tok,
|
||||||
specifier += *i;
|
specifier += *i;
|
||||||
if (argInfo.typeToken->tokType() == Token::eString) {
|
if (argInfo.typeToken->tokType() == Token::eString) {
|
||||||
invalidPrintfArgTypeError_sint(tok, numFormat, specifier, &argInfo);
|
invalidPrintfArgTypeError_sint(tok, numFormat, specifier, &argInfo);
|
||||||
|
} else if (argInfo.isArrayOrPointer() && !argInfo.element) {
|
||||||
|
// use %p on pointers and arrays
|
||||||
|
invalidPrintfArgTypeError_sint(tok, numFormat, specifier, &argInfo);
|
||||||
} else if (argInfo.isKnownType()) {
|
} else if (argInfo.isKnownType()) {
|
||||||
if (argInfo.isArrayOrPointer() && !argInfo.element) {
|
if (argInfo.typeToken->isUnsigned() && !Token::Match(argInfo.typeToken, "char|short")) {
|
||||||
// use %p on pointers and arrays
|
|
||||||
invalidPrintfArgTypeError_sint(tok, numFormat, specifier, &argInfo);
|
|
||||||
} else if (argInfo.typeToken->isUnsigned() && !Token::Match(argInfo.typeToken, "char|short")) {
|
|
||||||
if (!(!argInfo.isArrayOrPointer() && argInfo.element))
|
if (!(!argInfo.isArrayOrPointer() && argInfo.element))
|
||||||
invalidPrintfArgTypeError_sint(tok, numFormat, specifier, &argInfo);
|
invalidPrintfArgTypeError_sint(tok, numFormat, specifier, &argInfo);
|
||||||
} else if (!Token::Match(argInfo.typeToken, "bool|char|short|int|long")) {
|
} else if (!Token::Match(argInfo.typeToken, "bool|char|short|int|long")) {
|
||||||
|
@ -1196,9 +1193,6 @@ void CheckIO::checkFormatString(const Token * const tok,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (argInfo.isArrayOrPointer() && !argInfo.element) {
|
|
||||||
// use %p on pointers and arrays
|
|
||||||
invalidPrintfArgTypeError_sint(tok, numFormat, specifier, &argInfo);
|
|
||||||
}
|
}
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
|
@ -1206,11 +1200,11 @@ void CheckIO::checkFormatString(const Token * const tok,
|
||||||
specifier += *i;
|
specifier += *i;
|
||||||
if (argInfo.typeToken->tokType() == Token::eString) {
|
if (argInfo.typeToken->tokType() == Token::eString) {
|
||||||
invalidPrintfArgTypeError_uint(tok, numFormat, specifier, &argInfo);
|
invalidPrintfArgTypeError_uint(tok, numFormat, specifier, &argInfo);
|
||||||
|
} else if (argInfo.isArrayOrPointer() && !argInfo.element) {
|
||||||
|
// use %p on pointers and arrays
|
||||||
|
invalidPrintfArgTypeError_uint(tok, numFormat, specifier, &argInfo);
|
||||||
} else if (argInfo.isKnownType()) {
|
} else if (argInfo.isKnownType()) {
|
||||||
if (argInfo.isArrayOrPointer() && !argInfo.element) {
|
if (!argInfo.typeToken->isUnsigned() && !Token::Match(argInfo.typeToken, "bool|_Bool")) {
|
||||||
// use %p on pointers and arrays
|
|
||||||
invalidPrintfArgTypeError_uint(tok, numFormat, specifier, &argInfo);
|
|
||||||
} else if (!argInfo.typeToken->isUnsigned() && !Token::Match(argInfo.typeToken, "bool|_Bool")) {
|
|
||||||
if (!(!argInfo.isArrayOrPointer() && argInfo.element))
|
if (!(!argInfo.isArrayOrPointer() && argInfo.element))
|
||||||
invalidPrintfArgTypeError_uint(tok, numFormat, specifier, &argInfo);
|
invalidPrintfArgTypeError_uint(tok, numFormat, specifier, &argInfo);
|
||||||
} else if (!Token::Match(argInfo.typeToken, "bool|char|short|long|int")) {
|
} else if (!Token::Match(argInfo.typeToken, "bool|char|short|long|int")) {
|
||||||
|
@ -1269,8 +1263,6 @@ void CheckIO::checkFormatString(const Token * const tok,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (argInfo.isArrayOrPointer() && !argInfo.element) {
|
|
||||||
invalidPrintfArgTypeError_uint(tok, numFormat, specifier, &argInfo);
|
|
||||||
}
|
}
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
|
@ -1289,19 +1281,16 @@ void CheckIO::checkFormatString(const Token * const tok,
|
||||||
specifier += *i;
|
specifier += *i;
|
||||||
if (argInfo.typeToken->tokType() == Token::eString)
|
if (argInfo.typeToken->tokType() == Token::eString)
|
||||||
invalidPrintfArgTypeError_float(tok, numFormat, specifier, &argInfo);
|
invalidPrintfArgTypeError_float(tok, numFormat, specifier, &argInfo);
|
||||||
else if (argInfo.isKnownType()) {
|
else if (argInfo.isArrayOrPointer() && !argInfo.element) {
|
||||||
if (argInfo.isArrayOrPointer() && !argInfo.element) {
|
// use %p on pointers and arrays
|
||||||
// use %p on pointers and arrays
|
invalidPrintfArgTypeError_float(tok, numFormat, specifier, &argInfo);
|
||||||
invalidPrintfArgTypeError_float(tok, numFormat, specifier, &argInfo);
|
} else if (argInfo.isKnownType()) {
|
||||||
} else if (!Token::Match(argInfo.typeToken, "float|double")) {
|
if (!Token::Match(argInfo.typeToken, "float|double")) {
|
||||||
if (!(!argInfo.isArrayOrPointer() && argInfo.element))
|
if (!(!argInfo.isArrayOrPointer() && argInfo.element))
|
||||||
invalidPrintfArgTypeError_float(tok, numFormat, specifier, &argInfo);
|
invalidPrintfArgTypeError_float(tok, numFormat, specifier, &argInfo);
|
||||||
} else if ((specifier[0] == 'L' && (!argInfo.typeToken->isLong() || argInfo.typeToken->str() != "double")) ||
|
} else if ((specifier[0] == 'L' && (!argInfo.typeToken->isLong() || argInfo.typeToken->str() != "double")) ||
|
||||||
(specifier[0] != 'L' && argInfo.typeToken->isLong()))
|
(specifier[0] != 'L' && argInfo.typeToken->isLong()))
|
||||||
invalidPrintfArgTypeError_float(tok, numFormat, specifier, &argInfo);
|
invalidPrintfArgTypeError_float(tok, numFormat, specifier, &argInfo);
|
||||||
} else if (argInfo.isArrayOrPointer() && !argInfo.element) {
|
|
||||||
// use %p on pointers and arrays
|
|
||||||
invalidPrintfArgTypeError_float(tok, numFormat, specifier, &argInfo);
|
|
||||||
}
|
}
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue