10
10
//
11
11
12
12
#include " lib/Support/Radix.hpp"
13
- #include " lib/Support/SafeNames .hpp"
13
+ #include " lib/Support/LegibleNames .hpp"
14
14
#include " lib/Support/Validate.hpp"
15
15
#include " lib/Support/Debug.hpp"
16
16
#include < mrdocs/Corpus.hpp>
26
26
namespace clang {
27
27
namespace mrdocs {
28
28
29
- class SafeNames ::Impl
29
+ class LegibleNames ::Impl
30
30
{
31
31
Corpus const & corpus_;
32
32
33
33
// name used for the global namespace
34
34
std::string global_ns_;
35
35
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
38
38
{
39
- // safename without disambiguation characters
39
+ // legible name without disambiguation characters
40
40
std::string_view unqualified;
41
41
// number of characters from the SymbolID string
42
42
// required to uniquely identify this symbol
@@ -45,12 +45,12 @@ class SafeNames::Impl
45
45
std::string id_str;
46
46
};
47
47
48
- std::unordered_map<SymbolID, SafeNameInfo > map_;
48
+ std::unordered_map<SymbolID, LegibleNameInfo > map_;
49
49
50
50
// maps unqualified names to all symbols
51
51
// with that name within the current scope
52
52
std::unordered_multimap<std::string_view,
53
- SafeNameInfo *> disambiguation_map_;
53
+ LegibleNameInfo *> disambiguation_map_;
54
54
55
55
std::string_view
56
56
getReserved (const Info& I)
@@ -236,12 +236,12 @@ class SafeNames::Impl
236
236
#define MINIMAL_SUFFIX
237
237
238
238
void
239
- buildSafeMember (
239
+ buildLegibleMember (
240
240
const Info& I,
241
241
std::string_view name)
242
242
{
243
243
// generate the unqualified name and SymbolID string
244
- SafeNameInfo & info = map_.emplace (I.id , SafeNameInfo (
244
+ LegibleNameInfo & info = map_.emplace (I.id , LegibleNameInfo (
245
245
name, 0 , toBase16 (I.id , true ))).first ->second ;
246
246
// if there are other symbols with the same name, then disambiguation
247
247
// is required. iterate over the other symbols with the same unqualified name,
@@ -313,9 +313,9 @@ class SafeNames::Impl
313
313
corpus_.globalNamespace ();
314
314
// treat the global namespace as-if its "name"
315
315
// is in the same scope as its members
316
- buildSafeMember (global, global_ns_);
316
+ buildLegibleMember (global, global_ns_);
317
317
visit (global, *this );
318
- // after generating safenames for every symbol,
318
+ // after generating legible names for every symbol,
319
319
// set the number of disambiguation characters
320
320
// used for the global namespace to zero
321
321
map_.at (global.id ).disambig_chars = 0 ;
@@ -327,7 +327,7 @@ class SafeNames::Impl
327
327
traverse (I, [this ](const SymbolID& id)
328
328
{
329
329
if (const Info* M = corpus_.find (id))
330
- buildSafeMember (*M, getUnqualified (*M));
330
+ buildLegibleMember (*M, getUnqualified (*M));
331
331
});
332
332
// clear the disambiguation map after visiting the members,
333
333
// then build disambiguation information for each member
@@ -340,7 +340,7 @@ class SafeNames::Impl
340
340
}
341
341
342
342
void
343
- getSafeUnqualified (
343
+ getLegibleUnqualified (
344
344
std::string& result,
345
345
const SymbolID& id)
346
346
{
@@ -365,7 +365,7 @@ class SafeNames::Impl
365
365
}
366
366
367
367
void
368
- getSafeQualified (
368
+ getLegibleQualified (
369
369
std::string& result,
370
370
const SymbolID& id,
371
371
char delim)
@@ -378,42 +378,42 @@ class SafeNames::Impl
378
378
std::views::reverse |
379
379
std::views::drop (1 ))
380
380
{
381
- getSafeUnqualified (result, parent);
381
+ getLegibleUnqualified (result, parent);
382
382
result.push_back (delim);
383
383
}
384
384
}
385
- getSafeUnqualified (result, id);
385
+ getLegibleUnqualified (result, id);
386
386
}
387
387
};
388
388
389
389
// ------------------------------------------------
390
390
391
- SafeNames ::
392
- SafeNames (
391
+ LegibleNames ::
392
+ LegibleNames (
393
393
Corpus const & corpus,
394
394
bool enabled)
395
395
{
396
396
if (enabled)
397
397
impl_ = std::make_unique<Impl>(corpus, " index" );
398
398
}
399
399
400
- SafeNames ::
401
- ~SafeNames () noexcept = default ;
400
+ LegibleNames ::
401
+ ~LegibleNames () noexcept = default ;
402
402
403
403
std::string
404
- SafeNames ::
404
+ LegibleNames ::
405
405
getUnqualified (
406
406
SymbolID const & id) const
407
407
{
408
408
if (! impl_)
409
409
return toBase16 (id);
410
410
std::string result;
411
- impl_->getSafeUnqualified (result, id);
411
+ impl_->getLegibleUnqualified (result, id);
412
412
return result;
413
413
}
414
414
415
415
std::string
416
- SafeNames ::
416
+ LegibleNames ::
417
417
getUnqualified (
418
418
OverloadSet const & os) const
419
419
{
@@ -424,20 +424,20 @@ getUnqualified(
424
424
}
425
425
426
426
std::string
427
- SafeNames ::
427
+ LegibleNames ::
428
428
getQualified (
429
429
SymbolID const & id,
430
430
char delim) const
431
431
{
432
432
if (! impl_)
433
433
return toBase16 (id);
434
434
std::string result;
435
- impl_->getSafeQualified (result, id, delim);
435
+ impl_->getLegibleQualified (result, id, delim);
436
436
return result;
437
437
}
438
438
439
439
std::string
440
- SafeNames ::
440
+ LegibleNames ::
441
441
getQualified (
442
442
OverloadSet const & os,
443
443
char delim) const
@@ -447,12 +447,12 @@ getQualified(
447
447
std::string result;
448
448
if (os.Parent != SymbolID::global)
449
449
{
450
- impl_->getSafeQualified (result, os.Parent , delim);
450
+ impl_->getLegibleQualified (result, os.Parent , delim);
451
451
result.push_back (delim);
452
452
}
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
456
456
// whether they belong to an overload set
457
457
result.append (impl_->getUnqualified (
458
458
os.Members .front ()));
0 commit comments