From 004509dca1948c69808f1a4682a8f62b2987e78e Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Sat, 23 Apr 2016 03:55:14 +0000 Subject: [PATCH] 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 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 15 +++++---------- llvm/lib/IR/DebugInfoMetadata.cpp | 1 - 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 86945c0d5ccc..9d5f2807900a 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -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 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 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)), diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp index 3475971d348c..2c9873078c45 100644 --- a/llvm/lib/IR/DebugInfoMetadata.cpp +++ b/llvm/lib/IR/DebugInfoMetadata.cpp @@ -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,