Merge branch 'main' into alexdenisov+redsun82/tuple-mangling

This commit is contained in:
Paolo Tranquilli
2023-05-24 11:16:59 +02:00
committed by GitHub
1640 changed files with 111157 additions and 79250 deletions

View File

@@ -23,7 +23,10 @@ genrule(
"--schema=$(location //swift:schema)",
"--script-name=codegen/codegen.py",
]),
exec_tools = ["//misc/codegen", "//swift:schema"],
exec_tools = [
"//misc/codegen",
"//swift:schema",
],
)
filegroup(
@@ -49,7 +52,7 @@ swift_cc_library(
visibility = ["//visibility:public"],
deps = [
"//swift/extractor/infra/file",
"//swift/extractor/infra/log",
"//swift/logging",
"@absl//absl/numeric:bits",
],
)

View File

@@ -2,10 +2,11 @@
#include <memory>
#include <sstream>
#include "absl/strings/str_cat.h"
#include "swift/extractor/trap/TrapLabel.h"
#include "swift/extractor/infra/file/TargetFile.h"
#include "swift/extractor/infra/log/SwiftLogging.h"
#include "swift/logging/SwiftLogging.h"
#include "swift/extractor/infra/SwiftMangledName.h"
namespace codeql {
@@ -21,11 +22,26 @@ class TrapDomain {
}
template <typename Entry>
void emit(const Entry& e) {
void emit(const Entry& e, bool check = true) {
LOG_TRACE("{}", e);
if (check) {
e.forEachLabel([&e, this](const char* field, int index, auto& label) {
if (!label.valid()) {
LOG_ERROR("{} has undefined field {}{}", e.NAME, field,
index >= 0 ? absl::StrCat("[", index, "]") : "");
}
});
}
out << e << '\n';
}
template <typename... Args>
void emitComment(const Args&... args) {
out << "/* ";
(out << ... << args);
out << " */\n";
}
template <typename... Args>
void debug(const Args&... args) {
out << "/* DEBUG:\n";

View File

@@ -35,10 +35,6 @@ class UntypedTrapLabel {
explicit operator bool() const { return valid(); }
friend std::ostream& operator<<(std::ostream& out, UntypedTrapLabel l) {
// TODO: this is a temporary fix to catch us from outputting undefined labels to trap
// this should be moved to a validity check, probably aided by code generation and carried out
// by `SwiftDispatcher`
assert(l && "outputting an undefined label!");
out << '#' << std::hex << l.id_ << std::dec;
return out;
}