static std::string getDSPIPath(DILocation Loc) { std::string dir = Loc.getDirectory(); std::string file = Loc.getFilename(); if (dir.empty()) { return file; } else if (*dir.rbegin() == '/') { return dir + file; } else { return dir + "/" + file; } }
// // Function: printSourceInfo() // // Description: // Print source file and line number information about the instruction to // standard output. // static void printSourceInfo (std::string errorType, Instruction * I) { // // Print out where the fault will be inserted in the source code. // If we can't find the source line information, use a dummy line number and // the function name by default. // std::string fname = I->getParent()->getParent()->getNameStr(); std::string funcname = fname; uint64_t lineno = 0; unsigned dbgKind = I->getContext().getMDKindID("dbg"); if (MDNode *Dbg = I->getMetadata(dbgKind)) { DILocation Loc (Dbg); fname = Loc.getDirectory().str() + Loc.getFilename().str(); lineno = Loc.getLineNumber(); } std::cout << "Inject: " << errorType << ": " << funcname << ": " << fname << ": " << lineno << "\n"; return; }