Skip to content

Commit cac1bc8

Browse files
committed
chore: rename 'safe names' to 'legible names'
1 parent ab29a11 commit cac1bc8

15 files changed

+62
-62
lines changed

src/lib/Gen/adoc/AdocCorpus.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#define MRDOCS_LIB_GEN_ADOC_ADOCCORPUS_HPP
1313

1414
#include <mrdocs/Platform.hpp>
15-
#include "lib/Support/SafeNames.hpp"
15+
#include "lib/Support/LegibleNames.hpp"
1616
#include "Options.hpp"
1717
#include <mrdocs/Metadata/DomMetadata.hpp>
1818
#include <optional>
@@ -25,14 +25,14 @@ class AdocCorpus : public DomCorpus
2525
{
2626
public:
2727
Options options;
28-
SafeNames names_;
28+
LegibleNames names_;
2929

3030
AdocCorpus(
3131
Corpus const& corpus,
3232
Options&& opts)
3333
: DomCorpus(corpus)
3434
, options(std::move(opts))
35-
, names_(corpus, options.safe_names)
35+
, names_(corpus, options.legible_names)
3636
{
3737
}
3838

src/lib/Gen/adoc/AdocGenerator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "Builder.hpp"
1515
#include "MultiPageVisitor.hpp"
1616
#include "SinglePageVisitor.hpp"
17-
#include "lib/Support/SafeNames.hpp"
17+
#include "lib/Support/LegibleNames.hpp"
1818
#include <mrdocs/Metadata/DomMetadata.hpp>
1919
#include <mrdocs/Support/Error.hpp>
2020
#include <mrdocs/Support/Path.hpp>

src/lib/Gen/adoc/Builder.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Builder::
170170
getRelPrefix(std::size_t depth)
171171
{
172172
std::string rel_prefix;
173-
if(! depth || ! domCorpus.options.safe_names ||
173+
if(! depth || ! domCorpus.options.legible_names ||
174174
! domCorpus->config->multipage)
175175
return rel_prefix;
176176
--depth;

src/lib/Gen/adoc/Options.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct llvm::yaml::MappingTraits<
5757
clang::mrdocs::adoc::YamlKey& yk)
5858
{
5959
auto& opt= yk.opt;
60-
io.mapOptional("safe-names", opt.safe_names);
60+
io.mapOptional("legible-names", opt.legible_names);
6161
io.mapOptional("template-dir", opt.template_dir);
6262
}
6363
};

src/lib/Gen/adoc/Options.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace adoc {
2525
*/
2626
struct Options
2727
{
28-
bool safe_names = true;
28+
bool legible_names = true;
2929
std::string template_dir;
3030
};
3131

src/lib/Gen/bitcode/BitcodeGenerator.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "BitcodeGenerator.hpp"
1313
#include "lib/Support/Error.hpp"
14-
#include "lib/Support/SafeNames.hpp"
14+
#include "lib/Support/LegibleNames.hpp"
1515
#include "lib/AST/Bitcode.hpp"
1616
#include <mrdocs/Support/ThreadPool.hpp>
1717
#include <mrdocs/Metadata.hpp>
@@ -26,7 +26,7 @@ class MultiFileBuilder
2626
{
2727
Corpus const& corpus_;
2828
std::string_view outputPath_;
29-
SafeNames names_;
29+
LegibleNames names_;
3030
TaskGroup taskGroup_;
3131

3232
public:

src/lib/Gen/html/HTMLGenerator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "Builder.hpp"
1515
#include "MultiPageVisitor.hpp"
1616
#include "SinglePageVisitor.hpp"
17-
#include "lib/Support/SafeNames.hpp"
17+
#include "lib/Support/LegibleNames.hpp"
1818
#include <mrdocs/Metadata/DomMetadata.hpp>
1919
#include <mrdocs/Support/Error.hpp>
2020
#include <mrdocs/Support/Path.hpp>

src/lib/Gen/html/Options.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct llvm::yaml::MappingTraits<
5757
clang::mrdocs::html::YamlKey& yk)
5858
{
5959
auto& opt= yk.opt;
60-
io.mapOptional("safe-names", opt.safe_names);
60+
io.mapOptional("legible-names", opt.legible_names);
6161
io.mapOptional("template-dir", opt.template_dir);
6262
}
6363
};

src/lib/Gen/html/Options.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace html {
2525
*/
2626
struct Options
2727
{
28-
bool safe_names = false;
28+
bool legible_names = false;
2929
std::string template_dir;
3030
};
3131

src/lib/Gen/xml/XMLWriter.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "lib/Lib/ConfigImpl.hpp"
1616
#include "lib/Support/Yaml.hpp"
1717
#include "lib/Support/Radix.hpp"
18-
#include "lib/Support/SafeNames.hpp"
18+
#include "lib/Support/LegibleNames.hpp"
1919
#include <mrdocs/Platform.hpp>
2020
#include <llvm/Support/YAMLParser.h>
2121
#include <llvm/Support/YAMLTraits.h>
@@ -68,7 +68,7 @@ struct llvm::yaml::MappingTraits<
6868
auto& opt= opt_.opt;
6969
io.mapOptional("index", opt.index);
7070
io.mapOptional("prolog", opt.prolog);
71-
io.mapOptional("safe-names", opt.safe_names);
71+
io.mapOptional("legible-names", opt.legible_names);
7272
}
7373
};
7474

