diff --git a/patch.sh b/patch.sh new file mode 100755 index 0000000..c61e6df --- /dev/null +++ b/patch.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +PATCH_DIR="$(cd "$(dirname "$0")/patches"; pwd)" + +for patch_subdir in "$PATCH_DIR"/*; do + ( + repo="$(basename "$patch_subdir")" + cd "$repo" || exit 0 + echo "patching $repo" + for patch in "$patch_subdir"/*; do + echo " applying $(basename "$patch")" + git apply "$patch" + done + ) +done diff --git a/patches/swift/01-remove-assert-in-fallthrough-stmt.patch b/patches/swift/01-remove-assert-in-fallthrough-stmt.patch new file mode 100644 index 0000000..48f7d3c --- /dev/null +++ b/patches/swift/01-remove-assert-in-fallthrough-stmt.patch @@ -0,0 +1,15 @@ +There are some cases when we extract bad ASTs where we hit this assertion if we compile in debug +mode. This is undesirable. + +diff --git a/include/swift/AST/Stmt.h b/include/swift/AST/Stmt.h +index 532e038c386..f013eee2f98 100644 +--- a/include/swift/AST/Stmt.h ++++ b/include/swift/AST/Stmt.h +@@ -920,7 +920,6 @@ public: + /// Get the CaseStmt block to which the fallthrough transfers control. + /// Set during Sema. + CaseStmt *getFallthroughDest() const { +- assert(FallthroughDest && "fallthrough dest is not set until Sema"); + return FallthroughDest; + } + void setFallthroughDest(CaseStmt *C) { diff --git a/swift-build-system.patch b/patches/swift/02-handle-empty-pattern-list.patch similarity index 56% rename from swift-build-system.patch rename to patches/swift/02-handle-empty-pattern-list.patch index 1bddbf8..2010ee8 100644 --- a/swift-build-system.patch +++ b/patches/swift/02-handle-empty-pattern-list.patch @@ -1,15 +1,6 @@ -diff --git a/include/swift/AST/Stmt.h b/include/swift/AST/Stmt.h -index 532e038c386..f013eee2f98 100644 ---- a/include/swift/AST/Stmt.h -+++ b/include/swift/AST/Stmt.h -@@ -920,7 +920,6 @@ public: - /// Get the CaseStmt block to which the fallthrough transfers control. - /// Set during Sema. - CaseStmt *getFallthroughDest() const { -- assert(FallthroughDest && "fallthrough dest is not set until Sema"); - return FallthroughDest; - } - void setFallthroughDest(CaseStmt *C) { +`PatternBindingDecl::getPatternList()` can in some cases return an empty list, which causes a +segmentation fault when getting the source range. This case needs to be handled for the extractor. + diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 75b99a22e73..09115678a82 100644 --- a/lib/AST/Decl.cpp diff --git a/patches/swift/03-reinstate-swiftinterface-compilation-for-resource-dir.patch b/patches/swift/03-reinstate-swiftinterface-compilation-for-resource-dir.patch new file mode 100644 index 0000000..3b9ed4a --- /dev/null +++ b/patches/swift/03-reinstate-swiftinterface-compilation-for-resource-dir.patch @@ -0,0 +1,30 @@ +When running the extractor against a different version of the swift compiler, we provide it the +original standard library via `-resource-dir`, and we do want that to be lazily compiled out of the +`.swiftinterface` files. The code removed here explicitly disables that behavior. + +diff --git a/lib/Frontend/ModuleInterfaceLoader.cpp b/lib/Frontend/ModuleInterfaceLoader.cpp +index 2a490a680d8..8d8f48aeed0 100644 +--- a/lib/Frontend/ModuleInterfaceLoader.cpp ++++ b/lib/Frontend/ModuleInterfaceLoader.cpp +@@ -726,21 +726,6 @@ class ModuleInterfaceLoaderImpl { + << "; deferring to serialized module loader\n"); + UsableModulePath = adjacentMod; + return std::make_error_code(std::errc::not_supported); +- } else if (isInResourceDir(adjacentMod) && +- loadMode == ModuleLoadingMode::PreferSerialized) { +- // Special-case here: If we're loading a .swiftmodule from the resource +- // dir adjacent to the compiler, defer to the serialized loader instead +- // of falling back. This is mainly to support development of Swift, +- // where one might change the module format version but forget to +- // recompile the standard library. If that happens, don't fall back +- // and silently recompile the standard library -- instead, error like +- // we used to. +- LLVM_DEBUG(llvm::dbgs() << "Found out-of-date module in the " +- "resource-dir at " +- << adjacentMod +- << "; deferring to serialized module loader " +- "to diagnose\n"); +- return std::make_error_code(std::errc::not_supported); + } else { + LLVM_DEBUG(llvm::dbgs() << "Found out-of-date module at " + << adjacentMod << "\n");