本文整理汇总了C++中DIScope::getNode方法的典型用法代码示例。如果您正苦于以下问题:C++ DIScope::getNode方法的具体用法?C++ DIScope::getNode怎么用?C++ DIScope::getNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIScope
的用法示例。
在下文中一共展示了DIScope::getNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printLocation
// Print source location of function, and display name,
// falls back to printing the module's location and the function's LLVM name.
static void printLocation(const llvm::Function *F) {
unsigned MDDebugKind = F->getParent()->getMDKindID("dbg");
if (MDDebugKind) {
// Try to find the function's name and location
for (Function::const_iterator I=F->begin(),E=F->end();
I != E; ++I) {
if (const TerminatorInst *T = I->getTerminator()) {
if (MDNode *N = T->getMetadata(MDDebugKind)) {
DILocation Loc(N);
DIScope Scope = Loc.getScope();
while (Scope.isLexicalBlock()) {
DILexicalBlock LB(Scope.getNode());
Scope = LB.getContext();
}
if (Scope.isSubprogram()) {
DISubprogram SP(Scope.getNode());
errs() << /*Loc.getDirectory() << "/" << */Loc.getFilename()
<< ": in function '"
<< SP.getDisplayName()
<< "': ";
return;
}
}
}
}
}
// Fallback to printing module location and function name
printLocation(F->getParent());
errs() << "in function '" << F->getName() << "': ";
}
示例2: EmitDeclare
/// EmitDeclare - Constructs the debug code for allocation of a new variable.
/// region - "llvm.dbg.declare."
void DebugInfo::EmitDeclare(tree decl, unsigned Tag, const char *Name,
tree type, Value *AI, LLVMBuilder &Builder) {
// Ignore compiler generated temporaries.
if (DECL_IGNORED_P(decl))
return;
assert(!RegionStack.empty() && "Region stack mismatch, stack empty!");
expanded_location Loc = GetNodeLocation(decl, false);
// Construct variable.
DIScope VarScope = DIScope(cast<MDNode>(RegionStack.back()));
DIType Ty = getOrCreateType(type);
if (DECL_ARTIFICIAL (decl))
Ty = DebugFactory.CreateArtificialType(Ty);
// If type info is not available then do not emit debug info for this var.
if (!Ty.getNode())
return;
llvm::DIVariable D =
DebugFactory.CreateVariable(Tag, VarScope,
Name, getOrCreateFile(Loc.file),
Loc.line, Ty, optimize);
// Insert an llvm.dbg.declare into the current block.
Instruction *Call = DebugFactory.InsertDeclare(AI, D,
Builder.GetInsertBlock());
Call->setDebugLoc(DebugLoc::get(Loc.line, 0, VarScope.getNode()));
}