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. * 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
* The type of v is not volatile, and * The type of v is not volatile, and
* Either: * Either:
* v is a local/global variable, or * v is a local/global variable, or
* 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()) )
)
} }
/** /**