// Clang plugin declaration // Copyright (C) 2024 Nguyễn Gia Phong // // This file is part of GoatC. // // GoatC is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // GoatC is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with GoatC. If not, see . #include #include namespace goatc { class Visitor : public clang::RecursiveASTVisitor { clang::ASTContext* ctx; public: Visitor(clang::ASTContext* ctx) : ctx {ctx} { } bool VisitDecl (clang::Decl*); }; class Consumer : public clang::ASTConsumer { Visitor visitor; /// Consuming source file that is not patched bool noop; void HandleTranslationUnit (clang::ASTContext&) override; public: Consumer (clang::ASTContext* ctx, bool noop) : visitor {ctx}, noop {noop} { } }; class Action : public clang::PluginASTAction { std::string source_file; std::unique_ptr CreateASTConsumer (clang::CompilerInstance&, llvm::StringRef) override; bool ParseArgs (const clang::CompilerInstance&, const std::vector &) override; clang::PluginASTAction::ActionType getActionType () override; }; } // namespace goatc static clang::FrontendPluginRegistry::Add X {"goatc", "chimera breeder"};