Skip to content

Commit d6cffbb

Browse files
authored
Merge pull request #62145 from CodaFi/synfonia
Delete libSyntax
2 parents 4e3a4ff + 37e7052 commit d6cffbb

File tree

218 files changed

+232
-19467
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

218 files changed

+232
-19467
lines changed

include/swift/AST/ASTContext.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,6 @@ namespace rewriting {
144144
class RewriteContext;
145145
}
146146

147-
namespace syntax {
148-
class SyntaxArena;
149-
}
150-
151147
namespace ide {
152148
class TypeCheckCompletionCallback;
153149
}
@@ -498,9 +494,6 @@ class ASTContext final {
498494
setVector.size());
499495
}
500496

501-
/// Retrieve the syntax node memory manager for this context.
502-
llvm::IntrusiveRefCntPtr<syntax::SyntaxArena> getSyntaxArena() const;
503-
504497
/// Set a new stats reporter.
505498
void setStatsReporter(UnifiedStatsReporter *stats);
506499

include/swift/AST/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ else()
55
endif()
66

77
set(generated_include_sources
8-
Attr.def.gyb)
8+
Attr.def.gyb
9+
TokenKinds.def.gyb)
910

1011
add_gyb_target(swift-ast-generated-headers
1112
"${generated_include_sources}")

include/swift/AST/Decl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6769,8 +6769,7 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
67696769
// FIXME: Remove 'Parsed' from this list once we can always delay
67706770
// parsing bodies. The -experimental-skip-*-function-bodies options
67716771
// do currently skip parsing, unless disabled through other means in
6772-
// SourceFile::hasDelayedBodyParsing (eg. needing to build the full
6773-
// syntax tree due to -verify-syntax-tree).
6772+
// SourceFile::hasDelayedBodyParsing.
67746773
assert(getBodyKind() == BodyKind::None ||
67756774
getBodyKind() == BodyKind::Unparsed ||
67766775
getBodyKind() == BodyKind::Parsed);

