#include “Instrument.h”
#include “Utils.h”
using namespace llvm;
Copyright By PowCoder代写 加微信 powcoder
namespace instrument {
const auto PASS_NAME = “StaticAnalysisPass”;
const auto PASS_DESC = “Static Analysis Pass”;
bool Instrument::runOnFunction(Function &F) {
auto FunctionName = F.getName().str();
outs() << "Running " << PASS_DESC << " on function " << FunctionName << "\n";
outs() << "Locating Instructions\n";
for (inst_iterator Iter = inst_begin(F), E = inst_end(F); Iter != E; ++Iter) {
Instruction &Inst = (*Iter);
llvm::DebugLoc DebugLoc = Inst.getDebugLoc();
if (!DebugLoc) {
// Skip Instruction if it doesn't have debug information.
int Line = DebugLoc.getLine();
int Col = DebugLoc.getCol();
outs() << Line << ", " << Col << "\n";
* TODO: Add code to check if the instruction is a BinaryOperator and if so,
* print the information about its location and operands as specified in the
* Lab document.
return false;
char Instrument::ID = 1;
static RegisterPass
} // namespace instrument
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com