diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-02-13 01:20:38 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-02-13 01:20:38 +0000 |
commit | 171d077ae44a4a16d12f32db0c3cb100864949c7 (patch) | |
tree | a60f51a46f716106b68906efb84f4b4c72d1b021 /llvm/lib/Bitcode/Reader | |
parent | d6346e6f3ef8d46d91b582b089a6aabe91369624 (diff) | |
download | bcm5719-llvm-171d077ae44a4a16d12f32db0c3cb100864949c7.tar.gz bcm5719-llvm-171d077ae44a4a16d12f32db0c3cb100864949c7.zip |
AsmWriter/Bitcode: MDDerivedType and MDCompositeType
llvm-svn: 229009
Diffstat (limited to 'llvm/lib/Bitcode/Reader')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 2220c1dad87..6c38e0d85b4 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1183,12 +1183,17 @@ std::error_code BitcodeReader::ParseMetadata() { SmallVector<uint64_t, 64> Record; + auto getMD = + [&](unsigned ID) -> Metadata *{ return MDValueList.getValueFwdRef(ID); }; + auto getMDOrNull = [&](unsigned ID) -> Metadata *{ + if (ID) + return getMD(ID - 1); + return nullptr; + }; auto getMDString = [&](unsigned ID) -> MDString *{ // This requires that the ID is not really a forward reference. In // particular, the MDString must already have been resolved. - if (ID) - return cast<MDString>(MDValueList.getValueFwdRef(ID - 1)); - return nullptr; + return cast_or_null<MDString>(getMDOrNull(ID)); }; #define GET_OR_DISTINCT(CLASS, DISTINCT, ARGS) \ @@ -1382,6 +1387,36 @@ std::error_code BitcodeReader::ParseMetadata() { NextMDValueNo++); break; } + case bitc::METADATA_DERIVED_TYPE: { + if (Record.size() != 12) + return Error("Invalid record"); + + MDValueList.AssignValue( + GET_OR_DISTINCT(MDDerivedType, Record[0], + (Context, Record[1], getMDString(Record[2]), + getMDOrNull(Record[3]), Record[4], + getMDOrNull(Record[5]), getMD(Record[6]), Record[7], + Record[8], Record[9], Record[10], + getMDOrNull(Record[11]))), + NextMDValueNo++); + break; + } + case bitc::METADATA_COMPOSITE_TYPE: { + if (Record.size() != 16) + return Error("Invalid record"); + + MDValueList.AssignValue( + GET_OR_DISTINCT(MDCompositeType, Record[0], + (Context, Record[1], getMDString(Record[2]), + getMDOrNull(Record[3]), Record[4], + getMDOrNull(Record[5]), getMDOrNull(Record[6]), + Record[7], Record[8], Record[9], Record[10], + getMDOrNull(Record[11]), Record[12], + getMDOrNull(Record[13]), getMDOrNull(Record[14]), + getMDString(Record[15]))), + NextMDValueNo++); + break; + } case bitc::METADATA_FILE: { if (Record.size() != 3) return Error("Invalid record"); |