CPP: Fix UncheckedLeapYearAfterYearModification FPs.

This commit is contained in:
Geoffrey White 2019-06-24 11:21:48 +01:00
Родитель cff3f9bdaf
Коммит 7fca220eda
2 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -91,6 +91,9 @@ abstract class LeapYearFieldAccess extends YearFieldAccess {
mulBy100.getAChild().getValue().toInt() = 100 )))
or exists( BinaryArithmeticOperation bao |
bao = op.getAnOperand()
// we're specifically interested in calculations that update the existing
// value (like `x = x + 1`), so look for a child `YearFieldAccess`.
and bao.getAChild*() instanceof YearFieldAccess
and not ( bao.getAChild().getValue().toInt() = 1900
or bao.getAChild().getValue().toInt() = 2000
or bao.getAChild().getValue().toInt() = 1980

Просмотреть файл

@ -9,4 +9,3 @@
| test.cpp:636:11:636:17 | tm_year | Field $@ on variable $@ has been modified, but no appropriate check for LeapYear was found. | test.cpp:56:6:56:12 | tm_year | tm_year | test.cpp:628:12:628:19 | timeinfo | timeinfo |
| test.cpp:640:5:640:9 | wYear | Field $@ on variable $@ has been modified, but no appropriate check for LeapYear was found. | test.cpp:12:7:12:11 | wYear | wYear | test.cpp:629:13:629:14 | st | st |
| test.cpp:642:5:642:9 | wYear | Field $@ on variable $@ has been modified, but no appropriate check for LeapYear was found. | test.cpp:12:7:12:11 | wYear | wYear | test.cpp:629:13:629:14 | st | st |
| test.cpp:677:5:677:11 | tm_year | Field $@ on variable $@ has been modified, but no appropriate check for LeapYear was found. | test.cpp:56:6:56:12 | tm_year | tm_year | test.cpp:664:12:664:12 | t | t |