summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCDwarf.cpp
diff options
context:
space:
mode:
authorPaul Robinson <paul.robinson@sony.com>2018-02-22 21:03:33 +0000
committerPaul Robinson <paul.robinson@sony.com>2018-02-22 21:03:33 +0000
commit70def12a967508c93ed466af80b77031e522d796 (patch)
tree3ce9b4efb62aa8cb833ce5b6521d9a70d9e7d048 /llvm/lib/MC/MCDwarf.cpp
parentfd6fcbc0063876e14cbb52bac2902d570b4e28b2 (diff)
downloadbcm5719-llvm-70def12a967508c93ed466af80b77031e522d796.tar.gz
bcm5719-llvm-70def12a967508c93ed466af80b77031e522d796.zip
[DWARFv5] Turn an assert into a diagnostic. Hand-coded assembler files
should not trigger assertions. Differential Revision: https://reviews.llvm.org/D43152 llvm-svn: 325831
Diffstat (limited to 'llvm/lib/MC/MCDwarf.cpp')
-rw-r--r--llvm/lib/MC/MCDwarf.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index 29c08440f4f..1f0fa78bffc 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -497,16 +497,17 @@ void MCDwarfLineTable::EmitCU(MCObjectStreamer *MCOS,
MCOS->EmitLabel(LineEndSym);
}
-unsigned MCDwarfLineTable::getFile(StringRef &Directory, StringRef &FileName,
- MD5::MD5Result *Checksum,
- unsigned FileNumber) {
- return Header.getFile(Directory, FileName, Checksum, FileNumber);
+Expected<unsigned> MCDwarfLineTable::tryGetFile(StringRef &Directory,
+ StringRef &FileName,
+ MD5::MD5Result *Checksum,
+ unsigned FileNumber) {
+ return Header.tryGetFile(Directory, FileName, Checksum, FileNumber);
}
-unsigned MCDwarfLineTableHeader::getFile(StringRef &Directory,
- StringRef &FileName,
- MD5::MD5Result *Checksum,
- unsigned FileNumber) {
+Expected<unsigned> MCDwarfLineTableHeader::tryGetFile(StringRef &Directory,
+ StringRef &FileName,
+ MD5::MD5Result *Checksum,
+ unsigned FileNumber) {
if (Directory == CompilationDir)
Directory = "";
if (FileName.empty()) {
@@ -514,6 +515,9 @@ unsigned MCDwarfLineTableHeader::getFile(StringRef &Directory,
Directory = "";
}
assert(!FileName.empty());
+ // If any files have an MD5 checksum, they all must.
+ if (MCDwarfFiles.empty())
+ HasMD5 = (Checksum != nullptr);
if (FileNumber == 0) {
// File numbers start with 1 and/or after any file numbers
// allocated by inline-assembler .file directives.
@@ -532,13 +536,15 @@ unsigned MCDwarfLineTableHeader::getFile(StringRef &Directory,
// Get the new MCDwarfFile slot for this FileNumber.
MCDwarfFile &File = MCDwarfFiles[FileNumber];
- // It is an error to use see the same number more than once.
+ // It is an error to see the same number more than once.
if (!File.Name.empty())
- return 0;
+ return make_error<StringError>("file number already allocated",
+ inconvertibleErrorCode());
// If any files have an MD5 checksum, they all must.
- if (FileNumber > 1)
- assert(HasMD5 == (Checksum != nullptr));
+ if (HasMD5 != (Checksum != nullptr))
+ return make_error<StringError>("inconsistent use of MD5 checksums",
+ inconvertibleErrorCode());
if (Directory.empty()) {
// Separate the directory part from the basename of the FileName.
OpenPOWER on IntegriCloud