mirror of
https://github.com/github/codeql.git
synced 2025-12-17 09:13:20 +01:00
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.
26 lines
610 B
C++
26 lines
610 B
C++
#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;
|
|
}
|
|
|
|
SwiftMangledName& SwiftMangledName::operator<<(unsigned int i) & {
|
|
absl::StrAppend(&value, i);
|
|
return *this;
|
|
}
|
|
|
|
} // namespace codeql
|