// // Created by erki on 24.02.21. // #ifndef C_ANALYZER_TESTASTCONSUMER_HPP #define C_ANALYZER_TESTASTCONSUMER_HPP #include #include #include class DebuggeringASTVisitor : public clang::RecursiveASTVisitor { public: explicit DebuggeringASTVisitor(clang::ASTContext* context) : _context(context) { } bool VisitBinaryOperator(clang::BinaryOperator* bo) { llvm::outs() << "OKAY FUCK YOU\n"; bo->dump(); return true; } private: clang::ASTContext* _context; }; class DebuggeringASTConsumer : public clang::ASTConsumer { public: explicit DebuggeringASTConsumer(clang::ASTContext* context) : _visitor(context) { } void HandleTranslationUnit(clang::ASTContext& context) override { _visitor.TraverseAST(context); } private: DebuggeringASTVisitor _visitor; }; class DebuggeringASTAction : public clang::ASTFrontendAction { public: std::unique_ptr CreateASTConsumer( clang::CompilerInstance &Compiler, llvm::StringRef InFile) override { return std::unique_ptr( new DebuggeringASTConsumer(&Compiler.getASTContext())); } }; #endif //C_ANALYZER_TESTASTCONSUMER_HPP