File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 1414#include " swift/extractor/infra/SwiftLocationExtractor.h"
1515#include " swift/extractor/infra/SwiftBodyEmissionStrategy.h"
1616#include " swift/extractor/mangler/SwiftMangler.h"
17+ #include < picosha2.h>
1718
1819using namespace codeql ;
1920using namespace std ::string_literals;
@@ -50,8 +51,20 @@ static fs::path getFilename(swift::ModuleDecl& module,
5051 return resolvePath (primaryFile->getFilename ());
5152 }
5253 if (lazyDeclaration) {
54+ // this code will be thrown away in the near future
5355 SwiftMangler mangler;
54- return mangler.mangledName (*lazyDeclaration);
56+ auto mangled = mangler.mangledName (*lazyDeclaration);
57+ // mangled name can be too long to use as a file name, so we can't use it directly
58+ mangled = picosha2::hash256_hex_string (mangled);
59+ std::string ret;
60+ ret += module .getRealName ().str ();
61+ ret += ' _' ;
62+ // lazyDeclaration must be a ValueDecl, as already asserted in SwiftMangler::mangledName
63+ ret += llvm::cast<swift::ValueDecl>(lazyDeclaration)->getBaseName ().userFacingName ();
64+ ret += ' _' ;
65+ // half a SHA2 is enough
66+ ret += std::string_view (mangled).substr (0 , mangled.size () / 2 );
67+ return ret;
5568 }
5669 // PCM clang module
5770 if (module .isNonSwiftModule ()) {
You can’t perform that action at this time.
0 commit comments