mirror of
https://github.com/github/codeql.git
synced 2026-04-27 01:35:13 +02:00
Swift: make extractor compile again after 6.1 upgrade
This commit is contained in:
committed by
Paolo Tranquilli
parent
37bcedcf11
commit
1ac47a892b
@@ -155,7 +155,7 @@ static std::unordered_set<swift::ModuleDecl*> extractDeclarations(
|
||||
if (primaryFile && primaryFile->getBufferID()) {
|
||||
auto& sourceManager = compiler.getSourceMgr();
|
||||
auto tokens = swift::tokenize(compiler.getInvocation().getLangOptions(), sourceManager,
|
||||
*primaryFile->getBufferID());
|
||||
primaryFile->getBufferID());
|
||||
for (auto& token : tokens) {
|
||||
if (token.getKind() == swift::tok::comment) {
|
||||
comments.push_back(token);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <swift/AST/ASTAllocated.h>
|
||||
#include <llvm/ADT/DenseMap.h> // needed (but not included) by the following header
|
||||
#include <swift/AST/AvailabilitySpec.h>
|
||||
#include <swift/AST/Expr.h>
|
||||
#include <swift/AST/SourceFile.h>
|
||||
|
||||
@@ -177,6 +177,7 @@ MAP(swift::Expr, ExprTag)
|
||||
MAP(swift::ABISafeConversionExpr, AbiSafeConversionExprTag) // different acronym convention
|
||||
MAP(swift::ActorIsolationErasureExpr, ActorIsolationErasureExprTag)
|
||||
MAP(swift::UnreachableExpr, UnreachableExprTag)
|
||||
MAP(swift::UnsafeCastExpr, void) // TODO swift 6.1
|
||||
MAP(swift::ExplicitCastExpr, ExplicitCastExprTag)
|
||||
MAP(swift::CheckedCastExpr, CheckedCastExprTag)
|
||||
MAP(swift::ForcedCheckedCastExpr, ForcedCheckedCastExprTag)
|
||||
@@ -204,6 +205,7 @@ MAP(swift::Expr, ExprTag)
|
||||
MAP(swift::SingleValueStmtExpr, SingleValueStmtExprTag)
|
||||
MAP(swift::ExtractFunctionIsolationExpr, ExtractFunctionIsolationExprTag)
|
||||
MAP(swift::CurrentContextIsolationExpr, CurrentContextIsolationExprTag)
|
||||
MAP(swift::TypeValueExpr, void) // TODO swift 6.1
|
||||
MAP(swift::Decl, DeclTag)
|
||||
MAP(swift::ValueDecl, ValueDeclTag)
|
||||
MAP(swift::TypeDecl, TypeDeclTag)
|
||||
@@ -235,7 +237,6 @@ MAP(swift::Decl, DeclTag)
|
||||
MAP(swift::ExtensionDecl, ExtensionDeclTag)
|
||||
MAP(swift::TopLevelCodeDecl, TopLevelCodeDeclTag)
|
||||
MAP(swift::ImportDecl, ImportDeclTag)
|
||||
MAP(swift::IfConfigDecl, IfConfigDeclTag)
|
||||
MAP(swift::PoundDiagnosticDecl, PoundDiagnosticDeclTag)
|
||||
MAP(swift::PrecedenceGroupDecl, PrecedenceGroupDeclTag)
|
||||
MAP(swift::MissingMemberDecl, MissingMemberDeclTag)
|
||||
@@ -284,6 +285,8 @@ MAP(swift::TypeBase, TypeTag)
|
||||
MAP(swift::BuiltinVectorType, BuiltinVectorTypeTag)
|
||||
MAP(swift::BuiltinPackIndexType, void) // SIL type, cannot really appear in the frontend run
|
||||
MAP(swift::BuiltinNonDefaultDistributedActorStorageType, void) // Does not appear in AST/SIL, only used during IRGen
|
||||
MAP(swift::BuiltinFixedArrayType, void) // TODO swift 6.1
|
||||
MAP(swift::BuiltinUnboundGenericType, void) // TODO swift 6.1
|
||||
MAP(swift::TupleType, TupleTypeTag)
|
||||
MAP(swift::ReferenceStorageType, ReferenceStorageTypeTag)
|
||||
MAP(swift::WeakStorageType, WeakStorageTypeTag)
|
||||
@@ -336,8 +339,8 @@ MAP(swift::TypeBase, TypeTag)
|
||||
MAP(swift::PackElementType, PackElementTypeTag)
|
||||
MAP(swift::TypeVariableType, void) // created during type checking and only used for constraint checking
|
||||
MAP(swift::ErrorUnionType, void) // created during type checking and only used for constraint checking
|
||||
MAP(swift::IntegerType, void) // TODO swift 6.1
|
||||
MAP(swift::SugarType, SugarTypeTag)
|
||||
MAP(swift::ParenType, ParenTypeTag)
|
||||
MAP(swift::TypeAliasType, TypeAliasTypeTag)
|
||||
MAP(swift::SyntaxSugarType, SyntaxSugarTypeTag)
|
||||
MAP(swift::UnarySyntaxSugarType, UnarySyntaxSugarTypeTag)
|
||||
|
||||
@@ -353,9 +353,10 @@ SwiftMangledName SwiftMangler::visitOpaqueTypeArchetypeType(
|
||||
}
|
||||
|
||||
SwiftMangledName SwiftMangler::visitOpenedArchetypeType(const swift::OpenedArchetypeType* type) {
|
||||
llvm::SmallVector<char> uuid;
|
||||
type->getOpenedExistentialID().toString(uuid);
|
||||
return visitArchetypeType(type) << std::string_view(uuid.data(), uuid.size());
|
||||
// llvm::SmallVector<char> uuid;
|
||||
// type->getOpenedExistentialID().toString(uuid); // <- doesn't compile any more
|
||||
// return visitArchetypeType(type) << std::string_view(uuid.data(), uuid.size());
|
||||
return visitArchetypeType(type);
|
||||
}
|
||||
|
||||
SwiftMangledName SwiftMangler::visitProtocolCompositionType(
|
||||
@@ -370,10 +371,6 @@ SwiftMangledName SwiftMangler::visitProtocolCompositionType(
|
||||
return ret;
|
||||
}
|
||||
|
||||
SwiftMangledName SwiftMangler::visitParenType(const swift::ParenType* type) {
|
||||
return initMangled(type) << fetch(type->getUnderlyingType());
|
||||
}
|
||||
|
||||
SwiftMangledName SwiftMangler::visitLValueType(const swift::LValueType* type) {
|
||||
return initMangled(type) << fetch(type->getObjectType());
|
||||
}
|
||||
|
||||
@@ -94,7 +94,6 @@ class SwiftMangler : private swift::TypeVisitor<SwiftMangler, SwiftMangledName>,
|
||||
SwiftMangledName visitOpaqueTypeArchetypeType(const swift::OpaqueTypeArchetypeType* type);
|
||||
SwiftMangledName visitOpenedArchetypeType(const swift::OpenedArchetypeType* type);
|
||||
SwiftMangledName visitProtocolCompositionType(const swift::ProtocolCompositionType* type);
|
||||
SwiftMangledName visitParenType(const swift::ParenType* type);
|
||||
SwiftMangledName visitLValueType(const swift::LValueType* type);
|
||||
SwiftMangledName visitDynamicSelfType(const swift::DynamicSelfType* type);
|
||||
SwiftMangledName visitUnboundGenericType(const swift::UnboundGenericType* type);
|
||||
|
||||
@@ -334,14 +334,6 @@ void DeclTranslator::fillAbstractStorageDecl(const swift::AbstractStorageDecl& d
|
||||
fillValueDecl(decl, entry);
|
||||
}
|
||||
|
||||
codeql::IfConfigDecl DeclTranslator::translateIfConfigDecl(const swift::IfConfigDecl& decl) {
|
||||
auto entry = createEntry(decl);
|
||||
if (auto activeClause = decl.getActiveClause()) {
|
||||
entry.active_elements = dispatcher.fetchRepeatedLabels(activeClause->Elements);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
codeql::OpaqueTypeDecl DeclTranslator::translateOpaqueTypeDecl(const swift::OpaqueTypeDecl& decl) {
|
||||
auto entry = createEntry(decl);
|
||||
fillTypeDecl(decl, entry);
|
||||
|
||||
@@ -44,7 +44,6 @@ class DeclTranslator : public AstTranslatorBase<DeclTranslator> {
|
||||
codeql::ExtensionDecl translateExtensionDecl(const swift::ExtensionDecl& decl);
|
||||
codeql::ImportDecl translateImportDecl(const swift::ImportDecl& decl);
|
||||
codeql::ModuleDecl translateModuleDecl(const swift::ModuleDecl& decl);
|
||||
codeql::IfConfigDecl translateIfConfigDecl(const swift::IfConfigDecl& decl);
|
||||
codeql::OpaqueTypeDecl translateOpaqueTypeDecl(const swift::OpaqueTypeDecl& decl);
|
||||
codeql::PoundDiagnosticDecl translatePoundDiagnosticDecl(const swift::PoundDiagnosticDecl& decl);
|
||||
codeql::MissingMemberDecl translateMissingMemberDecl(const swift::MissingMemberDecl& decl);
|
||||
|
||||
@@ -624,7 +624,7 @@ codeql::AppliedPropertyWrapperExpr ExprTranslator::translateAppliedPropertyWrapp
|
||||
codeql::RegexLiteralExpr ExprTranslator::translateRegexLiteralExpr(
|
||||
const swift::RegexLiteralExpr& expr) {
|
||||
auto entry = createExprEntry(expr);
|
||||
auto pattern = expr.getRegexText();
|
||||
auto pattern = expr.getParsedRegexText(); // TODO: there is now this and getRegexToEmit
|
||||
// the pattern has enclosing '/' delimiters, we'd rather get it without
|
||||
entry.pattern = pattern.substr(1, pattern.size() - 2);
|
||||
entry.version = expr.getVersion();
|
||||
|
||||
@@ -76,12 +76,6 @@ codeql::DependentMemberType TypeTranslator::translateDependentMemberType(
|
||||
return entry;
|
||||
}
|
||||
|
||||
codeql::ParenType TypeTranslator::translateParenType(const swift::ParenType& type) {
|
||||
auto entry = createTypeEntry(type);
|
||||
entry.type = dispatcher.fetchLabel(type.getUnderlyingType());
|
||||
return entry;
|
||||
}
|
||||
|
||||
codeql::OptionalType TypeTranslator::translateOptionalType(const swift::OptionalType& type) {
|
||||
auto entry = createTypeEntry(type);
|
||||
fillUnarySyntaxSugarType(type, entry);
|
||||
|
||||
@@ -24,7 +24,6 @@ class TypeTranslator : public TypeTranslatorBase<TypeTranslator> {
|
||||
const swift::ExistentialMetatypeType& type);
|
||||
codeql::TypeAliasType translateTypeAliasType(const swift::TypeAliasType& type);
|
||||
codeql::DependentMemberType translateDependentMemberType(const swift::DependentMemberType& type);
|
||||
codeql::ParenType translateParenType(const swift::ParenType& type);
|
||||
codeql::UnarySyntaxSugarType translateUnarySyntaxSugarType(
|
||||
const swift::UnarySyntaxSugarType& type);
|
||||
codeql::OptionalType translateOptionalType(const swift::OptionalType& type);
|
||||
|
||||
6
swift/ql/.generated.list
generated
6
swift/ql/.generated.list
generated
@@ -12,7 +12,7 @@ lib/codeql/swift/elements/File.qll 642fde19ad366151c71ccb44c32b6063c3374d7169ada
|
||||
lib/codeql/swift/elements/KeyPathComponent.qll cc64d5a3cc6e6aa12faee7dfc95e6b5e10d0adb9bc10d815a93a3a61fd70e535 ab82cebb73753bf72ef8f79c271851dc7e738a25c7100b634630f4363ceec061
|
||||
lib/codeql/swift/elements/Locatable.qll a4e01abd3f337a60e3741705cede50be974ccffcb707a53f2b378972838c5977 89ba4dbebcfa291797407c27087d91a18b1ec1bc97140a14ec08dbb12cef7395
|
||||
lib/codeql/swift/elements/Location.qll db213e8e27f8d732ad472c16929f2c503634c622d4d7b6b6977ed8b7b3c71c5b 9b951af94891848ecea9a690741e4a401c4b7ad676fd1fcee703fce4dcee2da4
|
||||
lib/codeql/swift/elements/MacroRole.qll 2e814f75c578763570addab34c423245e4e68dba651ac9df05441b25c7ce6186 8822c126e2e19e9f7a2eb7035408acff3ac1d99ccb87def2a3b1d26dcfaeccfe
|
||||
lib/codeql/swift/elements/MacroRole.qll d55500010c47fab14fb2110db0afadef5f1f01115d05c803c9fd114508aca6da 858a7fe124cb8874e1fe62b3b36153740b0bb1cd1e9ed0005b36d01040960ed8
|
||||
lib/codeql/swift/elements/OtherAvailabilitySpec.qll b3e3aafc7b1f7b1ff2efa2bc9ff64370cc6847760a46ff5594f5144caee858ab 6630e73998c9359b6cefd265222cb72274b4484d6904b4a9f949bdb7a2781c0f
|
||||
lib/codeql/swift/elements/PlatformVersionAvailabilitySpec.qll 1a94d317cbb1731844986b57bbdc4095d90957c671d5248bc581bc1fdbb18f8b 3888eb1afc641d365c30fa514962f1a31b9b9c04383836e0062445e566003d34
|
||||
lib/codeql/swift/elements/UnknownFile.qll 29e9f59c24c3ee6c2b01ea19390dd6730192628e5e4a541c3c00a42d16daad78 0ec046d67ebdc1722915b0d952468d1d3c3dfdf2c61e7fa215c7ba2fb91de04c
|
||||
@@ -719,12 +719,12 @@ lib/codeql/swift/generated/File.qll 476ac95566ef0080e0ad8c3da144b1be1d945d2f33a2
|
||||
lib/codeql/swift/generated/KeyPathComponent.qll 5276acdc9a4ff0ec0cc8af615c04043391fb99613731ddcc86db4e47b37c8c5a ccc0931bbd6cc2cfae5037c2ee17bbdcbd87536f5fed90d07e73065c016c4382
|
||||
lib/codeql/swift/generated/Locatable.qll 1d37fa20de71c0b9986bfd7a7c0cb82ab7bf3fda2d2008700f955ad82ce109a7 e97d4d4fb8a4800e0008cc00f60c8ed9b1ebd5f1140fd85e68b034616178d721
|
||||
lib/codeql/swift/generated/Location.qll 5e20316c3e480ddfe632b7e88e016c19f10a67df1f6ae9c8f128755a6907d6f5 5a0af2d070bcb2ed53d6d0282bf9c60dc64c2dce89c21fdd485e9c7893c1c8fa
|
||||
lib/codeql/swift/generated/MacroRole.qll 0d8fa6b0b6e2045d9097a87d53888cae2ea5371b2fa7d140341cf206f575b556 ea3b8a7c0a88851809f9a5a5aa80b0d2da3c4779bb29044cdba2b60246a2722c
|
||||
lib/codeql/swift/generated/MacroRole.qll facf907e75490d69cd401c491215e4719324d751f40ea46c86ccf24cf3663c1f 969d8d4b44e3f1a9c193a152a4d83a303e56d2dbb871fc920c47a33f699cf018
|
||||
lib/codeql/swift/generated/OtherAvailabilitySpec.qll d9feaa2a71acff3184ca389045b0a49d09156210df0e034923d715b432ad594b 046737621a8bcf69bf805afb0cff476bd15259f12f0d77fce3206dd01b31518f
|
||||
lib/codeql/swift/generated/ParentChild.qll 7c9537f74a4c5a02622ce28c3de4b0ce02a7027d2e9aea9a860ece6a1e2ec340 49c1993b2a96df66903bffde78d63d8f4c68b2d604c419b20d88b63406366156
|
||||
lib/codeql/swift/generated/PlatformVersionAvailabilitySpec.qll dc17b49a90a18a8f7607adf2433bc8f0c194fa3e803aa3822f809d4d4fbd6793 be48ea9f8ae17354c8508aaed24337a9e57ce01f288fece3dcecd99776cabcec
|
||||
lib/codeql/swift/generated/PureSynthConstructors.qll bc31a6c4d142fa3fbdcae69d5ba6f1cec00eb9ad92b46c8d7b91ebfa7ef6c1f4 bc31a6c4d142fa3fbdcae69d5ba6f1cec00eb9ad92b46c8d7b91ebfa7ef6c1f4
|
||||
lib/codeql/swift/generated/Raw.qll 522f8500ce46d62fca22730ade5fa4716452adece25ffc36c50582b653f2fe6f 4d870e0695fff541c1a14eadc8ba51960a264ba2e6e53d0ccc32b34c7fd2cadd
|
||||
lib/codeql/swift/generated/Raw.qll 6012194c54f8992401dffc0916b5790cdf581f18ac7b884379362dc807a52706 f9538fdfb326b715fdbc47e9e8b310df684d5a34519f751a65b3a4a75e430ce9
|
||||
lib/codeql/swift/generated/Synth.qll a14dddab40979df82d30b2d73407fe0058a803ed6e1a882cd9a6ae5ffd240526 0879d2476a42123b46eee216d4ea03523e0c04fe0b68d9a68e0046253edb1bc9
|
||||
lib/codeql/swift/generated/SynthConstructors.qll f64121911e082aa15478eb8779025cee96e97503724c02aff31741e65a894a4b f64121911e082aa15478eb8779025cee96e97503724c02aff31741e65a894a4b
|
||||
lib/codeql/swift/generated/UnknownFile.qll 247ddf2ebb49ce5ed4bf7bf91a969ddff37de6c78d43d8affccaf7eb586e06f2 452b29f0465ef45e978ef8b647b75e5a2a1e53f2a568fc003bc8f52f73b3fa4d
|
||||
|
||||
2
swift/ql/lib/codeql/swift/elements/MacroRole.qll
generated
2
swift/ql/lib/codeql/swift/elements/MacroRole.qll
generated
@@ -5,7 +5,7 @@
|
||||
|
||||
private import internal.MacroRoleImpl
|
||||
import codeql.swift.elements.AstNode
|
||||
import codeql.swift.elements.expr.TypeExpr
|
||||
import codeql.swift.elements.expr.Expr
|
||||
|
||||
/**
|
||||
* The role of a macro, for example #freestanding(declaration) or @attached(member).
|
||||
|
||||
12
swift/ql/lib/codeql/swift/generated/MacroRole.qll
generated
12
swift/ql/lib/codeql/swift/generated/MacroRole.qll
generated
@@ -7,7 +7,7 @@
|
||||
private import codeql.swift.generated.Synth
|
||||
private import codeql.swift.generated.Raw
|
||||
import codeql.swift.elements.internal.AstNodeImpl::Impl as AstNodeImpl
|
||||
import codeql.swift.elements.expr.TypeExpr
|
||||
import codeql.swift.elements.expr.Expr
|
||||
|
||||
/**
|
||||
* INTERNAL: This module contains the fully generated definition of `MacroRole` and should not
|
||||
@@ -44,9 +44,9 @@ module Generated {
|
||||
* This includes nodes from the "hidden" AST. It can be overridden in subclasses to change the
|
||||
* behavior of both the `Immediate` and non-`Immediate` versions.
|
||||
*/
|
||||
TypeExpr getImmediateConformance(int index) {
|
||||
Expr getImmediateConformance(int index) {
|
||||
result =
|
||||
Synth::convertTypeExprFromRaw(Synth::convertMacroRoleToRaw(this)
|
||||
Synth::convertExprFromRaw(Synth::convertMacroRoleToRaw(this)
|
||||
.(Raw::MacroRole)
|
||||
.getConformance(index))
|
||||
}
|
||||
@@ -54,8 +54,8 @@ module Generated {
|
||||
/**
|
||||
* Gets the `index`th conformance of this macro role (0-based).
|
||||
*/
|
||||
final TypeExpr getConformance(int index) {
|
||||
exists(TypeExpr immediate |
|
||||
final Expr getConformance(int index) {
|
||||
exists(Expr immediate |
|
||||
immediate = this.getImmediateConformance(index) and
|
||||
result = immediate.resolve()
|
||||
)
|
||||
@@ -64,7 +64,7 @@ module Generated {
|
||||
/**
|
||||
* Gets any of the conformances of this macro role.
|
||||
*/
|
||||
final TypeExpr getAConformance() { result = this.getConformance(_) }
|
||||
final Expr getAConformance() { result = this.getConformance(_) }
|
||||
|
||||
/**
|
||||
* Gets the number of conformances of this macro role.
|
||||
|
||||
2
swift/ql/lib/codeql/swift/generated/Raw.qll
generated
2
swift/ql/lib/codeql/swift/generated/Raw.qll
generated
@@ -266,7 +266,7 @@ module Raw {
|
||||
/**
|
||||
* Gets the `index`th conformance of this macro role (0-based).
|
||||
*/
|
||||
TypeExpr getConformance(int index) { macro_role_conformances(this, index, result) }
|
||||
Expr getConformance(int index) { macro_role_conformances(this, index, result) }
|
||||
|
||||
/**
|
||||
* Gets the `index`th name of this macro role (0-based).
|
||||
|
||||
7
swift/ql/lib/swift.dbscheme
generated
7
swift/ql/lib/swift.dbscheme
generated
@@ -210,7 +210,7 @@ macro_roles(
|
||||
macro_role_conformances(
|
||||
int id: @macro_role ref,
|
||||
int index: int ref,
|
||||
int conformance: @type_expr_or_none ref
|
||||
int conformance: @expr_or_none ref
|
||||
);
|
||||
|
||||
#keyset[id, index]
|
||||
@@ -2794,11 +2794,6 @@ variadic_sequence_types( //dir=type
|
||||
| @unspecified_element
|
||||
;
|
||||
|
||||
@type_expr_or_none =
|
||||
@type_expr
|
||||
| @unspecified_element
|
||||
;
|
||||
|
||||
@type_repr_or_none =
|
||||
@type_repr
|
||||
| @unspecified_element
|
||||
|
||||
@@ -1394,7 +1394,7 @@ class MacroRole(AstNode):
|
||||
"""
|
||||
kind: int | doc("kind of this macro role (declaration, expression, member, etc.)") | ql.internal
|
||||
macro_syntax: int | doc("#freestanding or @attached") | ql.internal
|
||||
conformances: list[TypeExpr] | doc("conformances of this macro role")
|
||||
conformances: list[Expr] | doc("conformances of this macro role")
|
||||
names: list[string] | doc("names of this macro role")
|
||||
|
||||
class MacroDecl(GenericContext, ValueDecl):
|
||||
|
||||
4
swift/third_party/load.bzl
vendored
4
swift/third_party/load.bzl
vendored
@@ -5,6 +5,10 @@ load("//misc/bazel:lfs.bzl", "lfs_archive", "lfs_files")
|
||||
|
||||
_override = {
|
||||
# these are used to test new artifacts. Must be empty before merging to main
|
||||
"swift-prebuilt-macOS-swift-6.1-RELEASE-78.tar.zst": "4dcfe858b5519327c9b0c99735b47fe75c7a5090793d917de1ba6e42795aa86d",
|
||||
"swift-prebuilt-Linux-swift-6.1-RELEASE-78.tar.zst": "d01b90bccfec46995bdf98a59339bd94e64257da99b4963148869c4a108bc2a9",
|
||||
"resource-dir-macOS-swift-6.1-RELEASE-91.zip": "12bef89163486ac24d9ca00a5cc6ef3851b633e6fa63b7493c518e4d426e036c",
|
||||
"resource-dir-Linux-swift-6.1-RELEASE-91.zip": "874932f93c4ca6269ae3a9e9c841916b3fd88f65f5018eec8777a52dde56901d",
|
||||
}
|
||||
|
||||
_staging_url = "https://github.com/dsp-testing/codeql-swift-artifacts/releases/download/staging-{}/{}"
|
||||
|
||||
Reference in New Issue
Block a user