diff options
| author | Scott Linder <scott@scottlinder.com> | 2018-02-12 19:45:54 +0000 | 
|---|---|---|
| committer | Scott Linder <scott@scottlinder.com> | 2018-02-12 19:45:54 +0000 | 
| commit | 7160384d40ac5025c5ab23cd898b5370749c66a1 (patch) | |
| tree | a917fb3bd760c42467541559e913a5b09de8094c /llvm/lib/CodeGen | |
| parent | 4a4f35f32411abb73360247e53d59e1fea1ca7c8 (diff) | |
| download | bcm5719-llvm-7160384d40ac5025c5ab23cd898b5370749c66a1.tar.gz bcm5719-llvm-7160384d40ac5025c5ab23cd898b5370749c66a1.zip  | |
[DebugInfo] Unify ChecksumKind and Checksum value in DIFile
Rather than encode the absence of a checksum with a Kind variant, instead put
both the kind and value in a struct and wrap it in an Optional.
Differential Revision: http://reviews.llvm.org/D43043
llvm-svn: 324928
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 21 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 7 | 
2 files changed, 18 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index 9e714e4c38d..05c00014f44 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -165,14 +165,21 @@ unsigned CodeViewDebug::maybeRecordFile(const DIFile *F) {    auto Insertion = FileIdMap.insert(std::make_pair(FullPath, NextId));    if (Insertion.second) {      // We have to compute the full filepath and emit a .cv_file directive. -    std::string Checksum = fromHex(F->getChecksum()); -    void *CKMem = OS.getContext().allocate(Checksum.size(), 1); -    memcpy(CKMem, Checksum.data(), Checksum.size()); -    ArrayRef<uint8_t> ChecksumAsBytes(reinterpret_cast<const uint8_t *>(CKMem), -                                      Checksum.size()); -    DIFile::ChecksumKind ChecksumKind = F->getChecksumKind(); +    ArrayRef<uint8_t> ChecksumAsBytes; +    FileChecksumKind CSKind = FileChecksumKind::None; +    if (F->getChecksum()) { +      std::string Checksum = fromHex(F->getChecksum()->Value); +      void *CKMem = OS.getContext().allocate(Checksum.size(), 1); +      memcpy(CKMem, Checksum.data(), Checksum.size()); +      ChecksumAsBytes = ArrayRef<uint8_t>( +          reinterpret_cast<const uint8_t *>(CKMem), Checksum.size()); +      switch (F->getChecksum()->Kind) { +      case DIFile::CSK_MD5:  CSKind = FileChecksumKind::MD5; break; +      case DIFile::CSK_SHA1: CSKind = FileChecksumKind::SHA1; break; +      } +    }      bool Success = OS.EmitCVFileDirective(NextId, FullPath, ChecksumAsBytes, -                                          static_cast<unsigned>(ChecksumKind)); +                                          static_cast<unsigned>(CSKind));      (void)Success;      assert(Success && ".cv_file directive failed");    } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 939d13faec0..f799453d47d 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -280,15 +280,16 @@ void DwarfUnit::addSectionOffset(DIE &Die, dwarf::Attribute Attribute,  MD5::MD5Result *DwarfUnit::getMD5AsBytes(const DIFile *File) {    assert(File); -  if (File->getChecksumKind() != DIFile::CSK_MD5) +  Optional<DIFile::ChecksumInfo<StringRef>> Checksum = File->getChecksum(); +  if (!Checksum || Checksum->Kind != DIFile::CSK_MD5)      return nullptr;    // Convert the string checksum to an MD5Result for the streamer.    // The verifier validates the checksum so we assume it's okay.    // An MD5 checksum is 16 bytes. -  std::string Checksum = fromHex(File->getChecksum()); +  std::string ChecksumString = fromHex(Checksum->Value);    void *CKMem = Asm->OutStreamer->getContext().allocate(16, 1); -  memcpy(CKMem, Checksum.data(), 16); +  memcpy(CKMem, ChecksumString.data(), 16);    return reinterpret_cast<MD5::MD5Result *>(CKMem);  }  | 

