mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C++: Use or instead of if
The proposition in the true branch implied the condition, so `or` is more appropriate. Also eliminated an existentially quantified variable.
This commit is contained in:
@@ -111,9 +111,9 @@ float widenUpperBound(Type type, float ub) {
|
|||||||
* compilation units, which doesn't necessarily have a getValue() result from the extractor.
|
* compilation units, which doesn't necessarily have a getValue() result from the extractor.
|
||||||
*/
|
*/
|
||||||
private string getValue(Expr e) {
|
private string getValue(Expr e) {
|
||||||
if exists(e.getValue())
|
result = e.getValue()
|
||||||
then result = e.getValue()
|
or
|
||||||
else
|
not exists(e.getValue()) and
|
||||||
/*
|
/*
|
||||||
* It should be safe to propagate the initialization value to a variable if:
|
* It should be safe to propagate the initialization value to a variable if:
|
||||||
* The type of v is const, and
|
* The type of v is const, and
|
||||||
@@ -123,11 +123,10 @@ private string getValue(Expr e) {
|
|||||||
* v is a static member variable
|
* v is a static member variable
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exists(VariableAccess access, StaticStorageDurationVariable v |
|
exists(StaticStorageDurationVariable v |
|
||||||
not v.getUnderlyingType().isVolatile() and
|
not v.getUnderlyingType().isVolatile() and
|
||||||
v.getUnderlyingType().isConst() and
|
v.getUnderlyingType().isConst() and
|
||||||
e = access and
|
v = e.(VariableAccess).getTarget() and
|
||||||
v = access.getTarget() and
|
|
||||||
result = getValue(v.getAnAssignedValue())
|
result = getValue(v.getAnAssignedValue())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user