Skip to content

Commit b7235ff

Browse files
committed
---
yaml --- r: 348461 b: refs/heads/master c: 0e4fead h: refs/heads/master i: 348459: b4e040e
1 parent a557e2f commit b7235ff

File tree

13 files changed

+37
-129
lines changed

13 files changed

+37
-129
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 66d140dc4b4f27c1ded7dd752e861c56ff0578f9
2+
refs/heads/master: 0e4feadfbc32190a1feb3932607ed1ad3af0b778
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/Frontend/Frontend.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,6 @@ class CompilerInstance {
616616

617617
private:
618618
void createREPLFile(const ImplicitImports &implicitImports);
619-
std::unique_ptr<DelayedParsingCallbacks> computeDelayedParsingCallback();
620619

621620
void addMainFileToModule(const ImplicitImports &implicitImports);
622621

@@ -625,20 +624,17 @@ class CompilerInstance {
625624
SourceFile::ASTStage_t LimitStage);
626625

627626
void parseLibraryFile(unsigned BufferID,
628-
const ImplicitImports &implicitImports,
629-
DelayedParsingCallbacks *DelayedCB);
627+
const ImplicitImports &implicitImports);
630628

631629
/// Return true if had load error
632630
bool
633-
parsePartialModulesAndLibraryFiles(const ImplicitImports &implicitImports,
634-
DelayedParsingCallbacks *DelayedCB);
631+
parsePartialModulesAndLibraryFiles(const ImplicitImports &implicitImports);
635632

636633
OptionSet<TypeCheckingFlags> computeTypeCheckingOptions();
637634

638635
void forEachFileToTypeCheck(llvm::function_ref<void(SourceFile &)> fn);
639636

640637
void parseAndTypeCheckMainFileUpTo(SourceFile::ASTStage_t LimitStage,
641-
DelayedParsingCallbacks *DelayedParseCB,
642638
OptionSet<TypeCheckingFlags> TypeCheckOptions);
643639

644640
void finishTypeChecking(OptionSet<TypeCheckingFlags> TypeCheckOptions);

trunk/include/swift/Parse/DelayedParsingCallbacks.h

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

