Skip to content

Delete libSyntax #62145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions include/swift/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,6 @@ namespace rewriting {
class RewriteContext;
}

namespace syntax {
class SyntaxArena;
}

namespace ide {
class TypeCheckCompletionCallback;
}
Expand Down Expand Up @@ -498,9 +494,6 @@ class ASTContext final {
setVector.size());
}

/// Retrieve the syntax node memory manager for this context.
llvm::IntrusiveRefCntPtr<syntax::SyntaxArena> getSyntaxArena() const;

/// Set a new stats reporter.
void setStatsReporter(UnifiedStatsReporter *stats);

Expand Down
3 changes: 2 additions & 1 deletion include/swift/AST/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ else()
endif()

set(generated_include_sources
Attr.def.gyb)
Attr.def.gyb
TokenKinds.def.gyb)

add_gyb_target(swift-ast-generated-headers
"${generated_include_sources}")
Expand Down
3 changes: 1 addition & 2 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6769,8 +6769,7 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
// FIXME: Remove 'Parsed' from this list once we can always delay
// parsing bodies. The -experimental-skip-*-function-bodies options
// do currently skip parsing, unless disabled through other means in
// SourceFile::hasDelayedBodyParsing (eg. needing to build the full
// syntax tree due to -verify-syntax-tree).
// SourceFile::hasDelayedBodyParsing.
assert(getBodyKind() == BodyKind::None ||
getBodyKind() == BodyKind::Unparsed ||
getBodyKind() == BodyKind::Parsed);
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ class ObjectLiteralExpr final : public LiteralExpr {
/// The kind of object literal.
enum LiteralKind : unsigned {
#define POUND_OBJECT_LITERAL(Name, Desc, Proto) Name,
#include "swift/Syntax/TokenKinds.def"
#include "swift/AST/TokenKinds.def"
};

private:
Expand Down
4 changes: 0 additions & 4 deletions include/swift/AST/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,9 @@ namespace swift {
class ValueDecl;
class VarDecl;
class VisibleDeclConsumer;
class SyntaxParsingCache;
class ASTScope;
class SourceLookupCache;

namespace syntax {
class SourceFileSyntax;
}
namespace ast_scope {
class ASTSourceFileScope;
}
Expand Down
2 changes: 0 additions & 2 deletions include/swift/AST/ParseRequests.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "swift/AST/SimpleRequest.h"
#include "swift/Basic/Fingerprint.h"
#include "swift/Parse/Token.h"
#include "swift/Syntax/SyntaxNodes.h"

namespace swift {

Expand Down Expand Up @@ -90,7 +89,6 @@ struct SourceFileParsingResult {
ArrayRef<ASTNode> TopLevelItems;
Optional<ArrayRef<Token>> CollectedTokens;
Optional<StableHasher> InterfaceHasher;
Optional<syntax::SourceFileSyntax> SyntaxRoot;
};

/// Parse the top-level items of a SourceFile.
Expand Down
20 changes: 3 additions & 17 deletions include/swift/AST/SourceFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,15 @@ class SourceFile final : public FileUnit {
/// and the associated language option.
DisablePoundIfEvaluation = 1 << 1,

/// Whether to build a syntax tree.
BuildSyntaxTree = 1 << 2,

/// Whether to save the file's parsed tokens.
CollectParsedTokens = 1 << 3,
CollectParsedTokens = 1 << 2,

/// Whether to compute the interface hash of the file.
EnableInterfaceHash = 1 << 4,
EnableInterfaceHash = 1 << 3,

/// Whether to suppress warnings when parsing. This is set for secondary
/// files, as they get parsed multiple times.
SuppressWarnings = 1 << 5,
SuppressWarnings = 1 << 4,
};
using ParsingOptions = OptionSet<ParsingFlags>;

Expand Down Expand Up @@ -248,10 +245,6 @@ class SourceFile final : public FileUnit {
/// code for it. Note this method returns \c false in WMO.
bool isPrimary() const { return IsPrimary; }

/// A cache of syntax nodes that can be reused when creating the syntax tree
/// for this file.
swift::SyntaxParsingCache *SyntaxParsingCache = nullptr;

/// The list of local type declarations in the source file.
llvm::SetVector<TypeDecl *> LocalTypeDecls;

Expand Down Expand Up @@ -633,14 +626,10 @@ class SourceFile final : public FileUnit {
/// them to be accessed from \c getAllTokens.
bool shouldCollectTokens() const;

bool shouldBuildSyntaxTree() const;

/// Whether the bodies of types and functions within this file can be lazily
/// parsed.
bool hasDelayedBodyParsing() const;

syntax::SourceFileSyntax getSyntaxRoot() const;

OpaqueTypeDecl *lookupOpaqueResultType(StringRef MangledName) override;

/// Do not call when inside an inactive clause (\c
Expand All @@ -660,9 +649,6 @@ class SourceFile final : public FileUnit {
/// If not \c None, the underlying vector contains the parsed tokens of this
/// source file.
Optional<ArrayRef<Token>> AllCollectedTokens;

/// The root of the syntax tree representing the source file.
std::unique_ptr<syntax::SourceFileSyntax> SyntaxRoot;
};

inline SourceFile::ParsingOptions operator|(SourceFile::ParsingFlags lhs,
Expand Down
13 changes: 0 additions & 13 deletions include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,19 +420,6 @@ namespace swift {
/// Whether collect tokens during parsing for syntax coloring.
bool CollectParsedToken = false;

/// Whether to parse syntax tree. If the syntax tree is built, the generated
/// AST may not be correct when syntax nodes are reused as part of
/// incrementals parsing.
bool BuildSyntaxTree = false;

/// Whether parsing is occurring for creation of syntax tree only, and no typechecking will occur after
/// parsing e.g. when parsing for SwiftSyntax. This is intended to affect parsing, e.g. disable
/// unnecessary name lookups that are not useful for pure syntactic parsing.
bool ParseForSyntaxTreeOnly = false;

/// Whether to verify the parsed syntax tree and emit related diagnostics.
bool VerifySyntaxTree = false;

/// Whether to disable the evaluation of '#if' decls, such that the bodies
/// of active clauses aren't hoisted into the enclosing scope.
bool DisablePoundIfEvaluation = false;
Expand Down
2 changes: 0 additions & 2 deletions include/swift/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@ if(SWIFT_INCLUDE_TOOLS)
ESCAPE_QUOTES @ONLY)
add_subdirectory(AST)
add_subdirectory(Option)
add_subdirectory(Parse)
add_subdirectory(Syntax)
endif()

13 changes: 0 additions & 13 deletions include/swift/Frontend/Frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "swift/Migrator/MigratorOptions.h"
#include "swift/Parse/CodeCompletionCallbacks.h"
#include "swift/Parse/Parser.h"
#include "swift/Parse/SyntaxParsingCache.h"
#include "swift/Sema/SourceLoader.h"
#include "swift/Serialization/Validation.h"
#include "swift/Subsystems.h"
Expand Down Expand Up @@ -96,10 +95,6 @@ class CompilerInvocation {
IRGenOptions IRGenOpts;
TBDGenOptions TBDGenOpts;
ModuleInterfaceOptions ModuleInterfaceOpts;
/// The \c SyntaxParsingCache to use when parsing the main file of this
/// invocation
SyntaxParsingCache *MainFileSyntaxParsingCache = nullptr;

llvm::MemoryBuffer *CodeCompletionBuffer = nullptr;

/// Code completion offset in bytes from the beginning of the main
Expand Down Expand Up @@ -296,14 +291,6 @@ class CompilerInvocation {
IRGenOptions &getIRGenOptions() { return IRGenOpts; }
const IRGenOptions &getIRGenOptions() const { return IRGenOpts; }

void setMainFileSyntaxParsingCache(SyntaxParsingCache *Cache) {
MainFileSyntaxParsingCache = Cache;
}

SyntaxParsingCache *getMainFileSyntaxParsingCache() const {
return MainFileSyntaxParsingCache;
}

void setParseStdlib() {
FrontendOpts.ParseStdlib = true;
}
Expand Down
1 change: 0 additions & 1 deletion include/swift/Frontend/FrontendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ class FrontendOptions {
Typecheck, ///< Parse and type-check only
DumpParse, ///< Parse only and dump AST
DumpInterfaceHash, ///< Parse and dump the interface token hash.
EmitSyntax, ///< Parse and dump Syntax tree as JSON
DumpAST, ///< Parse, type-check, and dump AST
PrintAST, ///< Parse, type-check, and pretty-print AST
PrintASTDecl, ///< Parse, type-check, and pretty-print AST declarations
Expand Down
1 change: 1 addition & 0 deletions include/swift/Frontend/ModuleInterfaceLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
#include "swift/Frontend/ModuleInterfaceSupport.h"
#include "swift/Serialization/SerializedModuleLoader.h"
#include "llvm/Support/StringSaver.h"
#include "llvm/Support/YAMLTraits.h"

namespace clang {
class CompilerInstance;
Expand Down
2 changes: 1 addition & 1 deletion include/swift/IDE/CodeCompletionResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ enum class CodeCompletionKeywordKind : uint8_t {
None,
#define KEYWORD(X) kw_##X,
#define POUND_KEYWORD(X) pound_##X,
#include "swift/Syntax/TokenKinds.def"
#include "swift/AST/TokenKinds.def"
};

enum class CompletionKind : uint8_t {
Expand Down
4 changes: 2 additions & 2 deletions include/swift/IDE/CompletionLookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#include "swift/IDE/CodeCompletionResult.h"
#include "swift/IDE/CodeCompletionStringPrinter.h"
#include "swift/IDE/PossibleParamInfo.h"
#include "swift/Parse/CodeCompletionCallbacks.h"
#include "swift/Sema/IDETypeChecking.h"
#include "swift/Strings.h"
#include "swift/Syntax/SyntaxKind.h"

namespace swift {
namespace ide {
Expand Down Expand Up @@ -600,7 +600,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {

void collectPrecedenceGroups();

void getPrecedenceGroupCompletions(syntax::SyntaxKind SK);
void getPrecedenceGroupCompletions(CodeCompletionCallbacks::PrecedenceGroupCompletionKind SK);

void getPoundAvailablePlatformCompletions();

Expand Down
2 changes: 1 addition & 1 deletion include/swift/IDE/CompletionOverrideLookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "swift/AST/NameLookup.h"
#include "swift/IDE/CodeCompletionResultSink.h"
#include "swift/Sema/IDETypeChecking.h"
#include "swift/Syntax/TokenKinds.h"
#include "swift/Parse/Token.h"

namespace swift {
namespace ide {
Expand Down
9 changes: 4 additions & 5 deletions include/swift/Migrator/MigrationState.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#ifndef SWIFT_MIGRATOR_MIGRATIONSTATE_H
#define SWIFT_MIGRATOR_MIGRATIONSTATE_H

#include "swift/Syntax/References.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/StringRef.h"

Expand Down Expand Up @@ -78,19 +77,19 @@ struct MigrationState : public llvm::ThreadSafeRefCountedBase<MigrationState> {
return InputBufferID == OutputBufferID;
}

static RC<MigrationState>
static llvm::IntrusiveRefCntPtr<MigrationState>
start(SourceManager &SrcMgr, const unsigned InputBufferID) {
return RC<MigrationState> {
return llvm::IntrusiveRefCntPtr<MigrationState> {
new MigrationState {
MigrationKind::Start, SrcMgr, InputBufferID, InputBufferID
}
};
}

static RC<MigrationState>
static llvm::IntrusiveRefCntPtr<MigrationState>
make(MigrationKind Kind, SourceManager &SrcMgr, const unsigned InputBufferID,
const unsigned OutputBufferID) {
return RC<MigrationState> {
return llvm::IntrusiveRefCntPtr<MigrationState> {
new MigrationState {
Kind,
SrcMgr,
Expand Down
4 changes: 2 additions & 2 deletions include/swift/Migrator/Migrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define SWIFT_MIGRATOR_MIGRATOR_H

#include "swift/Migrator/MigrationState.h"
#include "swift/Syntax/References.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"

namespace swift {
class CompilerInstance;
Expand All @@ -39,7 +39,7 @@ struct Migrator {
CompilerInstance *StartInstance;
const CompilerInvocation &StartInvocation;
SourceManager SrcMgr;
std::vector<RC<MigrationState>> States;
std::vector<llvm::IntrusiveRefCntPtr<MigrationState>> States;

Migrator(CompilerInstance *StartInstance,
const CompilerInvocation &StartInvocation);
Expand Down
6 changes: 0 additions & 6 deletions include/swift/Option/FrontendOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ def verify_generic_signatures : Separate<["-"], "verify-generic-signatures">,
MetaVarName<"<module-name>">,
HelpText<"Verify the generic signatures in the given module">;

def verify_syntax_tree : Flag<["-"], "verify-syntax-tree">,
HelpText<"Verify that no unknown nodes exist in the libSyntax tree">;

def show_diagnostics_after_fatal : Flag<["-"], "show-diagnostics-after-fatal">,
HelpText<"Keep emitting subsequent diagnostics after a fatal error">;

Expand Down Expand Up @@ -835,9 +832,6 @@ def emit_sorted_sil : Flag<["-"], "emit-sorted-sil">,
HelpText<"When printing SIL, print out all sil entities sorted by name to "
"ease diffing">;

def emit_syntax : Flag<["-"], "emit-syntax">,
HelpText<"Parse input file(s) and emit the Syntax tree(s) as JSON">, ModeOpt;

def cxx_interop_getters_setters_as_properties :
Flag<["-"], "cxx-interop-getters-setters-as-properties">,
HelpText<"Import getters and setters as computed properties in Swift">,
Expand Down
16 changes: 0 additions & 16 deletions include/swift/Parse/CMakeLists.txt

This file was deleted.

8 changes: 7 additions & 1 deletion include/swift/Parse/CodeCompletionCallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,15 @@ class CodeCompletionCallbacks {
/// Complete 'async' and 'throws' at effects specifier position.
virtual void completeEffectsSpecifier(bool hasAsync, bool hasThrows) {};

enum class PrecedenceGroupCompletionKind {
Relation,
Associativity,
AttributeList,
Assignment,
};
/// Complete within a precedence group decl or after a colon in an
/// operator decl.
virtual void completeInPrecedenceGroup(SyntaxKind SK) {};
virtual void completeInPrecedenceGroup(PrecedenceGroupCompletionKind SK) {};

/// Complete the platform names inside #available statements.
virtual void completePoundAvailablePlatform() {};
Expand Down
Loading