From a2e033b2fa7ce134ed1f7e59928d297512206102 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Wed, 27 Sep 2023 16:38:18 -0400 Subject: [PATCH] fix: safename disambiguation --- .../asciidoc/layouts/single-symbol.adoc.hbs | 1 + .../generator/asciidoc/partials/enum.adoc.hbs | 1 - .../asciidoc/partials/field.adoc.hbs | 1 - .../asciidoc/partials/function.adoc.hbs | 1 - .../asciidoc/partials/namespace.adoc.hbs | 1 - .../asciidoc/partials/record.adoc.hbs | 1 - .../asciidoc/partials/typedef.adoc.hbs | 1 - .../asciidoc/partials/variable.adoc.hbs | 1 - src/lib/Support/SafeNames.cpp | 20 +++++++++---------- 9 files changed, 11 insertions(+), 17 deletions(-) diff --git a/share/mrdox/addons/generator/asciidoc/layouts/single-symbol.adoc.hbs b/share/mrdox/addons/generator/asciidoc/layouts/single-symbol.adoc.hbs index d9620be2e..6eb5c1801 100644 --- a/share/mrdox/addons/generator/asciidoc/layouts/single-symbol.adoc.hbs +++ b/share/mrdox/addons/generator/asciidoc/layouts/single-symbol.adoc.hbs @@ -1,4 +1,5 @@ {{#if relfileprefix}}:relfileprefix: {{relfileprefix}}{{/if}} {{#with symbol}} +[#{{#if (is_multipage)}}{{id}}{{else}}{{ref}}{{/if}}] {{> (lookup . 'kind') symbol=.}} {{/with}} diff --git a/share/mrdox/addons/generator/asciidoc/partials/enum.adoc.hbs b/share/mrdox/addons/generator/asciidoc/partials/enum.adoc.hbs index 4bbc4da3a..bb973b0fc 100644 --- a/share/mrdox/addons/generator/asciidoc/partials/enum.adoc.hbs +++ b/share/mrdox/addons/generator/asciidoc/partials/enum.adoc.hbs @@ -1,5 +1,4 @@ {{!-- enum --}} -[#{{symbol.id}}] == {{#if symbol.name}}Enum {{symbol.name}}{{else}}Unnamed enum{{/if}} {{symbol.doc.brief}} diff --git a/share/mrdox/addons/generator/asciidoc/partials/field.adoc.hbs b/share/mrdox/addons/generator/asciidoc/partials/field.adoc.hbs index 9e26ccfcf..35a7934e2 100644 --- a/share/mrdox/addons/generator/asciidoc/partials/field.adoc.hbs +++ b/share/mrdox/addons/generator/asciidoc/partials/field.adoc.hbs @@ -1,5 +1,4 @@ {{!-- field --}} -[#{{symbol.id}}] == {{symbol.name}} {{symbol.doc.brief}} diff --git a/share/mrdox/addons/generator/asciidoc/partials/function.adoc.hbs b/share/mrdox/addons/generator/asciidoc/partials/function.adoc.hbs index e2eee0d84..733adaeec 100644 --- a/share/mrdox/addons/generator/asciidoc/partials/function.adoc.hbs +++ b/share/mrdox/addons/generator/asciidoc/partials/function.adoc.hbs @@ -1,5 +1,4 @@ {{!-- function --}} -[#{{symbol.id}}] == {{symbol.name}} {{symbol.doc.brief}} diff --git a/share/mrdox/addons/generator/asciidoc/partials/namespace.adoc.hbs b/share/mrdox/addons/generator/asciidoc/partials/namespace.adoc.hbs index 6afa5776f..a032dcc8f 100644 --- a/share/mrdox/addons/generator/asciidoc/partials/namespace.adoc.hbs +++ b/share/mrdox/addons/generator/asciidoc/partials/namespace.adoc.hbs @@ -1,5 +1,4 @@ {{!-- namespace --}} -[#{{symbol.id}}] == {{#if symbol.name}}Namespace {{symbol.name}}{{else}}Unnamed namespace{{/if}} [,cols=2] diff --git a/share/mrdox/addons/generator/asciidoc/partials/record.adoc.hbs b/share/mrdox/addons/generator/asciidoc/partials/record.adoc.hbs index 769f11098..96d1fc01a 100644 --- a/share/mrdox/addons/generator/asciidoc/partials/record.adoc.hbs +++ b/share/mrdox/addons/generator/asciidoc/partials/record.adoc.hbs @@ -1,5 +1,4 @@ {{!-- record --}} -[#{{symbol.id}}] == {{#if symbol.name}}Class {{symbol.name}}{{else}}Unnamed class{{/if}} {{symbol.doc.brief}} diff --git a/share/mrdox/addons/generator/asciidoc/partials/typedef.adoc.hbs b/share/mrdox/addons/generator/asciidoc/partials/typedef.adoc.hbs index 204e8cb5d..6dd36fc9d 100644 --- a/share/mrdox/addons/generator/asciidoc/partials/typedef.adoc.hbs +++ b/share/mrdox/addons/generator/asciidoc/partials/typedef.adoc.hbs @@ -1,5 +1,4 @@ {{!-- typedef --}} -[#{{symbol.id}}] == {{symbol.name}} {{symbol.doc.brief}} diff --git a/share/mrdox/addons/generator/asciidoc/partials/variable.adoc.hbs b/share/mrdox/addons/generator/asciidoc/partials/variable.adoc.hbs index f097c825f..ab7c44a1a 100644 --- a/share/mrdox/addons/generator/asciidoc/partials/variable.adoc.hbs +++ b/share/mrdox/addons/generator/asciidoc/partials/variable.adoc.hbs @@ -1,5 +1,4 @@ {{!-- variable --}} -[#{{symbol.id}}] == {{symbol.name}} {{symbol.doc.brief}} diff --git a/src/lib/Support/SafeNames.cpp b/src/lib/Support/SafeNames.cpp index 449133241..d37884ca7 100644 --- a/src/lib/Support/SafeNames.cpp +++ b/src/lib/Support/SafeNames.cpp @@ -213,25 +213,25 @@ class SafeNames::Impl // to uniquely identify each symbol. then, update all symbols with the new value. if(! disambig_emplaced) { - std::uint8_t n_chars = 1; + std::uint8_t n_chars = 0; std::string_view id_str = it->second.id_str; - for(const SymbolID& other : disambig_it->second) + for(const SymbolID& other_id : disambig_it->second) { - std::string_view other_id_str = - map_.find(other)->second.id_str; + auto& other = map_.find(other_id)->second; auto [mismatch_id, mismatch_other] = std::mismatch(id_str.begin(), id_str.end(), - other_id_str.begin(), other_id_str.end()); - const auto n_required = std::distance( + other.id_str.begin(), other.id_str.end()); + std::uint8_t n_required = std::distance( id_str.begin(), mismatch_id) + 1; - n_chars = std::max(n_chars, - static_cast(n_required)); + n_chars = std::max({ + n_chars, other.disambig_chars, n_required}); } + MRDOX_ASSERT(n_chars); // update the number of disambiguation characters for each symbol it->second.disambig_chars = n_chars; - for(const SymbolID& other : disambig_it->second) - map_.find(other)->second.disambig_chars = n_chars; + for(const SymbolID& other_id : disambig_it->second) + map_.find(other_id)->second.disambig_chars = n_chars; } disambig_it->second.push_back(I->id);