1292 lines
52 KiB
Diff
1292 lines
52 KiB
Diff
From 7159e72f7babe3e74cc6839d62c8e07bcccbc1f6
|
|
From: Doug Gregor <dgregor@apple.com>
|
|
Date: Fri, 8 Sep 2023 10:43:45 -0700
|
|
Subject: [PATCH] Move regex literal parsing logic from SwiftCompilerSources to
|
|
ASTGen
|
|
|
|
ASTGen always builds with the host Swift compiler, without requiring
|
|
bootstrapping, and is enabled in more places. Move the regex literal
|
|
parsing logic there so it is enabled in more host environments, and
|
|
makes use of CMake's Swift support. Enable all of the regex literal
|
|
tests when ASTGen is built, to ensure everything is working.
|
|
|
|
Remove the "AST" and "Parse" Swift modules from SwiftCompilerSources,
|
|
because they are no longer needed.
|
|
|
|
diff --git a/swift/SwiftCompilerSources/CMakeLists.txt b/swift/SwiftCompilerSources/CMakeLists.txt
|
|
index 138d208d9a3a9..44ed3a90d0546 100644
|
|
--- a/swift/SwiftCompilerSources/CMakeLists.txt
|
|
+++ b/swift/SwiftCompilerSources/CMakeLists.txt
|
|
@@ -241,15 +241,9 @@ else()
|
|
#include \"Basic/BasicBridging.h\"
|
|
#include \"Basic/SourceLoc.h\"
|
|
|
|
-#include \"AST/ASTBridging.h\"
|
|
-#include \"AST/DiagnosticEngine.h\"
|
|
-#include \"AST/DiagnosticConsumer.h\"
|
|
-
|
|
#include \"SIL/SILBridging.h\"
|
|
|
|
#include \"SILOptimizer/OptimizerBridging.h\"
|
|
-
|
|
-#include \"Parse/RegexParserBridging.h\"
|
|
")
|
|
add_custom_command(
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp"
|
|
diff --git a/swift/SwiftCompilerSources/Package.swift b/swift/SwiftCompilerSources/Package.swift
|
|
index 3b1a3817cb686..5785c411c1907 100644
|
|
--- a/swift/SwiftCompilerSources/Package.swift
|
|
+++ b/swift/SwiftCompilerSources/Package.swift
|
|
@@ -48,38 +48,21 @@ let package = Package(
|
|
.library(
|
|
name: "swiftCompilerModules",
|
|
type: .static,
|
|
- targets: ["Basic", "AST", "Parse", "SIL", "Optimizer", "_CompilerRegexParser"]),
|
|
+ targets: ["Basic", "SIL", "Optimizer"]),
|
|
],
|
|
dependencies: [
|
|
],
|
|
// Note that targets and their dependencies must align with
|
|
// 'SwiftCompilerSources/Sources/CMakeLists.txt'
|
|
targets: [
|
|
- .compilerModuleTarget(
|
|
- name: "_CompilerRegexParser",
|
|
- dependencies: [],
|
|
- path: "_RegexParser_Sources",
|
|
- swiftSettings: [
|
|
- // Workaround until `_CompilerRegexParser` is imported as implementation-only
|
|
- // by `_StringProcessing`.
|
|
- .unsafeFlags([
|
|
- "-Xfrontend",
|
|
- "-disable-implicit-string-processing-module-import"
|
|
- ])]),
|
|
.compilerModuleTarget(
|
|
name: "Basic",
|
|
dependencies: []),
|
|
- .compilerModuleTarget(
|
|
- name: "AST",
|
|
- dependencies: ["Basic"]),
|
|
- .compilerModuleTarget(
|
|
- name: "Parse",
|
|
- dependencies: ["Basic", "AST", "_CompilerRegexParser"]),
|
|
.compilerModuleTarget(
|
|
name: "SIL",
|
|
dependencies: ["Basic"]),
|
|
.compilerModuleTarget(
|
|
name: "Optimizer",
|
|
- dependencies: ["Basic", "SIL", "Parse"]),
|
|
+ dependencies: ["Basic", "SIL"]),
|
|
]
|
|
)
|
|
diff --git a/swift/SwiftCompilerSources/Sources/AST/CMakeLists.txt b/swift/SwiftCompilerSources/Sources/AST/CMakeLists.txt
|
|
deleted file mode 100644
|
|
index 3d814cad0a6c4..0000000000000
|
|
--- a/swift/SwiftCompilerSources/Sources/AST/CMakeLists.txt
|
|
+++ /dev/null
|
|
@@ -1,14 +0,0 @@
|
|
-# This source file is part of the Swift.org open source project
|
|
-#
|
|
-# Copyright (c) 2022 Apple Inc. and the Swift project authors
|
|
-# Licensed under Apache License v2.0 with Runtime Library Exception
|
|
-#
|
|
-# See http://swift.org/LICENSE.txt for license information
|
|
-# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
|
|
-
|
|
-add_swift_compiler_module(AST
|
|
- DEPENDS
|
|
- Basic
|
|
- SOURCES
|
|
- DiagnosticEngine.swift)
|
|
-
|
|
diff --git a/swift/SwiftCompilerSources/Sources/AST/DiagnosticEngine.swift b/swift/SwiftCompilerSources/Sources/AST/DiagnosticEngine.swift
|
|
deleted file mode 100644
|
|
index 69d4c8b77f8a7..0000000000000
|
|
--- a/swift/SwiftCompilerSources/Sources/AST/DiagnosticEngine.swift
|
|
+++ /dev/null
|
|
@@ -1,122 +0,0 @@
|
|
-//===--- DiagnosticEngine.swift -------------------------------------------===//
|
|
-//
|
|
-// This source file is part of the Swift.org open source project
|
|
-//
|
|
-// Copyright (c) 2022 Apple Inc. and the Swift project authors
|
|
-// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
-//
|
|
-// See https://swift.org/LICENSE.txt for license information
|
|
-// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
-//
|
|
-//===----------------------------------------------------------------------===//
|
|
-
|
|
-import ASTBridging
|
|
-
|
|
-import Basic
|
|
-
|
|
-public typealias DiagID = BridgedDiagID
|
|
-
|
|
-public protocol DiagnosticArgument {
|
|
- func _withBridgedDiagnosticArgument(_ fn: (swift.DiagnosticArgument) -> Void)
|
|
-}
|
|
-extension String: DiagnosticArgument {
|
|
- public func _withBridgedDiagnosticArgument(_ fn: (swift.DiagnosticArgument) -> Void) {
|
|
- _withStringRef { fn(swift.DiagnosticArgument($0)) }
|
|
- }
|
|
-}
|
|
-extension Int: DiagnosticArgument {
|
|
- public func _withBridgedDiagnosticArgument(_ fn: (swift.DiagnosticArgument) -> Void) {
|
|
- fn(swift.DiagnosticArgument(Int32(self)))
|
|
- }
|
|
-}
|
|
-
|
|
-public struct DiagnosticFixIt {
|
|
- public let start: SourceLoc
|
|
- public let byteLength: Int
|
|
- public let text: String
|
|
-
|
|
- public init(start: SourceLoc, byteLength: Int, replacement text: String) {
|
|
- self.start = start
|
|
- self.byteLength = byteLength
|
|
- self.text = text
|
|
- }
|
|
-
|
|
- func withBridgedDiagnosticFixIt(_ fn: (swift.DiagnosticInfo.FixIt) -> Void) {
|
|
- text._withStringRef { bridgedTextRef in
|
|
- let bridgedDiagnosticFixIt = swift.DiagnosticInfo.FixIt(
|
|
- swift.CharSourceRange(start.bridged, UInt32(byteLength)),
|
|
- bridgedTextRef,
|
|
- ArrayRefOfDiagnosticArgument())
|
|
- fn(bridgedDiagnosticFixIt)
|
|
- }
|
|
- }
|
|
-}
|
|
-
|
|
-public struct DiagnosticEngine {
|
|
- private let bridged: BridgedDiagnosticEngine
|
|
-
|
|
- public init(bridged: BridgedDiagnosticEngine) {
|
|
- self.bridged = bridged
|
|
- }
|
|
- public init?(bridged: BridgedOptionalDiagnosticEngine) {
|
|
- guard let object = bridged.object else {
|
|
- return nil
|
|
- }
|
|
- self.bridged = BridgedDiagnosticEngine(object: object)
|
|
- }
|
|
-
|
|
- public func diagnose(_ position: SourceLoc?,
|
|
- _ id: DiagID,
|
|
- _ args: [DiagnosticArgument],
|
|
- highlight: CharSourceRange? = nil,
|
|
- fixIts: [DiagnosticFixIt] = []) {
|
|
-
|
|
- let bridgedSourceLoc: swift.SourceLoc = position.bridged
|
|
- let bridgedHighlightRange: swift.CharSourceRange = highlight.bridged
|
|
- var bridgedArgs: [swift.DiagnosticArgument] = []
|
|
- var bridgedFixIts: [swift.DiagnosticInfo.FixIt] = []
|
|
-
|
|
- // Build a higher-order function to wrap every 'withBridgedXXX { ... }'
|
|
- // calls, so we don't escape anything from the closure. 'bridgedArgs' and
|
|
- // 'bridgedFixIts' are temporary storage to store bridged values. So they
|
|
- // should not be used after the closure is executed.
|
|
-
|
|
- var closure: () -> Void = {
|
|
- bridgedArgs.withBridgedArrayRef { bridgedArgsRef in
|
|
- bridgedFixIts.withBridgedArrayRef { bridgedFixItsRef in
|
|
- DiagnosticEngine_diagnose(bridged, bridgedSourceLoc,
|
|
- id, bridgedArgsRef,
|
|
- bridgedHighlightRange, bridgedFixItsRef)
|
|
- }
|
|
- }
|
|
- }
|
|
- // 'reversed()' because the closure should be wrapped in that order.
|
|
- for arg in args.reversed() {
|
|
- closure = { [closure, arg] in
|
|
- arg._withBridgedDiagnosticArgument { bridgedArg in
|
|
- bridgedArgs.append(bridgedArg)
|
|
- closure()
|
|
- }
|
|
- }
|
|
- }
|
|
- // 'reversed()' because the closure should be wrapped in that order.
|
|
- for fixIt in fixIts.reversed() {
|
|
- closure = { [closure, fixIt] in
|
|
- fixIt.withBridgedDiagnosticFixIt { bridgedFixIt in
|
|
- bridgedFixIts.append(bridgedFixIt)
|
|
- closure()
|
|
- }
|
|
- }
|
|
- }
|
|
-
|
|
- closure()
|
|
- }
|
|
-
|
|
- public func diagnose(_ position: SourceLoc?,
|
|
- _ id: DiagID,
|
|
- _ args: DiagnosticArgument...,
|
|
- highlight: CharSourceRange? = nil,
|
|
- fixIts: DiagnosticFixIt...) {
|
|
- diagnose(position, id, args, highlight: highlight, fixIts: fixIts)
|
|
- }
|
|
-}
|
|
diff --git a/swift/SwiftCompilerSources/Sources/CMakeLists.txt b/swift/SwiftCompilerSources/Sources/CMakeLists.txt
|
|
index af6900ff8d0e9..622fa883889a9 100644
|
|
--- a/swift/SwiftCompilerSources/Sources/CMakeLists.txt
|
|
+++ b/swift/SwiftCompilerSources/Sources/CMakeLists.txt
|
|
@@ -8,11 +8,6 @@
|
|
|
|
# NOTE: Subdirectories must be added in dependency order.
|
|
|
|
-if(SWIFT_BUILD_REGEX_PARSER_IN_COMPILER)
|
|
- add_subdirectory(_RegexParser)
|
|
-endif()
|
|
add_subdirectory(Basic)
|
|
-add_subdirectory(AST)
|
|
-add_subdirectory(Parse)
|
|
add_subdirectory(SIL)
|
|
add_subdirectory(Optimizer)
|
|
diff --git a/swift/SwiftCompilerSources/Sources/Optimizer/CMakeLists.txt b/swift/SwiftCompilerSources/Sources/Optimizer/CMakeLists.txt
|
|
index acce165e1ee79..48b74e373e115 100644
|
|
--- a/swift/SwiftCompilerSources/Sources/Optimizer/CMakeLists.txt
|
|
+++ b/swift/SwiftCompilerSources/Sources/Optimizer/CMakeLists.txt
|
|
@@ -7,7 +7,7 @@
|
|
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
|
|
|
|
set(dependencies)
|
|
-list(APPEND dependencies Basic SIL Parse)
|
|
+list(APPEND dependencies Basic SIL)
|
|
|
|
add_swift_compiler_module(Optimizer DEPENDS ${dependencies})
|
|
|
|
diff --git a/swift/SwiftCompilerSources/Sources/Optimizer/PassManager/PassRegistration.swift b/swift/SwiftCompilerSources/Sources/Optimizer/PassManager/PassRegistration.swift
|
|
index 060adf01abf53..13f1b7fe7d106 100644
|
|
--- a/swift/SwiftCompilerSources/Sources/Optimizer/PassManager/PassRegistration.swift
|
|
+++ b/swift/SwiftCompilerSources/Sources/Optimizer/PassManager/PassRegistration.swift
|
|
@@ -12,14 +12,12 @@
|
|
|
|
import SIL
|
|
import OptimizerBridging
|
|
-import Parse
|
|
|
|
@_cdecl("initializeSwiftModules")
|
|
public func initializeSwiftModules() {
|
|
registerSILClasses()
|
|
registerSwiftAnalyses()
|
|
registerSwiftPasses()
|
|
- initializeSwiftParseModules()
|
|
}
|
|
|
|
private func registerPass(
|
|
diff --git a/swift/SwiftCompilerSources/Sources/Parse/CMakeLists.txt b/swift/SwiftCompilerSources/Sources/Parse/CMakeLists.txt
|
|
deleted file mode 100644
|
|
index 7e5c1c7d97717..0000000000000
|
|
--- a/swift/SwiftCompilerSources/Sources/Parse/CMakeLists.txt
|
|
+++ /dev/null
|
|
@@ -1,19 +0,0 @@
|
|
-# This source file is part of the Swift.org open source project
|
|
-#
|
|
-# Copyright (c) 2022 Apple Inc. and the Swift project authors
|
|
-# Licensed under Apache License v2.0 with Runtime Library Exception
|
|
-#
|
|
-# See http://swift.org/LICENSE.txt for license information
|
|
-# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
|
|
-
|
|
-set(dependencies Basic AST)
|
|
-if(SWIFT_BUILD_REGEX_PARSER_IN_COMPILER)
|
|
- list(APPEND dependencies _CompilerRegexParser)
|
|
-endif()
|
|
-
|
|
-add_swift_compiler_module(Parse
|
|
- DEPENDS
|
|
- ${dependencies}
|
|
- SOURCES
|
|
- Parse.swift
|
|
- Regex.swift)
|
|
diff --git a/swift/SwiftCompilerSources/Sources/Parse/Parse.swift b/swift/SwiftCompilerSources/Sources/Parse/Parse.swift
|
|
deleted file mode 100644
|
|
index a8a79489fc5a8..0000000000000
|
|
--- a/swift/SwiftCompilerSources/Sources/Parse/Parse.swift
|
|
+++ /dev/null
|
|
@@ -1,16 +0,0 @@
|
|
-//===--- Parse.swift - SourceLoc bridiging utilities ------------------===//
|
|
-//
|
|
-// This source file is part of the Swift.org open source project
|
|
-//
|
|
-// Copyright (c) 2022 Apple Inc. and the Swift project authors
|
|
-// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
-//
|
|
-// See https://swift.org/LICENSE.txt for license information
|
|
-// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
-//
|
|
-//===----------------------------------------------------------------------===//
|
|
-
|
|
-@_cdecl("initializeSwiftParseModules")
|
|
-public func initializeSwiftParseModules() {
|
|
- registerRegexParser()
|
|
-}
|
|
diff --git a/swift/SwiftCompilerSources/Sources/_RegexParser/CMakeLists.txt b/swift/SwiftCompilerSources/Sources/_RegexParser/CMakeLists.txt
|
|
deleted file mode 100644
|
|
index d202c421e84d1..0000000000000
|
|
--- a/swift/SwiftCompilerSources/Sources/_RegexParser/CMakeLists.txt
|
|
+++ /dev/null
|
|
@@ -1,20 +0,0 @@
|
|
-# This source file is part of the Swift.org open source project
|
|
-#
|
|
-# Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
|
|
-# Licensed under Apache License v2.0 with Runtime Library Exception
|
|
-#
|
|
-# See http://swift.org/LICENSE.txt for license information
|
|
-# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
|
|
-
|
|
-file(GLOB_RECURSE _LIBSWIFT_REGEX_PARSER_SOURCES
|
|
- "${SWIFT_PATH_TO_STRING_PROCESSING_SOURCE}/Sources/_RegexParser/*.swift")
|
|
-set(LIBSWIFT_REGEX_PARSER_SOURCES)
|
|
-foreach(source ${_LIBSWIFT_REGEX_PARSER_SOURCES})
|
|
- file(TO_CMAKE_PATH "${source}" source)
|
|
- list(APPEND LIBSWIFT_REGEX_PARSER_SOURCES ${source})
|
|
-endforeach()
|
|
-message(STATUS "Using Experimental String Processing library for libswift _RegexParser (${SWIFT_PATH_TO_STRING_PROCESSING_SOURCE}).")
|
|
-
|
|
-add_swift_compiler_module(_CompilerRegexParser
|
|
- SOURCES
|
|
- "${LIBSWIFT_REGEX_PARSER_SOURCES}")
|
|
diff --git a/swift/SwiftCompilerSources/_RegexParser_Sources b/swift/SwiftCompilerSources/_RegexParser_Sources
|
|
deleted file mode 120000
|
|
index 8c4799dab65a6..0000000000000
|
|
--- a/swift/SwiftCompilerSources/_RegexParser_Sources
|
|
+++ /dev/null
|
|
@@ -1 +0,0 @@
|
|
-../../swift-experimental-string-processing/Sources/_RegexParser
|
|
\ No newline at end of file
|
|
diff --git a/swift/SwiftCompilerSources/stubs.cpp b/swift/SwiftCompilerSources/stubs.cpp
|
|
index 36df93a14d970..908eef9cad9ad 100644
|
|
--- a/swift/SwiftCompilerSources/stubs.cpp
|
|
+++ b/swift/SwiftCompilerSources/stubs.cpp
|
|
@@ -13,9 +13,7 @@
|
|
extern "C" {
|
|
|
|
void initializeSwiftModules();
|
|
-void initializeSwiftParseModules();
|
|
|
|
}
|
|
|
|
void initializeSwiftModules() {}
|
|
-void initializeSwiftParseModules() {}
|
|
diff --git a/swift/include/swift/module.modulemap b/swift/include/swift/module.modulemap
|
|
index 2e421469dd1dd..4c8a45e88c69b 100644
|
|
--- a/swift/include/swift/module.modulemap
|
|
+++ b/swift/include/swift/module.modulemap
|
|
@@ -12,10 +12,7 @@ module CBasicBridging {
|
|
|
|
module ASTBridging {
|
|
header "AST/AnyFunctionRef.h"
|
|
- header "AST/ASTBridging.h"
|
|
header "AST/Builtins.h"
|
|
- header "AST/DiagnosticEngine.h"
|
|
- header "AST/DiagnosticConsumer.h"
|
|
header "AST/ForeignAsyncConvention.h"
|
|
header "AST/ForeignErrorConvention.h"
|
|
header "AST/SubstitutionMap.h"
|
|
@@ -41,8 +38,3 @@ module OptimizerBridging {
|
|
header "SILOptimizer/OptimizerBridging.h"
|
|
export *
|
|
}
|
|
-
|
|
-module _RegexParserBridging {
|
|
- header "Parse/RegexParserBridging.h"
|
|
- export *
|
|
-}
|
|
diff --git a/swift/include/swift/AST/ASTBridging.h b/swift/include/swift/AST/ASTBridging.h
|
|
deleted file mode 100644
|
|
index d02968cf85c34..0000000000000
|
|
--- a/swift/include/swift/AST/ASTBridging.h
|
|
+++ /dev/null
|
|
@@ -1,55 +0,0 @@
|
|
-//===--- ASTBridging.h - header for the swift SILBridging module ----------===//
|
|
-//
|
|
-// This source file is part of the Swift.org open source project
|
|
-//
|
|
-// Copyright (c) 2022 Apple Inc. and the Swift project authors
|
|
-// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
-//
|
|
-// See https://swift.org/LICENSE.txt for license information
|
|
-// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
-//
|
|
-//===----------------------------------------------------------------------===//
|
|
-
|
|
-#ifndef SWIFT_AST_ASTBRIDGING_H
|
|
-#define SWIFT_AST_ASTBRIDGING_H
|
|
-
|
|
-#include "swift/Basic/BasicBridging.h"
|
|
-#include "swift/Basic/Compiler.h"
|
|
-#include "swift/AST/DiagnosticEngine.h"
|
|
-#include <stdbool.h>
|
|
-#include <stddef.h>
|
|
-
|
|
-SWIFT_BEGIN_NULLABILITY_ANNOTATIONS
|
|
-
|
|
-//===----------------------------------------------------------------------===//
|
|
-// Diagnostic Engine
|
|
-//===----------------------------------------------------------------------===//
|
|
-
|
|
-// NOTE: This must be the same underlying value as C++ 'swift::DiagID' defined
|
|
-// in 'DiagnosticList.cpp'.
|
|
-typedef enum ENUM_EXTENSIBILITY_ATTR(open) BridgedDiagID : uint32_t {
|
|
-#define DIAG(KIND, ID, Options, Text, Signature) BridgedDiagID_##ID,
|
|
-#include "swift/AST/DiagnosticsAll.def"
|
|
-} BridgedDiagID;
|
|
-
|
|
-typedef struct {
|
|
- void * _Nonnull object;
|
|
-} BridgedDiagnosticEngine;
|
|
-
|
|
-typedef struct {
|
|
- void *_Nullable object;
|
|
-} BridgedOptionalDiagnosticEngine;
|
|
-
|
|
-// FIXME: Can we bridge InFlightDiagnostic?
|
|
-void DiagnosticEngine_diagnose(BridgedDiagnosticEngine, swift::SourceLoc loc,
|
|
- BridgedDiagID diagID, BridgedArrayRef arguments,
|
|
- swift::CharSourceRange highlight,
|
|
- BridgedArrayRef fixIts);
|
|
-
|
|
-bool DiagnosticEngine_hadAnyError(BridgedDiagnosticEngine);
|
|
-
|
|
-using ArrayRefOfDiagnosticArgument = llvm::ArrayRef<swift::DiagnosticArgument>;
|
|
-
|
|
-SWIFT_END_NULLABILITY_ANNOTATIONS
|
|
-
|
|
-#endif // SWIFT_AST_ASTBRIDGING_H
|
|
diff --git a/swift/include/swift/AST/BridgingUtils.h b/swift/include/swift/AST/BridgingUtils.h
|
|
deleted file mode 100644
|
|
index 6f5a0dfbbbe90..0000000000000
|
|
--- a/swift/include/swift/AST/BridgingUtils.h
|
|
+++ /dev/null
|
|
@@ -1,32 +0,0 @@
|
|
-//===--- BridgingUtils.h - utilities for swift bridging -------------------===//
|
|
-//
|
|
-// This source file is part of the Swift.org open source project
|
|
-//
|
|
-// Copyright (c) 2022 Apple Inc. and the Swift project authors
|
|
-// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
-//
|
|
-// See https://swift.org/LICENSE.txt for license information
|
|
-// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
-//
|
|
-//===----------------------------------------------------------------------===//
|
|
-
|
|
-#ifndef SWIFT_AST_BRIDGINGUTILS_H
|
|
-#define SWIFT_AST_BRIDGINGUTILS_H
|
|
-
|
|
-#include "swift/AST/ASTBridging.h"
|
|
-#include "swift/AST/DiagnosticEngine.h"
|
|
-
|
|
-namespace swift {
|
|
-
|
|
-inline BridgedDiagnosticEngine getBridgedDiagnosticEngine(DiagnosticEngine *D) {
|
|
- return {(void *)D};
|
|
-}
|
|
-inline BridgedOptionalDiagnosticEngine
|
|
-getBridgedOptionalDiagnosticEngine(DiagnosticEngine *D) {
|
|
- return {(void *)D};
|
|
-}
|
|
-
|
|
-} // namespace swift
|
|
-
|
|
-#endif
|
|
-
|
|
diff --git a/swift/include/swift/AST/CASTBridging.h b/swift/include/swift/AST/CASTBridging.h
|
|
index 0f798f961db94..fc2c07d5381f8 100644
|
|
--- a/swift/include/swift/AST/CASTBridging.h
|
|
+++ b/swift/include/swift/AST/CASTBridging.h
|
|
@@ -107,7 +107,7 @@ typedef struct BridgedDiagnostic {
|
|
} BridgedDiagnostic;
|
|
|
|
typedef struct BridgedDiagnosticEngine {
|
|
- void *raw;
|
|
+ void * _Nullable raw;
|
|
} BridgedDiagnosticEngine;
|
|
|
|
typedef enum ENUM_EXTENSIBILITY_ATTR(open) BridgedMacroDefinitionKind : long {
|
|
@@ -434,6 +434,53 @@ void Decl_dump(void *decl);
|
|
void Stmt_dump(void *statement);
|
|
void Type_dump(void *type);
|
|
|
|
+//===----------------------------------------------------------------------===//
|
|
+// Regular expression literal parsing hooks
|
|
+//===----------------------------------------------------------------------===//
|
|
+
|
|
+/// Attempt to lex a regex literal string. Takes the following arguments:
|
|
+///
|
|
+/// - CurPtrPtr: A pointer to the current pointer of lexer, which should be the
|
|
+/// start of the literal. This will be advanced to the point at
|
|
+/// which the lexer should resume, or will remain the same if this
|
|
+/// is not a regex literal.
|
|
+/// - BufferEnd: A pointer to the end of the buffer, which should not be lexed
|
|
+/// past.
|
|
+/// - MustBeRegex: whether an error during lexing should be considered a regex
|
|
+/// literal, or some thing else.
|
|
+/// - BridgedDiagnosticEngine: RegexLiteralLexingFn should diagnose the
|
|
+/// token using this engine.
|
|
+///
|
|
+/// Returns: A bool indicating whether lexing was completely erroneous, and
|
|
+/// cannot be recovered from, or false if there either was no error,
|
|
+/// or there was a recoverable error.
|
|
+typedef _Bool (*RegexLiteralLexingFn)(
|
|
+ /*CurPtrPtr*/ const char *_Nonnull *_Nonnull,
|
|
+ /*BufferEnd*/ const char *_Nonnull,
|
|
+ /*MustBeRegex*/ _Bool, BridgedDiagnosticEngine);
|
|
+void Parser_registerRegexLiteralLexingFn(RegexLiteralLexingFn _Nullable fn);
|
|
+
|
|
+/// Parse a regex literal string. Takes the following arguments:
|
|
+///
|
|
+/// - InputPtr: A null-terminated C string of the regex literal.
|
|
+/// - VersionOut: A buffer accepting a regex literal format version.
|
|
+/// - CaptureStructureOut: A buffer accepting a byte sequence representing the
|
|
+/// capture structure of the literal.
|
|
+/// - CaptureStructureSize: The size of the capture structure buffer. Must be
|
|
+/// greater than or equal to `strlen(InputPtr) + 3`.
|
|
+/// - DiagnosticBaseLoc: Start location of the regex literal.
|
|
+/// - BridgedDiagnosticEngine: RegexLiteralParsingFn should diagnose the
|
|
+/// parsing errors using this engine.
|
|
+///
|
|
+/// Returns: A bool value indicating if there was an error while parsing.
|
|
+typedef _Bool (*RegexLiteralParsingFn)(/*InputPtr*/ const char *_Nonnull,
|
|
+ /*VersionOut*/ unsigned *_Nonnull,
|
|
+ /*CaptureStructureOut*/ void *_Nonnull,
|
|
+ /*CaptureStructureSize*/ unsigned,
|
|
+ /*DiagnosticBaseLoc*/ BridgedSourceLoc,
|
|
+ BridgedDiagnosticEngine);
|
|
+void Parser_registerRegexLiteralParsingFn(RegexLiteralParsingFn _Nullable fn);
|
|
+
|
|
//===----------------------------------------------------------------------===//
|
|
// Plugins
|
|
//===----------------------------------------------------------------------===//
|
|
diff --git a/swift/include/swift/Parse/RegexParserBridging.h b/swift/include/swift/Parse/RegexParserBridging.h
|
|
deleted file mode 100644
|
|
index 35ea10eeadbfc..0000000000000
|
|
--- a/swift/include/swift/Parse/RegexParserBridging.h
|
|
+++ /dev/null
|
|
@@ -1,63 +0,0 @@
|
|
-//===-- RegexParserBridging.h --- Regex parser interface -*- C++ -*-===//
|
|
-//
|
|
-// This source file is part of the Swift.org open source project
|
|
-//
|
|
-// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
|
|
-// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
-//
|
|
-// See https://swift.org/LICENSE.txt for license information
|
|
-// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
-//
|
|
-//===----------------------------------------------------------------------===//
|
|
-
|
|
-
|
|
-#ifndef REGEX_PARSER_BRIDGING
|
|
-#define REGEX_PARSER_BRIDGING
|
|
-
|
|
-#include "swift/AST/ASTBridging.h"
|
|
-#include <stdbool.h>
|
|
-
|
|
-/// Attempt to lex a regex literal string. Takes the following arguments:
|
|
-///
|
|
-/// - CurPtrPtr: A pointer to the current pointer of lexer, which should be the
|
|
-/// start of the literal. This will be advanced to the point at
|
|
-/// which the lexer should resume, or will remain the same if this
|
|
-/// is not a regex literal.
|
|
-/// - BufferEnd: A pointer to the end of the buffer, which should not be lexed
|
|
-/// past.
|
|
-/// - MustBeRegex: whether an error during lexing should be considered a regex
|
|
-/// literal, or some thing else.
|
|
-/// - BridgedOptionalDiagnosticEngine: RegexLiteralLexingFn should diagnose the
|
|
-/// token using this engine.
|
|
-///
|
|
-/// Returns: A bool indicating whether lexing was completely erroneous, and
|
|
-/// cannot be recovered from, or false if there either was no error,
|
|
-/// or there was a recoverable error.
|
|
-typedef bool (*RegexLiteralLexingFn)(
|
|
- /*CurPtrPtr*/ const char *_Nonnull *_Nonnull,
|
|
- /*BufferEnd*/ const char *_Nonnull,
|
|
- /*MustBeRegex*/ bool, BridgedOptionalDiagnosticEngine);
|
|
-void Parser_registerRegexLiteralLexingFn(RegexLiteralLexingFn _Nullable fn);
|
|
-
|
|
-/// Parse a regex literal string. Takes the following arguments:
|
|
-///
|
|
-/// - InputPtr: A null-terminated C string of the regex literal.
|
|
-/// - VersionOut: A buffer accepting a regex literal format version.
|
|
-/// - CaptureStructureOut: A buffer accepting a byte sequence representing the
|
|
-/// capture structure of the literal.
|
|
-/// - CaptureStructureSize: The size of the capture structure buffer. Must be
|
|
-/// greater than or equal to `strlen(InputPtr) + 3`.
|
|
-/// - DiagnosticBaseLoc: Start location of the regex literal.
|
|
-/// - BridgedDiagnosticEngine: RegexLiteralParsingFn should diagnose the
|
|
-/// parsing errors using this engine.
|
|
-///
|
|
-/// Returns: A bool value indicating if there was an error while parsing.
|
|
-typedef bool (*RegexLiteralParsingFn)(/*InputPtr*/ const char *_Nonnull,
|
|
- /*VersionOut*/ unsigned *_Nonnull,
|
|
- /*CaptureStructureOut*/ void *_Nonnull,
|
|
- /*CaptureStructureSize*/ unsigned,
|
|
- /*DiagnosticBaseLoc*/ swift::SourceLoc,
|
|
- BridgedDiagnosticEngine);
|
|
-void Parser_registerRegexLiteralParsingFn(RegexLiteralParsingFn _Nullable fn);
|
|
-
|
|
-#endif // REGEX_PARSER_BRIDGING
|
|
diff --git a/swift/lib/AST/ASTBridging.cpp b/swift/lib/AST/ASTBridging.cpp
|
|
deleted file mode 100644
|
|
index 4b924f801637a..0000000000000
|
|
--- a/swift/lib/AST/ASTBridging.cpp
|
|
+++ /dev/null
|
|
@@ -1,59 +0,0 @@
|
|
-//===--- ASTBridging.cpp - AST bridging functions -------------------------===//
|
|
-//
|
|
-// This source file is part of the Swift.org open source project
|
|
-//
|
|
-// Copyright (c) 2022 Apple Inc. and the Swift project authors
|
|
-// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
-//
|
|
-// See https://swift.org/LICENSE.txt for license information
|
|
-// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
-//
|
|
-//===----------------------------------------------------------------------===//
|
|
-
|
|
-#include "swift/AST/ASTBridging.h"
|
|
-
|
|
-#include "swift/AST/DiagnosticEngine.h"
|
|
-#include "swift/Basic/BridgingUtils.h"
|
|
-
|
|
-using namespace swift;
|
|
-
|
|
-namespace {
|
|
-/// BridgedDiagnosticEngine -> DiagnosticEngine *.
|
|
-DiagnosticEngine *getDiagnosticEngine(const BridgedDiagnosticEngine &bridged) {
|
|
- return static_cast<DiagnosticEngine *>(bridged.object);
|
|
-}
|
|
-
|
|
-} // namespace
|
|
-
|
|
-void DiagnosticEngine_diagnose(
|
|
- BridgedDiagnosticEngine bridgedEngine, SourceLoc loc,
|
|
- BridgedDiagID bridgedDiagID,
|
|
- BridgedArrayRef /*DiagnosticArgument*/ bridgedArguments,
|
|
- CharSourceRange highlight,
|
|
- BridgedArrayRef /*DiagnosticInfo::FixIt*/ bridgedFixIts) {
|
|
- auto *D = getDiagnosticEngine(bridgedEngine);
|
|
-
|
|
- auto diagID = static_cast<DiagID>(bridgedDiagID);
|
|
- SmallVector<DiagnosticArgument, 2> arguments;
|
|
- for (auto arg : getArrayRef<DiagnosticArgument>(bridgedArguments)) {
|
|
- arguments.push_back(arg);
|
|
- }
|
|
- auto inflight = D->diagnose(loc, diagID, arguments);
|
|
-
|
|
- // Add highlight.
|
|
- if (highlight.isValid()) {
|
|
- inflight.highlightChars(highlight.getStart(), highlight.getEnd());
|
|
- }
|
|
-
|
|
- // Add fix-its.
|
|
- for (auto fixIt : getArrayRef<DiagnosticInfo::FixIt>(bridgedFixIts)) {
|
|
- auto range = fixIt.getRange();
|
|
- auto text = fixIt.getText();
|
|
- inflight.fixItReplaceChars(range.getStart(), range.getEnd(), text);
|
|
- }
|
|
-}
|
|
-
|
|
-bool DiagnosticEngine_hadAnyError(BridgedDiagnosticEngine bridgedEngine) {
|
|
- auto *D = getDiagnosticEngine(bridgedEngine);
|
|
- return D->hadAnyError();
|
|
-}
|
|
diff --git a/swift/lib/AST/CMakeLists.txt b/swift/lib/AST/CMakeLists.txt
|
|
index 9e5590b7315db..7222554f3b0af 100644
|
|
--- a/swift/lib/AST/CMakeLists.txt
|
|
+++ b/swift/lib/AST/CMakeLists.txt
|
|
@@ -10,7 +10,6 @@ add_swift_host_library(swiftAST STATIC
|
|
AccessNotes.cpp
|
|
AccessRequests.cpp
|
|
ArgumentList.cpp
|
|
- ASTBridging.cpp
|
|
ASTContext.cpp
|
|
ASTDemangler.cpp
|
|
ASTDumper.cpp
|
|
diff --git a/swift/lib/ASTGen/CMakeLists.txt b/swift/lib/ASTGen/CMakeLists.txt
|
|
index b80782f838e52..90367cf6caba1 100644
|
|
--- a/swift/lib/ASTGen/CMakeLists.txt
|
|
+++ b/swift/lib/ASTGen/CMakeLists.txt
|
|
@@ -5,6 +5,26 @@ add_pure_swift_host_library(swiftLLVMJSON STATIC EMIT_MODULE
|
|
swiftBasic
|
|
)
|
|
|
|
+set(ASTGen_Swift_dependencies swiftLLVMJSON)
|
|
+
|
|
+# If requested, build the regular expression parser into the compiler itself.
|
|
+if(SWIFT_BUILD_REGEX_PARSER_IN_COMPILER)
|
|
+ file(GLOB_RECURSE _LIBSWIFT_REGEX_PARSER_SOURCES
|
|
+ "${SWIFT_PATH_TO_STRING_PROCESSING_SOURCE}/Sources/_RegexParser/*.swift")
|
|
+ set(LIBSWIFT_REGEX_PARSER_SOURCES)
|
|
+ foreach(source ${_LIBSWIFT_REGEX_PARSER_SOURCES})
|
|
+ file(TO_CMAKE_PATH "${source}" source)
|
|
+ list(APPEND LIBSWIFT_REGEX_PARSER_SOURCES ${source})
|
|
+ endforeach()
|
|
+ message(STATUS "Using Experimental String Processing library for libswift _RegexParser (${SWIFT_PATH_TO_STRING_PROCESSING_SOURCE}).")
|
|
+
|
|
+ add_pure_swift_host_library(_CompilerRegexParser STATIC EMIT_MODULE
|
|
+ "${LIBSWIFT_REGEX_PARSER_SOURCES}"
|
|
+ )
|
|
+
|
|
+ list(APPEND ASTGen_Swift_dependencies _CompilerRegexParser)
|
|
+endif()
|
|
+
|
|
add_pure_swift_host_library(swiftASTGen STATIC
|
|
Sources/ASTGen/ASTGen.swift
|
|
Sources/ASTGen/Decls.swift
|
|
@@ -15,6 +35,7 @@ add_pure_swift_host_library(swiftASTGen STATIC
|
|
Sources/ASTGen/Macros.swift
|
|
Sources/ASTGen/Misc.swift
|
|
Sources/ASTGen/PluginHost.swift
|
|
+ Sources/ASTGen/Regex.swift
|
|
Sources/ASTGen/SourceFile.swift
|
|
Sources/ASTGen/SourceManager.swift
|
|
Sources/ASTGen/SourceManager+MacroExpansionContext.swift
|
|
@@ -34,5 +55,5 @@ add_pure_swift_host_library(swiftASTGen STATIC
|
|
SwiftSyntax::SwiftSyntaxBuilder
|
|
SwiftSyntax::SwiftSyntaxMacros
|
|
SwiftSyntax::SwiftSyntaxMacroExpansion
|
|
- swiftLLVMJSON
|
|
+ ${ASTGen_Swift_dependencies}
|
|
)
|
|
diff --git a/swift/lib/ASTGen/Package.swift b/swift/lib/ASTGen/Package.swift
|
|
index 151ea07f960ba..4965d3be9b2ca 100644
|
|
--- a/swift/lib/ASTGen/Package.swift
|
|
+++ b/swift/lib/ASTGen/Package.swift
|
|
@@ -24,6 +24,7 @@ let package = Package(
|
|
products: [
|
|
.library(name: "swiftASTGen", targets: ["swiftASTGen"]),
|
|
.library(name: "swiftLLVMJSON", targets: ["swiftLLVMJSON"]),
|
|
+ .library(name: "_CompilerRegexParser", targets: ["_CompilerRegexParser"]),
|
|
],
|
|
dependencies: [
|
|
.package(path: "../../../swift-syntax")
|
|
@@ -42,7 +43,8 @@ let package = Package(
|
|
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
|
|
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
|
|
.product(name: "SwiftSyntaxMacroExpansion", package: "swift-syntax"),
|
|
- "swiftLLVMJSON"
|
|
+ "swiftLLVMJSON",
|
|
+ "_CompilerRegexParser",
|
|
],
|
|
path: "Sources/ASTGen",
|
|
swiftSettings: swiftSetttings
|
|
@@ -53,5 +55,11 @@ let package = Package(
|
|
path: "Sources/LLVMJSON",
|
|
swiftSettings: swiftSetttings
|
|
),
|
|
+ .target(
|
|
+ name: "_CompilerRegexParser",
|
|
+ dependencies: [],
|
|
+ path: "_RegexParser_Sources",
|
|
+ swiftSettings: swiftSetttings
|
|
+ ),
|
|
]
|
|
)
|
|
diff --git a/swift/SwiftCompilerSources/Sources/Parse/Regex.swift b/swift/lib/ASTGen/Sources/ASTGen/Regex.swift
|
|
similarity index 80%
|
|
rename from swift/SwiftCompilerSources/Sources/Parse/Regex.swift
|
|
rename to swift/lib/ASTGen/Sources/ASTGen/Regex.swift
|
|
index a2229bc6fbc24..b8342fb909bc2 100644
|
|
--- a/swift/SwiftCompilerSources/Sources/Parse/Regex.swift
|
|
+++ b/swift/lib/ASTGen/Sources/ASTGen/Regex.swift
|
|
@@ -10,14 +10,14 @@
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
-import _RegexParserBridging
|
|
-import AST
|
|
-import Basic
|
|
+import CBasicBridging
|
|
+import CASTBridging
|
|
|
|
#if canImport(_CompilerRegexParser)
|
|
@_spi(CompilerInterface) import _CompilerRegexParser
|
|
|
|
-func registerRegexParser() {
|
|
+@_cdecl("initializeSwiftParseModules")
|
|
+public func initializeSwiftParseModules() {
|
|
Parser_registerRegexLiteralParsingFn(_RegexLiteralParsingFn)
|
|
Parser_registerRegexLiteralLexingFn(_RegexLiteralLexingFn)
|
|
}
|
|
@@ -46,8 +47,8 @@ private func _RegexLiteralLexingFn(
|
|
_ curPtrPtr: UnsafeMutablePointer<UnsafePointer<CChar>>,
|
|
_ bufferEndPtr: UnsafePointer<CChar>,
|
|
_ mustBeRegex: CBool,
|
|
- _ bridgedDiagnosticEngine: BridgedOptionalDiagnosticEngine
|
|
-) -> /*CompletelyErroneous*/ CBool {
|
|
+ _ bridgedDiagnosticEngine: BridgedDiagnosticEngine
|
|
+) -> /*CompletelyErroneous*/ Bool {
|
|
let inputPtr = curPtrPtr.pointee
|
|
|
|
guard let (resumePtr, error) = swiftCompilerLexRegexLiteral(
|
|
@@ -62,10 +63,16 @@ private func _RegexLiteralLexingFn(
|
|
|
|
if let error = error {
|
|
// Emit diagnostic if diagnostics are enabled.
|
|
- if let diagEngine = DiagnosticEngine(bridged: bridgedDiagnosticEngine) {
|
|
- let startLoc = SourceLoc(
|
|
- locationInFile: error.location.assumingMemoryBound(to: UInt8.self))!
|
|
- diagEngine.diagnose(startLoc, .foreign_diagnostic, error.message)
|
|
+ if bridgedDiagnosticEngine.raw != nil {
|
|
+ let startLoc = BridgedSourceLoc(raw: error.location)
|
|
+ var message = error.message
|
|
+ let diag = message.withBridgedString { bridgedMessage in
|
|
+ Diagnostic_create(
|
|
+ bridgedDiagnosticEngine, .error, startLoc,
|
|
+ bridgedMessage
|
|
+ )
|
|
+ }
|
|
+ Diagnostic_finish(diag)
|
|
}
|
|
return error.completelyErroneous
|
|
}
|
|
@@ -92,7 +99,7 @@ public func _RegexLiteralParsingFn(
|
|
_ versionOut: UnsafeMutablePointer<CUnsignedInt>,
|
|
_ captureStructureOut: UnsafeMutableRawPointer,
|
|
_ captureStructureSize: CUnsignedInt,
|
|
- _ bridgedDiagnosticBaseLoc: swift.SourceLoc,
|
|
+ _ bridgedDiagnosticBaseLoc: BridgedSourceLoc,
|
|
_ bridgedDiagnosticEngine: BridgedDiagnosticEngine
|
|
) -> Bool {
|
|
let str = String(cString: inputPtr)
|
|
@@ -106,13 +113,20 @@ public func _RegexLiteralParsingFn(
|
|
versionOut.pointee = CUnsignedInt(version)
|
|
return false
|
|
} catch let error as CompilerParseError {
|
|
- var diagLoc = SourceLoc(bridged: bridgedDiagnosticBaseLoc)
|
|
- let diagEngine = DiagnosticEngine(bridged: bridgedDiagnosticEngine)
|
|
- if let _diagLoc = diagLoc, let errorLoc = error.location {
|
|
+ var diagLoc = bridgedDiagnosticBaseLoc
|
|
+ if diagLoc.raw != nil, let errorLoc = error.location {
|
|
let offset = str.utf8.distance(from: str.startIndex, to: errorLoc)
|
|
- diagLoc = _diagLoc.advanced(by: offset)
|
|
+ diagLoc = SourceLoc_advanced(diagLoc, SwiftInt(offset))
|
|
+ }
|
|
+
|
|
+ var message = error.message
|
|
+ let diag = message.withBridgedString { bridgedMessage in
|
|
+ Diagnostic_create(
|
|
+ bridgedDiagnosticEngine, .error, diagLoc,
|
|
+ bridgedMessage
|
|
+ )
|
|
}
|
|
- diagEngine.diagnose(diagLoc, .foreign_diagnostic, error.message)
|
|
+ Diagnostic_finish(diag)
|
|
return true
|
|
} catch {
|
|
fatalError("Expected CompilerParseError")
|
|
diff --git a/swift/lib/ASTGen/_RegexParser_Sources b/swift/lib/ASTGen/_RegexParser_Sources
|
|
new file mode 120000
|
|
index 0000000000000..b52a98d0897ed
|
|
--- /dev/null
|
|
+++ b/swift/lib/ASTGen/_RegexParser_Sources
|
|
@@ -0,0 +1 @@
|
|
+../../../swift-experimental-string-processing/Sources/_RegexParser
|
|
\ No newline at end of file
|
|
diff --git a/swift/lib/DriverTool/driver.cpp b/swift/lib/DriverTool/driver.cpp
|
|
index af3b576aef2a2..a9666e628b95e 100644
|
|
--- a/swift/lib/DriverTool/driver.cpp
|
|
+++ b/swift/lib/DriverTool/driver.cpp
|
|
@@ -220,6 +220,8 @@ static llvm::SmallVector<const char *, 32> eraseFirstArg(ArrayRef<const char *>
|
|
static int run_driver(StringRef ExecName,
|
|
ArrayRef<const char *> argv,
|
|
const ArrayRef<const char *> originalArgv) {
|
|
+ initializeSwiftParseModules();
|
|
+
|
|
// This is done here and not done in FrontendTool.cpp, because
|
|
// FrontendTool.cpp is linked to tools, which don't use swift modules.
|
|
initializeSwiftModules();
|
|
diff --git a/swift/tools/sil-opt/SILOpt.cpp b/swift/tools/sil-opt/SILOpt.cpp
|
|
index b1248d8994537..89d15bd58e234 100644
|
|
--- a/swift/tools/sil-opt/SILOpt.cpp
|
|
+++ b/swift/tools/sil-opt/SILOpt.cpp
|
|
@@ -20,7 +20,6 @@
|
|
#include "swift/AST/SILOptions.h"
|
|
#include "swift/Basic/FileTypes.h"
|
|
#include "swift/Basic/LLVMInitialize.h"
|
|
-#include "swift/Basic/InitializeSwiftModules.h"
|
|
#include "swift/Basic/QuotedString.h"
|
|
#include "swift/Frontend/DiagnosticVerifier.h"
|
|
#include "swift/Frontend/Frontend.h"
|
|
diff --git a/swift/lib/Parse/Lexer.cpp b/swift/lib/Parse/Lexer.cpp
|
|
index 80e0a7182b711..b0c3dd032314f 100644
|
|
--- a/swift/lib/Parse/Lexer.cpp
|
|
+++ b/swift/lib/Parse/Lexer.cpp
|
|
@@ -15,13 +15,12 @@
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "swift/Parse/Lexer.h"
|
|
-#include "swift/AST/BridgingUtils.h"
|
|
+#include "swift/AST/CASTBridging.h"
|
|
#include "swift/AST/DiagnosticsParse.h"
|
|
#include "swift/AST/Identifier.h"
|
|
#include "swift/Basic/LangOptions.h"
|
|
#include "swift/Basic/SourceManager.h"
|
|
#include "swift/Parse/Confusables.h"
|
|
-#include "swift/Parse/RegexParserBridging.h"
|
|
#include "llvm/ADT/SmallString.h"
|
|
#include "llvm/ADT/StringSwitch.h"
|
|
#include "llvm/ADT/Twine.h"
|
|
@@ -35,9 +34,12 @@
|
|
|
|
// Regex lexing delivered via libSwift.
|
|
static RegexLiteralLexingFn regexLiteralLexingFn = nullptr;
|
|
+
|
|
+#if SWIFT_BUILD_SWIFT_SYNTAX
|
|
void Parser_registerRegexLiteralLexingFn(RegexLiteralLexingFn fn) {
|
|
regexLiteralLexingFn = fn;
|
|
}
|
|
+#endif
|
|
|
|
using namespace swift;
|
|
|
|
@@ -2090,7 +2092,7 @@ const char *Lexer::tryScanRegexLiteral(const char *TokStart, bool MustBeRegex,
|
|
// recovered from.
|
|
auto *Ptr = TokStart;
|
|
CompletelyErroneous = regexLiteralLexingFn(
|
|
- &Ptr, BufferEnd, MustBeRegex, getBridgedOptionalDiagnosticEngine(Diags));
|
|
+ &Ptr, BufferEnd, MustBeRegex, BridgedDiagnosticEngine{Diags});
|
|
|
|
// If we didn't make any lexing progress, this isn't a regex literal and we
|
|
// should fallback to lexing as something else.
|
|
diff --git a/lib/Parse/ParseRegex.cpp b/swift/lib/Parse/ParseRegex.cpp
|
|
index 5ed804653d3e0..14d76e941cc27 100644
|
|
--- a/swift/lib/Parse/ParseRegex.cpp
|
|
+++ b/swift/lib/Parse/ParseRegex.cpp
|
|
@@ -14,17 +14,20 @@
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
-#include "swift/AST/BridgingUtils.h"
|
|
#include "swift/AST/DiagnosticsParse.h"
|
|
-#include "swift/Basic/BridgingUtils.h"
|
|
#include "swift/Parse/Parser.h"
|
|
+#include "swift/AST/CASTBridging.h"
|
|
|
|
// Regex parser delivered via Swift modules.
|
|
-#include "swift/Parse/RegexParserBridging.h"
|
|
static RegexLiteralParsingFn regexLiteralParsingFn = nullptr;
|
|
+
|
|
+#if SWIFT_BUILD_SWIFT_SYNTAX
|
|
void Parser_registerRegexLiteralParsingFn(RegexLiteralParsingFn fn) {
|
|
regexLiteralParsingFn = fn;
|
|
}
|
|
+#else
|
|
+extern "C" void initializeSwiftParseModules() { }
|
|
+#endif
|
|
|
|
using namespace swift;
|
|
|
|
@@ -44,8 +47,8 @@ ParserResult<Expr> Parser::parseExprRegexLiteral() {
|
|
regexLiteralParsingFn(regexText.str().c_str(), &version,
|
|
/*captureStructureOut*/ capturesBuf.data(),
|
|
/*captureStructureSize*/ capturesBuf.size(),
|
|
- /*diagBaseLoc*/ Tok.getLoc(),
|
|
- getBridgedDiagnosticEngine(&Diags));
|
|
+ /*diagBaseLoc*/ BridgedSourceLoc{Tok.getLoc().getOpaquePointerValue()},
|
|
+ BridgedDiagnosticEngine{&Diags});
|
|
auto loc = consumeToken();
|
|
SourceMgr.recordRegexLiteralStartLoc(loc);
|
|
|
|
diff --git a/test/IDE/complete_regex.swift b/swift/test/IDE/complete_regex.swift
|
|
index 587c3b24324ca..c5da4e05e02f9 100644
|
|
--- a/swift/test/IDE/complete_regex.swift
|
|
+++ b/swift/test/IDE/complete_regex.swift
|
|
@@ -1,4 +1,4 @@
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-ide-test -enable-bare-slash-regex -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t
|
|
diff --git a/test/SourceKit/CodeComplete/rdar95772803.swift b/swift/test/SourceKit/CodeComplete/rdar95772803.swift
|
|
index b68bca2571ad9..eec4f67e38ad2 100644
|
|
--- a/swift/test/SourceKit/CodeComplete/rdar95772803.swift
|
|
+++ b/swift/test/SourceKit/CodeComplete/rdar95772803.swift
|
|
@@ -11,4 +11,4 @@ var qux: Regex<Substring> { / x}/ }
|
|
// RUN: -req=complete -pos=4:28 %s -- -enable-bare-slash-regex %s == \
|
|
// RUN: -req=complete -pos=5:28 %s -- -enable-bare-slash-regex %s
|
|
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
diff --git a/test/SourceKit/Sema/sema_regex.swift b/swift/test/SourceKit/Sema/sema_regex.swift
|
|
index 2c657b36d4b7b..8620b9f13cf95 100644
|
|
--- a/swift/test/SourceKit/Sema/sema_regex.swift
|
|
+++ b/swift/test/SourceKit/Sema/sema_regex.swift
|
|
@@ -2,7 +2,7 @@ public func retRegex() -> Regex<Substring> {
|
|
/foo/
|
|
}
|
|
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
// RUN: %sourcekitd-test -req=sema %s -- %s -Xfrontend -enable-bare-slash-regex -Xfrontend -disable-availability-checking | %FileCheck %s
|
|
|
|
// CHECK: [
|
|
diff --git a/test/StringProcessing/Frontend/enable-flag.swift b/swift/test/StringProcessing/Frontend/enable-flag.swift
|
|
index 601cdb71e1a59..b1768a913dcc6 100644
|
|
--- a/swift/test/StringProcessing/Frontend/enable-flag.swift
|
|
+++ b/swift/test/StringProcessing/Frontend/enable-flag.swift
|
|
@@ -2,7 +2,7 @@
|
|
// RUN: %target-typecheck-verify-swift -disable-availability-checking -enable-experimental-string-processing -enable-bare-slash-regex
|
|
// RUN: %target-typecheck-verify-swift -disable-availability-checking -disable-experimental-string-processing -enable-experimental-string-processing -enable-bare-slash-regex
|
|
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
|
|
prefix operator /
|
|
|
|
diff --git a/test/StringProcessing/Parse/forward-slash-regex-disabled.swift b/swift/test/StringProcessing/Parse/forward-slash-regex-disabled.swift
|
|
index 4c491a4a863a0..db403c97dfea8 100644
|
|
--- a/swift/test/StringProcessing/Parse/forward-slash-regex-disabled.swift
|
|
+++ b/swift/test/StringProcessing/Parse/forward-slash-regex-disabled.swift
|
|
@@ -1,6 +1,6 @@
|
|
// RUN: %target-typecheck-verify-swift -disable-availability-checking
|
|
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
|
|
prefix operator /
|
|
prefix operator ^/
|
|
diff --git a/test/StringProcessing/Parse/forward-slash-regex-skipping-allowed.swift b/swift/test/StringProcessing/Parse/forward-slash-regex-skipping-allowed.swift
|
|
index e9b9c2b122c47..1974bd55c6044 100644
|
|
--- a/swift/test/StringProcessing/Parse/forward-slash-regex-skipping-allowed.swift
|
|
+++ b/swift/test/StringProcessing/Parse/forward-slash-regex-skipping-allowed.swift
|
|
@@ -4,7 +4,7 @@
|
|
// RUN: %{python} %utils/process-stats-dir.py --set-csv-baseline %t/stats.csv %t
|
|
// RUN: %FileCheck -input-file %t/stats.csv %s
|
|
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
|
|
// Make sure we can skip in all of the below cases.
|
|
|
|
diff --git a/test/StringProcessing/Parse/forward-slash-regex-skipping-invalid.swift b/swift/test/StringProcessing/Parse/forward-slash-regex-skipping-invalid.swift
|
|
index ccebc28bee855..23e3e8c16f9f0 100644
|
|
--- a/swift/test/StringProcessing/Parse/forward-slash-regex-skipping-invalid.swift
|
|
+++ b/swift/test/StringProcessing/Parse/forward-slash-regex-skipping-invalid.swift
|
|
@@ -2,7 +2,7 @@
|
|
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking -experimental-skip-non-inlinable-function-bodies-without-types
|
|
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking -experimental-skip-non-inlinable-function-bodies
|
|
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
|
|
// We don't consider this a regex literal when skipping as it has an initial
|
|
// space.
|
|
diff --git a/test/StringProcessing/Parse/forward-slash-regex-skipping.swift b/swift/test/StringProcessing/Parse/forward-slash-regex-skipping.swift
|
|
index e3e9c9d07048b..031bef3a1ef20 100644
|
|
--- a/swift/test/StringProcessing/Parse/forward-slash-regex-skipping.swift
|
|
+++ b/swift/test/StringProcessing/Parse/forward-slash-regex-skipping.swift
|
|
@@ -2,7 +2,7 @@
|
|
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking -experimental-skip-non-inlinable-function-bodies-without-types
|
|
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking -experimental-skip-non-inlinable-function-bodies
|
|
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
|
|
// Make sure we properly handle `/.../` regex literals in skipped function
|
|
// bodies. Currently we detect them and avoid skipping, but in the future we
|
|
diff --git a/test/StringProcessing/Parse/forward-slash-regex.swift b/swift/test/StringProcessing/Parse/forward-slash-regex.swift
|
|
index 22c6a654e6da0..f4990d4fcb4d4 100644
|
|
--- a/swift/test/StringProcessing/Parse/forward-slash-regex.swift
|
|
+++ b/swift/test/StringProcessing/Parse/forward-slash-regex.swift
|
|
@@ -1,5 +1,5 @@
|
|
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking -typo-correction-limit 0
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
// REQUIRES: concurrency
|
|
|
|
prefix operator /
|
|
diff --git a/test/StringProcessing/Parse/prefix-slash.swift b/swift/test/StringProcessing/Parse/prefix-slash.swift
|
|
index 4be97f55397e2..dbe33cac8d91c 100644
|
|
--- a/swift/test/StringProcessing/Parse/prefix-slash.swift
|
|
+++ b/swift/test/StringProcessing/Parse/prefix-slash.swift
|
|
@@ -1,5 +1,5 @@
|
|
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
|
|
// Test the behavior of prefix '/' with regex literals enabled.
|
|
|
|
diff --git a/test/StringProcessing/Parse/regex.swift b/swift/test/StringProcessing/Parse/regex.swift
|
|
index 797fc2af85eec..a25db9de0019c 100644
|
|
--- a/swift/test/StringProcessing/Parse/regex.swift
|
|
+++ b/swift/test/StringProcessing/Parse/regex.swift
|
|
@@ -1,5 +1,5 @@
|
|
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
|
|
_ = /abc/
|
|
_ = #/abc/#
|
|
diff --git a/test/StringProcessing/Parse/regex_parse_end_of_buffer.swift b/swift/test/StringProcessing/Parse/regex_parse_end_of_buffer.swift
|
|
index 5c62181c0c8c2..177dcd66bbf35 100644
|
|
--- a/swift/test/StringProcessing/Parse/regex_parse_end_of_buffer.swift
|
|
+++ b/swift/test/StringProcessing/Parse/regex_parse_end_of_buffer.swift
|
|
@@ -1,7 +1,7 @@
|
|
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
|
|
// Note there is purposefully no trailing newline here.
|
|
// expected-error@+2:20 {{unterminated regex literal}}
|
|
// expected-error@+1:25 {{cannot parse regular expression: expected ')'}}
|
|
-var unterminated = #/(xy
|
|
\ No newline at end of file
|
|
+var unterminated = #/(xy
|
|
diff --git a/test/StringProcessing/Parse/regex_parse_error.swift b/swift/test/StringProcessing/Parse/regex_parse_error.swift
|
|
index c719e33ad9b80..ffa05d1ac9a8c 100644
|
|
--- a/swift/test/StringProcessing/Parse/regex_parse_error.swift
|
|
+++ b/swift/test/StringProcessing/Parse/regex_parse_error.swift
|
|
@@ -1,5 +1,5 @@
|
|
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
|
|
_ = /(/ // expected-error@:7 {{expected ')'}}
|
|
_ = #/(/# // expected-error@:8 {{expected ')'}}
|
|
diff --git a/test/StringProcessing/Runtime/regex_basic.swift b/swift/test/StringProcessing/Runtime/regex_basic.swift
|
|
index 9ad6c31d30662..498894cd1dff6 100644
|
|
--- a/swift/test/StringProcessing/Runtime/regex_basic.swift
|
|
+++ b/swift/test/StringProcessing/Runtime/regex_basic.swift
|
|
@@ -1,6 +1,6 @@
|
|
// RUN: %target-run-simple-swift(-Xfrontend -enable-bare-slash-regex)
|
|
|
|
-// REQUIRES: swift_in_compiler,string_processing,executable_test
|
|
+// REQUIRES: swift_swift_parser,string_processing,executable_test
|
|
|
|
import StdlibUnittest
|
|
|
|
diff --git a/test/StringProcessing/SILGen/regex_literal_silgen.swift b/swift/test/StringProcessing/SILGen/regex_literal_silgen.swift
|
|
index 7d16c82d81040..3cfa2bba161af 100644
|
|
--- a/swift/test/StringProcessing/SILGen/regex_literal_silgen.swift
|
|
+++ b/swift/test/StringProcessing/SILGen/regex_literal_silgen.swift
|
|
@@ -1,5 +1,5 @@
|
|
// RUN: %target-swift-frontend -emit-silgen -enable-bare-slash-regex -disable-availability-checking %s | %FileCheck %s
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
|
|
var s = #/abc/#
|
|
// CHECK: [[REGEX_STR_LITERAL:%[0-9]+]] = string_literal utf8 "#/abc/#"
|
|
diff --git a/test/StringProcessing/Sema/regex_builder_fix_import_after_imports.swift b/swift/test/StringProcessing/Sema/regex_builder_fix_import_after_imports.swift
|
|
index 29e7881822ac1..acaf229511b91 100644
|
|
--- a/swift/test/StringProcessing/Sema/regex_builder_fix_import_after_imports.swift
|
|
+++ b/swift/test/StringProcessing/Sema/regex_builder_fix_import_after_imports.swift
|
|
@@ -7,7 +7,7 @@
|
|
|
|
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking -I %t
|
|
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
|
|
import A
|
|
|
|
diff --git a/test/StringProcessing/Sema/regex_builder_fix_import_decl.swift b/swift/test/StringProcessing/Sema/regex_builder_fix_import_decl.swift
|
|
index 31feb6744497d..a0df60f6cdfd3 100644
|
|
--- a/swift/test/StringProcessing/Sema/regex_builder_fix_import_decl.swift
|
|
+++ b/swift/test/StringProcessing/Sema/regex_builder_fix_import_decl.swift
|
|
@@ -1,6 +1,6 @@
|
|
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking
|
|
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
|
|
struct S {
|
|
func foo() {
|
|
diff --git a/test/StringProcessing/Sema/regex_builder_fix_import_top_level.swift b/swift/test/StringProcessing/Sema/regex_builder_fix_import_top_level.swift
|
|
index eaae05546891c..155b43f50d71a 100644
|
|
--- a/swift/test/StringProcessing/Sema/regex_builder_fix_import_top_level.swift
|
|
+++ b/swift/test/StringProcessing/Sema/regex_builder_fix_import_top_level.swift
|
|
@@ -1,6 +1,6 @@
|
|
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking
|
|
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
|
|
Regex {} // expected-error {{regex builder requires the 'RegexBuilder' module be imported'}} {{5:1-1=import RegexBuilder\n\n}}
|
|
|
|
diff --git a/test/StringProcessing/Sema/regex_builder_unavailable.swift b/swift/test/StringProcessing/Sema/regex_builder_unavailable.swift
|
|
index 38bf6049b31d3..7167315c87a34 100644
|
|
--- a/swift/test/StringProcessing/Sema/regex_builder_unavailable.swift
|
|
+++ b/swift/test/StringProcessing/Sema/regex_builder_unavailable.swift
|
|
@@ -1,6 +1,6 @@
|
|
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -target %target-cpu-apple-macosx12.0
|
|
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
// REQUIRES: OS=macosx
|
|
|
|
import RegexBuilder
|
|
diff --git a/test/StringProcessing/Sema/regex_literal_availability.swift b/swift/test/StringProcessing/Sema/regex_literal_availability.swift
|
|
index ec68855876783..bcf8cdce2d0fb 100644
|
|
--- a/swift/test/StringProcessing/Sema/regex_literal_availability.swift
|
|
+++ b/swift/test/StringProcessing/Sema/regex_literal_availability.swift
|
|
@@ -1,6 +1,6 @@
|
|
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -target %target-cpu-apple-macosx12.0
|
|
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
// REQUIRES: OS=macosx
|
|
|
|
_ = /x/ // expected-error {{'Regex' is only available in}}
|
|
diff --git a/test/StringProcessing/Sema/regex_literal_diagnostics.swift b/swift/test/StringProcessing/Sema/regex_literal_diagnostics.swift
|
|
index 0a0f0629669ba..e3ec4b77c70dd 100644
|
|
--- a/swift/test/StringProcessing/Sema/regex_literal_diagnostics.swift
|
|
+++ b/swift/test/StringProcessing/Sema/regex_literal_diagnostics.swift
|
|
@@ -1,6 +1,6 @@
|
|
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking
|
|
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
|
|
postfix operator ^^
|
|
postfix func ^^ <T> (_ x: T) -> T { x }
|
|
diff --git a/test/StringProcessing/Sema/regex_literal_type_inference.swift b/swift/test/StringProcessing/Sema/regex_literal_type_inference.swift
|
|
index 9cce7a1b0e76e..5ea94df139e08 100644
|
|
--- a/swift/test/StringProcessing/Sema/regex_literal_type_inference.swift
|
|
+++ b/swift/test/StringProcessing/Sema/regex_literal_type_inference.swift
|
|
@@ -1,5 +1,5 @@
|
|
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
|
|
let r0 = #/./#
|
|
let _: Regex<Substring> = r0
|
|
diff --git a/test/StringProcessing/Sema/string_processing_import.swift b/swift/test/StringProcessing/Sema/string_processing_import.swift
|
|
index 5a83931364d6b..200e0729f8b78 100644
|
|
--- a/swift/test/StringProcessing/Sema/string_processing_import.swift
|
|
+++ b/swift/test/StringProcessing/Sema/string_processing_import.swift
|
|
@@ -1,5 +1,5 @@
|
|
// RUN: %target-typecheck-verify-swift -disable-implicit-string-processing-module-import -disable-availability-checking
|
|
-// REQUIRES: swift_in_compiler
|
|
+// REQUIRES: swift_swift_parser
|
|
|
|
// expected-error @+1 {{missing 'Regex' declaration, probably because the '_StringProcessing' module was not imported properly}}
|
|
let r0 = #/./#
|
|
diff --git a/tools/SourceKit/tools/sourcekitd/lib/Service/Requests.cpp b/swift/tools/SourceKit/tools/sourcekitd/lib/Service/Requests.cpp
|
|
index dc9990e4ff141..54018ab10fca4 100644
|
|
--- a/swift/tools/SourceKit/tools/sourcekitd/lib/Service/Requests.cpp
|
|
+++ b/swift/tools/SourceKit/tools/sourcekitd/lib/Service/Requests.cpp
|
|
@@ -111,6 +111,7 @@ void sourcekitd::initializeService(
|
|
StringRef diagnosticDocumentationPath,
|
|
std::function<void(sourcekitd_response_t)> postNotification) {
|
|
INITIALIZE_LLVM();
|
|
+ initializeSwiftParseModules();
|
|
initializeSwiftModules();
|
|
llvm::EnablePrettyStackTrace();
|
|
GlobalCtx = new SourceKit::Context(swiftExecutablePath, runtimeLibPath,
|
|
diff --git a/tools/swift-ide-test/swift-ide-test.cpp b/swift/tools/swift-ide-test/swift-ide-test.cpp
|
|
index e676be519090f..f6e7a8ae6998b 100644
|
|
--- a/swift/tools/swift-ide-test/swift-ide-test.cpp
|
|
+++ b/swift/tools/swift-ide-test/swift-ide-test.cpp
|
|
@@ -4240,6 +4240,7 @@ std::string getDriverPath(StringRef MainExecutablePath) {
|
|
int main(int argc, char *argv[]) {
|
|
PROGRAM_START(argc, argv);
|
|
INITIALIZE_LLVM();
|
|
+ initializeSwiftParseModules();
|
|
initializeSwiftModules();
|
|
|
|
std::string mainExecutablePath = llvm::sys::fs::getMainExecutable(
|