Debug Info: Move isSubprogramContext from DebugInfo to DwarfDebug.
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfDebug.cpp
index 885d4ba5cdc516f2e3b740f124864af13e68da0d..bdcb813e227b2eff0245f1795b81d6b4cfb32948 100644 (file)
@@ -332,6 +332,19 @@ static void addSubprogramNames(CompileUnit *TheCU, DISubprogram SP,
   }
 }
 
+/// isSubprogramContext - Return true if Context is either a subprogram
+/// or another context nested inside a subprogram.
+bool DwarfDebug::isSubprogramContext(const MDNode *Context) {
+  if (!Context)
+    return false;
+  DIDescriptor D(Context);
+  if (D.isSubprogram())
+    return true;
+  if (D.isType())
+    return isSubprogramContext(DIType(Context).getContext());
+  return false;
+}
+
 // Find DIE for the given subprogram and attach appropriate DW_AT_low_pc
 // and DW_AT_high_pc attributes. If there are global variables in this
 // scope then create and insert DIEs for these variables.