Skip to content

Commit cc07637

Browse files
committed
Swift: make extractor compile again after 6.1 upgrade
1 parent ff8cd98 commit cc07637

18 files changed

+33
-50
lines changed

Diff for: MODULE.bazel

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True
3737
# the versions there are canonical, the versions here are used for CI in github/codeql, as well as for the vendoring of dependencies.
3838
RUST_EDITION = "2024"
3939

40-
RUST_VERSION = "1.85.0"
40+
RUST_VERSION = "1.86.0"
4141

4242
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
4343
rust.toolchain(
@@ -80,9 +80,9 @@ use_repo(
8080
"vendor_ts__either-1.15.0",
8181
"vendor_ts__encoding-0.2.33",
8282
"vendor_ts__figment-0.10.19",
83-
"vendor_ts__flate2-1.1.0",
83+
"vendor_ts__flate2-1.1.1",
8484
"vendor_ts__glob-0.3.2",
85-
"vendor_ts__globset-0.4.15",
85+
"vendor_ts__globset-0.4.16",
8686
"vendor_ts__itertools-0.14.0",
8787
"vendor_ts__lazy_static-1.5.0",
8888
"vendor_ts__mustache-0.9.0",
@@ -117,7 +117,7 @@ use_repo(
117117
"vendor_ts__tracing-0.1.41",
118118
"vendor_ts__tracing-flame-0.2.0",
119119
"vendor_ts__tracing-subscriber-0.3.19",
120-
"vendor_ts__tree-sitter-0.24.6",
120+
"vendor_ts__tree-sitter-0.25.3",
121121
"vendor_ts__tree-sitter-embedded-template-0.23.2",
122122
"vendor_ts__tree-sitter-json-0.24.8",
123123
"vendor_ts__tree-sitter-ql-0.23.1",

Diff for: swift/extractor/SwiftExtractor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static std::unordered_set<swift::ModuleDecl*> extractDeclarations(
155155
if (primaryFile && primaryFile->getBufferID()) {
156156
auto& sourceManager = compiler.getSourceMgr();
157157
auto tokens = swift::tokenize(compiler.getInvocation().getLangOptions(), sourceManager,
158-
*primaryFile->getBufferID());
158+
primaryFile->getBufferID());
159159
for (auto& token : tokens) {
160160
if (token.getKind() == swift::tok::comment) {
161161
comments.push_back(token);

Diff for: swift/extractor/infra/SwiftLocationExtractor.h

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <swift/AST/ASTAllocated.h>
4+
#include <llvm/ADT/DenseMap.h> // needed (but not included) by the following header
45
#include <swift/AST/AvailabilitySpec.h>
56
#include <swift/AST/Expr.h>
67
#include <swift/AST/SourceFile.h>

Diff for: swift/extractor/infra/SwiftTagTraits.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ MAP(swift::Expr, ExprTag)
177177
MAP(swift::ABISafeConversionExpr, AbiSafeConversionExprTag) // different acronym convention
178178
MAP(swift::ActorIsolationErasureExpr, ActorIsolationErasureExprTag)
179179
MAP(swift::UnreachableExpr, UnreachableExprTag)
180+
MAP(swift::UnsafeCastExpr, void) // TODO swift 6.1
180181
MAP(swift::ExplicitCastExpr, ExplicitCastExprTag)
181182
MAP(swift::CheckedCastExpr, CheckedCastExprTag)
182183
MAP(swift::ForcedCheckedCastExpr, ForcedCheckedCastExprTag)
@@ -204,6 +205,7 @@ MAP(swift::Expr, ExprTag)
204205
MAP(swift::SingleValueStmtExpr, SingleValueStmtExprTag)
205206
MAP(swift::ExtractFunctionIsolationExpr, ExtractFunctionIsolationExprTag)
206207
MAP(swift::CurrentContextIsolationExpr, CurrentContextIsolationExprTag)
208+
MAP(swift::TypeValueExpr, void) // TODO swift 6.1
207209
MAP(swift::Decl, DeclTag)
208210
MAP(swift::ValueDecl, ValueDeclTag)
209211
MAP(swift::TypeDecl, TypeDeclTag)
@@ -235,7 +237,6 @@ MAP(swift::Decl, DeclTag)
235237
MAP(swift::ExtensionDecl, ExtensionDeclTag)
236238
MAP(swift::TopLevelCodeDecl, TopLevelCodeDeclTag)
237239
MAP(swift::ImportDecl, ImportDeclTag)
238-
MAP(swift::IfConfigDecl, IfConfigDeclTag)
239240
MAP(swift::PoundDiagnosticDecl, PoundDiagnosticDeclTag)
240241
MAP(swift::PrecedenceGroupDecl, PrecedenceGroupDeclTag)
241242
MAP(swift::MissingMemberDecl, MissingMemberDeclTag)
@@ -284,6 +285,8 @@ MAP(swift::TypeBase, TypeTag)
284285
MAP(swift::BuiltinVectorType, BuiltinVectorTypeTag)
285286
MAP(swift::BuiltinPackIndexType, void) // SIL type, cannot really appear in the frontend run
286287
MAP(swift::BuiltinNonDefaultDistributedActorStorageType, void) // Does not appear in AST/SIL, only used during IRGen
288+
MAP(swift::BuiltinFixedArrayType, void) // TODO swift 6.1
289+
MAP(swift::BuiltinUnboundGenericType, void) // TODO swift 6.1
287290
MAP(swift::TupleType, TupleTypeTag)
288291
MAP(swift::ReferenceStorageType, ReferenceStorageTypeTag)
289292
MAP(swift::WeakStorageType, WeakStorageTypeTag)
@@ -336,8 +339,8 @@ MAP(swift::TypeBase, TypeTag)
336339
MAP(swift::PackElementType, PackElementTypeTag)
337340
MAP(swift::TypeVariableType, void) // created during type checking and only used for constraint checking
338341
MAP(swift::ErrorUnionType, void) // created during type checking and only used for constraint checking
342+
MAP(swift::IntegerType, void) // TODO swift 6.1
339343
MAP(swift::SugarType, SugarTypeTag)
340-
MAP(swift::ParenType, ParenTypeTag)
341344
MAP(swift::TypeAliasType, TypeAliasTypeTag)
342345
MAP(swift::SyntaxSugarType, SyntaxSugarTypeTag)
343346
MAP(swift::UnarySyntaxSugarType, UnarySyntaxSugarTypeTag)

Diff for: swift/extractor/mangler/SwiftMangler.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,10 @@ SwiftMangledName SwiftMangler::visitOpaqueTypeArchetypeType(
353353
}
354354

355355
SwiftMangledName SwiftMangler::visitOpenedArchetypeType(const swift::OpenedArchetypeType* type) {
356-
llvm::SmallVector<char> uuid;
357-
type->getOpenedExistentialID().toString(uuid);
358-
return visitArchetypeType(type) << std::string_view(uuid.data(), uuid.size());
356+
// llvm::SmallVector<char> uuid;
357+
// type->getOpenedExistentialID().toString(uuid); // <- doesn't compile any more
358+
// return visitArchetypeType(type) << std::string_view(uuid.data(), uuid.size());
359+
return visitArchetypeType(type);
359360
}
360361

361362
SwiftMangledName SwiftMangler::visitProtocolCompositionType(
@@ -370,10 +371,6 @@ SwiftMangledName SwiftMangler::visitProtocolCompositionType(
370371
return ret;
371372
}
372373

373-
SwiftMangledName SwiftMangler::visitParenType(const swift::ParenType* type) {
374-
return initMangled(type) << fetch(type->getUnderlyingType());
375-
}
376-
377374
SwiftMangledName SwiftMangler::visitLValueType(const swift::LValueType* type) {
378375
return initMangled(type) << fetch(type->getObjectType());
379376
}

Diff for: swift/extractor/mangler/SwiftMangler.h

-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ class SwiftMangler : private swift::TypeVisitor<SwiftMangler, SwiftMangledName>,
9494
SwiftMangledName visitOpaqueTypeArchetypeType(const swift::OpaqueTypeArchetypeType* type);
9595
SwiftMangledName visitOpenedArchetypeType(const swift::OpenedArchetypeType* type);
9696
SwiftMangledName visitProtocolCompositionType(const swift::ProtocolCompositionType* type);
97-
SwiftMangledName visitParenType(const swift::ParenType* type);
9897
SwiftMangledName visitLValueType(const swift::LValueType* type);
9998
SwiftMangledName visitDynamicSelfType(const swift::DynamicSelfType* type);
10099
SwiftMangledName visitUnboundGenericType(const swift::UnboundGenericType* type);

Diff for: swift/extractor/translators/DeclTranslator.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,6 @@ void DeclTranslator::fillAbstractStorageDecl(const swift::AbstractStorageDecl& d
334334
fillValueDecl(decl, entry);
335335
}
336336

337-
codeql::IfConfigDecl DeclTranslator::translateIfConfigDecl(const swift::IfConfigDecl& decl) {
338-
auto entry = createEntry(decl);
339-
if (auto activeClause = decl.getActiveClause()) {
340-
entry.active_elements = dispatcher.fetchRepeatedLabels(activeClause->Elements);
341-
}
342-
return entry;
343-
}
344-
345337
codeql::OpaqueTypeDecl DeclTranslator::translateOpaqueTypeDecl(const swift::OpaqueTypeDecl& decl) {
346338
auto entry = createEntry(decl);
347339
fillTypeDecl(decl, entry);

Diff for: swift/extractor/translators/DeclTranslator.h

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class DeclTranslator : public AstTranslatorBase<DeclTranslator> {
4444
codeql::ExtensionDecl translateExtensionDecl(const swift::ExtensionDecl& decl);
4545
codeql::ImportDecl translateImportDecl(const swift::ImportDecl& decl);
4646
codeql::ModuleDecl translateModuleDecl(const swift::ModuleDecl& decl);
47-
codeql::IfConfigDecl translateIfConfigDecl(const swift::IfConfigDecl& decl);
4847
codeql::OpaqueTypeDecl translateOpaqueTypeDecl(const swift::OpaqueTypeDecl& decl);
4948
codeql::PoundDiagnosticDecl translatePoundDiagnosticDecl(const swift::PoundDiagnosticDecl& decl);
5049
codeql::MissingMemberDecl translateMissingMemberDecl(const swift::MissingMemberDecl& decl);

Diff for: swift/extractor/translators/ExprTranslator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ codeql::AppliedPropertyWrapperExpr ExprTranslator::translateAppliedPropertyWrapp
624624
codeql::RegexLiteralExpr ExprTranslator::translateRegexLiteralExpr(
625625
const swift::RegexLiteralExpr& expr) {
626626
auto entry = createExprEntry(expr);
627-
auto pattern = expr.getRegexText();
627+
auto pattern = expr.getParsedRegexText(); // TODO: there is now this and getRegexToEmit
628628
// the pattern has enclosing '/' delimiters, we'd rather get it without
629629
entry.pattern = pattern.substr(1, pattern.size() - 2);
630630
entry.version = expr.getVersion();

Diff for: swift/extractor/translators/TypeTranslator.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ codeql::DependentMemberType TypeTranslator::translateDependentMemberType(
7676
return entry;
7777
}
7878

79-
codeql::ParenType TypeTranslator::translateParenType(const swift::ParenType& type) {
80-
auto entry = createTypeEntry(type);
81-
entry.type = dispatcher.fetchLabel(type.getUnderlyingType());
82-
return entry;
83-
}
84-
8579
codeql::OptionalType TypeTranslator::translateOptionalType(const swift::OptionalType& type) {
8680
auto entry = createTypeEntry(type);
8781
fillUnarySyntaxSugarType(type, entry);

Diff for: swift/extractor/translators/TypeTranslator.h

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class TypeTranslator : public TypeTranslatorBase<TypeTranslator> {
2424
const swift::ExistentialMetatypeType& type);
2525
codeql::TypeAliasType translateTypeAliasType(const swift::TypeAliasType& type);
2626
codeql::DependentMemberType translateDependentMemberType(const swift::DependentMemberType& type);
27-
codeql::ParenType translateParenType(const swift::ParenType& type);
2827
codeql::UnarySyntaxSugarType translateUnarySyntaxSugarType(
2928
const swift::UnarySyntaxSugarType& type);
3029
codeql::OptionalType translateOptionalType(const swift::OptionalType& type);

Diff for: swift/ql/.generated.list

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: swift/ql/lib/codeql/swift/elements/MacroRole.qll

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: swift/ql/lib/codeql/swift/generated/MacroRole.qll

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: swift/ql/lib/codeql/swift/generated/Raw.qll

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: swift/ql/lib/swift.dbscheme

+1-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: swift/schema.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ class MacroRole(AstNode):
13941394
"""
13951395
kind: int | doc("kind of this macro role (declaration, expression, member, etc.)") | ql.internal
13961396
macro_syntax: int | doc("#freestanding or @attached") | ql.internal
1397-
conformances: list[TypeExpr] | doc("conformances of this macro role")
1397+
conformances: list[Expr] | doc("conformances of this macro role")
13981398
names: list[string] | doc("names of this macro role")
13991399

14001400
class MacroDecl(GenericContext, ValueDecl):

Diff for: swift/third_party/load.bzl

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ load("//misc/bazel:lfs.bzl", "lfs_archive", "lfs_files")
55

66
_override = {
77
# these are used to test new artifacts. Must be empty before merging to main
8+
"swift-prebuilt-macOS-swift-6.1-RELEASE-78.tar.zst": "4dcfe858b5519327c9b0c99735b47fe75c7a5090793d917de1ba6e42795aa86d",
9+
"swift-prebuilt-Linux-swift-6.1-RELEASE-78.tar.zst": "d01b90bccfec46995bdf98a59339bd94e64257da99b4963148869c4a108bc2a9",
10+
"resource-dir-macOS-swift-6.1-RELEASE-91.zip": "12bef89163486ac24d9ca00a5cc6ef3851b633e6fa63b7493c518e4d426e036c",
11+
"resource-dir-Linux-swift-6.1-RELEASE-91.zip": "874932f93c4ca6269ae3a9e9c841916b3fd88f65f5018eec8777a52dde56901d",
812
}
913

1014
_staging_url = "https://github.com/dsp-testing/codeql-swift-artifacts/releases/download/staging-{}/{}"

0 commit comments

Comments
 (0)