[llvm] r176837 - Add asserts to DIBuilder & fix DINameSpace::Verify to allow unnamed namespaces.
David Blaikie
dblaikie at gmail.com
Mon Mar 11 16:21:19 PDT 2013
Author: dblaikie
Date: Mon Mar 11 18:21:19 2013
New Revision: 176837
URL: http://llvm.org/viewvc/llvm-project?rev=176837&view=rev
Log:
Add asserts to DIBuilder & fix DINameSpace::Verify to allow unnamed namespaces.
Modified:
llvm/trunk/lib/IR/DIBuilder.cpp
llvm/trunk/lib/IR/DebugInfo.cpp
Modified: llvm/trunk/lib/IR/DIBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=176837&r1=176836&r2=176837&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DIBuilder.cpp (original)
+++ llvm/trunk/lib/IR/DIBuilder.cpp Mon Mar 11 18:21:19 2013
@@ -487,7 +487,9 @@ DIType DIBuilder::createClassType(DIDesc
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(DIDesc
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::createStructT
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(unsi
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::createLocalVariabl
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::createLocalVariabl
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(D
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::createLexi
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::createLexicalB
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.
Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=176837&r1=176836&r2=176837&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Mar 11 18:21:19 2013
@@ -517,8 +517,6 @@ bool DILocation::Verify() const {
bool DINameSpace::Verify() const {
if (!DbgNode)
return false;
- if (getName().empty())
- return false;
return true;
}
More information about the llvm-commits
mailing list