Skip to content

Commit

Permalink
Swift: minimal 5.9 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Denisov committed Jul 5, 2023
1 parent b651c02 commit 3a727a5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 34 deletions.
4 changes: 2 additions & 2 deletions swift/extractor/SwiftExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ static std::unordered_set<swift::ModuleDecl*> extractDeclarations(
}

std::vector<swift::Token> comments;
if (primaryFile && primaryFile->getBufferID().hasValue()) {
if (primaryFile && primaryFile->getBufferID().has_value()) {
auto& sourceManager = compiler.getSourceMgr();
auto tokens = swift::tokenize(compiler.getInvocation().getLangOptions(), sourceManager,
primaryFile->getBufferID().getValue());
primaryFile->getBufferID().value());
for (auto& token : tokens) {
if (token.getKind() == swift::tok::comment) {
comments.push_back(token);
Expand Down
13 changes: 12 additions & 1 deletion swift/extractor/infra/SwiftTagTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ MAP(swift::Stmt, StmtTag)
MAP(swift::FailStmt, FailStmtTag)
MAP(swift::ThrowStmt, ThrowStmtTag)
MAP(swift::PoundAssertStmt, PoundAssertStmtTag)
MAP(swift::DiscardStmt, void) // TODO (introduced in 5.9)

MAP(swift::Argument, ArgumentTag)
MAP(swift::KeyPathExpr::Component, KeyPathComponentTag)
Expand Down Expand Up @@ -95,7 +96,7 @@ 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)
MAP(swift::BorrowExpr, void) // TODO (introduced in 5.9)
MAP(swift::AwaitExpr, AwaitExprTag)
MAP(swift::UnresolvedMemberChainResultExpr, UnresolvedMemberChainResultExprTag)
MAP(swift::AnyTryExpr, AnyTryExprTag)
Expand Down Expand Up @@ -189,6 +190,11 @@ 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)
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)

MAP(swift::Decl, DeclTag)
MAP(swift::ValueDecl, ValueDeclTag)
MAP(swift::TypeDecl, TypeDeclTag)
Expand Down Expand Up @@ -231,6 +237,7 @@ MAP(swift::Decl, DeclTag)
MAP(swift::PrefixOperatorDecl, PrefixOperatorDeclTag)
MAP(swift::PostfixOperatorDecl, PostfixOperatorDeclTag)
MAP(swift::MacroExpansionDecl, void) // TODO (introduced in 5.8)
MAP(swift::MissingDecl, void) // TODO (introduced in 5.9)

MAP(swift::Pattern, PatternTag)
MAP(swift::ParenPattern, ParenPatternTag)
Expand Down Expand Up @@ -266,6 +273,8 @@ MAP(swift::TypeBase, TypeTag)
MAP(swift::BuiltinUnsafeValueBufferType, BuiltinUnsafeValueBufferTypeTag)
MAP(swift::BuiltinDefaultActorStorageType, BuiltinDefaultActorStorageTypeTag)
MAP(swift::BuiltinVectorType, BuiltinVectorTypeTag)
MAP(swift::BuiltinPackIndexType, void) // TODO: (introduced in 5.9)
MAP(swift::BuiltinNonDefaultDistributedActorStorageType, void) // TODO: (introduced in 5.9)
MAP(swift::TupleType, TupleTypeTag)
MAP(swift::ReferenceStorageType, ReferenceStorageTypeTag)
MAP(swift::WeakStorageType, WeakStorageTypeTag)
Expand Down Expand Up @@ -307,13 +316,15 @@ 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)
MAP(swift::SILPackType, void) // TODO: (introduced in 5.9)
MAP(swift::ProtocolCompositionType, ProtocolCompositionTypeTag)
MAP(swift::ParameterizedProtocolType, ParameterizedProtocolTypeTag)
MAP(swift::ExistentialType, ExistentialTypeTag)
MAP(swift::LValueType, LValueTypeTag)
MAP(swift::InOutType, InOutTypeTag)
MAP(swift::PackType, void) // experimental variadic generics
MAP(swift::PackExpansionType, void) // experimental variadic generics
MAP(swift::PackElementType, void) // TODO: (introduced in 5.9)
MAP(swift::TypeVariableType, void) // created during type checking and only used for constraint checking
MAP(swift::SugarType, SugarTypeTag)
MAP(swift::ParenType, ParenTypeTag)
Expand Down
1 change: 0 additions & 1 deletion swift/third_party/load.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down

This file was deleted.

0 comments on commit 3a727a5

Please sign in to comment.