mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Swift: rename classes to reflect they belong to Swift
This commit is contained in:
@@ -9,9 +9,9 @@ alias(
|
||||
cc_binary(
|
||||
name = "extractor",
|
||||
srcs = [
|
||||
"Extractor.h",
|
||||
"Extractor.cpp",
|
||||
"Configuration.h",
|
||||
"SwiftExtractor.h",
|
||||
"SwiftExtractor.cpp",
|
||||
"SwiftExtractorConfiguration.h",
|
||||
"main.cpp",
|
||||
],
|
||||
copts = [
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "Extractor.h"
|
||||
#include "SwiftExtractor.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
@@ -14,10 +14,11 @@
|
||||
|
||||
using namespace codeql;
|
||||
|
||||
Extractor::Extractor(const Configuration& config, swift::CompilerInstance& instance)
|
||||
SwiftExtractor::SwiftExtractor(const SwiftExtractorConfiguration& config,
|
||||
swift::CompilerInstance& instance)
|
||||
: config{config}, compiler{instance} {}
|
||||
|
||||
void Extractor::extract() {
|
||||
void SwiftExtractor::extract() {
|
||||
// Swift frontend can be called in several different modes, we are interested
|
||||
// only in the cases when either a primary or a main source file is present
|
||||
if (compiler.getPrimarySourceFiles().empty()) {
|
||||
@@ -35,7 +36,7 @@ void Extractor::extract() {
|
||||
}
|
||||
}
|
||||
|
||||
void Extractor::extractFile(swift::SourceFile& file) {
|
||||
void SwiftExtractor::extractFile(swift::SourceFile& file) {
|
||||
if (std::error_code ec = llvm::sys::fs::create_directories(config.trapDir)) {
|
||||
std::cerr << "Cannot create TRAP directory: " << ec.message() << "\n";
|
||||
return;
|
||||
@@ -102,4 +103,3 @@ void Extractor::extractFile(swift::SourceFile& file) {
|
||||
<< trapPath.str().str() << "': " << ec.message() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef SWIFT_EXTRACTOR_H_
|
||||
#define SWIFT_EXTRACTOR_H_
|
||||
|
||||
#include "Configuration.h"
|
||||
#include "SwiftExtractorConfiguration.h"
|
||||
#include <swift/AST/SourceFile.h>
|
||||
#include <swift/Frontend/Frontend.h>
|
||||
#include <memory>
|
||||
@@ -9,15 +9,16 @@
|
||||
namespace codeql {
|
||||
|
||||
// TODO: add documentation for the class and its public methods
|
||||
class Extractor {
|
||||
class SwiftExtractor {
|
||||
public:
|
||||
explicit Extractor(const Configuration& config, swift::CompilerInstance& instance);
|
||||
explicit SwiftExtractor(const SwiftExtractorConfiguration& config,
|
||||
swift::CompilerInstance& instance);
|
||||
void extract();
|
||||
|
||||
private:
|
||||
void extractFile(swift::SourceFile& file);
|
||||
|
||||
const Configuration& config;
|
||||
const SwiftExtractorConfiguration& config;
|
||||
swift::CompilerInstance& compiler;
|
||||
};
|
||||
} // namespace codeql
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <vector>
|
||||
|
||||
namespace codeql {
|
||||
struct Configuration {
|
||||
struct SwiftExtractorConfiguration {
|
||||
// The location for storing TRAP files to be imported by CodeQL engine.
|
||||
std::string trapDir;
|
||||
// The location for storing extracted source files.
|
||||
@@ -5,21 +5,21 @@
|
||||
#include <swift/Basic/LLVMInitialize.h>
|
||||
#include <swift/FrontendTool/FrontendTool.h>
|
||||
|
||||
#include "Extractor.h"
|
||||
#include "SwiftExtractor.h"
|
||||
|
||||
using namespace std::string_literals;
|
||||
|
||||
class Observer : public swift::FrontendObserver {
|
||||
public:
|
||||
explicit Observer(const codeql::Configuration& config) : config{config} {}
|
||||
explicit Observer(const codeql::SwiftExtractorConfiguration& config) : config{config} {}
|
||||
|
||||
void performedSemanticAnalysis(swift::CompilerInstance& instance) override {
|
||||
codeql::Extractor extractor(config, instance);
|
||||
codeql::SwiftExtractor extractor(config, instance);
|
||||
extractor.extract();
|
||||
}
|
||||
|
||||
private:
|
||||
const codeql::Configuration& config;
|
||||
const codeql::SwiftExtractorConfiguration& config;
|
||||
};
|
||||
|
||||
static std::string getenv_or(const char* envvar, const std::string& def) {
|
||||
@@ -38,7 +38,7 @@ int main(int argc, char** argv) {
|
||||
PROGRAM_START(argc, argv);
|
||||
INITIALIZE_LLVM();
|
||||
|
||||
codeql::Configuration configuration{};
|
||||
codeql::SwiftExtractorConfiguration configuration{};
|
||||
configuration.trapDir = getenv_or("CODEQL_EXTRACTOR_SWIFT_TRAP_DIR", ".");
|
||||
configuration.sourceArchiveDir = getenv_or("CODEQL_EXTRACTOR_SWIFT_SOURCE_ARCHIVE_DIR", ".");
|
||||
std::vector<const char*> args;
|
||||
|
||||
Reference in New Issue
Block a user