mirror of
https://github.com/github/codeql.git
synced 2026-05-05 13:45:19 +02:00
Swift: replace internal swift mangler with our own
Our mangler is split in two version: * `SwiftTrapMangler`, with the same behaviour as the previous `SwiftMangler`, constructing mangled names with trap label references * `SwiftRecursiveMangler` that replaces trap label references with recursive calls to its own `mangle` functions, effectively rolling out the entire chain of references The latter is used to create lazy trap file names. Hashing is used to avoid excessively long filenames.
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
#include "swift/extractor/infra/SwiftMangledName.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
|
||||
#include <picosha2.h>
|
||||
|
||||
namespace codeql {
|
||||
|
||||
std::string SwiftMangledName::hash() const {
|
||||
auto ret = picosha2::hash256_hex_string(value);
|
||||
// half a hash is already enough for disambuiguation
|
||||
ret.resize(ret.size() / 2);
|
||||
return ret;
|
||||
}
|
||||
|
||||
SwiftMangledName& SwiftMangledName::operator<<(UntypedTrapLabel label) & {
|
||||
absl::StrAppend(&value, "{", label.str(), "}");
|
||||
return *this;
|
||||
|
||||
Reference in New Issue
Block a user