From 11539b0969468cbab46a5b920a5454b016ccc4b9 Mon Sep 17 00:00:00 2001 From: Paul Robinson Date: Fri, 22 Jun 2018 14:16:11 +0000 Subject: [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 --- llvm/lib/MC/MCContext.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'llvm/lib/MC/MCContext.cpp') 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 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 &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 -- cgit v1.2.3