@@ -139,7 +139,7 @@ build()
139139
"<mrdocs xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
140140
" xsi:noNamespaceSchemaLocation=\"https://github.com/cppalliance/mrdocs/raw/develop/mrdocs.rnc\">\n";
141141

142-
if(options_.index || options_.safe_names)
142+
if(options_.index || options_.legible_names)
143143
writeIndex();
144144

145145
visit(corpus_.globalNamespace(), *this);
@@ -159,14 +159,14 @@ writeIndex()
159159
std::string temp;
160160
temp.reserve(256);
161161
tags_.open("symbols");
162-
if(options_.safe_names)
162+
if(options_.legible_names)
163163
{
164-
SafeNames names(corpus_, true);
164+
LegibleNames names(corpus_, true);
165165
for(auto& I : corpus_)
166166
{
167-
auto safe_name = names.getUnqualified(I.id);
167+
auto legible_name = names.getUnqualified(I.id);
168168
tags_.write("symbol", {}, {
169-
{ "safe", safe_name },
169+
{ "legible", legible_name },
170170
{ "name", corpus_.getFullyQualifiedName(I, temp) },
171171
{ "tag", toString(I.Kind) },
172172
{ I.id } });

src/lib/Gen/xml/XMLWriter.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class XMLWriter
4343
{
4444
bool index = false;
4545
bool prolog = true;
46-
bool safe_names = false;
46+
bool legible_names = false;
4747
};
4848
Options options_;
4949

src/lib/Metadata/DomMetadata.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111

1212
#include "lib/Support/Radix.hpp"
13-
#include "lib/Support/SafeNames.hpp"
13+
#include "lib/Support/LegibleNames.hpp"
1414
#include <mrdocs/Metadata.hpp>
1515
#include <mrdocs/Metadata/DomMetadata.hpp>
1616
#include <llvm/ADT/StringMap.h>

src/lib/Metadata/Function.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace {
2222
struct Item
2323
{
2424
char const* name;
25-
char const* safe_name;
25+
char const* legible_name;
2626
char const* short_name;
2727
OperatorKind kind;
2828
};
@@ -122,7 +122,7 @@ getSafeOperatorName(
122122
bool include_keyword) noexcept
123123
{
124124
MRDOCS_ASSERT(Table[to_underlying(kind)].kind == kind);
125-
std::string_view full = Table[to_underlying(kind)].safe_name;
125+
std::string_view full = Table[to_underlying(kind)].legible_name;
126126
if(include_keyword || kind == OperatorKind::None)
127127
return full;
128128
// remove "operator_"

src/lib/Support/SafeNames.cpp renamed to src/lib/Support/LegibleNames.cpp

+30-30
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111

1212
#include "lib/Support/Radix.hpp"
13-
#include "lib/Support/SafeNames.hpp"
13+
#include "lib/Support/LegibleNames.hpp"
1414
#include "lib/Support/Validate.hpp"
1515
#include "lib/Support/Debug.hpp"
1616
#include <mrdocs/Corpus.hpp>
@@ -26,17 +26,17 @@
2626
namespace clang {
2727
namespace mrdocs {
2828

29-
class SafeNames::Impl
29+
class LegibleNames::Impl
3030
{
3131
Corpus const& corpus_;
3232

3333
// name used for the global namespace
3434
std::string global_ns_;
3535

36-
// store all info required to generate a safename
37-
struct SafeNameInfo
36+
// store all info required to generate a legible name
37+
struct LegibleNameInfo
3838
{
39-
// safename without disambiguation characters
39+
// legible name without disambiguation characters
4040
std::string_view unqualified;
4141
// number of characters from the SymbolID string
4242
// required to uniquely identify this symbol
@@ -45,12 +45,12 @@ class SafeNames::Impl
4545
std::string id_str;
4646
};
4747

48-
std::unordered_map<SymbolID, SafeNameInfo> map_;
48+
std::unordered_map<SymbolID, LegibleNameInfo> map_;
4949

5050
// maps unqualified names to all symbols
5151
// with that name within the current scope
5252
std::unordered_multimap<std::string_view,
53-
SafeNameInfo*> disambiguation_map_;
53+
LegibleNameInfo*> disambiguation_map_;
5454

5555
std::string_view
5656
getReserved(const Info& I)
@@ -236,12 +236,12 @@ class SafeNames::Impl
236236
#define MINIMAL_SUFFIX
237237

238238
void
239-
buildSafeMember(
239+
buildLegibleMember(
240240
const Info& I,
241241
std::string_view name)
242242
{
243243
// generate the unqualified name and SymbolID string
244-
SafeNameInfo& info = map_.emplace(I.id, SafeNameInfo(
244+
LegibleNameInfo& info = map_.emplace(I.id, LegibleNameInfo(
245245
name, 0, toBase16(I.id, true))).first->second;
246246
// if there are other symbols with the same name, then disambiguation
247247
// is required. iterate over the other symbols with the same unqualified name,
@@ -313,9 +313,9 @@ class SafeNames::Impl
313313
corpus_.globalNamespace();
314314
// treat the global namespace as-if its "name"
315315
// is in the same scope as its members
316-
buildSafeMember(global, global_ns_);
316+
buildLegibleMember(global, global_ns_);
317317
visit(global, *this);
318-
// after generating safenames for every symbol,
318+
// after generating legible names for every symbol,
319319
// set the number of disambiguation characters
320320
// used for the global namespace to zero
321321
map_.at(global.id).disambig_chars = 0;
@@ -327,7 +327,7 @@ class SafeNames::Impl
327327
traverse(I, [this](const SymbolID& id)
328328
{
329329
if(const Info* M = corpus_.find(id))
330-
buildSafeMember(*M, getUnqualified(*M));
330+
buildLegibleMember(*M, getUnqualified(*M));
331331
});
332332
// clear the disambiguation map after visiting the members,
333333
// then build disambiguation information for each member
@@ -340,7 +340,7 @@ class SafeNames::Impl
340340
}
341341

342342
void
343-
getSafeUnqualified(
343+
getLegibleUnqualified(
344344
std::string& result,
345345
const SymbolID& id)
346346
{
@@ -365,7 +365,7 @@ class SafeNames::Impl
365365
}
366366

367367
void
368-
getSafeQualified(
368+
getLegibleQualified(
369369
std::string& result,
370370
const SymbolID& id,
371371
char delim)
@@ -378,42 +378,42 @@ class SafeNames::Impl
378378
std::views::reverse |
379379
std::views::drop(1))
380380
{
381-
getSafeUnqualified(result, parent);
381+
getLegibleUnqualified(result, parent);
382382
result.push_back(delim);
383383
}
384384
}
385-
getSafeUnqualified(result, id);
385+
getLegibleUnqualified(result, id);
386386
}
387387
};
388388

389389
//------------------------------------------------
390390

391-
SafeNames::
392-
SafeNames(
391+
LegibleNames::
392+
LegibleNames(
393393
Corpus const& corpus,
394394
bool enabled)
395395
{
396396
if(enabled)
397397
impl_ = std::make_unique<Impl>(corpus, "index");
398398
}
399399

400-
SafeNames::
401-
~SafeNames() noexcept = default;
400+
LegibleNames::
401+
~LegibleNames() noexcept = default;
402402

403403
std::string
404-
SafeNames::
404+
LegibleNames::
405405
getUnqualified(
406406
SymbolID const& id) const
407407
{
408408
if(! impl_)
409409
return toBase16(id);
410410
std::string result;
411-
impl_->getSafeUnqualified(result, id);
411+
impl_->getLegibleUnqualified(result, id);
412412
return result;
413413
}
414414

415415
std::string
416-
SafeNames::
416+
LegibleNames::
417417
getUnqualified(
418418
OverloadSet const& os) const
419419
{
@@ -424,20 +424,20 @@ getUnqualified(
424424
}
425425

426426
std::string
427-
SafeNames::
427+
LegibleNames::
428428
getQualified(
429429
SymbolID const& id,
430430
char delim) const
431431
{
432432
if(! impl_)
433433
return toBase16(id);
434434
std::string result;
435-
impl_->getSafeQualified(result, id, delim);
435+
impl_->getLegibleQualified(result, id, delim);
436436
return result;
437437
}
438438

439439
std::string
440-
SafeNames::
440+
LegibleNames::
441441
getQualified(
442442
OverloadSet const& os,
443443
char delim) const
@@ -447,12 +447,12 @@ getQualified(
447447
std::string result;
448448
if(os.Parent != SymbolID::global)
449449
{
450-
impl_->getSafeQualified(result, os.Parent, delim);
450+
impl_->getLegibleQualified(result, os.Parent, delim);
451451
result.push_back(delim);
452452
}
453-
// the safename for an overload set is the unqualified
454-
// safe name of its members, without any disambiguation characters.
455-
// members of an overload set use the same safe name regardless of
453+
// the legible name for an overload set is the unqualified
454+
// legible name of its members, without any disambiguation characters.
455+
// members of an overload set use the same legible name regardless of
456456
// whether they belong to an overload set
457457
result.append(impl_->getUnqualified(
458458
os.Members.front()));

0 commit comments

Comments
 (0)