From edbc7684c321b4a0f92ecbf4c98663cf98a23344 Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Sun, 16 Feb 2025 20:32:32 +0000 Subject: [PATCH] Add LibertyCell::leakagePower overload using std::optional More modern C++ style Signed-off-by: Matt Liberty --- include/sta/Liberty.hh | 2 ++ liberty/Liberty.cc | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/sta/Liberty.hh b/include/sta/Liberty.hh index 1ac7921f..0bdb3753 100644 --- a/include/sta/Liberty.hh +++ b/include/sta/Liberty.hh @@ -26,6 +26,7 @@ #include #include +#include #include "MinMax.hh" #include "RiseFallMinMax.hh" @@ -474,6 +475,7 @@ public: void leakagePower(// Return values. float &leakage, bool &exists) const; + std::optional leakagePower() const; bool leakagePowerExists() const { return leakage_power_exists_; } // Register, Latch or Statetable. diff --git a/liberty/Liberty.cc b/liberty/Liberty.cc index e4893739..e5324dc4 100644 --- a/liberty/Liberty.cc +++ b/liberty/Liberty.cc @@ -1307,6 +1307,16 @@ LibertyCell::leakagePower(// Return values. exists = leakage_power_exists_; } +std::optional +LibertyCell::leakagePower() const +{ + std::optional leakage; + if (leakage_power_exists_) { + leakage = leakage_power_; + } + return leakage; +} + void LibertyCell::finish(bool infer_latches, Report *report,