diff options
| author | Paul Robinson <paul.robinson@sony.com> | 2018-06-22 14:16:11 +0000 |
|---|---|---|
| committer | Paul Robinson <paul.robinson@sony.com> | 2018-06-22 14:16:11 +0000 |
| commit | 11539b0969468cbab46a5b920a5454b016ccc4b9 (patch) | |
| tree | 531399d789460d2335fdac157d04fa0190d4ab0e /llvm/lib/MC | |
| parent | 1e564504bb17c65a46bbd7dc2ee6a45e78a8101e (diff) | |
| download | bcm5719-llvm-11539b0969468cbab46a5b920a5454b016ccc4b9.tar.gz bcm5719-llvm-11539b0969468cbab46a5b920a5454b016ccc4b9.zip | |
[DWARFv5] Allow ".loc 0" to refer to the root file.
DWARF v5 explicitly represents file #0 in the line table. Prior
versions did not, so ".loc 0" is still an error in those cases.
Differential Revision: https://reviews.llvm.org/D48452
llvm-svn: 335350
Diffstat (limited to 'llvm/lib/MC')
| -rw-r--r-- | llvm/lib/MC/MCContext.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/MC/MCParser/AsmParser.cpp | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 5c4d67b10dd..e4f90f4987a 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -556,11 +556,13 @@ Expected<unsigned> MCContext::getDwarfFile(StringRef Directory, /// isValidDwarfFileNumber - takes a dwarf file number and returns true if it /// currently is assigned and false otherwise. bool MCContext::isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID) { - const SmallVectorImpl<MCDwarfFile> &MCDwarfFiles = getMCDwarfFiles(CUID); - if (FileNumber == 0 || FileNumber >= MCDwarfFiles.size()) + const MCDwarfLineTable &LineTable = getMCDwarfLineTable(CUID); + if (FileNumber == 0) + return getDwarfVersion() >= 5 && LineTable.hasRootFile(); + if (FileNumber >= LineTable.getMCDwarfFiles().size()) return false; - return !MCDwarfFiles[FileNumber].Name.empty(); + return !LineTable.getMCDwarfFiles()[FileNumber].Name.empty(); } /// Remove empty sections from SectionStartEndSyms, to avoid generating diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 12c7ddee706..f021192f29f 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -3412,7 +3412,7 @@ bool AsmParser::parseDirectiveLoc() { int64_t FileNumber = 0, LineNumber = 0; SMLoc Loc = getTok().getLoc(); if (parseIntToken(FileNumber, "unexpected token in '.loc' directive") || - check(FileNumber < 1, Loc, + check(FileNumber < 1 && Ctx.getDwarfVersion() < 5, Loc, "file number less than one in '.loc' directive") || check(!getContext().isValidDwarfFileNumber(FileNumber), Loc, "unassigned file number in '.loc' directive")) |

