Skip to content

Commit 2b806ad

Browse files
committed
C++: Add missing DateTime models for PTIME_FIELDS and TIME_FIELDS
1 parent a534d26 commit 2b806ad

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

cpp/ql/lib/semmle/code/cpp/commons/DateTime.qll

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ class PackedTimeType extends Type {
1414
}
1515
}
1616

17-
private predicate timeType(string typeName) { typeName = ["_SYSTEMTIME", "SYSTEMTIME", "tm"] }
17+
private predicate timeType(string typeName) {
18+
typeName = ["_SYSTEMTIME", "SYSTEMTIME", "tm", "TIME_FIELDS", "_TIME_FIELDS", "PTIME_FIELDS"]
19+
}
1820

1921
/**
2022
* A type that is used to represent times and dates in an 'unpacked' form, that is,
@@ -95,3 +97,24 @@ class StructTmMonthFieldAccess extends MonthFieldAccess {
9597
class StructTmYearFieldAccess extends YearFieldAccess {
9698
StructTmYearFieldAccess() { this.getTarget().getName() = "tm_year" }
9799
}
100+
101+
/**
102+
* A `DayFieldAccess` for the `TIME_FIELDS` struct.
103+
*/
104+
class TimeFieldsDayFieldAccess extends DayFieldAccess {
105+
TimeFieldsDayFieldAccess() { this.getTarget().getName() = "Day" }
106+
}
107+
108+
/**
109+
* A `MonthFieldAccess` for the `TIME_FIELDS` struct.
110+
*/
111+
class TimeFieldsMonthFieldAccess extends MonthFieldAccess {
112+
TimeFieldsMonthFieldAccess() { this.getTarget().getName() = "Month" }
113+
}
114+
115+
/**
116+
* A `YearFieldAccess` for the `TIME_FIELDS` struct.
117+
*/
118+
class TimeFieldsYearFieldAccess extends YearFieldAccess {
119+
TimeFieldsYearFieldAccess() { this.getTarget().getName() = "Year" }
120+
}

0 commit comments

Comments
 (0)