CPP: Correct overuse of 'toString'.

This commit is contained in:
Geoffrey White 2019-06-25 15:18:28 +01:00
Родитель bc5fb24371
Коммит 66dffdde05
2 изменённых файлов: 18 добавлений и 18 удалений

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

@ -35,7 +35,7 @@ class CheckForLeapYearOperation extends Operation {
CheckForLeapYearOperation() { CheckForLeapYearOperation() {
exists(BinaryArithmeticOperation bo | bo = this | exists(BinaryArithmeticOperation bo | bo = this |
bo.getAnOperand().getValue().toInt() = 4 and bo.getAnOperand().getValue().toInt() = 4 and
bo.getOperator().toString() = "%" and bo.getOperator() = "%" and
additionalLogicalCheck(this.getEnclosingElement(), "%", 100) and additionalLogicalCheck(this.getEnclosingElement(), "%", 100) and
additionalLogicalCheck(this.getEnclosingElement(), "%", 400) additionalLogicalCheck(this.getEnclosingElement(), "%", 400)
) )
@ -144,7 +144,7 @@ abstract class LeapYearFieldAccess extends YearFieldAccess {
exists(BinaryArithmeticOperation bo | exists(BinaryArithmeticOperation bo |
bo.getAnOperand() = this and bo.getAnOperand() = this and
bo.getAnOperand().getValue().toInt() = 4 and bo.getAnOperand().getValue().toInt() = 4 and
bo.getOperator().toString() = "%" bo.getOperator() = "%"
) )
} }
@ -168,14 +168,14 @@ abstract class LeapYearFieldAccess extends YearFieldAccess {
* `YearFieldAccess` for the `SYSTEMTIME` struct. * `YearFieldAccess` for the `SYSTEMTIME` struct.
*/ */
class StructSystemTimeLeapYearFieldAccess extends LeapYearFieldAccess { class StructSystemTimeLeapYearFieldAccess extends LeapYearFieldAccess {
StructSystemTimeLeapYearFieldAccess() { this.toString() = "wYear" } StructSystemTimeLeapYearFieldAccess() { this.getTarget().getName() = "wYear" }
} }
/** /**
* `YearFieldAccess` for `struct tm`. * `YearFieldAccess` for `struct tm`.
*/ */
class StructTmLeapYearFieldAccess extends LeapYearFieldAccess { class StructTmLeapYearFieldAccess extends LeapYearFieldAccess {
StructTmLeapYearFieldAccess() { this.toString() = "tm_year" } StructTmLeapYearFieldAccess() { this.getTarget().getName() = "tm_year" }
override predicate isUsedInCorrectLeapYearCheck() { override predicate isUsedInCorrectLeapYearCheck() {
this.isUsedInMod4Operation() and this.isUsedInMod4Operation() and

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

@ -9,8 +9,8 @@ import cpp
*/ */
class FileTimeStruct extends Type { class FileTimeStruct extends Type {
FileTimeStruct() { FileTimeStruct() {
this.toString() = "_FILETIME" this.getName() = "_FILETIME"
or this.toString().matches("_FILETIME %") or this.getName().matches("_FILETIME %")
} }
} }
@ -20,12 +20,12 @@ class FileTimeStruct extends Type {
*/ */
class DateDataStruct extends Type { class DateDataStruct extends Type {
DateDataStruct() { DateDataStruct() {
this.toString() = "_SYSTEMTIME" this.getName() = "_SYSTEMTIME"
or this.toString() = "SYSTEMTIME" or this.getName() = "SYSTEMTIME"
or this.toString() = "tm" or this.getName() = "tm"
or this.toString().matches("_SYSTEMTIME %") or this.getName().matches("_SYSTEMTIME %")
or this.toString().matches("SYSTEMTIME %") or this.getName().matches("SYSTEMTIME %")
or this.toString().matches("tm %") or this.getName().matches("tm %")
} }
} }
@ -61,7 +61,7 @@ abstract class YearFieldAccess extends StructFieldAccess {}
*/ */
class SystemTimeDayFieldAccess extends DayFieldAccess { class SystemTimeDayFieldAccess extends DayFieldAccess {
SystemTimeDayFieldAccess () { SystemTimeDayFieldAccess () {
this.toString() = "wDay" this.getTarget().getName() = "wDay"
} }
} }
@ -70,7 +70,7 @@ class SystemTimeDayFieldAccess extends DayFieldAccess {
*/ */
class SystemTimeMonthFieldAccess extends MonthFieldAccess { class SystemTimeMonthFieldAccess extends MonthFieldAccess {
SystemTimeMonthFieldAccess () { SystemTimeMonthFieldAccess () {
this.toString() = "wMonth" this.getTarget().getName() = "wMonth"
} }
} }
@ -79,7 +79,7 @@ class SystemTimeMonthFieldAccess extends MonthFieldAccess {
*/ */
class StructSystemTimeYearFieldAccess extends YearFieldAccess { class StructSystemTimeYearFieldAccess extends YearFieldAccess {
StructSystemTimeYearFieldAccess() { StructSystemTimeYearFieldAccess() {
this.toString() = "wYear" this.getTarget().getName() = "wYear"
} }
} }
@ -88,7 +88,7 @@ class StructSystemTimeYearFieldAccess extends YearFieldAccess {
*/ */
class StructTmDayFieldAccess extends DayFieldAccess { class StructTmDayFieldAccess extends DayFieldAccess {
StructTmDayFieldAccess() { StructTmDayFieldAccess() {
this.toString() = "tm_mday" this.getTarget().getName() = "tm_mday"
} }
} }
@ -97,7 +97,7 @@ class StructTmDayFieldAccess extends DayFieldAccess {
*/ */
class StructTmMonthFieldAccess extends MonthFieldAccess { class StructTmMonthFieldAccess extends MonthFieldAccess {
StructTmMonthFieldAccess() { StructTmMonthFieldAccess() {
this.toString() = "tm_mon" this.getTarget().getName() = "tm_mon"
} }
} }
@ -106,6 +106,6 @@ class StructTmMonthFieldAccess extends MonthFieldAccess {
*/ */
class StructTmYearFieldAccess extends YearFieldAccess { class StructTmYearFieldAccess extends YearFieldAccess {
StructTmYearFieldAccess() { StructTmYearFieldAccess() {
this.toString() = "tm_year" this.getTarget().getName() = "tm_year"
} }
} }