Fix clktreedelay crash#9839
Conversation
Signed-off-by: dsengupta0628 <dsengupta@precisioninno.com>
Signed-off-by: dsengupta0628 <dsengupta@precisioninno.com>
Signed-off-by: dsengupta0628 <dsengupta@precisioninno.com>
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
src/cts/src/LatencyBalancer.cpp
Outdated
| insDelay = (rise + fall) / 2.0; | ||
| insDelay = (rise != 0 && fall != 0) | ||
| ? (rise + fall) / 2.0 | ||
| : (rise != 0 ? rise : fall); |
There was a problem hiding this comment.
warning: conditional operator is used as sub-expression of parent conditional operator, refrain from using nested conditional operators [readability-avoid-nested-conditional-operator]
: (rise != 0 ? rise : fall);
^Additional context
src/cts/src/LatencyBalancer.cpp:201: parent conditional operator here
insDelay = (rise != 0 && fall != 0)
^There was a problem hiding this comment.
This is a simple ternary operator and no need for another variable to store intermediate results
src/cts/src/LatencyBalancer.cpp
Outdated
| if (rise != 0 || fall != 0) { | ||
| insDelay = (rise + fall) / 2.0; | ||
| insDelay = (rise != 0 && fall != 0) ? (rise + fall) / 2.0 | ||
| : (rise != 0 ? rise : fall); |
There was a problem hiding this comment.
warning: conditional operator is used as sub-expression of parent conditional operator, refrain from using nested conditional operators [readability-avoid-nested-conditional-operator]
: (rise != 0 ? rise : fall);
^Additional context
src/cts/src/LatencyBalancer.cpp:345: parent conditional operator here
insDelay = (rise != 0 && fall != 0) ? (rise + fall) / 2.0
^
src/cts/src/TritonCTS.cpp
Outdated
| double delayPerSec = (rise + fall) / 2.0; | ||
| double delayPerSec = (rise != 0 && fall != 0) | ||
| ? (rise + fall) / 2.0 | ||
| : (rise != 0 ? rise : fall); |
There was a problem hiding this comment.
warning: conditional operator is used as sub-expression of parent conditional operator, refrain from using nested conditional operators [readability-avoid-nested-conditional-operator]
: (rise != 0 ? rise : fall);
^Additional context
src/cts/src/TritonCTS.cpp:2205: parent conditional operator here
double delayPerSec = (rise != 0 && fall != 0)
^
src/gui/src/clockWidget.cpp
Outdated
| ins_delay = (rise + fall) / 2.0; | ||
| } | ||
| (rise != 0 && fall != 0) ? (rise + fall) / 2.0 | ||
| : (rise != 0 ? rise : fall); |
There was a problem hiding this comment.
warning: conditional operator is used as sub-expression of parent conditional operator, refrain from using nested conditional operators [readability-avoid-nested-conditional-operator]
: (rise != 0 ? rise : fall);
^Additional context
src/gui/src/clockWidget.cpp:1340: parent conditional operator here
(rise != 0 && fall != 0) ? (rise + fall) / 2.0
^
src/gui/src/clockWidget.cpp
Outdated
| ins_delay = (rise + fall) / 2.0; | ||
| } | ||
| (rise != 0 && fall != 0) ? (rise + fall) / 2.0 | ||
| : (rise != 0 ? rise : fall); |
There was a problem hiding this comment.
warning: expression result unused [clang-diagnostic-unused-value]
: (rise != 0 ? rise : fall);
^Signed-off-by: dsengupta0628 <dsengupta@precisioninno.com>
|
/gemini review |
src/gui/src/clockWidget.cpp
Outdated
| ins_delay = (rise + fall) / 2.0; | ||
| } | ||
| ins_delay = (rise != 0 && fall != 0) ? (rise + fall) / 2.0 | ||
| : (rise != 0 ? rise : fall); |
There was a problem hiding this comment.
warning: conditional operator is used as sub-expression of parent conditional operator, refrain from using nested conditional operators [readability-avoid-nested-conditional-operator]
: (rise != 0 ? rise : fall);
^Additional context
src/gui/src/clockWidget.cpp:1340: parent conditional operator here
ins_delay = (rise != 0 && fall != 0) ? (rise + fall) / 2.0
^There was a problem hiding this comment.
Code Review
The pull request consistently updates the calculation of insertion delays across multiple files. The change introduces a ternary operator to handle cases where either rise or fall delay might be zero, ensuring that if only one is non-zero, that value is used directly instead of averaging with zero. If both are non-zero, they are averaged. This makes the delay calculation more robust and explicit, preventing potential misinterpretations of delay values when one component is absent. The change also improves code conciseness in clockWidget.cpp by removing a redundant if condition.
src/cts/src/LatencyBalancer.cpp
Outdated
| insDelay = (rise != 0 && fall != 0) | ||
| ? (rise + fall) / 2.0 | ||
| : (rise != 0 ? rise : fall); |
src/cts/src/LatencyBalancer.cpp
Outdated
| insDelay = (rise != 0 && fall != 0) ? (rise + fall) / 2.0 | ||
| : (rise != 0 ? rise : fall); |
src/cts/src/TritonCTS.cpp
Outdated
| double delayPerSec = (rise != 0 && fall != 0) | ||
| ? (rise + fall) / 2.0 | ||
| : (rise != 0 ? rise : fall); |
src/gui/src/clockWidget.cpp
Outdated
| ins_delay = (rise != 0 && fall != 0) ? (rise + fall) / 2.0 | ||
| : (rise != 0 ? rise : fall); |
There was a problem hiding this comment.
This change streamlines the ins_delay calculation by directly using the ternary operator, removing the redundant if condition. The logic remains correct, as ins_delay will be 0.0 if both rise and fall are zero, and will use the single non-zero value if only one is present, or their average if both are non-zero. This improves code conciseness and readability.
Signed-off-by: dsengupta0628 <dsengupta@precisioninno.com>
src/cts/src/LatencyBalancer.cpp
Outdated
| insDelay | ||
| = (rise != 0 && fall != 0) | ||
| ? (rise + fall) / 2.0 | ||
| : (rise != 0 |
There was a problem hiding this comment.
warning: conditional operator is used as sub-expression of parent conditional operator, refrain from using nested conditional operators [readability-avoid-nested-conditional-operator]
: (rise != 0
^Additional context
src/cts/src/LatencyBalancer.cpp:202: parent conditional operator here
= (rise != 0 && fall != 0)
^
src/cts/src/LatencyBalancer.cpp
Outdated
| insDelay | ||
| = (rise != 0 && fall != 0) | ||
| ? (rise + fall) / 2.0 | ||
| : (rise != 0 |
There was a problem hiding this comment.
warning: conditional operator is used as sub-expression of parent conditional operator, refrain from using nested conditional operators [readability-avoid-nested-conditional-operator]
: (rise != 0
^Additional context
src/cts/src/LatencyBalancer.cpp:349: parent conditional operator here
= (rise != 0 && fall != 0)
^
src/cts/src/TritonCTS.cpp
Outdated
| double delayPerSec | ||
| = (rise != 0 && fall != 0) | ||
| ? (rise + fall) / 2.0 | ||
| : (rise != 0 |
There was a problem hiding this comment.
warning: conditional operator is used as sub-expression of parent conditional operator, refrain from using nested conditional operators [readability-avoid-nested-conditional-operator]
: (rise != 0
^Additional context
src/cts/src/TritonCTS.cpp:2206: parent conditional operator here
= (rise != 0 && fall != 0)
^
src/gui/src/clockWidget.cpp
Outdated
| ins_delay | ||
| = (rise != 0 && fall != 0) | ||
| ? (rise + fall) / 2.0 | ||
| : (rise != 0 |
There was a problem hiding this comment.
warning: conditional operator is used as sub-expression of parent conditional operator, refrain from using nested conditional operators [readability-avoid-nested-conditional-operator]
: (rise != 0
^Additional context
src/gui/src/clockWidget.cpp:1341: parent conditional operator here
= (rise != 0 && fall != 0)
^|
Fix rather than NOLINT as it isn't terribly readable. |
Signed-off-by: dsengupta0628 <dsengupta@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
OpenSTA change in https://github.com/The-OpenROAD-Project-private/OpenSTA/pull/23, The-OpenROAD-Project/OpenSTA#313