[llvm-commits] [llvm] r90282 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp

Devang Patel dpatel at apple.com
Tue Dec 1 15:09:02 PST 2009


Author: dpatel
Date: Tue Dec  1 17:09:02 2009
New Revision: 90282

URL: http://llvm.org/viewvc/llvm-project?rev=90282&view=rev
Log:
Add utility routine to create subprogram definition entry from subprogram declaration entry.

Modified:
    llvm/trunk/include/llvm/Analysis/DebugInfo.h
    llvm/trunk/lib/Analysis/DebugInfo.cpp

Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=90282&r1=90281&r2=90282&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Tue Dec  1 17:09:02 2009
@@ -567,6 +567,10 @@
                                   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,

Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=90282&r1=90281&r2=90282&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/DebugInfo.cpp Tue Dec  1 17:09:02 2009
@@ -884,6 +884,29 @@
   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,





More information about the llvm-commits mailing list