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,9 +111,9 @@ 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
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
@@ -123,11 +123,10 @@ private string getValue(Expr e) {
* v is a static member variable
*/
exists(VariableAccess access, StaticStorageDurationVariable v |
exists(StaticStorageDurationVariable v |
not v.getUnderlyingType().isVolatile() and
v.getUnderlyingType().isConst() and
e = access and
v = access.getTarget() and
v = e.(VariableAccess).getTarget() and
result = getValue(v.getAnAssignedValue())
)
}