summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader
diff options
context:
space:
mode:
authorScott Linder <scott@scottlinder.com>2018-02-12 19:45:54 +0000
committerScott Linder <scott@scottlinder.com>2018-02-12 19:45:54 +0000
commit7160384d40ac5025c5ab23cd898b5370749c66a1 (patch)
treea917fb3bd760c42467541559e913a5b09de8094c /llvm/lib/Bitcode/Reader
parent4a4f35f32411abb73360247e53d59e1fea1ca7c8 (diff)
downloadbcm5719-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/Bitcode/Reader')
-rw-r--r--llvm/lib/Bitcode/Reader/MetadataLoader.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
index 374e3152816..0931192cd18 100644
--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -1354,13 +1354,20 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
return error("Invalid record");
IsDistinct = Record[0];
+ Optional<DIFile::ChecksumInfo<MDString *>> Checksum;
+ // The BitcodeWriter writes null bytes into Record[3:4] when the Checksum
+ // is not present. This matches up with the old internal representation,
+ // and the old encoding for CSK_None in the ChecksumKind. The new
+ // representation reserves the value 0 in the ChecksumKind to continue to
+ // encode None in a backwards-compatible way.
+ if (Record.size() == 5 && Record[3] && Record[4])
+ Checksum.emplace(static_cast<DIFile::ChecksumKind>(Record[3]),
+ getMDString(Record[4]));
MetadataList.assignValue(
GET_OR_DISTINCT(
DIFile,
(Context, getMDString(Record[1]), getMDString(Record[2]),
- Record.size() == 3 ? DIFile::CSK_None
- : static_cast<DIFile::ChecksumKind>(Record[3]),
- Record.size() == 3 ? nullptr : getMDString(Record[4]))),
+ Checksum)),
NextMetadataNo);
NextMetadataNo++;
break;
OpenPOWER on IntegriCloud