bool DIVariable::isInlinedFnArgument(const Function *CurFn) { assert(CurFn && "Invalid function"); DISubprogram SP = dyn_cast<MDSubprogram>(getContext()); if (!SP) return false; // This variable is not inlined function argument if its scope // does not describe current function. return !SP.describes(CurFn); }
DISubprogram llvm::getDISubprogram(const Function *F) { // We look for the first instr that has a debug annotation leading back to F. for (auto &BB : *F) { auto Inst = std::find_if(BB.begin(), BB.end(), [](const Instruction &Inst) { return !Inst.getDebugLoc().isUnknown(); }); if (Inst == BB.end()) continue; DebugLoc DLoc = Inst->getDebugLoc(); const MDNode *Scope = DLoc.getScopeNode(); DISubprogram Subprogram = getDISubprogram(Scope); return Subprogram.describes(F) ? Subprogram : DISubprogram(); } return DISubprogram(); }