Skip to content

Commit 6d516e0

Browse files
committed
C++: Make some implementations in DatTime.qll more robust (and cope with 'const').
1 parent 8b1892d commit 6d516e0

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,23 @@ import cpp
1010
class PackedTimeType extends Type {
1111
PackedTimeType() {
1212
this.getName() = "_FILETIME" or
13-
this.getName().matches("_FILETIME %")
13+
this.(DerivedType).getBaseType*().getName() = "_FILETIME"
1414
}
1515
}
1616

17+
private predicate timeType(string typeName) {
18+
typeName = "_SYSTEMTIME" or
19+
typeName = "SYSTEMTIME" or
20+
typeName = "tm"
21+
}
1722
/**
1823
* A type that is used to represent times and dates in an 'unpacked' form, that is,
1924
* with separate fields for day, month, year etc.
2025
*/
2126
class UnpackedTimeType extends Type {
2227
UnpackedTimeType() {
23-
this.getName() = "_SYSTEMTIME" or
24-
this.getName() = "SYSTEMTIME" or
25-
this.getName() = "tm" or
26-
this.getName().matches("_SYSTEMTIME %") or
27-
this.getName().matches("SYSTEMTIME %") or
28-
this.getName().matches("tm %")
28+
timeType(this.getName()) or
29+
timeType(this.(DerivedType).getBaseType*().getName())
2930
}
3031
}
3132

0 commit comments

Comments
 (0)