本文整理汇总了C++中DILocation::getLineNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ DILocation::getLineNumber方法的具体用法?C++ DILocation::getLineNumber怎么用?C++ DILocation::getLineNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DILocation
的用法示例。
在下文中一共展示了DILocation::getLineNumber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Loc
//
// 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;
}
示例2: ExtractDebugLocation
/// ExtractDebugLocation - Extract debug location information
/// from DILocation.
DebugLoc ExtractDebugLocation(DILocation &Loc,
DebugLocTracker &DebugLocInfo) {
DebugLoc DL;
MDNode *Context = Loc.getScope().getNode();
MDNode *InlinedLoc = NULL;
if (!Loc.getOrigLocation().isNull())
InlinedLoc = Loc.getOrigLocation().getNode();
// If this location is already tracked then use it.
DebugLocTuple Tuple(Context, InlinedLoc, Loc.getLineNumber(),
Loc.getColumnNumber());
DenseMap<DebugLocTuple, unsigned>::iterator II
= DebugLocInfo.DebugIdMap.find(Tuple);
if (II != DebugLocInfo.DebugIdMap.end())
return DebugLoc::get(II->second);
// Add a new location entry.
unsigned Id = DebugLocInfo.DebugLocations.size();
DebugLocInfo.DebugLocations.push_back(Tuple);
DebugLocInfo.DebugIdMap[Tuple] = Id;
return DebugLoc::get(Id);
}