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 14
14
#include " swift/extractor/infra/SwiftLocationExtractor.h"
15
15
#include " swift/extractor/infra/SwiftBodyEmissionStrategy.h"
16
16
#include " swift/extractor/mangler/SwiftMangler.h"
17
+ #include < picosha2.h>
17
18
18
19
using namespace codeql ;
19
20
using namespace std ::string_literals;
@@ -50,8 +51,20 @@ static fs::path getFilename(swift::ModuleDecl& module,
50
51
return resolvePath (primaryFile->getFilename ());
51
52
}
52
53
if (lazyDeclaration) {
54
+ // this code will be thrown away in the near future
53
55
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;
55
68
}
56
69
// PCM clang module
57
70
if (module .isNonSwiftModule ()) {
You can’t perform that action at this time.
0 commit comments