diff --git a/swift/extractor/infra/SwiftTagTraits.h b/swift/extractor/infra/SwiftTagTraits.h index 0371a783bb79..b58a6f4ef835 100644 --- a/swift/extractor/infra/SwiftTagTraits.h +++ b/swift/extractor/infra/SwiftTagTraits.h @@ -12,6 +12,7 @@ #include #include #include +#include namespace codeql { @@ -26,6 +27,9 @@ namespace codeql { using type = TAG; \ }; +#define CODEQL_SWIFT_VERSION_GE(MAJOR, MINOR) \ + CODEQL_SWIFT_VERSION_MAJOR >= (MAJOR) && CODEQL_SWIFT_VERSION_MINOR >= (MINOR) + // clang-format off // use indentation to recreate all involved type hierarchies MAP(std::filesystem::path, DbFileTag) @@ -56,6 +60,9 @@ MAP(swift::Stmt, StmtTag) MAP(swift::FailStmt, FailStmtTag) MAP(swift::ThrowStmt, ThrowStmtTag) MAP(swift::PoundAssertStmt, PoundAssertStmtTag) +#if CODEQL_SWIFT_VERSION_GE(5, 9) + MAP(swift::DiscardStmt, void) // TODO (introduced in 5.9) +#endif MAP(swift::Argument, ArgumentTag) MAP(swift::KeyPathExpr::Component, KeyPathComponentTag) @@ -95,7 +102,11 @@ MAP(swift::Expr, ExprTag) MAP(swift::IdentityExpr, IdentityExprTag) MAP(swift::ParenExpr, ParenExprTag) MAP(swift::DotSelfExpr, DotSelfExprTag) - MAP(swift::MoveExpr, void) // TODO (introduced in 5.8) +#if CODEQL_SWIFT_VERSION_GE(5, 9) + MAP(swift::BorrowExpr, void) // TODO (introduced in 5.9) +#else + MAP(swift::MoveExpr, void) // TODO (introduced in 5.8, gone in 5.9) +#endif MAP(swift::AwaitExpr, AwaitExprTag) MAP(swift::UnresolvedMemberChainResultExpr, UnresolvedMemberChainResultExprTag) MAP(swift::AnyTryExpr, AnyTryExprTag) @@ -189,6 +200,13 @@ MAP(swift::Expr, ExprTag) MAP(swift::TapExpr, TapExprTag) MAP(swift::TypeJoinExpr, void) // TODO (introduced in 5.8) MAP(swift::MacroExpansionExpr, void) // TODO (introduced in 5.8) +#if CODEQL_SWIFT_VERSION_GE(5, 9) + MAP(swift::CopyExpr, void) // TODO (introduced in 5.9) + MAP(swift::ConsumeExpr, void) // TODO (introduced in 5.9) + MAP(swift::MaterializePackExpr, void) // TODO (introduced in 5.9) + MAP(swift::SingleValueStmtExpr, void) // TODO (introduced in 5.9) +#endif + MAP(swift::Decl, DeclTag) MAP(swift::ValueDecl, ValueDeclTag) MAP(swift::TypeDecl, TypeDeclTag) @@ -231,6 +249,9 @@ MAP(swift::Decl, DeclTag) MAP(swift::PrefixOperatorDecl, PrefixOperatorDeclTag) MAP(swift::PostfixOperatorDecl, PostfixOperatorDeclTag) MAP(swift::MacroExpansionDecl, void) // TODO (introduced in 5.8) +#if CODEQL_SWIFT_VERSION_GE(5, 9) + MAP(swift::MissingDecl, void) // TODO (introduced in 5.9) +#endif MAP(swift::Pattern, PatternTag) MAP(swift::ParenPattern, ParenPatternTag) @@ -266,6 +287,10 @@ MAP(swift::TypeBase, TypeTag) MAP(swift::BuiltinUnsafeValueBufferType, BuiltinUnsafeValueBufferTypeTag) MAP(swift::BuiltinDefaultActorStorageType, BuiltinDefaultActorStorageTypeTag) MAP(swift::BuiltinVectorType, BuiltinVectorTypeTag) +#if CODEQL_SWIFT_VERSION_GE(5, 9) + MAP(swift::BuiltinPackIndexType, void) // TODO: (introduced in 5.9) + MAP(swift::BuiltinNonDefaultDistributedActorStorageType, void) // TODO: (introduced in 5.9) +#endif MAP(swift::TupleType, TupleTypeTag) MAP(swift::ReferenceStorageType, ReferenceStorageTypeTag) MAP(swift::WeakStorageType, WeakStorageTypeTag) @@ -307,6 +332,9 @@ MAP(swift::TypeBase, TypeTag) MAP(swift::SILBoxType, void) // SIL types cannot really appear in the frontend run) MAP(swift::SILMoveOnlyWrappedType, void) // SIL types cannot really appear in the frontend run) MAP(swift::SILTokenType, void) // SIL types cannot really appear in the frontend run) +#if CODEQL_SWIFT_VERSION_GE(5, 9) + MAP(swift::SILPackType, void) // TODO: (introduced in 5.9) +#endif MAP(swift::ProtocolCompositionType, ProtocolCompositionTypeTag) MAP(swift::ParameterizedProtocolType, ParameterizedProtocolTypeTag) MAP(swift::ExistentialType, ExistentialTypeTag) @@ -314,6 +342,9 @@ MAP(swift::TypeBase, TypeTag) MAP(swift::InOutType, InOutTypeTag) MAP(swift::PackType, void) // experimental variadic generics MAP(swift::PackExpansionType, void) // experimental variadic generics +#if CODEQL_SWIFT_VERSION_GE(5, 9) + MAP(swift::PackElementType, void) // TODO: (introduced in 5.9) +#endif MAP(swift::TypeVariableType, void) // created during type checking and only used for constraint checking MAP(swift::SugarType, SugarTypeTag) MAP(swift::ParenType, ParenTypeTag) diff --git a/swift/third_party/load.bzl b/swift/third_party/load.bzl index 9cefc77948d1..cfeb9ef7a9d8 100644 --- a/swift/third_party/load.bzl +++ b/swift/third_party/load.bzl @@ -46,7 +46,6 @@ def load_dependencies(workspace_name): patches = [ "@%s//swift/third_party/swift-llvm-support:patches/%s.patch" % (workspace_name, patch_name) for patch_name in ( - "remove-result-of", "remove-redundant-operators", "add-constructor-to-Compilation", ) diff --git a/swift/third_party/swift-llvm-support/patches/remove-result-of.patch b/swift/third_party/swift-llvm-support/patches/remove-result-of.patch deleted file mode 100644 index ab3f2155b678..000000000000 --- a/swift/third_party/swift-llvm-support/patches/remove-result-of.patch +++ /dev/null @@ -1,30 +0,0 @@ -`std::result_of` was removed in C++20, but is still used in the Swift headers. We can't -remove it from there before prebuilding, as that is still done with C++14, but we can -replace it with `std::invoke_result` for compiling the extractor. - -diff --git a/include/swift/Basic/RelativePointer.h b/include/swift/Basic/RelativePointer.h -index 73f91262afa..bdaa304c804 100644 ---- a/include/swift/Basic/RelativePointer.h -+++ b/include/swift/Basic/RelativePointer.h -@@ -551,7 +551,7 @@ public: - } - - template -- typename std::result_of::type operator()(ArgTy... arg) const { -+ typename std::invoke_result::type operator()(ArgTy... arg) const { - #if SWIFT_PTRAUTH - void *ptr = this->super::getWithoutCast(); - return reinterpret_cast(ptrauth_sign_unauthenticated( -diff --git a/include/swift/Basic/STLExtras.h b/include/swift/Basic/STLExtras.h -index 7fa3d0c8890..6bc891a9b63 100644 ---- a/include/swift/Basic/STLExtras.h -+++ b/include/swift/Basic/STLExtras.h -@@ -405,7 +405,7 @@ class OptionalTransformIterator { - typename std::iterator_traits::reference; - - using ResultReference = -- typename std::result_of::type; -+ typename std::invoke_result::type; - - public: - /// Used to indicate when the current iterator has already been