Compare commits

..

No commits in common. "5a2d5ed933866651b5d72a9740d5c5fc6c3a23da" and "b609c48bfe83e7d91ee55fb0dc9f24285adf2f9d" have entirely different histories.

17 changed files with 173 additions and 496 deletions

View File

@ -42,11 +42,6 @@
<rule entity="CLASS_MEMBER_FUNCTION,STRUCT_MEMBER_FUNCTION" visibility="PROTECTED,PRIVATE" specifier="ANY" prefix="_" style="PASCAL_CASE" suffix="" />
</rules>
</Objective-C-extensions>
<codeStyleSettings language="CMake">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="ObjectiveC">
<option name="BRACE_STYLE" value="2" />
<option name="CLASS_BRACE_STYLE" value="2" />

View File

@ -1,52 +0,0 @@
//
// Created by erki on 02.03.21.
//
#ifndef C_ANALYZER_ASTHELPERS_HPP
#define C_ANALYZER_ASTHELPERS_HPP
#include <clang/AST/ASTContext.h>
template<typename TOp>
clang::StringRef getOpcode(const TOp *op)
{
return op->getOpcodeStr(op->getOpcode());
}
inline clang::SourceLocation resolveOperationSourceLocation(const clang::SourceManager& source_manager,
const clang::SourceLocation& original)
{
if (source_manager.isMacroBodyExpansion(original))
{
return source_manager.getExpansionLoc(original);
}
return original;
}
inline std::tuple<std::string, unsigned int, unsigned int> resolveLocationsWithLoc(const clang::SourceLocation& loc,
const clang::SourceManager& source_manager)
{
const auto& loc_resolved = resolveOperationSourceLocation(source_manager, loc);
return {
source_manager.getFilename(loc_resolved).str(),
source_manager.getSpellingLineNumber(loc_resolved),
source_manager.getSpellingColumnNumber(loc_resolved)
};
}
template<typename TStmt>
std::tuple<std::string, unsigned int, unsigned int> resolveLocations(const TStmt* op,
const clang::SourceManager& source_manager)
{
const auto& loc = resolveOperationSourceLocation(source_manager, op->getBeginLoc());
return {
source_manager.getFilename(loc).str(),
source_manager.getSpellingLineNumber(loc),
source_manager.getSpellingColumnNumber(loc)
};
}
#endif //C_ANALYZER_ASTHELPERS_HPP

View File