trunk/include/swift/Parse/Parser.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ namespace llvm {
4646
namespace swift {
4747
class CodeCompletionCallbacks;
4848
class DefaultArgumentInitializer;
49-
class DelayedParsingCallbacks;
5049
class DiagnosticEngine;
5150
class Expr;
5251
class Lexer;
@@ -165,14 +164,8 @@ class Parser {
165164

166165
LocalContext *CurLocalContext = nullptr;
167166

168-
DelayedParsingCallbacks *DelayedParseCB = nullptr;
169-
170167
bool isDelayedParsingEnabled() const {
171-
return DelayBodyParsing || DelayedParseCB != nullptr;
172-
}
173-
174-
void setDelayedParsingCallbacks(DelayedParsingCallbacks *DelayedParseCB) {
175-
this->DelayedParseCB = DelayedParseCB;
168+
return DelayBodyParsing || SourceMgr.getCodeCompletionLoc().isValid();
176169
}
177170

178171
void setCodeCompletionCallbacks(CodeCompletionCallbacks *Callbacks) {

trunk/include/swift/Subsystems.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ namespace swift {
4343
class CodeCompletionCallbacksFactory;
4444
class Decl;
4545
class DeclContext;
46-
class DelayedParsingCallbacks;
4746
class DiagnosticConsumer;
4847
class DiagnosticEngine;
4948
class Evaluator;
@@ -114,23 +113,29 @@ namespace swift {
114113
/// \param PersistentState if non-null the same PersistentState object can
115114
/// be used to resume parsing or parse delayed function bodies.
116115
///
117-
/// \param DelayedParseCB if non-null enables delayed parsing for function
118-
/// bodies.
119-
///
120116
/// \return true if the parser found code with side effects.
121117
bool parseIntoSourceFile(SourceFile &SF, unsigned BufferID, bool *Done,
122118
SILParserState *SIL = nullptr,
123119
PersistentParserState *PersistentState = nullptr,
124-
DelayedParsingCallbacks *DelayedParseCB = nullptr,
125120
bool DelayBodyParsing = true);
126121

122+
/// DEPRECATED: Only used to break LLDB/Swift dependency.
123+
inline
124+
bool parseIntoSourceFile(SourceFile &SF, unsigned BufferID, bool *Done,
125+
SILParserState *SIL,
126+
PersistentParserState *PersistentState,
127+
std::nullptr_t,
128+
bool DelayBodyParsing) {
129+
return parseIntoSourceFile(SF, BufferID, Done, SIL, PersistentState,
130+
DelayBodyParsing);
131+
}
132+
127133
/// Parse a single buffer into the given source file, until the full source
128134
/// contents are parsed.
129135
///
130136
/// \return true if the parser found code with side effects.
131137
bool parseIntoSourceFileFull(SourceFile &SF, unsigned BufferID,
132-
PersistentParserState *PersistentState = nullptr,
133-
DelayedParsingCallbacks *DelayedParseCB = nullptr,
138+
PersistentParserState *PersistentState = nullptr,
134139
bool DelayBodyParsing = true);
135140

136141
/// Finish the parsing by going over the nodes that were delayed

trunk/lib/Basic/SourceLoc.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ void SourceManager::verifyAllBuffers() const {
3535
}
3636

3737
SourceLoc SourceManager::getCodeCompletionLoc() const {
38+
if (CodeCompletionBufferID == 0U)
39+
return SourceLoc();
40+
3841
return getLocForBufferStart(CodeCompletionBufferID)
3942
.getAdvancedLoc(CodeCompletionOffset);
4043
}

trunk/lib/Frontend/Frontend.cpp

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "swift/Basic/SourceManager.h"
2525
#include "swift/Basic/Statistic.h"
2626
#include "swift/Frontend/ParseableInterfaceModuleLoader.h"
27-
#include "swift/Parse/DelayedParsingCallbacks.h"
2827
#include "swift/Parse/Lexer.h"
2928
#include "swift/SIL/SILModule.h"
3029
#include "swift/SILOptimizer/PassManager/Passes.h"
@@ -755,14 +754,6 @@ void CompilerInstance::createREPLFile(const ImplicitImports &implicitImports) {
755754
addAdditionalInitialImportsTo(SingleInputFile, implicitImports);
756755
}
757756

758-
std::unique_ptr<DelayedParsingCallbacks>
759-
CompilerInstance::computeDelayedParsingCallback() {
760-
if (Invocation.isCodeCompletion())
761-
return llvm::make_unique<CodeCompleteDelayedCallbacks>(
762-
SourceMgr.getCodeCompletionLoc());
763-
return nullptr;
764-
}
765-
766757
void CompilerInstance::addMainFileToModule(
767758
const ImplicitImports &implicitImports) {
768759
auto *MainFile = createSourceFileForMainModule(
@@ -773,13 +764,10 @@ void CompilerInstance::addMainFileToModule(
773764
void CompilerInstance::parseAndCheckTypesUpTo(
774765
const ImplicitImports &implicitImports, SourceFile::ASTStage_t limitStage) {
775766
FrontendStatsTracer tracer(Context->Stats, "parse-and-check-types");
776-
std::unique_ptr<DelayedParsingCallbacks> DelayedCB{
777-
computeDelayedParsingCallback()};
778767

779768
PersistentState = llvm::make_unique<PersistentParserState>();
780769

781-
bool hadLoadError = parsePartialModulesAndLibraryFiles(
782-
implicitImports, DelayedCB.get());
770+
bool hadLoadError = parsePartialModulesAndLibraryFiles(implicitImports);
783771
if (Invocation.isCodeCompletion()) {
784772
// When we are doing code completion, make sure to emit at least one
785773
// diagnostic, so that ASTContext is marked as erroneous. In this case
@@ -797,7 +785,7 @@ void CompilerInstance::parseAndCheckTypesUpTo(
797785
// In addition, the main file has parsing and type-checking
798786
// interwined.
799787
if (MainBufferID != NO_SUCH_BUFFER) {
800-
parseAndTypeCheckMainFileUpTo(limitStage, DelayedCB.get(), TypeCheckOptions);
788+
parseAndTypeCheckMainFileUpTo(limitStage, TypeCheckOptions);
801789
}
802790

803791
assert(llvm::all_of(MainModule->getFiles(), [](const FileUnit *File) -> bool {
@@ -843,8 +831,7 @@ void CompilerInstance::parseAndCheckTypesUpTo(
843831
}
844832

845833
void CompilerInstance::parseLibraryFile(
846-
unsigned BufferID, const ImplicitImports &implicitImports,
847-
DelayedParsingCallbacks *DelayedCB) {
834+
unsigned BufferID, const ImplicitImports &implicitImports) {
848835
FrontendStatsTracer tracer(Context->Stats, "parse-library-file");
849836

850837
auto *NextInput = createSourceFileForMainModule(
@@ -862,7 +849,7 @@ void CompilerInstance::parseLibraryFile(
862849
// Parser may stop at some erroneous constructions like #else, #endif
863850
// or '}' in some cases, continue parsing until we are done
864851
parseIntoSourceFile(*NextInput, BufferID, &Done, nullptr,
865-
PersistentState.get(), DelayedCB,
852+
PersistentState.get(),
866853
/*DelayedBodyParsing=*/!IsPrimary);
867854
} while (!Done);
868855

@@ -890,8 +877,7 @@ OptionSet<TypeCheckingFlags> CompilerInstance::computeTypeCheckingOptions() {
890877
}
891878

892879
bool CompilerInstance::parsePartialModulesAndLibraryFiles(
893-
const ImplicitImports &implicitImports,
894-
DelayedParsingCallbacks *DelayedCB) {
880+
const ImplicitImports &implicitImports) {
895881
FrontendStatsTracer tracer(Context->Stats,
896882
"parse-partial-modules-and-library-files");
897883
bool hadLoadError = false;
@@ -907,15 +893,14 @@ bool CompilerInstance::parsePartialModulesAndLibraryFiles(
907893
// Then parse all the library files.
908894
for (auto BufferID : InputSourceCodeBufferIDs) {
909895
if (BufferID != MainBufferID) {
910-
parseLibraryFile(BufferID, implicitImports, DelayedCB);
896+
parseLibraryFile(BufferID, implicitImports);
911897
}
912898
}
913899
return hadLoadError;
914900
}
915901

916902
void CompilerInstance::parseAndTypeCheckMainFileUpTo(
917903
SourceFile::ASTStage_t LimitStage,
918-
DelayedParsingCallbacks *DelayedParseCB,
919904
OptionSet<TypeCheckingFlags> TypeCheckOptions) {
920905
FrontendStatsTracer tracer(Context->Stats,
921906
"parse-and-typecheck-main-file");
@@ -939,7 +924,7 @@ void CompilerInstance::parseAndTypeCheckMainFileUpTo(
939924
// with 'sil' definitions.
940925
parseIntoSourceFile(MainFile, MainFile.getBufferID().getValue(), &Done,
941926
TheSILModule ? &SILContext : nullptr,
942-
PersistentState.get(), DelayedParseCB,
927+
PersistentState.get(),
943928
/*DelayedBodyParsing=*/false);
944929

945930
if (mainIsPrimary && (Done || CurTUElem < MainFile.Decls.size())) {
@@ -1066,7 +1051,7 @@ void CompilerInstance::performParseOnly(bool EvaluateConditionals,
10661051
BufferID);
10671052

10681053
parseIntoSourceFileFull(*NextInput, BufferID, PersistentState.get(),
1069-
nullptr, /*DelayBodyParsing=*/!IsPrimary);
1054+
/*DelayBodyParsing=*/!IsPrimary);
10701055
}
10711056

10721057
// Now parse the main file.
@@ -1076,7 +1061,7 @@ void CompilerInstance::performParseOnly(bool EvaluateConditionals,
10761061
MainFile.SyntaxParsingCache = Invocation.getMainFileSyntaxParsingCache();
10771062

10781063
parseIntoSourceFileFull(MainFile, MainFile.getBufferID().getValue(),
1079-
PersistentState.get(), nullptr,
1064+
PersistentState.get(),
10801065
/*DelayBodyParsing=*/false);
10811066
}
10821067

trunk/lib/IDE/REPLCodeCompletion.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "swift/AST/Module.h"
2121
#include "swift/Basic/LLVM.h"
2222
#include "swift/Basic/SourceManager.h"
23-
#include "swift/Parse/DelayedParsingCallbacks.h"
2423
#include "swift/Parse/Parser.h"
2524
#include "swift/IDE/CodeCompletion.h"
2625
#include "swift/Subsystems.h"
@@ -208,12 +207,9 @@ doCodeCompletion(SourceFile &SF, StringRef EnteredCode, unsigned *BufferID,
208207
const unsigned OriginalDeclCount = SF.Decls.size();
209208

210209
PersistentParserState PersistentState;
211-
std::unique_ptr<DelayedParsingCallbacks> DelayedCB(
212-
new CodeCompleteDelayedCallbacks(Ctx.SourceMgr.getCodeCompletionLoc()));
213210
bool Done;
214211
do {
215-
parseIntoSourceFile(SF, *BufferID, &Done, nullptr, &PersistentState,
216-
DelayedCB.get());
212+
parseIntoSourceFile(SF, *BufferID, &Done, nullptr, &PersistentState);
217213
} while (!Done);
218214
performTypeChecking(SF, PersistentState.getTopLevelContext(), None,
219215
OriginalDeclCount);

trunk/lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include "swift/Parse/Parser.h"
1818
#include "swift/Parse/CodeCompletionCallbacks.h"
19-
#include "swift/Parse/DelayedParsingCallbacks.h"
2019
#include "swift/Parse/ParsedSyntaxRecorder.h"
2120
#include "swift/Parse/ParseSILSupport.h"
2221
#include "swift/Parse/SyntaxParsingContext.h"
@@ -5387,9 +5386,8 @@ void Parser::consumeAbstractFunctionBody(AbstractFunctionDecl *AFD,
53875386

53885387
BodyRange.End = PreviousLoc;
53895388

5390-
if (DelayedParseCB &&
5391-
DelayedParseCB->shouldDelayFunctionBodyParsing(*this, AFD, Attrs,
5392-
BodyRange)) {
5389+
if (SourceMgr.getCodeCompletionLoc().isInvalid() ||
5390+
SourceMgr.rangeContainsCodeCompletionLoc(BodyRange)) {
53935391
AFD->setBodyDelayed(BodyRange);
53945392
} else {
53955393
AFD->setBodySkipped(BodyRange);

trunk/lib/Parse/ParseRequests.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,12 @@ BraceStmt *ParseAbstractFunctionBodyRequest::evaluate(
7474
}
7575

7676
case BodyKind::Unparsed: {
77-
// FIXME: It should be fine to delay body parsing of local functions, so
78-
// the DelayBodyParsing should go away entirely
7977
// FIXME: How do we configure code completion?
8078
SourceFile &sf = *afd->getDeclContext()->getParentSourceFile();
8179
SourceManager &sourceMgr = sf.getASTContext().SourceMgr;
8280
unsigned bufferID = sourceMgr.findBufferContainingLoc(afd->getLoc());
8381
Parser parser(bufferID, sf, static_cast<SILParserTUStateBase *>(nullptr),
84-
nullptr, nullptr, /*DelayBodyParsing=*/false);
82+
nullptr, nullptr);
8583
parser.SyntaxContext->setDiscard();
8684
auto body = parser.parseAbstractFunctionBodyDelayed(afd);
8785
afd->setBodyKind(BodyKind::Parsed);

trunk/lib/Parse/Parser.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "swift/Basic/Timer.h"
2626
#include "swift/Parse/Lexer.h"
2727
#include "swift/Parse/CodeCompletionCallbacks.h"
28-
#include "swift/Parse/DelayedParsingCallbacks.h"
2928
#include "swift/Parse/ParsedSyntaxNodes.h"
3029
#include "swift/Parse/ParsedSyntaxRecorder.h"
3130
#include "swift/Parse/ParseSILSupport.h"
@@ -112,7 +111,6 @@ void tokenize(const LangOptions &LangOpts, const SourceManager &SM,
112111
using namespace swift;
113112
using namespace swift::syntax;
114113

115-
void DelayedParsingCallbacks::anchor() { }
116114
void SILParserTUStateBase::anchor() { }
117115

118116
namespace {

0 commit comments

Comments
 (0)