Thunks/gen: Move definition of GenerateThunkLibsAction into gen.cpp

This commit is contained in:
Tony Wasserka 2022-09-12 18:14:11 +02:00
parent a583ebe590
commit 56460b220c
2 changed files with 19 additions and 18 deletions

View File

@ -394,6 +394,20 @@ public:
}
};
class GenerateThunkLibsAction : public clang::ASTFrontendAction {
public:
GenerateThunkLibsAction(const std::string& libname, const OutputFilenames&);
void EndSourceFileAction() override;
std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance&, clang::StringRef /*file*/) override;
private:
const std::string& libfilename;
std::string libname; // sanitized filename, usable as part of emitted function names
const OutputFilenames& output_filenames;
};
GenerateThunkLibsAction::GenerateThunkLibsAction(const std::string& libname_, const OutputFilenames& output_filenames_)
: libfilename(libname_), libname(libname_), output_filenames(output_filenames_) {
for (auto& c : libname) {
@ -738,3 +752,7 @@ void GenerateThunkLibsAction::EndSourceFileAction() {
std::unique_ptr<clang::ASTConsumer> GenerateThunkLibsAction::CreateASTConsumer(clang::CompilerInstance&, clang::StringRef) {
return std::make_unique<ASTConsumer>();
}
std::unique_ptr<clang::FrontendAction> GenerateThunkLibsActionFactory::create() {
return std::make_unique<GenerateThunkLibsAction>(libname, output_filenames);
}

View File

@ -1,4 +1,3 @@
#include <clang/Frontend/FrontendAction.h>
#include <clang/Tooling/Tooling.h>
#include <optional>
@ -9,29 +8,13 @@ struct OutputFilenames {
std::string guest;
};
class GenerateThunkLibsAction : public clang::ASTFrontendAction {
public:
GenerateThunkLibsAction(const std::string& libname, const OutputFilenames&);
void EndSourceFileAction() override;
std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance&, clang::StringRef /*file*/) override;
private:
const std::string& libfilename;
std::string libname; // sanitized filename, usable as part of emitted function names
const OutputFilenames& output_filenames;
};
class GenerateThunkLibsActionFactory : public clang::tooling::FrontendActionFactory {
public:
GenerateThunkLibsActionFactory(std::string_view libname_, OutputFilenames output_filenames_)
: libname(std::move(libname_)), output_filenames(std::move(output_filenames_)) {
}
std::unique_ptr<clang::FrontendAction> create() override {
return std::make_unique<GenerateThunkLibsAction>(libname, output_filenames);
}
std::unique_ptr<clang::FrontendAction> create() override;
private:
std::string libname;