Add asserts to DIBuilder & fix DINameSpace::Verify to allow unnamed namespaces.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176837 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2013-03-11 23:21:19 +00:00
parent 6acbcd423b
commit 6643868498
2 changed files with 31 additions and 8 deletions

View File

@ -487,7 +487,9 @@ DIType DIBuilder::createClassType(DIDescriptor Context, StringRef Name,
DIType DerivedFrom, DIArray Elements,
MDNode *VTableHolder,
MDNode *TemplateParams) {
// TAG_class_type is encoded in DICompositeType format.
assert((!Context || Context.Verify()) &&
"createClassType should be called with a valid Context");
// TAG_class_type is encoded in DICompositeType format.
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_class_type),
getNonCompileUnitScope(Context),
@ -504,7 +506,9 @@ DIType DIBuilder::createClassType(DIDescriptor Context, StringRef Name,
VTableHolder,
TemplateParams
};
return DIType(MDNode::get(VMContext, Elts));
DIType R(MDNode::get(VMContext, Elts));
assert(R.Verify() && "createClassType should return a verifiable DIType");
return R;
}
/// createStructType - Create debugging information entry for a struct.
@ -534,7 +538,9 @@ DICompositeType DIBuilder::createStructType(DIDescriptor Context,
VTableHolder,
NULL,
};
return DICompositeType(MDNode::get(VMContext, Elts));
DICompositeType R(MDNode::get(VMContext, Elts));
assert(R.Verify() && "createStructType should return a verifiable DIType");
return R;
}
/// createUnionType - Create debugging information entry for an union.
@ -766,6 +772,8 @@ DIType DIBuilder::createForwardDecl(unsigned Tag, StringRef Name,
ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang)
};
MDNode *Node = MDNode::getTemporary(VMContext, Elts);
assert(DIType(Node).Verify() &&
"createForwardDecl result should be verifiable");
return DIType(Node);
}
@ -846,6 +854,11 @@ DIVariable DIBuilder::createLocalVariable(unsigned Tag, DIDescriptor Scope,
unsigned LineNo, DIType Ty,
bool AlwaysPreserve, unsigned Flags,
unsigned ArgNo) {
DIDescriptor Context(getNonCompileUnitScope(Scope));
assert((!Context || Context.Verify()) &&
"createLocalVariable should be called with a valid Context");
assert(Ty.Verify() &&
"createLocalVariable should be called with a valid type");
Value *Elts[] = {
GetTagConstant(VMContext, Tag),
getNonCompileUnitScope(Scope),
@ -865,6 +878,8 @@ DIVariable DIBuilder::createLocalVariable(unsigned Tag, DIDescriptor Scope,
NamedMDNode *FnLocals = getOrInsertFnSpecificMDNode(M, Fn);
FnLocals->addOperand(Node);
}
assert(DIVariable(Node).Verify() &&
"createLocalVariable should return a verifiable DIVariable");
return DIVariable(Node);
}
@ -990,7 +1005,10 @@ DINameSpace DIBuilder::createNameSpace(DIDescriptor Scope, StringRef Name,
File,
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo)
};
return DINameSpace(MDNode::get(VMContext, Elts));
DINameSpace R(MDNode::get(VMContext, Elts));
assert(R.Verify() &&
"createNameSpace should return a verifiable DINameSpace");
return R;
}
/// createLexicalBlockFile - This creates a new MDNode that encapsulates
@ -1002,7 +1020,11 @@ DILexicalBlockFile DIBuilder::createLexicalBlockFile(DIDescriptor Scope,
Scope,
File
};
return DILexicalBlockFile(MDNode::get(VMContext, Elts));
DILexicalBlockFile R(MDNode::get(VMContext, Elts));
assert(
R.Verify() &&
"createLexicalBlockFile should return a verifiable DILexicalBlockFile");
return R;
}
DILexicalBlock DIBuilder::createLexicalBlock(DIDescriptor Scope, DIFile File,
@ -1017,7 +1039,10 @@ DILexicalBlock DIBuilder::createLexicalBlock(DIDescriptor Scope, DIFile File,
File,
ConstantInt::get(Type::getInt32Ty(VMContext), unique_id++)
};
return DILexicalBlock(MDNode::get(VMContext, Elts));
DILexicalBlock R(MDNode::get(VMContext, Elts));
assert(R.Verify() &&
"createLexicalBlock should return a verifiable DILexicalBlock");
return R;
}
/// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.

View File

@ -517,8 +517,6 @@ bool DILocation::Verify() const {
bool DINameSpace::Verify() const {
if (!DbgNode)
return false;
if (getName().empty())
return false;
return true;
}