@@ -2462,7 +2462,7 @@ Layout::get_pcell_variant_dict (pcell_id_type pcell_id, const std::map<std::stri
24622462 pcell_variant_type *variant = header->get_variant (*this , parameters);
24632463 if (! variant) {
24642464
2465- std::string b (header->get_name ( ));
2465+ std::string b (header->declaration ()-> get_cell_name (parameters ));
24662466 if (m_cell_map.find (b.c_str ()) != m_cell_map.end ()) {
24672467 b = uniquify_cell_name (b.c_str ());
24682468 }
@@ -2501,7 +2501,7 @@ Layout::get_pcell_variant (pcell_id_type pcell_id, const std::vector<tl::Variant
25012501 pcell_variant_type *variant = header->get_variant (*this , parameters);
25022502 if (! variant) {
25032503
2504- std::string b (header->get_name ( ));
2504+ std::string b (header->declaration ()-> get_cell_name (parameters ));
25052505 if (m_cell_map.find (b.c_str ()) != m_cell_map.end ()) {
25062506 b = uniquify_cell_name (b.c_str ());
25072507 }
@@ -2627,9 +2627,18 @@ Layout::convert_cell_to_static (db::cell_index_type ci)
26272627
26282628 const cell_type &org_cell = cell (ci);
26292629
2630- // Note: convert to static cell by explicitly cloning to the db::Cell class
2631- ret_ci = add_cell (org_cell.get_basic_name ().c_str ());
2630+ std::string vn = org_cell.get_variant_name ();
2631+ if (vn == std::string (cell_name (ci), vn.size ())) {
2632+ // there is a cell name conflict: give priority to the static cell, so it
2633+ // will see the variant name or at least the original disambiguated name
2634+ std::string rename_org = uniquify_cell_name (vn.c_str ());
2635+ vn = cell_name (ci);
2636+ rename_cell (ci, rename_org.c_str ());
2637+ }
2638+
2639+ ret_ci = add_cell (vn.c_str ());
26322640 cell_type &new_cell = cell (ret_ci);
2641+ // Note: we convert to static cell by explicitly converting to the db::Cell class
26332642 new_cell = org_cell;
26342643 new_cell.set_cell_index (ret_ci);
26352644
@@ -3126,6 +3135,12 @@ Layout::basic_name (cell_index_type cell_index) const
31263135 return cell (cell_index).get_basic_name ();
31273136}
31283137
3138+ std::string
3139+ Layout::variant_name (cell_index_type cell_index) const
3140+ {
3141+ return cell (cell_index).get_variant_name ();
3142+ }
3143+
31293144void
31303145Layout::register_lib_proxy (db::LibraryProxy *lib_proxy)
31313146{
@@ -3161,7 +3176,7 @@ Layout::get_lib_proxy (Library *lib, cell_index_type cell_index)
31613176 } else {
31623177
31633178 // create a new unique name
3164- std::string b (lib->layout ().basic_name (cell_index));
3179+ std::string b (lib->layout ().variant_name (cell_index));
31653180 if (m_cell_map.find (b.c_str ()) != m_cell_map.end ()) {
31663181 b = uniquify_cell_name (b.c_str ());
31673182 }
0 commit comments