Add utility routine to create subprogram definition entry from subprogram declaration...
authorDevang Patel <dpatel@apple.com>
Tue, 1 Dec 2009 23:09:02 +0000 (23:09 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 1 Dec 2009 23:09:02 +0000 (23:09 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90282 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/DebugInfo.h
lib/Analysis/DebugInfo.cpp

index 866ed8a8757e2a34cd7fc26aa9279533ec28bedf..b67468d855708256fc93388a6ed816708d8e0ab8 100644 (file)
@@ -567,6 +567,10 @@ namespace llvm {
                                   DIType Type, bool isLocalToUnit,
                                   bool isDefinition);
 
+    /// CreateSubprogramDefinition - Create new subprogram descriptor for the
+    /// given declaration. 
+    DISubprogram CreateSubprogramDefinition(DISubprogram &SPDeclaration);
+
     /// CreateGlobalVariable - Create a new descriptor for the specified global.
     DIGlobalVariable
     CreateGlobalVariable(DIDescriptor Context, StringRef Name,
index 41d803c699d5f055c16f48278b4209259a702b42..b1eff9efe16a8ca932e280233d1af9aeb26409b6 100644 (file)
@@ -884,6 +884,29 @@ DISubprogram DIFactory::CreateSubprogram(DIDescriptor Context,
   return DISubprogram(MDNode::get(VMContext, &Elts[0], 11));
 }
 
+/// CreateSubprogramDefinition - Create new subprogram descriptor for the
+/// given declaration. 
+DISubprogram DIFactory::CreateSubprogramDefinition(DISubprogram &SPDeclaration) {
+  if (SPDeclaration.isDefinition())
+    return DISubprogram(SPDeclaration.getNode());
+
+  MDNode *DeclNode = SPDeclaration.getNode();
+  Value *Elts[] = {
+    GetTagConstant(dwarf::DW_TAG_subprogram),
+    llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
+    DeclNode->getElement(2), // Context
+    DeclNode->getElement(3), // Name
+    DeclNode->getElement(4), // DisplayName
+    DeclNode->getElement(5), // LinkageName
+    DeclNode->getElement(6), // CompileUnit
+    DeclNode->getElement(7), // LineNo
+    DeclNode->getElement(8), // Type
+    DeclNode->getElement(9), // isLocalToUnit
+    ConstantInt::get(Type::getInt1Ty(VMContext), true)
+  };
+  return DISubprogram(MDNode::get(VMContext, &Elts[0], 11));
+}
+
 /// CreateGlobalVariable - Create a new descriptor for the specified global.
 DIGlobalVariable
 DIFactory::CreateGlobalVariable(DIDescriptor Context, StringRef Name,