[ELF] - Improve call graph pasing error reporting.

This adds a file name to the error message,
adds a missing test case and refactors code a bit. 

llvm-svn: 336651
This commit is contained in:
George Rimar 2018-07-10 10:28:55 +00:00
parent 20b92c4d0d
commit bc6702a424
2 changed files with 15 additions and 4 deletions

View File

@ -631,11 +631,9 @@ static void readCallGraph(MemoryBufferRef MB) {
for (StringRef L : args::getLines(MB)) {
SmallVector<StringRef, 3> Fields;
L.split(Fields, ' ');
if (Fields.size() != 3)
fatal("parse error");
uint64_t Count;
if (!to_integer(Fields[2], Count))
fatal("parse error");
if (Fields.size() != 3 || !to_integer(Fields[2], Count))
fatal(MB.getBufferIdentifier() + ": parse error");
const Symbol *FromSym = SymbolNameToSymbol.lookup(Fields[0]);
const Symbol *ToSym = SymbolNameToSymbol.lookup(Fields[1]);
if (Config->WarnSymbolOrdering) {

View File

@ -0,0 +1,13 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: echo "A B C 100" > %t.call_graph
# RUN: not ld.lld %t --call-graph-ordering-file \
# RUN: %t.call_graph -o /dev/null 2>&1 | FileCheck %s
# CHECK: {{.*}}.call_graph: parse error
# RUN: echo "A B C" > %t.call_graph
# RUN: not ld.lld %t --call-graph-ordering-file \
# RUN: %t.call_graph -o /dev/null 2>&1 | FileCheck %s