Swift: move location extraction logic into a separate class

This commit is contained in:
Alex Denisov
2023-03-01 11:32:50 +01:00
parent 97d5401118
commit b1aef82117
4 changed files with 100 additions and 61 deletions

View File

@@ -12,6 +12,7 @@
#include "swift/extractor/infra/TargetDomains.h"
#include "swift/extractor/SwiftBuiltinSymbols.h"
#include "swift/extractor/infra/file/Path.h"
#include "swift/extractor/infra/SwiftLocationExtractor.h"
using namespace codeql;
using namespace std::string_literals;
@@ -139,7 +140,9 @@ static std::unordered_set<swift::ModuleDecl*> extractDeclarations(
}
}
SwiftVisitor visitor(compiler.getSourceMgr(), *trap, module, primaryFile);
SwiftLocationExtractor locationExtractor(*trap);
locationExtractor.emitFile(primaryFile);
SwiftVisitor visitor(compiler.getSourceMgr(), *trap, locationExtractor, module, primaryFile);
auto topLevelDecls = getTopLevelDecls(module, primaryFile);
for (auto decl : topLevelDecls) {
visitor.extract(decl);