CheckError use std::string

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2026-03-08 15:02:14 -07:00
parent ab99512351
commit 8bd938d840
5 changed files with 15 additions and 27 deletions

View File

@ -79,7 +79,7 @@ class GraphLoop;
using ModeNameMap = std::map<std::string, Mode*>;
using SceneNameMap = std::map<std::string, Scene*>;
using SlowDrvrIterator = Iterator<Instance*>;
using CheckError = StringSeq;
using CheckError = StdStringSeq;
using CheckErrorSeq = std::vector<CheckError*>;
enum class CmdNamespace { sta, sdc };
using ParasiticsNameMap = std::map<std::string, Parasitics*>;

View File

@ -31,7 +31,6 @@
#include <vector>
#include <unordered_map>
#include "StringSeq.hh"
#include "StringUtil.hh"
#include "MinMax.hh"
#include "NetworkClass.hh"

View File

@ -24,7 +24,6 @@
#include "CheckTiming.hh"
#include "ContainerHelpers.hh"
#include "Error.hh"
#include "TimingRole.hh"
#include "Network.hh"
@ -64,7 +63,6 @@ void
CheckTiming::deleteErrors()
{
for (CheckError *error : errors_) {
deleteContents(error);
delete error;
}
}
@ -204,25 +202,23 @@ CheckTiming::checkLoops()
errorMsgSubst("Warning: There %is %d combinational loop%s in the design.",
loop_count, error_msg);
CheckError *error = new CheckError;
error->push_back(stringCopy(error_msg.c_str()));
error->push_back(error_msg);
for (GraphLoop *loop : loops) {
if (loop->isCombinational()) {
Edge *last_edge = nullptr;
for (Edge *edge : *loop->edges()) {
Pin *pin = edge->from(graph_)->pin();
const char *pin_name = stringCopy(sdc_network_->pathName(pin));
error->push_back(pin_name);
error->push_back(sdc_network_->pathName(pin));
last_edge = edge;
}
if (last_edge) {
error->push_back(stringCopy("| loop cut point"));
error->push_back("| loop cut point");
const Pin *pin = last_edge->to(graph_)->pin();
const char *pin_name = stringCopy(sdc_network_->pathName(pin));
error->push_back(pin_name);
error->push_back(sdc_network_->pathName(pin));
// Separator between loops.
error->push_back(stringCopy("--------------------------------"));
error->push_back("--------------------------------");
}
}
}
@ -362,15 +358,12 @@ CheckTiming::pushPinErrors(const char *msg,
CheckError *error = new CheckError;
std::string error_msg;
errorMsgSubst(msg, pins.size(), error_msg);
// Copy the error strings because the error deletes them when it
// is deleted.
error->push_back(stringCopy(error_msg.c_str()));
error->push_back(error_msg);
// Sort the error pins so the output is independent of the order
// the the errors are discovered.
PinSeq pins1 = sortByPathName(&pins, network_);
for (const Pin *pin : pins1) {
const char *pin_name = stringCopy(sdc_network_->pathName(pin));
error->push_back(pin_name);
error->push_back(sdc_network_->pathName(pin));
}
errors_.push_back(error);
}
@ -384,15 +377,12 @@ CheckTiming::pushClkErrors(const char *msg,
CheckError *error = new CheckError;
std::string error_msg;
errorMsgSubst(msg, clks.size(), error_msg);
// Copy the error strings because the error deletes them when it
// is deleted.
error->push_back(stringCopy(error_msg.c_str()));
error->push_back(error_msg);
// Sort the error clks so the output is independent of the order
// the the errors are discovered.
ClockSeq clks1 = sortByName(&clks);
for (const Clock *clk : clks1) {
const char *clk_name = stringCopy(clk->name());
error->push_back(clk_name);
error->push_back(clk->name());
}
errors_.push_back(error);
}

View File

@ -26,7 +26,7 @@
#include <vector>
#include "StringSeq.hh"
#include "StringUtil.hh"
#include "NetworkClass.hh"
#include "GraphClass.hh"
#include "SdcClass.hh"
@ -36,7 +36,7 @@ namespace sta {
class ClkNetwork;
using CheckError = StringSeq;
using CheckError = StdStringSeq;
using CheckErrorSeq = std::vector<CheckError*>;
class CheckTiming : public StaState

View File

@ -1137,10 +1137,9 @@ using namespace sta;
CheckErrorSeq *check_errors = $1;
for (CheckError *error : *check_errors) {
Tcl_Obj *string_list = Tcl_NewListObj(0, nullptr);
for (const char *str : *error) {
size_t str_len = strlen(str);
Tcl_Obj *obj = Tcl_NewStringObj(const_cast<char*>(str),
static_cast<int>(str_len));
for (const std::string &str : *error) {
Tcl_Obj *obj = Tcl_NewStringObj(str.c_str(),
static_cast<int>(str.size()));
Tcl_ListObjAppendElement(interp, string_list, obj);
}
Tcl_ListObjAppendElement(interp, error_list, string_list);