This commit is contained in:
James Cherry 2021-02-07 17:22:59 +00:00
parent e3d60f0b8c
commit 6359bd6fc5
4 changed files with 26 additions and 16 deletions

View File

@ -522,8 +522,13 @@ libertyIncludeBegin(const char *filename)
liberty_filename = filename; liberty_filename = filename;
liberty_line = 1; liberty_line = 1;
} }
else else {
libertyParseError("cannot open include file %s.", filename); // Copy the filename to the stack so it is deleted when
// libertyParseError throws an error.
string filename1(filename);
stringDelete(filename);
libertyParseError("cannot open include file %s.", filename1.c_str());
}
return stream; return stream;
} }

View File

@ -600,6 +600,7 @@ LibertyReader::endLibraryAttrs(LibertyGroup *group)
else else
libWarn(31, group, "default_wire_load %s not found.", default_wireload_); libWarn(31, group, "default_wire_load %s not found.", default_wireload_);
stringDelete(default_wireload_); stringDelete(default_wireload_);
default_wireload_ = nullptr;
} }
if (default_wireload_selection_) { if (default_wireload_selection_) {
@ -611,6 +612,7 @@ LibertyReader::endLibraryAttrs(LibertyGroup *group)
libWarn(32, group, "default_wire_selection %s not found.", libWarn(32, group, "default_wire_selection %s not found.",
default_wireload_selection_); default_wireload_selection_);
stringDelete(default_wireload_selection_); stringDelete(default_wireload_selection_);
default_wireload_selection_ = nullptr;
} }
if (default_operating_condition_) { if (default_operating_condition_) {
@ -622,6 +624,7 @@ LibertyReader::endLibraryAttrs(LibertyGroup *group)
libWarn(60, group, "default_operating_condition %s not found.", libWarn(60, group, "default_operating_condition %s not found.",
default_operating_condition_); default_operating_condition_);
stringDelete(default_operating_condition_); stringDelete(default_operating_condition_);
default_operating_condition_ = nullptr;
} }
bool missing_threshold = false; bool missing_threshold = false;
@ -1074,10 +1077,12 @@ LibertyReader::visitDefaultWireLoad(LibertyAttr *attr)
{ {
if (library_) { if (library_) {
const char *value = getAttrString(attr); const char *value = getAttrString(attr);
if (value) if (value) {
stringDelete(default_wireload_);
default_wireload_ = stringCopy(value); default_wireload_ = stringCopy(value);
} }
} }
}
void void
LibertyReader::visitDefaultWireLoadMode(LibertyAttr *attr) LibertyReader::visitDefaultWireLoadMode(LibertyAttr *attr)
@ -1100,20 +1105,24 @@ LibertyReader::visitDefaultWireLoadSelection(LibertyAttr *attr)
{ {
if (library_) { if (library_) {
const char *value = getAttrString(attr); const char *value = getAttrString(attr);
if (value) if (value) {
stringDelete(default_wireload_selection_);
default_wireload_selection_ = stringCopy(value); default_wireload_selection_ = stringCopy(value);
} }
} }
}
void void
LibertyReader::visitDefaultOperatingConditions(LibertyAttr *attr) LibertyReader::visitDefaultOperatingConditions(LibertyAttr *attr)
{ {
if (library_) { if (library_) {
const char *value = getAttrString(attr); const char *value = getAttrString(attr);
if (value) if (value) {
stringDelete(default_operating_condition_);
default_operating_condition_ = stringCopy(value); default_operating_condition_ = stringCopy(value);
} }
} }
}
void void
LibertyReader::visitInputThresholdPctFall(LibertyAttr *attr) LibertyReader::visitInputThresholdPctFall(LibertyAttr *attr)

View File

@ -60,6 +60,7 @@ write_verilog_cmd(const char *filename,
Sta *sta = Sta::sta(); Sta *sta = Sta::sta();
Network *network = sta->network(); Network *network = sta->network();
writeVerilog(filename, sort, include_pwr_gnd, remove_cells, network); writeVerilog(filename, sort, include_pwr_gnd, remove_cells, network);
delete remove_cells;
} }
%} // inline %} // inline

View File

@ -80,7 +80,10 @@ public:
const char *msg, const char *msg,
bool warn); bool warn);
~VerilogError(); ~VerilogError();
void report(Report *report); const char *msg() const { return msg_; }
const char *filename() const { return filename_; }
int id() const { return id_; }
int line() const { return line_; }
bool warn() const { return warn_; } bool warn() const { return warn_; }
private: private:
@ -114,15 +117,6 @@ VerilogError::~VerilogError()
stringDelete(msg_); stringDelete(msg_);
} }
void
VerilogError::report(Report *report)
{
if (warn_)
report->fileWarn(id_, filename_, line_, "%s", msg_);
else
report->fileError(id_, filename_, line_, "%s", msg_);
}
class VerilogErrorCmp class VerilogErrorCmp
{ {
public: public:
@ -2224,7 +2218,8 @@ VerilogReader::reportLinkErrors(Report *report)
VerilogErrorSeq::Iterator error_iter(link_errors_); VerilogErrorSeq::Iterator error_iter(link_errors_);
while (error_iter.hasNext()) { while (error_iter.hasNext()) {
VerilogError *error = error_iter.next(); VerilogError *error = error_iter.next();
error->report(report); // Report as warnings to avoid throwing.
report->fileWarn(error->id(), error->filename(), error->line(), "%s", error->msg());
errors |= !error->warn(); errors |= !error->warn();
delete error; delete error;
} }