-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathStructWithExactEraDate.ql
More file actions
47 lines (42 loc) · 1.57 KB
/
StructWithExactEraDate.ql
File metadata and controls
47 lines (42 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* @name Hard-coded Japanese era start date in struct
* @description Japanese era changes can lead to code behaving differently. Avoid hard-coding Japanese era start dates.
* @kind problem
* @problem.severity warning
* @id cpp/japanese-era/struct-with-exact-era-date
* @precision medium
* @tags reliability
* japanese-era
* @deprecated This query is deprecated, use
* Hard-coded Japanese era start date (`cpp/japanese-era/exact-era-date`)
* instead.
*/
import cpp
import semmle.code.cpp.commons.DateTime
predicate assignedYear(Struct s, YearFieldAccess year, int value) {
exists(Operation yearAssignment |
s.getAField().getAnAccess() = year and
yearAssignment.getAnOperand() = year and
yearAssignment.getAnOperand().getValue().toInt() = value
)
}
predicate assignedMonth(Struct s, MonthFieldAccess month, int value) {
exists(Operation monthAssignment |
s.getAField().getAnAccess() = month and
monthAssignment.getAnOperand() = month and
monthAssignment.getAnOperand().getValue().toInt() = value
)
}
predicate assignedDay(Struct s, DayFieldAccess day, int value) {
exists(Operation dayAssignment |
s.getAField().getAnAccess() = day and
dayAssignment.getAnOperand() = day and
dayAssignment.getAnOperand().getValue().toInt() = value
)
}
from StructLikeClass s, YearFieldAccess year, MonthFieldAccess month, DayFieldAccess day
where
assignedYear(s, year, 1989) and
assignedMonth(s, month, 1) and
assignedDay(s, day, 8)
select year, "A time struct that is initialized with exact Japanese calendar era start date."