SDC: Extract regexp escaping to separate method
Signed-off-by: Tomasz Michalak <tmichalak@antmicro.com>
diff --git a/sdc-plugin/clocks.cc b/sdc-plugin/clocks.cc
index 4f2ab29..638ba66 100644
--- a/sdc-plugin/clocks.cc
+++ b/sdc-plugin/clocks.cc
@@ -119,8 +119,7 @@
if (!wire) {
return std::string();
}
- std::string wire_name(RTLIL::unescape_id(wire->name));
- return std::regex_replace(wire_name, std::regex{"\\$"}, "\\$");
+ return AddEscaping(RTLIL::unescape_id(wire->name));
}
const std::map<std::string, RTLIL::Wire*> Clocks::GetClocks(RTLIL::Design* design) {
diff --git a/sdc-plugin/clocks.h b/sdc-plugin/clocks.h
index d405c62..2bcdf75 100644
--- a/sdc-plugin/clocks.h
+++ b/sdc-plugin/clocks.h
@@ -43,6 +43,9 @@
static float FallingEdge(RTLIL::Wire* clock_wire);
static std::string Name(RTLIL::Wire* clock_wire);
static std::string WireName(RTLIL::Wire* wire);
+ static std::string AddEscaping(const std::string& name) {
+ return std::regex_replace(name, std::regex{"\\$"}, "\\$");
+ }
private:
static std::pair<float, float> Waveform(RTLIL::Wire* clock_wire);