Swift: make extractor compilable with Swift 6

This commit is contained in:
Paolo Tranquilli
2024-10-08 16:39:21 +02:00
parent 4ab925507d
commit 524686ce37
4 changed files with 12 additions and 8 deletions

View File

@@ -152,10 +152,10 @@ static std::unordered_set<swift::ModuleDecl*> extractDeclarations(
}
std::vector<swift::Token> comments;
if (primaryFile && primaryFile->getBufferID().hasValue()) {
if (primaryFile && primaryFile->getBufferID()) {
auto& sourceManager = compiler.getSourceMgr();
auto tokens = swift::tokenize(compiler.getInvocation().getLangOptions(), sourceManager,
primaryFile->getBufferID().getValue());
*primaryFile->getBufferID());
for (auto& token : tokens) {
if (token.getKind() == swift::tok::comment) {
comments.push_back(token);
@@ -188,6 +188,7 @@ static std::unordered_set<std::string> collectInputFilenames(swift::CompilerInst
std::unordered_set<std::string> sourceFiles;
const auto& inOuts = compiler.getInvocation().getFrontendOptions().InputsAndOutputs;
for (auto& input : inOuts.getAllInputs()) {
LOG_INFO("> {}", input.getFileName());
if (input.getType() == swift::file_types::TY_Swift &&
(!inOuts.hasPrimaryInputs() || input.isPrimary())) {
sourceFiles.insert(input.getFileName());

View File

@@ -175,6 +175,8 @@ MAP(swift::Expr, ExprTag)
MAP(swift::LinearFunctionExtractOriginalExpr, LinearFunctionExtractOriginalExprTag)
MAP(swift::LinearToDifferentiableFunctionExpr, LinearToDifferentiableFunctionExprTag)
MAP(swift::ABISafeConversionExpr, AbiSafeConversionExprTag) // different acronym convention
MAP(swift::ActorIsolationErasureExpr, void) // TODO swift 6.0
MAP(swift::UnreachableExpr, void) // TODO swift 6.0
MAP(swift::ExplicitCastExpr, ExplicitCastExprTag)
MAP(swift::CheckedCastExpr, CheckedCastExprTag)
MAP(swift::ForcedCheckedCastExpr, ForcedCheckedCastExprTag)
@@ -200,7 +202,8 @@ MAP(swift::Expr, ExprTag)
MAP(swift::ConsumeExpr, ConsumeExprTag)
MAP(swift::MaterializePackExpr, MaterializePackExprTag)
MAP(swift::SingleValueStmtExpr, SingleValueStmtExprTag)
MAP(swift::ExtractFunctionIsolationExpr, void) // TODO swift 6.0
MAP(swift::CurrentContextIsolationExpr, void) // TODO swift 6.0
MAP(swift::Decl, DeclTag)
MAP(swift::ValueDecl, ValueDeclTag)
MAP(swift::TypeDecl, TypeDeclTag)
@@ -332,6 +335,7 @@ MAP(swift::TypeBase, TypeTag)
MAP(swift::PackExpansionType, PackExpansionTypeTag)
MAP(swift::PackElementType, PackElementTypeTag)
MAP(swift::TypeVariableType, void) // created during type checking and only used for constraint checking
MAP(swift::ErrorUnionType, void) // TODO swift 6.0
MAP(swift::SugarType, SugarTypeTag)
MAP(swift::ParenType, ParenTypeTag)
MAP(swift::TypeAliasType, TypeAliasTypeTag)

View File

@@ -378,7 +378,7 @@ codeql::KeyPathExpr ExprTranslator::translateKeyPathExpr(const swift::KeyPathExp
for (const auto& component : expr.getComponents()) {
entry.components.push_back(emitKeyPathComponent(component));
}
if (auto rootTypeRepr = expr.getRootType()) {
if (auto rootTypeRepr = expr.getExplicitRootType()) {
auto keyPathType = expr.getType()->getAs<swift::BoundGenericClassType>();
CODEQL_EXPECT_OR(return entry, keyPathType, "KeyPathExpr must have BoundGenericClassType");
auto keyPathTypeArgs = keyPathType->getGenericArgs();

View File

@@ -1,11 +1,10 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
_swift_prebuilt_version = "swift-5.10.1-RELEASE.323"
_swift_prebuilt_version = "swift-6.0.1-RELEASE.330"
_swift_sha_map = {
"Linux-X64": "29c7c53ab2f438e85daecdb4567173c78ac32afc45753d7277d744aed515229d",
"macOS-ARM64": "e697f423c8abcb8a942246489fd4f8ce71472119510b64b2073eaeaec86b771e",
"macOS-X64": "faef29334e8615e8a71263c7453ebc7e566d6f2928d827675f6faae233c544a6",
"Linux-X64": "3da9b257b08da3bed023656c3bea2e1d0e6504b1592f593a077023c59e5339fc",
"macOS-X64": "66641b3b285e593342b88d48defa6668b15a85603acfe5aba5b62b9ed9123465",
}
_swift_arch_map = {