BitcodeReader: Use getMD/getMDOrNull helpers consistently, almost NFC

The only functionality change was removing an error check from the
BitcodeReader (and an assertion from DILocation::getImpl) that is
already caught by Verifier::visitDILocation.  The Verifier is a better
place for this anyway, and being inconsistent with other subclasses of
MDNode isn't serving anyone.

llvm-svn: 267267
This commit is contained in:
Duncan P. N. Exon Smith 2016-04-23 03:55:14 +00:00
parent 6e6a1f0a5b
commit 004509dca1
2 changed files with 5 additions and 11 deletions

View File

@ -2057,7 +2057,7 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
if (!Ty)
return error("Invalid record");
if (Ty->isMetadataTy())
Elts.push_back(MetadataList.getMetadataFwdRef(Record[i + 1]));
Elts.push_back(getMD(Record[i + 1]));
else if (!Ty->isVoidTy()) {
auto *MD =
ValueAsMetadata::get(ValueList.getValueFwdRef(Record[i + 1], Ty));
@ -2090,7 +2090,7 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
SmallVector<Metadata *, 8> Elts;
Elts.reserve(Record.size());
for (unsigned ID : Record)
Elts.push_back(ID ? MetadataList.getMetadataFwdRef(ID - 1) : nullptr);
Elts.push_back(getMDOrNull(ID));
MetadataList.assignValue(IsDistinct ? MDNode::getDistinct(Context, Elts)
: MDNode::get(Context, Elts),
NextMetadataNo++);
@ -2102,11 +2102,8 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
unsigned Line = Record[1];
unsigned Column = Record[2];
MDNode *Scope = MetadataList.getMDNodeFwdRefOrNull(Record[3]);
if (!Scope)
return error("Invalid record");
Metadata *InlinedAt =
Record[4] ? MetadataList.getMetadataFwdRef(Record[4] - 1) : nullptr;
Metadata *Scope = getMD(Record[3]);
Metadata *InlinedAt = getMDOrNull(Record[4]);
MetadataList.assignValue(
GET_OR_DISTINCT(DILocation, Record[0],
(Context, Line, Column, Scope, InlinedAt)),
@ -2126,9 +2123,7 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
auto *Header = getMDString(Record[3]);
SmallVector<Metadata *, 8> DwarfOps;
for (unsigned I = 4, E = Record.size(); I != E; ++I)
DwarfOps.push_back(Record[I]
? MetadataList.getMetadataFwdRef(Record[I] - 1)
: nullptr);
DwarfOps.push_back(getMDOrNull(Record[I]));
MetadataList.assignValue(
GET_OR_DISTINCT(GenericDINode, Record[0],
(Context, Tag, Header, DwarfOps)),

View File

@ -45,7 +45,6 @@ DILocation *DILocation::getImpl(LLVMContext &Context, unsigned Line,
// Fixup column.
adjustColumn(Column);
assert(Scope && "Expected scope");
if (Storage == Uniqued) {
if (auto *N =
getUniqued(Context.pImpl->DILocations,