[-Wunreachable-code] generalize configuration value checking to all comparison operators.

llvm-svn: 203016
This commit is contained in:
Ted Kremenek 2014-03-05 22:32:39 +00:00
parent 6a56b21729
commit 3cdbc39a6e
2 changed files with 9 additions and 1 deletions

View File

@ -382,7 +382,7 @@ static bool isConfigurationValue(const Stmt *S) {
return true;
case Stmt::BinaryOperatorClass: {
const BinaryOperator *B = cast<BinaryOperator>(S);
return (B->isLogicalOp() || B->isRelationalOp()) &&
return (B->isLogicalOp() || B->isComparisonOp()) &&
(isConfigurationValue(B->getLHS()) ||
isConfigurationValue(B->getRHS()));
}

View File

@ -226,3 +226,11 @@ int test_config_constant(int x) {
calledFun(); // expected-warning {{will never be executed}}
}
int sizeof_int() {
if (sizeof(long) == sizeof(int))
return 1; // no-warning
if (sizeof(long) != sizeof(int))
return 0; // no-warning
return 2; // no-warning
}