include/swift/AST/Expr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ class ObjectLiteralExpr final : public LiteralExpr {
11081108
/// The kind of object literal.
11091109
enum LiteralKind : unsigned {
11101110
#define POUND_OBJECT_LITERAL(Name, Desc, Proto) Name,
1111-
#include "swift/Syntax/TokenKinds.def"
1111+
#include "swift/AST/TokenKinds.def"
11121112
};
11131113

11141114
private:

include/swift/AST/Module.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,9 @@ namespace swift {
7575
class ValueDecl;
7676
class VarDecl;
7777
class VisibleDeclConsumer;
78-
class SyntaxParsingCache;
7978
class ASTScope;
8079
class SourceLookupCache;
8180

82-
namespace syntax {
83-
class SourceFileSyntax;
84-
}
8581
namespace ast_scope {
8682
class ASTSourceFileScope;
8783
}

include/swift/AST/ParseRequests.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "swift/AST/SimpleRequest.h"
2222
#include "swift/Basic/Fingerprint.h"
2323
#include "swift/Parse/Token.h"
24-
#include "swift/Syntax/SyntaxNodes.h"
2524

2625
namespace swift {
2726

@@ -90,7 +89,6 @@ struct SourceFileParsingResult {
9089
ArrayRef<ASTNode> TopLevelItems;
9190
Optional<ArrayRef<Token>> CollectedTokens;
9291
Optional<StableHasher> InterfaceHasher;
93-
Optional<syntax::SourceFileSyntax> SyntaxRoot;
9492
};
9593

9694
/// Parse the top-level items of a SourceFile.

include/swift/AST/SourceFile.h

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,15 @@ class SourceFile final : public FileUnit {
7878
/// and the associated language option.
7979
DisablePoundIfEvaluation = 1 << 1,
8080

81-
/// Whether to build a syntax tree.
82-
BuildSyntaxTree = 1 << 2,
83-
8481
/// Whether to save the file's parsed tokens.
85-
CollectParsedTokens = 1 << 3,
82+
CollectParsedTokens = 1 << 2,
8683

8784
/// Whether to compute the interface hash of the file.
88-
EnableInterfaceHash = 1 << 4,
85+
EnableInterfaceHash = 1 << 3,
8986

9087
/// Whether to suppress warnings when parsing. This is set for secondary
9188
/// files, as they get parsed multiple times.
92-
SuppressWarnings = 1 << 5,
89+
SuppressWarnings = 1 << 4,
9390
};
9491
using ParsingOptions = OptionSet<ParsingFlags>;
9592

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

251-
/// A cache of syntax nodes that can be reused when creating the syntax tree
252-
/// for this file.
253-
swift::SyntaxParsingCache *SyntaxParsingCache = nullptr;
254-
255248
/// The list of local type declarations in the source file.
256249
llvm::SetVector<TypeDecl *> LocalTypeDecls;
257250

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

636-
bool shouldBuildSyntaxTree() const;
637-
638629
/// Whether the bodies of types and functions within this file can be lazily
639630
/// parsed.
640631
bool hasDelayedBodyParsing() const;
641632

642-
syntax::SourceFileSyntax getSyntaxRoot() const;
643-
644633
OpaqueTypeDecl *lookupOpaqueResultType(StringRef MangledName) override;
645634

646635
/// Do not call when inside an inactive clause (\c
@@ -660,9 +649,6 @@ class SourceFile final : public FileUnit {
660649
/// If not \c None, the underlying vector contains the parsed tokens of this
661650
/// source file.
662651
Optional<ArrayRef<Token>> AllCollectedTokens;
663-
664-
/// The root of the syntax tree representing the source file.
665-
std::unique_ptr<syntax::SourceFileSyntax> SyntaxRoot;
666652
};
667653

668654
inline SourceFile::ParsingOptions operator|(SourceFile::ParsingFlags lhs,

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -420,19 +420,6 @@ namespace swift {
420420
/// Whether collect tokens during parsing for syntax coloring.
421421
bool CollectParsedToken = false;
422422

423-
/// Whether to parse syntax tree. If the syntax tree is built, the generated
424-
/// AST may not be correct when syntax nodes are reused as part of
425-
/// incrementals parsing.
426-
bool BuildSyntaxTree = false;
427-
428-
/// Whether parsing is occurring for creation of syntax tree only, and no typechecking will occur after
429-
/// parsing e.g. when parsing for SwiftSyntax. This is intended to affect parsing, e.g. disable
430-
/// unnecessary name lookups that are not useful for pure syntactic parsing.
431-
bool ParseForSyntaxTreeOnly = false;
432-
433-
/// Whether to verify the parsed syntax tree and emit related diagnostics.
434-
bool VerifySyntaxTree = false;
435-
436423
/// Whether to disable the evaluation of '#if' decls, such that the bodies
437424
/// of active clauses aren't hoisted into the enclosing scope.
438425
bool DisablePoundIfEvaluation = false;

include/swift/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@ if(SWIFT_INCLUDE_TOOLS)
99
ESCAPE_QUOTES @ONLY)
1010
add_subdirectory(AST)
1111
add_subdirectory(Option)
12-
add_subdirectory(Parse)
13-
add_subdirectory(Syntax)
1412
endif()
1513

include/swift/Frontend/Frontend.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include "swift/Migrator/MigratorOptions.h"
3838
#include "swift/Parse/CodeCompletionCallbacks.h"
3939
#include "swift/Parse/Parser.h"
40-
#include "swift/Parse/SyntaxParsingCache.h"
4140
#include "swift/Sema/SourceLoader.h"
4241
#include "swift/Serialization/Validation.h"
4342
#include "swift/Subsystems.h"
@@ -96,10 +95,6 @@ class CompilerInvocation {
9695
IRGenOptions IRGenOpts;
9796
TBDGenOptions TBDGenOpts;
9897
ModuleInterfaceOptions ModuleInterfaceOpts;
99-
/// The \c SyntaxParsingCache to use when parsing the main file of this
100-
/// invocation
101-
SyntaxParsingCache *MainFileSyntaxParsingCache = nullptr;
102-
10398
llvm::MemoryBuffer *CodeCompletionBuffer = nullptr;
10499

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

299-
void setMainFileSyntaxParsingCache(SyntaxParsingCache *Cache) {
300-
MainFileSyntaxParsingCache = Cache;
301-
}
302-
303-
SyntaxParsingCache *getMainFileSyntaxParsingCache() const {
304-
return MainFileSyntaxParsingCache;
305-
}
306-
307294
void setParseStdlib() {
308295
FrontendOpts.ParseStdlib = true;
309296
}

include/swift/Frontend/FrontendOptions.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ class FrontendOptions {
126126
Typecheck, ///< Parse and type-check only
127127
DumpParse, ///< Parse only and dump AST
128128
DumpInterfaceHash, ///< Parse and dump the interface token hash.
129-
EmitSyntax, ///< Parse and dump Syntax tree as JSON
130129
DumpAST, ///< Parse, type-check, and dump AST
131130
PrintAST, ///< Parse, type-check, and pretty-print AST
132131
PrintASTDecl, ///< Parse, type-check, and pretty-print AST declarations

include/swift/Frontend/ModuleInterfaceLoader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
#include "swift/Frontend/ModuleInterfaceSupport.h"
113113
#include "swift/Serialization/SerializedModuleLoader.h"
114114
#include "llvm/Support/StringSaver.h"
115+
#include "llvm/Support/YAMLTraits.h"
115116

116117
namespace clang {
117118
class CompilerInstance;

include/swift/IDE/CodeCompletionResult.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ enum class CodeCompletionKeywordKind : uint8_t {
184184
None,
185185
#define KEYWORD(X) kw_##X,
186186
#define POUND_KEYWORD(X) pound_##X,
187-
#include "swift/Syntax/TokenKinds.def"
187+
#include "swift/AST/TokenKinds.def"
188188
};
189189

190190
enum class CompletionKind : uint8_t {

include/swift/IDE/CompletionLookup.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
#include "swift/IDE/CodeCompletionResult.h"
2727
#include "swift/IDE/CodeCompletionStringPrinter.h"
2828
#include "swift/IDE/PossibleParamInfo.h"
29+
#include "swift/Parse/CodeCompletionCallbacks.h"
2930
#include "swift/Sema/IDETypeChecking.h"
3031
#include "swift/Strings.h"
31-
#include "swift/Syntax/SyntaxKind.h"
3232

3333
namespace swift {
3434
namespace ide {
@@ -600,7 +600,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
600600

601601
void collectPrecedenceGroups();
602602

603-
void getPrecedenceGroupCompletions(syntax::SyntaxKind SK);
603+
void getPrecedenceGroupCompletions(CodeCompletionCallbacks::PrecedenceGroupCompletionKind SK);
604604

605605
void getPoundAvailablePlatformCompletions();
606606

include/swift/IDE/CompletionOverrideLookup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "swift/AST/NameLookup.h"
1717
#include "swift/IDE/CodeCompletionResultSink.h"
1818
#include "swift/Sema/IDETypeChecking.h"
19-
#include "swift/Syntax/TokenKinds.h"
19+
#include "swift/Parse/Token.h"
2020

2121
namespace swift {
2222
namespace ide {

include/swift/Migrator/MigrationState.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#ifndef SWIFT_MIGRATOR_MIGRATIONSTATE_H
1919
#define SWIFT_MIGRATOR_MIGRATIONSTATE_H
2020

21-
#include "swift/Syntax/References.h"
2221
#include "llvm/ADT/IntrusiveRefCntPtr.h"
2322
#include "llvm/ADT/StringRef.h"
2423

@@ -78,19 +77,19 @@ struct MigrationState : public llvm::ThreadSafeRefCountedBase<MigrationState> {
7877
return InputBufferID == OutputBufferID;
7978
}
8079

81-
static RC<MigrationState>
80+
static llvm::IntrusiveRefCntPtr<MigrationState>
8281
start(SourceManager &SrcMgr, const unsigned InputBufferID) {
83-
return RC<MigrationState> {
82+
return llvm::IntrusiveRefCntPtr<MigrationState> {
8483
new MigrationState {
8584
MigrationKind::Start, SrcMgr, InputBufferID, InputBufferID
8685
}
8786
};
8887
}
8988

90-
static RC<MigrationState>
89+
static llvm::IntrusiveRefCntPtr<MigrationState>
9190
make(MigrationKind Kind, SourceManager &SrcMgr, const unsigned InputBufferID,
9291
const unsigned OutputBufferID) {
93-
return RC<MigrationState> {
92+
return llvm::IntrusiveRefCntPtr<MigrationState> {
9493
new MigrationState {
9594
Kind,
9695
SrcMgr,

include/swift/Migrator/Migrator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#define SWIFT_MIGRATOR_MIGRATOR_H
1919

2020
#include "swift/Migrator/MigrationState.h"
21-
#include "swift/Syntax/References.h"
21+
#include "llvm/ADT/IntrusiveRefCntPtr.h"
2222

2323
namespace swift {
2424
class CompilerInstance;
@@ -39,7 +39,7 @@ struct Migrator {
3939
CompilerInstance *StartInstance;
4040
const CompilerInvocation &StartInvocation;
4141
SourceManager SrcMgr;
42-
std::vector<RC<MigrationState>> States;
42+
std::vector<llvm::IntrusiveRefCntPtr<MigrationState>> States;
4343

4444
Migrator(CompilerInstance *StartInstance,
4545
const CompilerInvocation &StartInvocation);

include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,6 @@ def verify_generic_signatures : Separate<["-"], "verify-generic-signatures">,
119119
MetaVarName<"<module-name>">,
120120
HelpText<"Verify the generic signatures in the given module">;
121121

122-
def verify_syntax_tree : Flag<["-"], "verify-syntax-tree">,
123-
HelpText<"Verify that no unknown nodes exist in the libSyntax tree">;
124-
125122
def show_diagnostics_after_fatal : Flag<["-"], "show-diagnostics-after-fatal">,
126123
HelpText<"Keep emitting subsequent diagnostics after a fatal error">;
127124

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

838-
def emit_syntax : Flag<["-"], "emit-syntax">,
839-
HelpText<"Parse input file(s) and emit the Syntax tree(s) as JSON">, ModeOpt;
840-
841835
def cxx_interop_getters_setters_as_properties :
842836
Flag<["-"], "cxx-interop-getters-setters-as-properties">,
843837
HelpText<"Import getters and setters as computed properties in Swift">,

include/swift/Parse/CMakeLists.txt

Lines changed: 0 additions & 16 deletions
This file was deleted.

include/swift/Parse/CodeCompletionCallbacks.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,15 @@ class CodeCompletionCallbacks {
192192
/// Complete 'async' and 'throws' at effects specifier position.
193193
virtual void completeEffectsSpecifier(bool hasAsync, bool hasThrows) {};
194194

195+
enum class PrecedenceGroupCompletionKind {
196+
Relation,
197+
Associativity,
198+
AttributeList,
199+
Assignment,
200+
};
195201
/// Complete within a precedence group decl or after a colon in an
196202
/// operator decl.
197-
virtual void completeInPrecedenceGroup(SyntaxKind SK) {};
203+
virtual void completeInPrecedenceGroup(PrecedenceGroupCompletionKind SK) {};
198204

199205
/// Complete the platform names inside #available statements.
200206
virtual void completePoundAvailablePlatform() {};

0 commit comments

Comments
 (0)