[PATCH] D27962: Get function start line number from DWARF info

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 1 13:48:34 PST 2017


dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks good - a few minor improvements/tidyups that'd be good.



================
Comment at: lib/DebugInfo/DWARF/DWARFContext.cpp:567-568
       Frame.FunctionName = Name;
+    Optional<uint64_t> DeclLineResult = FunctionDIE.getDeclLine();
+    if (DeclLineResult)
+      Frame.StartLine = *DeclLineResult;
----------------
Roll the declaration into the if condition:

  if (auto DeclLineResult = FunctionDIE.getDeclLine())

(up to you if you use auto - whatever you think's more readable)


================
Comment at: lib/DebugInfo/DWARF/DWARFDie.cpp:295-307
+  if (auto DeclLine = find(DW_AT_decl_line))
+    return DeclLine->getAsUnsignedConstant();
+
+  // Try to get name from specification DIE.
+  if (auto SpecDie = getAttributeValueAsReferencedDie(DW_AT_specification)) {
+    if (auto DeclLine = SpecDie.getDeclLine())
+      return DeclLine;
----------------
I think this whole function can now be implemented with this:

  return toUnsigned(findRecursively(DW_AT_line));


================
Comment at: test/tools/llvm-symbolizer/sym-verbose.test:28
 #CHECK-NEXT: Column: 3
+#CHECK-NEXT: Start line: 4
 #CHECK-NEXT: Discriminator: 1
----------------
Might be good to describe this as "Function start line" to be more clear (& maybe put it above "Line" - so that line/col/discrim are together, since they're closely related.


https://reviews.llvm.org/D27962





More information about the llvm-commits mailing list