@@ -386,7 +386,7 @@ void MCDwarfLineTableHeader::emitV2FileDirTables(MCStreamer *MCOS) const {
386386}
387387
388388static void emitOneV5FileEntry (MCStreamer *MCOS, const MCDwarfFile &DwarfFile,
389- bool EmitMD5, bool HasSource ,
389+ bool EmitMD5, bool HasAnySource ,
390390 std::optional<MCDwarfLineStr> &LineStr) {
391391 assert (!DwarfFile.Name .empty ());
392392 if (LineStr)
@@ -401,7 +401,7 @@ static void emitOneV5FileEntry(MCStreamer *MCOS, const MCDwarfFile &DwarfFile,
401401 MCOS->emitBinaryData (
402402 StringRef (reinterpret_cast <const char *>(Cksum.data ()), Cksum.size ()));
403403 }
404- if (HasSource ) {
404+ if (HasAnySource ) {
405405 if (LineStr)
406406 LineStr->emitRef (MCOS, DwarfFile.Source .value_or (StringRef ()));
407407 else {
@@ -452,7 +452,7 @@ void MCDwarfLineTableHeader::emitV5FileDirTables(
452452 uint64_t Entries = 2 ;
453453 if (HasAllMD5)
454454 Entries += 1 ;
455- if (HasSource )
455+ if (HasAnySource )
456456 Entries += 1 ;
457457 MCOS->emitInt8 (Entries);
458458 MCOS->emitULEB128IntValue (dwarf::DW_LNCT_path);
@@ -464,7 +464,7 @@ void MCDwarfLineTableHeader::emitV5FileDirTables(
464464 MCOS->emitULEB128IntValue (dwarf::DW_LNCT_MD5);
465465 MCOS->emitULEB128IntValue (dwarf::DW_FORM_data16);
466466 }
467- if (HasSource ) {
467+ if (HasAnySource ) {
468468 MCOS->emitULEB128IntValue (dwarf::DW_LNCT_LLVM_source);
469469 MCOS->emitULEB128IntValue (LineStr ? dwarf::DW_FORM_line_strp
470470 : dwarf::DW_FORM_string);
@@ -479,9 +479,9 @@ void MCDwarfLineTableHeader::emitV5FileDirTables(
479479 assert ((!RootFile.Name .empty () || MCDwarfFiles.size () >= 1 ) &&
480480 " No root file and no .file directives" );
481481 emitOneV5FileEntry (MCOS, RootFile.Name .empty () ? MCDwarfFiles[1 ] : RootFile,
482- HasAllMD5, HasSource , LineStr);
482+ HasAllMD5, HasAnySource , LineStr);
483483 for (unsigned i = 1 ; i < MCDwarfFiles.size (); ++i)
484- emitOneV5FileEntry (MCOS, MCDwarfFiles[i], HasAllMD5, HasSource , LineStr);
484+ emitOneV5FileEntry (MCOS, MCDwarfFiles[i], HasAllMD5, HasAnySource , LineStr);
485485}
486486
487487std::pair<MCSymbol *, MCSymbol *>
@@ -598,7 +598,7 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory, StringRef &FileName,
598598 // If any files have embedded source, they all must.
599599 if (MCDwarfFiles.empty ()) {
600600 trackMD5Usage (Checksum.has_value ());
601- HasSource = ( Source != std:: nullopt );
601+ HasAnySource |= Source. has_value ( );
602602 }
603603 if (DwarfVersion >= 5 && isRootFile (RootFile, Directory, FileName, Checksum))
604604 return 0 ;
@@ -625,11 +625,6 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory, StringRef &FileName,
625625 return make_error<StringError>(" file number already allocated" ,
626626 inconvertibleErrorCode ());
627627
628- // If any files have embedded source, they all must.
629- if (HasSource != (Source != std::nullopt ))
630- return make_error<StringError>(" inconsistent use of embedded source" ,
631- inconvertibleErrorCode ());
632-
633628 if (Directory.empty ()) {
634629 // Separate the directory part from the basename of the FileName.
635630 StringRef tFileName = sys::path::filename (FileName);
@@ -662,8 +657,8 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory, StringRef &FileName,
662657 File.Checksum = Checksum;
663658 trackMD5Usage (Checksum.has_value ());
664659 File.Source = Source;
665- if (Source)
666- HasSource = true ;
660+ if (Source. has_value () )
661+ HasAnySource = true ;
667662
668663 // return the allocated FileNumber.
669664 return FileNumber;
0 commit comments