38 lines
1.0 KiB
C++
38 lines
1.0 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 fallthroughBranchEntered();
|
|
void fallthroughBranchExited();
|
|
|
|
void forLoopEntered();
|
|
void forLoopExited();
|
|
|
|
private:
|
|
std::unique_ptr<OperationLog::BasicOperation>
|
|
_createBasicOperationLogEntry(const clang::Expr* source, const clang::Expr* op1, const clang::Expr* op2);
|
|
|
|
int _next_for_loop_id = 0;
|
|
bool _in_fallthrough = false;
|
|
std::vector<int> _for_loop_stack;
|
|
IOperationOutput* _storage;
|
|
};
|
|
|
|
#endif //LLVM_PROTO_OPERATIONFINDER_HPP
|