mirror of
https://github.com/YosysHQ/yosys
synced 2025-11-05 05:49:15 +00:00
Ensure that new_id(_suffix)() cannot create collisions with existing IdStrings.
This commit is contained in:
parent
bf732df591
commit
442a969812
1 changed files with 11 additions and 0 deletions
|
|
@ -23,6 +23,7 @@
|
|||
#include "kernel/yosys_common.h"
|
||||
#include "kernel/yosys.h"
|
||||
|
||||
#include <charconv>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
|
||||
|
|
@ -199,6 +200,16 @@ struct RTLIL::IdString
|
|||
if ((unsigned)ch <= (unsigned)' ')
|
||||
log_error("Found control character or space (0x%02x) in string '%s' which is not allowed in RTLIL identifiers\n", ch, std::string(p).c_str());
|
||||
|
||||
if (p.substr(0, 6) == "$auto$") {
|
||||
// Ensure new_id(_suffix) will not create collisions.
|
||||
size_t autoidx_pos = p.find_last_of('$');
|
||||
int p_autoidx;
|
||||
std::string_view v = p.substr(autoidx_pos + 1);
|
||||
if (std::from_chars(v.begin(), v.end(), p_autoidx).ec == std::errc()) {
|
||||
autoidx = std::max(autoidx, p_autoidx + 1);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef YOSYS_NO_IDS_REFCNT
|
||||
if (global_free_idx_list_.empty()) {
|
||||
log_assert(global_id_storage_.size() < 0x40000000);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue