Skip to content

Commit ffcb382

Browse files
committed
Swift: only consider Builting and __ObjC declarations as lazy
1 parent 276fec3 commit ffcb382

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

swift/extractor/SwiftExtractor.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,11 @@ static void cleanupPendingDeclarations(SwiftExtractorState& state) {
224224
}
225225
}
226226
}
227-
228227
static void extractLazy(SwiftExtractorState& state, swift::CompilerInstance& compiler) {
229228
cleanupPendingDeclarations(state);
230229
std::vector<const swift::Decl*> worklist;
231230
std::copy(std::begin(state.pendingDeclarations), std::end(state.pendingDeclarations),
232231
std::back_inserter(worklist));
233-
234232
for (auto pending : worklist) {
235233
extractDeclarations(state, compiler, *pending->getModuleContext(), nullptr, pending);
236234
}

swift/extractor/infra/SwiftDispatcher.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,18 @@ class SwiftDispatcher {
6060
return std::move(encounteredModules);
6161
}
6262

63-
void extractedDeclaration(const swift::Decl* decl) { state.emittedDeclarations.insert(decl); }
64-
void skippedDeclaration(const swift::Decl* decl) { state.pendingDeclarations.insert(decl); }
63+
void extractedDeclaration(const swift::Decl* decl) {
64+
swift::ModuleDecl* module = decl->getModuleContext();
65+
if (module->isBuiltinModule() || module->getName().str() == "__ObjC") {
66+
state.emittedDeclarations.insert(decl);
67+
}
68+
}
69+
void skippedDeclaration(const swift::Decl* decl) {
70+
swift::ModuleDecl* module = decl->getModuleContext();
71+
if (module->isBuiltinModule() || module->getName().str() == "__ObjC") {
72+
state.pendingDeclarations.insert(decl);
73+
}
74+
}
6575

6676
template <typename Entry>
6777
void emit(Entry&& entry) {

swift/extractor/translators/DeclTranslator.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <swift/AST/Decl.h>
44
#include <swift/AST/ASTMangler.h>
5+
#include <swift/AST/Module.h>
56

67
#include "swift/extractor/translators/TranslatorBase.h"
78
#include "swift/extractor/trap/generated/decl/TrapClasses.h"
@@ -73,8 +74,9 @@ class DeclTranslator : public AstTranslatorBase<DeclTranslator> {
7374
dispatcher.extractedDeclaration(&decl);
7475
entry.emplace(id);
7576
fillDecl(decl, *entry);
77+
} else {
78+
dispatcher.skippedDeclaration(&decl);
7679
}
77-
dispatcher.skippedDeclaration(&decl);
7880
return entry;
7981
}
8082

0 commit comments

Comments
 (0)