masters-thesis/op-finder/OperationFinder.hpp

41 lines
1.3 KiB
C++

//
// Created by erki on 16.02.21.
//
#ifndef LLVM_PROTO_OPERATIONFINDER_HPP
#define LLVM_PROTO_OPERATIONFINDER_HPP
#include <clang/ASTMatchers/ASTMatchFinder.h>
#include "OperationLog.hpp"
class OperationFinder
{
public:
explicit OperationFinder(IOperationOutput* storage);
void processArithmetic(const clang::BinaryOperator* op, const clang::SourceManager& source_manager);
void processUnaryArithmetic(const clang::UnaryOperator* op, const clang::SourceManager& source_manager);
void processFunctionCall(const clang::CallExpr* call, const clang::SourceManager& source_manager);
void processArraySubscript(const clang::ArraySubscriptExpr* subscript, const clang::SourceManager& source_manager);
void fallthroughBranchEntered();
void fallthroughBranchExited();
void forLoopEntered();
void forLoopExited();
private:
std::unique_ptr<OperationLog::BasicOperation>
_createBasicOperationLogEntry(const std::string& opcode, const clang::Expr* source, const clang::Expr* op1, const clang::Expr* op2);
std::pair<std::string, OperationLog> _createBaseOperationLog(const clang::Stmt* stmt, const clang::SourceManager& source_manager);
int _next_for_loop_id = 0;
bool _in_fallthrough = false;
std::vector<int> _for_loop_stack;
IOperationOutput* _storage;
};
#endif //LLVM_PROTO_OPERATIONFINDER_HPP