Skip to content

Commit 73a7c0e

Browse files
zoecarverDougGregor
authored andcommitted
Apply Doug's review comments
(cherry picked from commit ddede20)
1 parent 129fd38 commit 73a7c0e

File tree

17 files changed

+56
-37
lines changed

17 files changed

+56
-37
lines changed

include/swift/Basic/Features.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ EXPERIMENTAL_FEATURE(ParserSequenceFolding)
141141
/// Enables implicit some while also enabling existential `any`
142142
EXPERIMENTAL_FEATURE(ImplicitSome)
143143

144+
/// Parse using the Swift (swift-syntax) parser and use ASTGen.
145+
EXPERIMENTAL_FEATURE(SwiftParser)
146+
144147
#undef EXPERIMENTAL_FEATURE
145148
#undef UPCOMING_FEATURE
146149
#undef SUPPRESSIBLE_LANGUAGE_FEATURE

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,6 @@ namespace swift {
275275
/// disabled because it is not complete.
276276
bool EnableCXXInterop = false;
277277

278-
bool EnableSwiftParser = false;
279-
280278
/// Imports getters and setters as computed properties.
281279
bool CxxInteropGettersSettersAsProperties = false;
282280

include/swift/Option/Options.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,6 @@ def enable_experimental_swift_parser :
640640
Flags<[FrontendOption, HelpHidden, ModuleInterfaceOption]>,
641641
HelpText<"Enable the new and expiremental Swift parser + AST generation.">;
642642

643-
644643
def experimental_cxx_stdlib :
645644
Separate<["-"], "experimental-cxx-stdlib">,
646645
Flags<[HelpHidden]>,

lib/AST/ASTPrinter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3091,6 +3091,10 @@ static bool usesFeatureAdditiveArithmeticDerivedConformances(Decl *decl) {
30913091
return false;
30923092
}
30933093

3094+
static bool usesFeatureSwiftParser(Decl *decl) {
3095+
return false;
3096+
}
3097+
30943098
static void
30953099
suppressingFeatureNoAsyncAvailability(PrintOptions &options,
30963100
llvm::function_ref<void()> action) {

lib/AST/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ endif()
156156

157157
target_link_libraries(swiftAST
158158
PUBLIC swiftBasic
159-
PRIVATE legacySwiftSyntax)
159+
PRIVATE swiftSyntax)
160160
if(SWIFT_BUILD_ONLY_SYNTAXPARSERLIB)
161161
# Remove dependencies from clangBasic to avoid bringing along some llvm
162162
# libraries that we don't need to be building.

lib/ASTGen/CMakeLists.txt

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1-
add_subdirectory(${SWIFT_SOURCE_DIR}/../swift-syntax ${CMAKE_CURRENT_BINARY_DIR}/swift-syntax)
1+
# TODO: why do we need these on Linux?
2+
set(CMAKE_Swift_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <OBJECTS>")
3+
set(CMAKE_Swift_ARCHIVE_FINISH "")
24

3-
add_library(ASTGen
4-
ASTGen.swift)
5+
if (SWIFT_SWIFT_PARSER)
6+
add_library(ASTGen
7+
ASTGen.swift)
58

6-
target_compile_options(ASTGen PUBLIC
7-
"-emit-module-interface")
9+
target_link_libraries(ASTGen PUBLIC
10+
SwiftSyntax
11+
SwiftParser
12+
SwiftDiagnostics)
13+
14+
target_link_directories(ASTGen PUBLIC
15+
"${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/lib")
816

9-
target_link_libraries(ASTGen PUBLIC
10-
SwiftSyntax
11-
SwiftParser
12-
SwiftDiagnostics)
13-
14-
target_include_directories(SwiftParser PUBLIC
15-
"${CMAKE_CURRENT_BINARY_DIR}/../Parser/swift-syntax/SwiftSyntax"
16-
"${CMAKE_CURRENT_BINARY_DIR}/../Parser/swift-syntax/SwiftDiagnostics"
17-
"${CMAKE_CURRENT_BINARY_DIR}/../Parser/swift-syntax/SwiftParser")
17+
target_include_directories(ASTGen PUBLIC
18+
"${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/swift")
19+
else()
20+
add_library(ASTGen
21+
DummyASTGen.swift)
22+
endif()
1823

19-
set_property(GLOBAL APPEND PROPERTY SWIFTSYNTAX_EXPORTS ASTGen)
24+
set_target_properties(ASTGen PROPERTIES LINKER_LANGUAGE Swift)
2025

21-
install(TARGETS ASTGen
22-
EXPORT SwiftSyntaxTargets
23-
ARCHIVE DESTINATION lib
24-
LIBRARY DESTINATION lib
25-
RUNTIME DESTINATION bin)
26+
target_compile_options(ASTGen PUBLIC
27+
"-emit-module-interface")
2628

2729
add_dependencies(ASTGen swiftAST)

lib/ASTGen/DummyASTGen.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@_cdecl("parseTopLevelSwift")
2+
public func parseTopLevelSwift(
3+
buffer: UnsafePointer<CChar>, declContext: UnsafeMutableRawPointer,
4+
ctx: UnsafeMutableRawPointer,
5+
outputContext: UnsafeMutableRawPointer,
6+
callback: @convention(c) (UnsafeMutableRawPointer, UnsafeMutableRawPointer) -> Void
7+
) {
8+
fatalError("Please run build script with --early-swiftsyntax to use ASTGen.")
9+
}

lib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ list(APPEND LLVM_COMMON_DEPENDS swift-parse-syntax-generated-headers)
1919

2020
add_subdirectory(APIDigester)
2121
add_subdirectory(AST)
22-
add_subdirectory(ASTGen) # Must come before Parse
22+
add_subdirectory(ASTGen)
2323
add_subdirectory(ASTSectionImporter)
2424
add_subdirectory(Basic)
2525
add_subdirectory(ConstExtract)

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
863863
}
864864

865865
Opts.EnableCXXInterop |= Args.hasArg(OPT_enable_experimental_cxx_interop);
866-
Opts.EnableSwiftParser |= Args.hasArg(OPT_enable_experimental_swift_parser);
867866
Opts.EnableObjCInterop =
868867
Args.hasFlag(OPT_enable_objc_interop, OPT_disable_objc_interop,
869868
Target.isOSDarwin());

lib/Migrator/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ add_swift_host_library(swiftMigrator STATIC
5757
RewriteBufferEditsReceiver.cpp)
5858
target_link_libraries(swiftMigrator PRIVATE
5959
swiftIDE
60-
legacySwiftSyntax)
60+
swiftSyntax)
6161

6262
add_dependencies(swiftMigrator
6363
"symlink_migrator_data")

0 commit comments

Comments
 (0)