Expand subprogram and added block descriptor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26782 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp
index 68aeb10..b77721d 100644
--- a/lib/CodeGen/DwarfWriter.cpp
+++ b/lib/CodeGen/DwarfWriter.cpp
@@ -1518,19 +1518,19 @@
// Gather the details (simplify add attribute code.)
const std::string &Name = SPD->getName();
- unsigned FileID = Unit->getID();
- // FIXME - faking the line for the time being.
- unsigned Line = 1;
-
- // FIXME - faking the type for the time being.
- DIE *Type = NewBasicType(Unit->getDie(), Type::IntTy);
+ CompileUnitDesc *FileDesc = static_cast<CompileUnitDesc *>(SPD->getFile());
+ CompileUnit *File = FindCompileUnit(FileDesc);
+ unsigned FileID = File->getID();
+ DIE *Type = NewBasicType(Unit->getDie(), Type::IntTy);
+ unsigned Line = SPD->getLine();
+ unsigned IsExternal = SPD->isStatic() ? 0 : 1;
DIE *SubprogramDie = new DIE(DW_TAG_subprogram);
SubprogramDie->AddString (DW_AT_name, DW_FORM_string, Name);
SubprogramDie->AddUInt (DW_AT_decl_file, 0, FileID);
SubprogramDie->AddUInt (DW_AT_decl_line, 0, Line);
SubprogramDie->AddDIEntry (DW_AT_type, DW_FORM_ref4, Type);
- SubprogramDie->AddUInt (DW_AT_external, DW_FORM_flag, 1);
+ SubprogramDie->AddUInt (DW_AT_external, DW_FORM_flag, IsExternal);
// Add to map.
Slot = SubprogramDie;