mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
Swift: more mangling
This commit is contained in:
@@ -61,6 +61,14 @@ static std::string mangledDeclName(const swift::ValueDecl& decl) {
|
||||
// prefix adds a couple of special symbols, we don't necessary need them
|
||||
return mangler.mangleEntity(&decl);
|
||||
}
|
||||
if (decl.getKind() == swift::DeclKind::GenericTypeParam) {
|
||||
// internal mangling does not distinguish generic type parameters with the same name and
|
||||
// position of different functions. We prepend the context (that is, the function) to
|
||||
// circumvent that
|
||||
auto context = llvm::dyn_cast<swift::ValueDecl>(decl.getDeclContext()->getAsDecl());
|
||||
assert(context);
|
||||
return mangledDeclName(*context) + '_' + mangler.mangleAnyDecl(&decl, /* prefix = */ false);
|
||||
}
|
||||
return mangler.mangleAnyDecl(&decl, /* prefix = */ false);
|
||||
}
|
||||
|
||||
@@ -71,6 +79,7 @@ static fs::path getFilename(swift::ModuleDecl& module,
|
||||
return resolvePath(primaryFile->getFilename());
|
||||
}
|
||||
if (lazyDeclaration) {
|
||||
<<<<<<< HEAD
|
||||
// this code will be thrown away in the near future
|
||||
auto decl = llvm::dyn_cast<swift::ValueDecl>(lazyDeclaration);
|
||||
assert(decl);
|
||||
@@ -85,6 +94,11 @@ static fs::path getFilename(swift::ModuleDecl& module,
|
||||
// half a SHA2 is enough
|
||||
ret += std::string_view(mangled).substr(0, mangled.size() / 2);
|
||||
return ret;
|
||||
=======
|
||||
// static int i;
|
||||
// return mangledDeclName(*lazyDeclaration) + std::to_string(i++);
|
||||
return mangledDeclName(*lazyDeclaration);
|
||||
>>>>>>> 4cbad80695 (Swift: more mangling)
|
||||
}
|
||||
// PCM clang module
|
||||
if (module.isNonSwiftModule()) {
|
||||
|
||||
Reference in New Issue
Block a user