mirror of
https://github.com/github/codeql.git
synced 2026-06-18 11:21:07 +02:00
* visiting now happens in a later stage than fetching labels. While fetching a list of entities to be visited is created, and then acted upon in actual extraction. This partially flattens the recursive nature of `fetchLabel` into a loop inside `SwiftVisitor::extract`. Recursion in `fetchLabel` will only happen on labels fetched while naming an entity (calling into `SwiftMangler`). * The choice whether to name a declaration or type has been moved from the translators to `SwiftMangler`. Acting on this choice is contained in `SwiftDispatcher::createLabel`. * The choice whether to emit a body of a declaration has been moved from `DeclTranslator` to the dispatcher. This choice is also contained in `SwiftDispatcher::createLabel`. * The simple functionality of the `LabelStore` has been moved to the `SwiftDispatcher` as well.
31 lines
607 B
C++
31 lines
607 B
C++
#include "swift/extractor/infra/SwiftMangledName.h"
|
|
|
|
namespace codeql {
|
|
|
|
namespace {
|
|
void appendPart(std::string& out, const std::string& prefix) {
|
|
out += prefix;
|
|
}
|
|
|
|
void appendPart(std::string& out, UntypedTrapLabel label) {
|
|
out += '{';
|
|
out += label.str();
|
|
out += '}';
|
|
}
|
|
|
|
void appendPart(std::string& out, unsigned index) {
|
|
out += std::to_string(index);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
std::string SwiftMangledName::str() const {
|
|
std::string out;
|
|
for (const auto& part : parts) {
|
|
std::visit([&](const auto& contents) { appendPart(out, contents); }, part);
|
|
}
|
|
return out;
|
|
}
|
|
|
|
} // namespace codeql
|