// // Created by erki on 02.03.21. // #ifndef C_ANALYZER_OPERATIONFINDERASTVISITOR_HPP #define C_ANALYZER_OPERATIONFINDERASTVISITOR_HPP #include class OperationFinder; class OperationFinderAstVisitor : public clang::RecursiveASTVisitor { public: explicit OperationFinderAstVisitor(OperationFinder* op_finder); void NewContext(clang::ASTContext* context); bool VisitForStmt(clang::ForStmt* stmt); bool VisitBinaryOperator(clang::BinaryOperator* op); bool VisitUnaryOperator(clang::UnaryOperator* op); bool VisitCallExpr(clang::CallExpr* call); bool VisitArraySubscriptExpr(clang::ArraySubscriptExpr* subscript); bool dataTraverseStmtPre(clang::Stmt* stmt); bool dataTraverseStmtPost(clang::Stmt* stmt); private: clang::ASTContext* _context; OperationFinder* _op_finder; struct _LoopHeaderStateMachine { bool in_loop_header = false; clang::Stmt* init = nullptr; clang::Stmt* header_start = nullptr; clang::Stmt* header_end = nullptr; }; _LoopHeaderStateMachine _loop_header; std::vector _branch_stack; clang::Stmt* _isBranchEntry(clang::Stmt* stmt); }; #endif //C_ANALYZER_OPERATIONFINDERASTVISITOR_HPP