Skip to content

Commit 5808d9b

Browse files
committed
Parse: Remove parse-time name lookup
1 parent 641a257 commit 5808d9b

Some content is hidden

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

54 files changed

+39
-5084
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,6 @@ namespace swift {
258258
/// This is a staging flag; eventually it will be removed.
259259
bool EnableDeserializationRecovery = true;
260260

261-
/// Someday, ASTScopeLookup will supplant lookup in the parser
262-
bool DisableParserLookup = false;
263-
264261
/// Whether to enable the new operator decl and precedencegroup lookup
265262
/// behavior. This is a staging flag, and will be removed in the future.
266263
bool EnableNewOperatorLookup = false;

include/swift/Option/Options.td

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,14 +1118,6 @@ def emit_supported_features : Flag<["-"], "emit-supported-features">,
11181118
HelpText<"Emit a JSON file including all supported compiler features">, ModeOpt,
11191119
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>;
11201120

1121-
def disable_parser_lookup : Flag<["-"], "disable-parser-lookup">,
1122-
Flags<[FrontendOption]>,
1123-
HelpText<"Disable parser lookup & use ASTScope lookup only (experimental)">;
1124-
1125-
def enable_parser_lookup : Flag<["-"], "enable-parser-lookup">,
1126-
Flags<[FrontendOption]>,
1127-
HelpText<"Enable parser lookup">;
1128-
11291121
def enable_request_based_incremental_dependencies : Flag<["-"],
11301122
"enable-request-based-incremental-dependencies">,
11311123
Flags<[FrontendOption]>,

include/swift/Parse/Parser.h

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,6 @@ class Parser {
136136

137137
void recordTokenHash(StringRef token);
138138

139-
/// DisabledVars is a list of variables for whom local name lookup is
140-
/// disabled. This is used when parsing a PatternBindingDecl to reject self
141-
/// uses and to disable uses of the bound variables in a let/else block. The
142-
/// diagnostic to emit is stored in DisabledVarReason.
143-
ArrayRef<VarDecl *> DisabledVars;
144-
Diag<> DisabledVarReason;
145-
146139
enum {
147140
/// InVarOrLetPattern has this value when not parsing a pattern.
148141
IVOLP_NotInVarOrLet,
@@ -790,23 +783,6 @@ class Parser {
790783
consumeStartingCharacterOfCurrentToken(tok Kind = tok::oper_binary_unspaced,
791784
size_t Len = 1);
792785

793-
swift::ScopeInfo &getScopeInfo() { return State->getScopeInfo(); }
794-
795-
/// Add the given Decl to the current scope.
796-
void addToScope(ValueDecl *D, bool diagnoseRedefinitions = true) {
797-
if (Context.LangOpts.DisableParserLookup)
798-
return;
799-
800-
getScopeInfo().addToScope(D, *this, diagnoseRedefinitions);
801-
}
802-
803-
ValueDecl *lookupInScope(DeclNameRef Name) {
804-
if (Context.LangOpts.DisableParserLookup)
805-
return nullptr;
806-
807-
return getScopeInfo().lookupValueName(Name);
808-
}
809-
810786
//===--------------------------------------------------------------------===//
811787
// Primitive Parsing
812788

@@ -1171,9 +1147,6 @@ class Parser {
11711147
ParserResult<DestructorDecl>
11721148
parseDeclDeinit(ParseDeclOptions Flags, DeclAttributes &Attributes);
11731149

1174-
void addPatternVariablesToScope(ArrayRef<Pattern *> Patterns);
1175-
void addParametersToScope(ParameterList *PL);
1176-
11771150
ParserResult<OperatorDecl> parseDeclOperator(ParseDeclOptions Flags,
11781151
DeclAttributes &Attributes);
11791152
ParserResult<OperatorDecl> parseDeclOperatorImpl(SourceLoc OperatorLoc,
@@ -1224,8 +1197,7 @@ class Parser {
12241197
ParserResult<TypeRepr> parseOldStyleProtocolComposition();
12251198
ParserResult<TypeRepr> parseAnyType();
12261199
ParserResult<TypeRepr> parseSILBoxType(GenericParamList *generics,
1227-
const TypeAttributes &attrs,
1228-
Optional<Scope> &GenericsScope);
1200+
const TypeAttributes &attrs);
12291201

12301202
ParserResult<TypeRepr> parseTypeTupleBody();
12311203
ParserResult<TypeRepr> parseTypeArray(TypeRepr *Base);

include/swift/Parse/PersistentParserState.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#include "swift/Basic/SourceLoc.h"
2121
#include "swift/Parse/LocalContext.h"
22-
#include "swift/Parse/Scope.h"
2322

2423
namespace swift {
2524

@@ -38,33 +37,27 @@ class CodeCompletionDelayedDeclState {
3837
CodeCompletionDelayedDeclKind Kind;
3938
unsigned Flags;
4039
DeclContext *ParentContext;
41-
SavedScope Scope;
4240
unsigned StartOffset;
4341
unsigned EndOffset;
4442
unsigned PrevOffset;
4543

46-
SavedScope takeScope() { return std::move(Scope); }
47-
4844
CodeCompletionDelayedDeclState(CodeCompletionDelayedDeclKind Kind,
4945
unsigned Flags, DeclContext *ParentContext,
50-
SavedScope &&Scope, unsigned StartOffset,
51-
unsigned EndOffset, unsigned PrevOffset)
46+
unsigned StartOffset, unsigned EndOffset,
47+
unsigned PrevOffset)
5248
: Kind(Kind), Flags(Flags), ParentContext(ParentContext),
53-
Scope(std::move(Scope)), StartOffset(StartOffset), EndOffset(EndOffset),
49+
StartOffset(StartOffset), EndOffset(EndOffset),
5450
PrevOffset(PrevOffset) {}
5551
};
5652

5753
/// Parser state persistent across multiple parses.
5854
class PersistentParserState {
59-
swift::ScopeInfo ScopeInfo;
60-
6155
std::unique_ptr<CodeCompletionDelayedDeclState> CodeCompletionDelayedDeclStat;
6256

6357
/// The local context for all top-level code.
6458
TopLevelContext TopLevelCode;
6559

6660
public:
67-
swift::ScopeInfo &getScopeInfo() { return ScopeInfo; }
6861
PersistentParserState();
6962
PersistentParserState(ASTContext &ctx) : PersistentParserState() { }
7063
~PersistentParserState();

include/swift/Parse/Scope.h

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

lib/Driver/ToolChains.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,6 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI,
268268
inputArgs.AddLastArg(arguments, options::OPT_debug_diagnostic_names);
269269
inputArgs.AddLastArg(arguments, options::OPT_print_educational_notes);
270270
inputArgs.AddLastArg(arguments, options::OPT_diagnostic_style);
271-
inputArgs.AddLastArg(arguments, options::OPT_disable_parser_lookup);
272-
inputArgs.AddLastArg(arguments, options::OPT_enable_parser_lookup);
273271
inputArgs.AddLastArg(arguments,
274272
options::OPT_enable_experimental_concise_pound_file);
275273
inputArgs.AddLastArg(

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
434434
= A->getOption().matches(OPT_enable_target_os_checking);
435435
}
436436

437-
Opts.DisableParserLookup |= Args.hasFlag(OPT_disable_parser_lookup,
438-
OPT_enable_parser_lookup,
439-
/*default*/ true);
440437
Opts.EnableNewOperatorLookup = Args.hasFlag(OPT_enable_new_operator_lookup,
441438
OPT_disable_new_operator_lookup,
442439
/*default*/ false);

lib/IDE/CompletionInstance.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,6 @@ bool CompletionInstance::performCachedOperationIfPossible(
366366
tmpSM.setCodeCompletionPoint(tmpBufferID, Offset);
367367

368368
LangOptions langOpts = CI.getASTContext().LangOpts;
369-
langOpts.DisableParserLookup = true;
370369
TypeCheckerOptions typeckOpts = CI.getASTContext().TypeCheckerOpts;
371370
SearchPathOptions searchPathOpts = CI.getASTContext().SearchPathOpts;
372371
DiagnosticEngine tmpDiags(tmpSM);
@@ -444,17 +443,6 @@ bool CompletionInstance::performCachedOperationIfPossible(
444443
1);
445444
SM.setCodeCompletionPoint(newBufferID, newOffset);
446445

447-
// Construct dummy scopes. We don't need to restore the original scope
448-
// because they are probably not 'isResolvable()' anyway.
449-
auto &SI = oldState->getScopeInfo();
450-
assert(SI.getCurrentScope() == nullptr);
451-
Scope Top(SI, ScopeKind::TopLevel);
452-
Scope Body(SI, ScopeKind::FunctionBody);
453-
454-
assert(oldInfo.Kind == CodeCompletionDelayedDeclKind::FunctionBody &&
455-
"If the interface hash is the same as old one, the previous kind "
456-
"must be FunctionBody too. Otherwise, hashing is too weak");
457-
oldInfo.Kind = CodeCompletionDelayedDeclKind::FunctionBody;
458446
oldInfo.ParentContext = DC;
459447
oldInfo.StartOffset = newInfo.StartOffset;
460448
oldInfo.EndOffset = newInfo.EndOffset;

lib/Parse/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ add_swift_host_library(swiftParse STATIC
2222
ParseStmt.cpp
2323
ParseType.cpp
2424
PersistentParserState.cpp
25-
Scope.cpp
2625
SyntaxParsingCache.cpp
2726
SyntaxParsingContext.cpp)
2827
_swift_gyb_target_sources(swiftParse PRIVATE

0 commit comments

Comments
 (0)