masters-thesis/op-finder/OperationFinderAstVisitor.hpp

37 lines
889 B
C++

//
// Created by erki on 02.03.21.
//
#ifndef C_ANALYZER_OPERATIONFINDERASTVISITOR_HPP
#define C_ANALYZER_OPERATIONFINDERASTVISITOR_HPP
#include <clang/AST/RecursiveASTVisitor.h>
class OperationFinder;
class OperationFinderAstVisitor
: public clang::RecursiveASTVisitor<OperationFinderAstVisitor>
{
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 dataTraverseStmtPre(clang::Stmt* stmt);
bool dataTraverseStmtPost(clang::Stmt* stmt);
private:
void _checkIfForLoopInitDone(clang::Stmt* stmt);
clang::ASTContext* _context;
OperationFinder* _op_finder;
clang::Stmt* _loop_init = nullptr;
};
#endif //C_ANALYZER_OPERATIONFINDERASTVISITOR_HPP