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:
Simon Friis Vindum
2025-10-24 16:08:35 +02:00
parent 3af9885489
commit 383e6a44aa

View File

@@ -111,25 +111,24 @@ float widenUpperBound(Type type, float ub) {
* compilation units, which doesn't necessarily have a getValue() result from the extractor.
*/
private string getValue(Expr e) {
if exists(e.getValue())
then result = e.getValue()
else
/*
* 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 not volatile, and
* Either:
* v is a local/global variable, or
* v is a static member variable
*/
result = e.getValue()
or
not exists(e.getValue()) and
/*
* 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 not volatile, and
* Either:
* v is a local/global variable, or
* v is a static member variable
*/
exists(VariableAccess access, StaticStorageDurationVariable v |
not v.getUnderlyingType().isVolatile() and
v.getUnderlyingType().isConst() and
e = access and
v = access.getTarget() and
result = getValue(v.getAnAssignedValue())
)
exists(StaticStorageDurationVariable v |
not v.getUnderlyingType().isVolatile() and
v.getUnderlyingType().isConst() and
v = e.(VariableAccess).getTarget() and
result = getValue(v.getAnAssignedValue())
)
}
/**