Verifier: Check operands of MDSubprogram nodes

Check operands of `MDSubprogram`s in the verifier, and update the
accessors and factory functions to use more specific types.

There were a lot of broken testcases, which I fixed in r233466.  If you
have out-of-tree tests for debug info, you probably need similar changes
to the ones I made there.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233559 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith
2015-03-30 16:19:15 +00:00
parent f88cbb8c49
commit bd38c8d788
6 changed files with 186 additions and 91 deletions

View File

@ -674,9 +674,11 @@ DISubprogram DIBuilder::createFunction(DIDescriptor Context, StringRef Name,
"function types should be subroutines");
auto *Node = MDSubprogram::get(
VMContext, DIScope(getNonCompileUnitScope(Context)).getRef(), Name,
LinkageName, File.getFileNode(), LineNo, Ty, isLocalToUnit, isDefinition,
ScopeLine, nullptr, 0, 0, Flags, isOptimized, getConstantOrNull(Fn),
TParams, Decl, MDNode::getTemporary(VMContext, None).release());
LinkageName, File.get(), LineNo, cast_or_null<MDSubroutineType>(Ty.get()),
isLocalToUnit, isDefinition, ScopeLine, nullptr, 0, 0, Flags, isOptimized,
getConstantOrNull(Fn), cast_or_null<MDTuple>(TParams),
cast_or_null<MDSubprogram>(Decl),
MDTuple::getTemporary(VMContext, None).release());
if (isDefinition)
AllSubprograms.push_back(Node);
@ -694,9 +696,11 @@ DIBuilder::createTempFunctionFwdDecl(DIDescriptor Context, StringRef Name,
MDNode *TParams, MDNode *Decl) {
return MDSubprogram::getTemporary(
VMContext, DIScope(getNonCompileUnitScope(Context)).getRef(), Name,
LinkageName, File.getFileNode(), LineNo, Ty, isLocalToUnit,
LinkageName, File.get(), LineNo,
cast_or_null<MDSubroutineType>(Ty.get()), isLocalToUnit,
isDefinition, ScopeLine, nullptr, 0, 0, Flags, isOptimized,
getConstantOrNull(Fn), TParams, Decl, nullptr).release();
getConstantOrNull(Fn), cast_or_null<MDTuple>(TParams),
cast_or_null<MDSubprogram>(Decl), nullptr).release();
}
DISubprogram DIBuilder::createMethod(DIDescriptor Context, StringRef Name,
@ -714,10 +718,10 @@ DISubprogram DIBuilder::createMethod(DIDescriptor Context, StringRef Name,
"the compile unit.");
// FIXME: Do we want to use different scope/lines?
auto *Node = MDSubprogram::get(
VMContext, DIScope(Context).getRef(), Name, LinkageName, F.getFileNode(),
LineNo, Ty, isLocalToUnit, isDefinition, LineNo, VTableHolder.getRef(),
VK, VIndex, Flags, isOptimized, getConstantOrNull(Fn), TParam, nullptr,
nullptr);
VMContext, DIScope(Context).getRef(), Name, LinkageName, F.get(), LineNo,
cast_or_null<MDSubroutineType>(Ty.get()), isLocalToUnit, isDefinition,
LineNo, VTableHolder.getRef(), VK, VIndex, Flags, isOptimized,
getConstantOrNull(Fn), cast_or_null<MDTuple>(TParam), nullptr, nullptr);
if (isDefinition)
AllSubprograms.push_back(Node);