Skip to content

Commit 46fb041

Browse files
authored
Merge pull request #19384 from github/redsun82/swift-add-logs
Swift: add more debug logs
2 parents d4b083b + d9a6a63 commit 46fb041

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

swift/extractor/SwiftExtractor.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ void codeql::extractSwiftFiles(SwiftExtractorState& state, swift::CompilerInstan
210210
auto inputFiles = collectInputFilenames(compiler);
211211
std::vector<swift::ModuleDecl*> todo = collectLoadedModules(compiler);
212212
state.encounteredModules.insert(todo.begin(), todo.end());
213+
LOG_DEBUG("{} modules loaded", todo.size());
213214

214215
while (!todo.empty()) {
215216
auto module = todo.back();
@@ -223,13 +224,18 @@ void codeql::extractSwiftFiles(SwiftExtractorState& state, swift::CompilerInstan
223224
}
224225
isFromSourceFile = true;
225226
if (inputFiles.count(sourceFile->getFilename().str()) == 0) {
227+
LOG_DEBUG("skipping module {} from file {}, not in input files", module->getName().get(),
228+
sourceFile->getFilename());
226229
continue;
227230
}
231+
LOG_DEBUG("extracting module {} from input file {}", module->getName().get(),
232+
sourceFile->getFilename());
228233
archiveFile(state.configuration, *sourceFile);
229234
encounteredModules =
230235
extractDeclarations(state, compiler, *module, sourceFile, /*lazy declaration*/ nullptr);
231236
}
232237
if (!isFromSourceFile) {
238+
LOG_DEBUG("extracting module {} from non-source file", module->getName().get());
233239
encounteredModules = extractDeclarations(state, compiler, *module, /*source file*/ nullptr,
234240
/*lazy declaration*/ nullptr);
235241
}

swift/extractor/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class Observer : public swift::FrontendObserver {
9393
explicit Observer(const codeql::SwiftExtractorConfiguration& config) : state{config} {}
9494

9595
void parsedArgs(swift::CompilerInvocation& invocation) override {
96+
LOG_DEBUG("{}()", __func__);
9697
auto& options = invocation.getFrontendOptions();
9798
options.KeepASTContext = true;
9899
lockOutputSwiftModuleTraps(state, options);
@@ -101,18 +102,21 @@ class Observer : public swift::FrontendObserver {
101102
}
102103

103104
void configuredCompiler(swift::CompilerInstance& instance) override {
105+
LOG_DEBUG("{}()", __func__);
104106
// remove default consumers to avoid double messaging
105107
instance.getDiags().takeConsumers();
106108
instance.addDiagnosticConsumer(&diagConsumer);
107109
}
108110

109111
void performedCompilation(swift::CompilerInstance& compiler) override {
112+
LOG_DEBUG("{}()", __func__);
110113
codeql::extractSwiftFiles(state, compiler);
111114
codeql::extractSwiftInvocation(state, compiler, invocationTrap);
112115
codeql::extractExtractLazyDeclarations(state, compiler);
113116
}
114117

115118
void markSuccessfullyExtractedFiles() {
119+
LOG_DEBUG("{}()", __func__);
116120
codeql::SwiftLocationExtractor locExtractor{invocationTrap};
117121
for (const auto& src : state.sourceFiles) {
118122
auto fileLabel = locExtractor.emitFile(src);

0 commit comments

Comments
 (0)