@ -21,10 +21,6 @@ add_executable(op-finder
main.cpp
OperationFinder.cpp
OperationStorage.cpp
OperationAstMatcher.cpp
OperationFinderAstVisitor.cpp
OperationFinderAstConsumer.cpp
OperationFinderAstAction.cpp
)
target_include_directories(op-finder

View File

@ -1,57 +0,0 @@
//
// Created by erki on 02.03.21.
//
#include "OperationAstMatcher.hpp"
#include "OperationFinder.hpp"
using namespace clang;
using namespace clang::ast_matchers;
namespace
{
StatementMatcher AssignmentMatcher =
binaryOperation(isAssignmentOperator(),
hasLHS(expr().bind("lhs")),
hasRHS(expr().bind("rhs"))).bind("assignment");
StatementMatcher ArithmeticMatcher =
binaryOperation(hasAnyOperatorName("+", "-", "/", "*", "<", ">",
"<=", ">=", "==", "<<", ">>", "%"),
hasLHS(expr().bind("lhs")),
hasRHS(expr().bind("lhs"))).bind("arithmetic");
StatementMatcher UnaryArithmeticMatcher =
unaryOperator(hasAnyOperatorName("!", "++", "--"),
hasUnaryOperand(expr().bind("lhs"))).bind("unary_arithmetic");
}
OperationASTMatcher::OperationASTMatcher(OperationFinder* finder)
: _op_finder(finder)
{ }
void OperationASTMatcher::addToFinder(clang::ast_matchers::MatchFinder& finder)
{
finder.addMatcher(traverse(TK_IgnoreUnlessSpelledInSource, ArithmeticMatcher), this);
finder.addMatcher(traverse(TK_IgnoreUnlessSpelledInSource, AssignmentMatcher), this);
finder.addMatcher(traverse(TK_IgnoreUnlessSpelledInSource, UnaryArithmeticMatcher), this);
}
void OperationASTMatcher::run(const clang::ast_matchers::MatchFinder::MatchResult& result)
{
if (const auto* op = result.Nodes.getNodeAs<clang::BinaryOperator>("assignment"))
{
_op_finder->processArithmetic(op, *result.SourceManager);
}
else if (const auto* op = result.Nodes.getNodeAs<clang::BinaryOperator>("arithmetic"))
{
_op_finder->processArithmetic(op, *result.SourceManager);
}
else if (const auto* op = result.Nodes.getNodeAs<clang::UnaryOperator>("unary_arithmetic"))
{
_op_finder->processUnaryArithmetic(op, *result.SourceManager);
}
}

View File

@ -1,25 +0,0 @@
//
// Created by erki on 02.03.21.
//
#ifndef C_ANALYZER_OPERATIONASTMATCHER_HPP
#define C_ANALYZER_OPERATIONASTMATCHER_HPP
#include <clang/ASTMatchers/ASTMatchFinder.h>
class OperationFinder;
class OperationASTMatcher : public clang::ast_matchers::MatchFinder::MatchCallback
{
public:
explicit OperationASTMatcher(OperationFinder* finder);
void addToFinder(clang::ast_matchers::MatchFinder& finder);
void run(const clang::ast_matchers::MatchFinder::MatchResult& result) override;
private:
OperationFinder* _op_finder;
};
#endif //C_ANALYZER_OPERATIONASTMATCHER_HPP

View File

@ -6,77 +6,165 @@
#include <iostream>
#include "ASTHelpers.hpp"
using namespace clang;
using namespace clang::ast_matchers;
OperationFinder::OperationFinder(IOperationOutput* storage)
: _storage(storage)
namespace
{
assert(storage);
StatementMatcher AssignmentMatcher =
binaryOperation(isAssignmentOperator(),
hasLHS(expr().bind("lhs")),
hasRHS(expr().bind("rhs"))).bind("assignment");
StatementMatcher ArithmeticMatcher =
binaryOperation(hasAnyOperatorName("+", "-", "/", "*", "<", ">",
"<=", ">=", "==", "<<", ">>", "%"),
hasLHS(expr().bind("lhs")),
hasRHS(expr().bind("lhs"))).bind("arithmetic");
StatementMatcher UnaryArithmeticMatcher =
unaryOperator(hasAnyOperatorName("!", "++", "--"),
hasUnaryOperand(expr().bind("lhs"))).bind("unary_arithmetic");
StatementMatcher CompoundMatcher =
compoundStmt().bind("compound_stmt");
//StatementMatcher ForStatementMatcher =
// forStmt(hasInitStatement(expr().bind("init"))).bind("for_stmt");
template<typename TOp>
StringRef getOpcode(const TOp *op)
{
return op->getOpcodeStr(op->getOpcode());
}
void OperationFinder::processArithmetic(const clang::BinaryOperator* op, const clang::SourceManager& source_manager)
SourceLocation ResolveOperationSourceLocation(const SourceManager& source_manager, const SourceLocation& original)
{
const auto [file_name, line_number, column_number] = resolveLocations(op, source_manager);
if (source_manager.isMacroBodyExpansion(original))
{
return source_manager.getExpansionLoc(original);
}
return original;
}
template<typename TOp>
std::tuple<std::string, unsigned int, unsigned int> resolveLocations(const TOp* op, const SourceManager& source_manager)
{
const auto& loc = ResolveOperationSourceLocation(source_manager, op->getBeginLoc());
return {
source_manager.getFilename(loc).str(),
source_manager.getSpellingLineNumber(loc),
source_manager.getSpellingColumnNumber(loc)
};
}
}
OperationFinder::OperationFinder(const std::string& output_dir)
: _storage(output_dir)
{ }
void OperationFinder::addMatcher(MatchFinder &finder)
{
finder.addMatcher(traverse(TK_IgnoreUnlessSpelledInSource, ArithmeticMatcher), this);
finder.addMatcher(traverse(TK_IgnoreUnlessSpelledInSource, AssignmentMatcher), this);
finder.addMatcher(traverse(TK_IgnoreUnlessSpelledInSource, UnaryArithmeticMatcher), this);
}
void OperationFinder::run(const MatchFinder::MatchResult& result)
{
if (result.Nodes.getNodeAs<clang::BinaryOperator>("assignment"))
{
_processAssignment(result);
}
else if (result.Nodes.getNodeAs<clang::BinaryOperator>("arithmetic"))
{
_processArithmetic(result);
}
else if (result.Nodes.getNodeAs<clang::UnaryOperator>("unary_arithmetic"))
{
_processUnaryArithmetic(result);
}
}
void OperationFinder::_processAssignment(const clang::ast_matchers::MatchFinder::MatchResult& result)
{
const BinaryOperator* op = result.Nodes.getNodeAs<BinaryOperator>("assignment");
assert(op);
const auto [file_name, line_number, column_number] = resolveLocations(op, *result.SourceManager);
llvm::outs() << file_name << ":"
<< line_number << ":"
<< column_number << ":"
<< "Assignment: Assigned to: ";
OperationStorage::Log log;
log.line = line_number;
log.operation = "=";
_processExpressionTypes(log, op, op->getLHS(), op->getRHS());
_storage.pushOperation(file_name, log);
llvm::outs() << "\n";
}
void OperationFinder::_processArithmetic(const MatchFinder::MatchResult& result)
{
const BinaryOperator* op = result.Nodes.getNodeAs<clang::BinaryOperator>("arithmetic");
assert(op);
const auto [file_name, line_number, column_number] = resolveLocations(op, *result.SourceManager);
llvm::outs() << file_name << ":"
<< line_number << ":"
<< column_number << ":"
<< "Binary arithmetic: Type: " << getOpcode(op) << " LHS: ";
OperationLog log;
OperationStorage::Log log;
log.line = line_number;
log.operation = getOpcode(op).str();
log.current_for_loops = _for_loop_stack;
_processExpressionTypes(log, op, op->getLHS(), op->getRHS());
_storage->pushOperation(file_name, log);
_storage.pushOperation(file_name, log);
llvm::outs() << "\n";
}
void OperationFinder::processUnaryArithmetic(const clang::UnaryOperator* op, const clang::SourceManager& source_manager)
void OperationFinder::_processUnaryArithmetic(const MatchFinder::MatchResult &result)
{
const Expr* lhs = op->getExprStmt();
const UnaryOperator* op = result.Nodes.getNodeAs<UnaryOperator>("unary_arithmetic");
const Expr* lhs = result.Nodes.getNodeAs<Expr>("lhs");
assert(op);
assert(lhs);
const auto [file_name, line_number, column_number] = resolveLocations(op, source_manager);
const auto [file_name, line_number, column_number] = resolveLocations(op, *result.SourceManager);
llvm::outs() << file_name << ":"
<< line_number << ":"
<< column_number << ":"
<< "Unary arithmetic: Type: " << getOpcode(op) << " LHS: ";
OperationLog log;
OperationStorage::Log log;
log.line = line_number;
log.operation = getOpcode(op).str();
log.current_for_loops = _for_loop_stack;
_processExpressionTypes(log, op, lhs, nullptr);
_storage->pushOperation(file_name, log);
_storage.pushOperation(file_name, log);
llvm::outs() << "\n";
}
void OperationFinder::forLoopEntered()
{
_for_loop_stack.push_back(_next_for_loop_id);
_next_for_loop_id++;
}
void OperationFinder::forLoopExited()
{
_for_loop_stack.pop_back();
}
void OperationFinder::_processExpressionTypes(OperationLog& log, const Expr* source, const Expr* op1, const Expr* op2)
void OperationFinder::_processExpressionTypes(OperationStorage::Log& log, const Expr* source, const Expr* op1, const Expr* op2)
{
auto printTypeName = [](const QualType& t) -> std::string

View File

@ -5,27 +5,27 @@
#ifndef LLVM_PROTO_OPERATIONFINDER_HPP
#define LLVM_PROTO_OPERATIONFINDER_HPP
#include <clang/ASTMatchers/ASTMatchers.h>
#include <clang/ASTMatchers/ASTMatchFinder.h>
#include "OperationLog.hpp"
#include "OperationStorage.hpp"
class OperationFinder
class OperationFinder : public clang::ast_matchers::MatchFinder::MatchCallback
{
public:
explicit OperationFinder(IOperationOutput* storage);
OperationFinder(const std::string& output_dir);
void processArithmetic(const clang::BinaryOperator* op, const clang::SourceManager& source_manager);
void processUnaryArithmetic(const clang::UnaryOperator* op, const clang::SourceManager& source_manager);
void forLoopEntered();
void forLoopExited();
void addMatcher(clang::ast_matchers::MatchFinder& finder);
void run(const clang::ast_matchers::MatchFinder::MatchResult& result) override;
private:
void _processExpressionTypes(OperationLog& log, const clang::Expr* source, const clang::Expr* op1, const clang::Expr* op2);
void _processAssignment(const clang::ast_matchers::MatchFinder::MatchResult& result);
void _processArithmetic(const clang::ast_matchers::MatchFinder::MatchResult& result);
void _processUnaryArithmetic(const clang::ast_matchers::MatchFinder::MatchResult& result);
int _next_for_loop_id = 0;
std::vector<int> _for_loop_stack;
IOperationOutput* _storage;
void _processExpressionTypes(OperationStorage::Log& log, const clang::Expr* source, const clang::Expr* op1, const clang::Expr* op2);
OperationStorage _storage;
};
#endif //LLVM_PROTO_OPERATIONFINDER_HPP

View File

@ -1,17 +0,0 @@
//
// Created by erki on 02.03.21.
//
#include "OperationFinderAstAction.hpp"
#include "OperationFinderAstConsumer.hpp"
OperationFinderAstAction::OperationFinderAstAction(OperationFinder* op_finder)
: _op_finder(op_finder)
{ }
std::unique_ptr<clang::ASTConsumer> OperationFinderAstAction::newASTConsumer()
{
return std::unique_ptr<clang::ASTConsumer>(
new OperationFinderAstConsumer(_op_finder));
}

View File

@ -1,24 +0,0 @@
//
// Created by erki on 02.03.21.
//
#ifndef C_ANALYZER_OPERATIONFINDERASTACTION_HPP
#define C_ANALYZER_OPERATIONFINDERASTACTION_HPP
#include <clang/Frontend/CompilerInstance.h>
#include <clang/Frontend/FrontendActions.h>
class OperationFinder;
class OperationFinderAstAction
{
public:
explicit OperationFinderAstAction(OperationFinder* op_finder);
std::unique_ptr<clang::ASTConsumer> newASTConsumer();
private:
OperationFinder* _op_finder;
};
#endif //C_ANALYZER_OPERATIONFINDERASTACTION_HPP

View File

@ -1,19 +0,0 @@
//
// Created by erki on 02.03.21.
//
#include "OperationFinderAstConsumer.hpp"
OperationFinderAstConsumer::OperationFinderAstConsumer(OperationFinder* op_finder)
: _visitor(op_finder)
{ }
void OperationFinderAstConsumer::Initialize(clang::ASTContext& context)
{
_visitor.NewContext(&context);
}
void OperationFinderAstConsumer::HandleTranslationUnit(clang::ASTContext& context)
{
_visitor.TraverseAST(context);
}

View File

@ -1,27 +0,0 @@
//
// Created by erki on 02.03.21.
//
#ifndef C_ANALYZER_OPERATIONFINDERASTCONSUMER_HPP
#define C_ANALYZER_OPERATIONFINDERASTCONSUMER_HPP
#include <clang/AST/ASTConsumer.h>
#include "OperationFinderAstVisitor.hpp"
class OperationFinder;
class OperationFinderAstConsumer : public clang::ASTConsumer
{
public:
explicit OperationFinderAstConsumer(OperationFinder* op_finder);
void Initialize(clang::ASTContext& context) override;
void HandleTranslationUnit(clang::ASTContext& context) override;
private:
OperationFinderAstVisitor _visitor;
};
#endif //C_ANALYZER_OPERATIONFINDERASTCONSUMER_HPP

View File

@ -1,103 +0,0 @@
//
// Created by erki on 02.03.21.
//
#include "OperationFinderAstVisitor.hpp"
#include "OperationFinder.hpp"
#include "ASTHelpers.hpp"
OperationFinderAstVisitor::OperationFinderAstVisitor(OperationFinder* op_finder)
: _context(nullptr)
, _op_finder(op_finder)
{ }
void OperationFinderAstVisitor::NewContext(clang::ASTContext* context)
{
_context = context;
}
bool OperationFinderAstVisitor::VisitForStmt(clang::ForStmt* stmt)
{
assert(_context);
return true;
}
bool OperationFinderAstVisitor::VisitBinaryOperator(clang::BinaryOperator* op)
{
assert(_context);
if (!op->isCompoundAssignmentOp())
_op_finder->processArithmetic(op, _context->getSourceManager());
return true;
}
bool OperationFinderAstVisitor::VisitUnaryOperator(clang::UnaryOperator* op)
{
assert(_context);
_op_finder->processUnaryArithmetic(op, _context->getSourceManager());
return true;
}
bool OperationFinderAstVisitor::dataTraverseStmtPre(clang::Stmt* stmt)
{
assert(_context);
if (auto* loop = clang::dyn_cast<clang::ForStmt>(stmt))
{
if (loop->getInit())
{
_loop_init = loop->getInit();
}
else
{
_op_finder->forLoopEntered();
}
}
else
{
_checkIfForLoopInitDone(stmt);
}
return true;
}
bool OperationFinderAstVisitor::dataTraverseStmtPost(clang::Stmt* stmt)
{
assert(_context);
if (clang::dyn_cast<clang::ForStmt>(stmt))
_op_finder->forLoopExited();
return true;
}
void OperationFinderAstVisitor::_checkIfForLoopInitDone(clang::Stmt* stmt)
{
if (!_loop_init || stmt == _loop_init)
return;
const auto [file, line, column] = resolveLocationsWithLoc(stmt->getEndLoc(), _context->getSourceManager());
const auto [for_file, for_line, for_column] = resolveLocationsWithLoc(_loop_init->getEndLoc(), _context->getSourceManager());
bool is_done = false;
if (line > for_line)
{
is_done = true;
}
else if (line == for_line && column > for_column)
{
is_done = true;
}
if (is_done)
{
_loop_init = nullptr;
_op_finder->forLoopEntered();
}
}

View File

@ -1,36 +0,0 @@
//
// 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

View File

@ -1,52 +0,0 @@
//
// Created by erki on 28.02.21.
//
#ifndef C_ANALYZER_OPERATIONLOG_HPP
#define C_ANALYZER_OPERATIONLOG_HPP
#include <vector>
struct OperationLog
{
std::string operation;
unsigned int line;
std::string operand_lhs;
std::string operand_rhs;
std::string operand_result;
std::vector<int> current_for_loops;
};
class IOperationOutput
{
public:
virtual ~IOperationOutput() = default;
virtual void pushOperation(const std::string& filename, const OperationLog& op) = 0;
};
#include <nlohmann/json.hpp>
inline void to_json(nlohmann::json& j, const OperationLog& l)
{
j = nlohmann::json{
{"operation", l.operation},
{"line", l.line},
{"operand_lhs", l.operand_lhs},
{"operand_rhs", l.operand_rhs},
{"operand_result", l.operand_result},
{"current_for_loops", l.current_for_loops}
};
}
inline void from_json(const nlohmann::json& j, OperationLog& l)
{
j.at("operation").get_to(l.operation);
j.at("line").get_to(l.line);
j.at("operand_lhs").get_to(l.operand_lhs);
j.at("operand_rhs").get_to(l.operand_rhs);
j.at("operand_result").get_to(l.operand_result);
j.at("current_for_loops").get_to(l.current_for_loops);
}
#endif //C_ANALYZER_OPERATIONLOG_HPP

View File

@ -8,6 +8,27 @@
#include <filesystem>
#include <llvm/Support/CommandLine.h>
#include <nlohmann/json.hpp>
void to_json(nlohmann::json& j, const OperationStorage::Log& l)
{
j = nlohmann::json{
{"operation", l.operation},
{"line", l.line},
{"operand_lhs", l.operand_lhs},
{"operand_rhs", l.operand_rhs},
{"operand_result", l.operand_result}
};
}
void from_json(const nlohmann::json& j, OperationStorage::Log& l)
{
j.at("operation").get_to(l.operation);
j.at("line").get_to(l.line);
j.at("operand_lhs").get_to(l.operand_lhs);
j.at("operand_rhs").get_to(l.operand_rhs);
j.at("operand_result").get_to(l.operand_result);
}
OperationStorage::OperationStorage(const std::string& output_filename)
: _output_filename(output_filename)
@ -18,7 +39,7 @@ OperationStorage::~OperationStorage()
_dumpToFile();
}
void OperationStorage::pushOperation(const std::string& filename, const OperationLog& op)
void OperationStorage::pushOperation(const std::string& filename, const Log& op)
{
auto it = _operations.find(filename);
@ -28,7 +49,7 @@ void OperationStorage::pushOperation(const std::string& filename, const Operatio
it->second.push_back(op);
}
const std::unordered_map<std::string, std::vector<OperationLog>>& OperationStorage::getOperations() const
const std::unordered_map<std::string, std::vector<OperationStorage::Log>>& OperationStorage::getOperations() const
{
return _operations;
}

View File

@ -9,21 +9,28 @@
#include <unordered_map>
#include <vector>
#include "OperationLog.hpp"
class OperationStorage : public IOperationOutput
class OperationStorage
{
public:
struct Log
{
std::string operation;
unsigned int line;
std::string operand_lhs;
std::string operand_rhs;
std::string operand_result;
};
OperationStorage() = delete;
OperationStorage(const OperationStorage&) = delete;
explicit OperationStorage(const std::string& output_filename);
~OperationStorage() override;
~OperationStorage();
void pushOperation(const std::string& filename, const OperationLog& op) override;
[[nodiscard]] const std::unordered_map<std::string, std::vector<OperationLog>>& getOperations() const;
void pushOperation(const std::string& filename, const Log& op);
[[nodiscard]] const std::unordered_map<std::string, std::vector<Log>>& getOperations() const;
private:
std::unordered_map<std::string, std::vector<OperationLog>> _operations;
std::unordered_map<std::string, std::vector<Log>> _operations;
std::string _output_filename;
void _dumpToFile();

View File

@ -5,10 +5,7 @@
// Declares llvm::cl::extrahelp.
#include "llvm/Support/CommandLine.h"
#include "OperationAstMatcher.hpp"
#include "OperationFinder.hpp"
#include "OperationStorage.hpp"
#include "OperationFinderAstAction.hpp"
using namespace clang::tooling;
using namespace clang::ast_matchers;
@ -16,21 +13,18 @@ using namespace llvm;
// Apply a custom category to all command-line options so that they are the
// only ones displayed.
static cl::OptionCategory MyToolCategory("op-finder options");
static llvm::cl::OptionCategory MyToolCategory("op-finder options");
static cl::opt<std::string> OutputFile("o", cl::desc("File to output the JSON to."),
cl::cat(MyToolCategory));
static cl::opt<std::string> RootDirectory("r", cl::desc("The root directory of the source files."),
static llvm::cl::opt<std::string> OutputFile("o", cl::desc("File to output the JSON to."),
cl::cat(MyToolCategory));
// CommonOptionsParser declares HelpMessage with a description of the common
// command-line options related to the compilation database and input files.
// It's nice to have this help message in all tools.
static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
static llvm::cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
// A help message for this specific tool can be added afterwards.
static cl::extrahelp MoreHelp("\nThe program takes the input <source0> ... files, parses their\n"
static llvm::cl::extrahelp MoreHelp("\nThe program takes the input <source0> ... files, parses their\n"
"AST and outputs a singular file containing a list of all noteworthy operations\n"
"for later analysis.\n");
@ -48,22 +42,10 @@ int main(int argc, const char** argv)
ClangTool Tool(OptionsParser.getCompilations(),
OptionsParser.getSourcePathList());
OperationStorage storage(OutputFile.getValue());
OperationFinder op_finder(OutputFile.getValue());
MatchFinder finder;
OperationFinder op_finder(&storage);
#if 0
MatchFinder matcher;
OperationASTMatcher finder(&op_finder);
finder.addToFinder(matcher);
//Tool.run(newFrontendActionFactory<DebuggeringASTAction>().get());
op_finder.addMatcher(finder);
return Tool.run(newFrontendActionFactory(&finder).get());
#endif
OperationFinderAstAction action(&op_finder);
return Tool.run(newFrontendActionFactory(&action).get());
}