-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C++: Fix some Ql4Ql violations. #20325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2268,8 +2268,8 @@ class ContentSet instanceof Content { | |
|
||
/** | ||
* Holds if this element is at the specified location. | ||
* The location spans column `startcolumn` of line `startline` to | ||
* column `endcolumn` of line `endline` in file `filepath`. | ||
* The location spans column `sc` of line `sl` to | ||
* column `ec` of line `el` in file `path`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above, rename the arguments. |
||
* For more information, see | ||
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/). | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,11 +191,19 @@ module BoostorgAsio { | |
class SslContextClass extends Class { | ||
SslContextClass() { this.getQualifiedName() = "boost::asio::ssl::context" } | ||
|
||
ConstructorCall getAContructorCall() { | ||
/** | ||
* Gets a constructor call, if any. | ||
*/ | ||
ConstructorCall getAConstructorCall() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs a change note. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
this.getAConstructor().getACallToThisFunction() = result and | ||
not result.getLocation().getFile().toString().matches("%/boost/asio/%") and | ||
result.fromSource() | ||
} | ||
|
||
/** | ||
* DEPRECATED: Use `getAConstructorCall` instead. | ||
*/ | ||
deprecated ConstructorCall getAContructorCall() { result = this.getAConstructorCall() } | ||
} | ||
|
||
/** | ||
|
@@ -368,7 +376,7 @@ module BoostorgAsio { | |
*/ | ||
default predicate isSink(DataFlow::Node sink) { | ||
exists(ConstructorCall cc, SslContextClass c, Expr e | e = sink.asExpr() | | ||
c.getAContructorCall() = cc and | ||
c.getAConstructorCall() = cc and | ||
cc.getArgument(0) = e | ||
) | ||
} | ||
|
@@ -468,7 +476,7 @@ module BoostorgAsio { | |
predicate isSource(DataFlow::Node source) { | ||
exists(SslContextClass c, ConstructorCall cc | | ||
cc = source.asExpr() and | ||
c.getAContructorCall() = cc | ||
c.getAConstructorCall() = cc | ||
) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -648,7 +648,7 @@ private predicate mk_UuidofOperator(Type t, UuidofOperator e) { | |
} | ||
|
||
private predicate analyzableTypeidType(TypeidOperator e) { | ||
count(e.getAChild()) = 0 and | ||
not exists(e.getAChild()) and | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a library that we test against in DCA, but it is used by the field team e.g., so if we want to change this we need to make sure in some way that it's not changing performance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverting. |
||
strictcount(e.getResultType()) = 1 | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,12 +164,17 @@ predicate valueOccurrenceCount(string value, int n) { | |
n > 20 | ||
} | ||
|
||
predicate occurenceCount(Literal lit, string value, int n) { | ||
predicate occurrenceCount(Literal lit, string value, int n) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs a change note. |
||
valueOccurrenceCount(value, n) and | ||
value = lit.getValue() and | ||
nonTrivialValue(_, lit) | ||
} | ||
|
||
/** | ||
* DEPRECATED: Use `occurrenceCount` instead. | ||
*/ | ||
deprecated predicate occurenceCount = occurrenceCount/3; | ||
|
||
/* | ||
* Literals repeated frequently | ||
*/ | ||
|
@@ -178,7 +183,7 @@ predicate check(Literal lit, string value, int n, File f) { | |
// Check that the literal is nontrivial | ||
not trivial(lit) and | ||
// Check that it is repeated a number of times | ||
occurenceCount(lit, value, n) and | ||
occurrenceCount(lit, value, n) and | ||
n > 20 and | ||
f = lit.getFile() and | ||
// Exclude generated files | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,11 +128,18 @@ abstract class LeapYearFieldAccess extends YearFieldAccess { | |
/** | ||
* Holds if the top-level binary operation includes an addition or subtraction operator with an operand specified by `valueToCheck`. | ||
*/ | ||
predicate additionalAdditionOrSubstractionCheckForLeapYear(int valueToCheck) { | ||
predicate additionalAdditionOrSubtractionCheckForLeapYear(int valueToCheck) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs a change note. |
||
additionalLogicalCheck(this, "+", valueToCheck) or | ||
additionalLogicalCheck(this, "-", valueToCheck) | ||
} | ||
|
||
/** | ||
* DEPRECATED: Use `additionalAdditionOrSubtractionCheckForLeapYear` instead. | ||
*/ | ||
deprecated predicate additionalAdditionOrSubstractionCheckForLeapYear(int valueToCheck) { | ||
this.additionalAdditionOrSubtractionCheckForLeapYear(valueToCheck) | ||
} | ||
|
||
/** | ||
* Holds if this object is used on a modulus 4 operation, which would likely indicate the start of a leap year check. | ||
*/ | ||
|
@@ -180,13 +187,13 @@ class StructTmLeapYearFieldAccess extends LeapYearFieldAccess { | |
this.additionalModulusCheckForLeapYear(100) and | ||
// tm_year represents years since 1900 | ||
( | ||
this.additionalAdditionOrSubstractionCheckForLeapYear(1900) | ||
this.additionalAdditionOrSubtractionCheckForLeapYear(1900) | ||
or | ||
// some systems may use 2000 for 2-digit year conversions | ||
this.additionalAdditionOrSubstractionCheckForLeapYear(2000) | ||
this.additionalAdditionOrSubtractionCheckForLeapYear(2000) | ||
or | ||
// converting from/to Unix epoch | ||
this.additionalAdditionOrSubstractionCheckForLeapYear(1970) | ||
this.additionalAdditionOrSubtractionCheckForLeapYear(1970) | ||
) | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,8 @@ import cpp | |
class RangeFunction extends Function { | ||
/** | ||
* Holds if this function is at the specified location. | ||
* The location spans column `startcolumn` of line `startline` to | ||
* column `endcolumn` of line `endline` in file `filepath`. | ||
* The location spans column `sc` of line `sl` to | ||
* column `ec` of line `el` in file `path`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As earlier, rename the arguments. |
||
* For more information, see | ||
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/). | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just rename the predicate arguments here. This makes things less clear.