@@ -16,6 +16,20 @@ namespace codeql {
16
16
17
17
class SwiftDispatcher ;
18
18
19
+ // This class is tasked with assigning unique names to entities that need it (non-local
20
+ // declarations and types), to be used as trap keys.
21
+ // When the identity depends on some other entity (like the parent of a declaration, or the
22
+ // declaration introducing a user type) a [trap id-ref][1] is used, using the dispatcher to give us
23
+ // a label reference to that entity. Because that entity will also generally have a mangled name,
24
+ // it is important that this does not lead to any recursive loop (which is checked at runtime
25
+ // within the dispatcher).
26
+ //
27
+ // [1]: https://github.com/github/codeql-core/blob/main/wiki/extractors/trap.md#ids
28
+ //
29
+ // * all names are prefixed with the name of the entity class (for example `ParamDecl_`)
30
+ // * declarations usually use a reference to their declaration context as first element, followed
31
+ // by whatever distinguishes them within that context (the name, or the signature for function)
32
+ // * user defined types have a name that is a simple wrapper around a reference to their declaration
19
33
class SwiftMangler : private swift ::TypeVisitor<SwiftMangler, SwiftMangledName>,
20
34
private swift::DeclVisitor<SwiftMangler, SwiftMangledName> {
21
35
using TypeVisitor = swift::TypeVisitor<SwiftMangler, SwiftMangledName>;
@@ -26,7 +40,6 @@ class SwiftMangler : private swift::TypeVisitor<SwiftMangler, SwiftMangledName>,
26
40
27
41
static SwiftMangledName mangleModuleName (std::string_view name);
28
42
29
- // TODO actual visit
30
43
SwiftMangledName mangleDecl (const swift::Decl& decl) {
31
44
return DeclVisitor::visit (const_cast <swift::Decl*>(&decl));
32
45
}
0 commit comments