summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2016-05-16 20:42:27 +0000
committerDavid Blaikie <dblaikie@gmail.com>2016-05-16 20:42:27 +0000
commitd1f7ab3396d0ad8f5121f83e4109130b02002b05 (patch)
tree90bd89c39295cd764d519a5d605dbb4a0703c694
parente897f56da86c355505a3738912a57ea1c26df80a (diff)
downloadbcm5719-llvm-d1f7ab3396d0ad8f5121f83e4109130b02002b05.tar.gz
bcm5719-llvm-d1f7ab3396d0ad8f5121f83e4109130b02002b05.zip
llvm-dwp: Streamline duplicate DWO ID diagnostic handling
Actually use the error return path rather than printing the duplicate information then a separate error. But also just tidy up/deduplicate some of the code for generating the diagnostic text. llvm-svn: 269692
-rw-r--r--llvm/test/tools/llvm-dwp/X86/duplicate.test12
-rw-r--r--llvm/tools/llvm-dwp/llvm-dwp.cpp51
2 files changed, 33 insertions, 30 deletions
diff --git a/llvm/test/tools/llvm-dwp/X86/duplicate.test b/llvm/test/tools/llvm-dwp/X86/duplicate.test
index 67b68294789..43266a24b60 100644
--- a/llvm/test/tools/llvm-dwp/X86/duplicate.test
+++ b/llvm/test/tools/llvm-dwp/X86/duplicate.test
@@ -18,10 +18,10 @@ RUN: | FileCheck --check-prefix=DWO1DWP %s
Build from a, b, and c.c all containing a single void() func by the name of the file.
-DWOS: Duplicate DWO ID ({{.*}}) in 'c.c' and 'c.c'{{$}}
-1DWP: Duplicate DWO ID ({{.*}}) in 'c.c' (from '{{.*}}ac.dwp') and 'c.c'{{$}}
-2DWP: Duplicate DWO ID ({{.*}}) in 'c.c' and 'c.c' (from '{{.*}}bc.dwp'){{$}}
+DWOS: error: Duplicate DWO ID ({{.*}}) in 'c.c' and 'c.c'{{$}}
+1DWP: error: Duplicate DWO ID ({{.*}}) in 'c.c' (from '{{.*}}ac.dwp') and 'c.c'{{$}}
+2DWP: error: Duplicate DWO ID ({{.*}}) in 'c.c' and 'c.c' (from '{{.*}}bc.dwp'){{$}}
-DWODWOS: Duplicate DWO ID ({{.*}}) in 'c.c' and 'c.c'{{$}}
-DWO1DWP: Duplicate DWO ID ({{.*}}) in 'c.c' (from 'c.dwo' in '{{.*}}ac.dwp') and 'c.c'{{$}}
-DWO2DWP: Duplicate DWO ID ({{.*}}) in 'c.c' and 'c.c' (from 'c.dwo' in '{{.*}}bc.dwp'){{$}}
+DWODWOS: error: Duplicate DWO ID ({{.*}}) in 'c.c' and 'c.c'{{$}}
+DWO1DWP: error: Duplicate DWO ID ({{.*}}) in 'c.c' (from 'c.dwo' in '{{.*}}ac.dwp') and 'c.c'{{$}}
+DWO2DWP: error: Duplicate DWO ID ({{.*}}) in 'c.c' and 'c.c' (from 'c.dwo' in '{{.*}}bc.dwp'){{$}}
diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp
index f25c87c241a..5e83d7c9cac 100644
--- a/llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -346,24 +346,31 @@ static bool consumeCompressedDebugSectionHeader(StringRef &data,
return true;
}
-void printDuplicateError(const std::pair<uint64_t, UnitIndexEntry> &PrevE,
- const CompileUnitIdentifiers &ID, StringRef DWPName) {
- errs() << "Duplicate DWO ID (" << PrevE.first << ") in '" << PrevE.second.Name
- << '\'';
- if (!PrevE.second.DWPName.empty()) {
- errs() << " (from ";
- if (!PrevE.second.DWOName.empty())
- errs() << '\'' << PrevE.second.DWOName << "' in ";
- errs() << "'" << PrevE.second.DWPName.str() << "')";
- }
- errs() << " and '" << ID.Name << '\'';
+std::string buildDWODescription(StringRef Name, StringRef DWPName, StringRef DWOName) {
+ std::string Text = "\'";
+ Text += Name;
+ Text += '\'';
if (!DWPName.empty()) {
- errs() << " (from ";
- if (*ID.DWOName)
- errs() << '\'' << ID.DWOName << "\' in ";
- errs() << '\'' << DWPName << "')";
+ Text += " (from ";
+ if (!DWOName.empty()) {
+ Text += '\'';
+ Text += DWOName;
+ Text += "' in ";
+ }
+ Text += '\'';
+ Text += DWPName;
+ Text += "')";
}
- errs() << '\n';
+ return Text;
+}
+
+std::string
+buildDuplicateError(const std::pair<uint64_t, UnitIndexEntry> &PrevE,
+ const CompileUnitIdentifiers &ID, StringRef DWPName) {
+ return std::string("Duplicate DWO ID (") + utohexstr(PrevE.first) + ") in " +
+ buildDWODescription(PrevE.second.Name, PrevE.second.DWPName,
+ PrevE.second.DWOName) +
+ " and " + buildDWODescription(ID.Name, DWPName, ID.DWOName);
}
static Error write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
const auto &MCOFI = *Out.getContext().getObjectFileInfo();
@@ -504,10 +511,8 @@ static Error write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
getSubsection(InfoSection, E, DW_SECT_INFO),
getSubsection(CurStrOffsetSection, E, DW_SECT_STR_OFFSETS),
CurStrSection);
- if (!P.second) {
- printDuplicateError(*P.first, ID, Input);
- return make_error<DWPError>("Duplicate DWO ID");
- }
+ if (!P.second)
+ return make_error<DWPError>(buildDuplicateError(*P.first, ID, Input));
auto &NewEntry = P.first->second;
NewEntry.Name = ID.Name;
NewEntry.DWOName = ID.DWOName;
@@ -535,10 +540,8 @@ static Error write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
CompileUnitIdentifiers ID = getCUIdentifiers(
AbbrevSection, InfoSection, CurStrOffsetSection, CurStrSection);
auto P = IndexEntries.insert(std::make_pair(ID.Signature, CurEntry));
- if (!P.second) {
- printDuplicateError(*P.first, ID, "");
- return make_error<DWPError>("Duplicate DWO ID");
- }
+ if (!P.second)
+ return make_error<DWPError>(buildDuplicateError(*P.first, ID, ""));
P.first->second.Name = ID.Name;
P.first->second.DWOName = ID.DWOName;
addAllTypes(Out, TypeIndexEntries, TypesSection, CurTypesSection,
OpenPOWER on IntegriCloud