Skip to content

Commit 524686c

Browse files
author
Paolo Tranquilli
committed
Swift: make extractor compilable with Swift 6
1 parent 4ab9255 commit 524686c

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

swift/extractor/SwiftExtractor.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ static std::unordered_set<swift::ModuleDecl*> extractDeclarations(
152152
}
153153

154154
std::vector<swift::Token> comments;
155-
if (primaryFile && primaryFile->getBufferID().hasValue()) {
155+
if (primaryFile && primaryFile->getBufferID()) {
156156
auto& sourceManager = compiler.getSourceMgr();
157157
auto tokens = swift::tokenize(compiler.getInvocation().getLangOptions(), sourceManager,
158-
primaryFile->getBufferID().getValue());
158+
*primaryFile->getBufferID());
159159
for (auto& token : tokens) {
160160
if (token.getKind() == swift::tok::comment) {
161161
comments.push_back(token);
@@ -188,6 +188,7 @@ static std::unordered_set<std::string> collectInputFilenames(swift::CompilerInst
188188
std::unordered_set<std::string> sourceFiles;
189189
const auto& inOuts = compiler.getInvocation().getFrontendOptions().InputsAndOutputs;
190190
for (auto& input : inOuts.getAllInputs()) {
191+
LOG_INFO("> {}", input.getFileName());
191192
if (input.getType() == swift::file_types::TY_Swift &&
192193
(!inOuts.hasPrimaryInputs() || input.isPrimary())) {
193194
sourceFiles.insert(input.getFileName());

swift/extractor/infra/SwiftTagTraits.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ MAP(swift::Expr, ExprTag)
175175
MAP(swift::LinearFunctionExtractOriginalExpr, LinearFunctionExtractOriginalExprTag)
176176
MAP(swift::LinearToDifferentiableFunctionExpr, LinearToDifferentiableFunctionExprTag)
177177
MAP(swift::ABISafeConversionExpr, AbiSafeConversionExprTag) // different acronym convention
178+
MAP(swift::ActorIsolationErasureExpr, void) // TODO swift 6.0
179+
MAP(swift::UnreachableExpr, void) // TODO swift 6.0
178180
MAP(swift::ExplicitCastExpr, ExplicitCastExprTag)
179181
MAP(swift::CheckedCastExpr, CheckedCastExprTag)
180182
MAP(swift::ForcedCheckedCastExpr, ForcedCheckedCastExprTag)
@@ -200,7 +202,8 @@ MAP(swift::Expr, ExprTag)
200202
MAP(swift::ConsumeExpr, ConsumeExprTag)
201203
MAP(swift::MaterializePackExpr, MaterializePackExprTag)
202204
MAP(swift::SingleValueStmtExpr, SingleValueStmtExprTag)
203-
205+
MAP(swift::ExtractFunctionIsolationExpr, void) // TODO swift 6.0
206+
MAP(swift::CurrentContextIsolationExpr, void) // TODO swift 6.0
204207
MAP(swift::Decl, DeclTag)
205208
MAP(swift::ValueDecl, ValueDeclTag)
206209
MAP(swift::TypeDecl, TypeDeclTag)
@@ -332,6 +335,7 @@ MAP(swift::TypeBase, TypeTag)
332335
MAP(swift::PackExpansionType, PackExpansionTypeTag)
333336
MAP(swift::PackElementType, PackElementTypeTag)
334337
MAP(swift::TypeVariableType, void) // created during type checking and only used for constraint checking
338+
MAP(swift::ErrorUnionType, void) // TODO swift 6.0
335339
MAP(swift::SugarType, SugarTypeTag)
336340
MAP(swift::ParenType, ParenTypeTag)
337341
MAP(swift::TypeAliasType, TypeAliasTypeTag)

swift/extractor/translators/ExprTranslator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ codeql::KeyPathExpr ExprTranslator::translateKeyPathExpr(const swift::KeyPathExp
378378
for (const auto& component : expr.getComponents()) {
379379
entry.components.push_back(emitKeyPathComponent(component));
380380
}
381-
if (auto rootTypeRepr = expr.getRootType()) {
381+
if (auto rootTypeRepr = expr.getExplicitRootType()) {
382382
auto keyPathType = expr.getType()->getAs<swift::BoundGenericClassType>();
383383
CODEQL_EXPECT_OR(return entry, keyPathType, "KeyPathExpr must have BoundGenericClassType");
384384
auto keyPathTypeArgs = keyPathType->getGenericArgs();

swift/third_party/load.bzl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
22
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
33

4-
_swift_prebuilt_version = "swift-5.10.1-RELEASE.323"
4+
_swift_prebuilt_version = "swift-6.0.1-RELEASE.330"
55
_swift_sha_map = {
6-
"Linux-X64": "29c7c53ab2f438e85daecdb4567173c78ac32afc45753d7277d744aed515229d",
7-
"macOS-ARM64": "e697f423c8abcb8a942246489fd4f8ce71472119510b64b2073eaeaec86b771e",
8-
"macOS-X64": "faef29334e8615e8a71263c7453ebc7e566d6f2928d827675f6faae233c544a6",
6+
"Linux-X64": "3da9b257b08da3bed023656c3bea2e1d0e6504b1592f593a077023c59e5339fc",
7+
"macOS-X64": "66641b3b285e593342b88d48defa6668b15a85603acfe5aba5b62b9ed9123465",
98
}
109

1110
_swift_arch_map = {

0 commit comments

Comments
 (0)