aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/DIBuilder.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2011-09-12 18:26:08 +0000
committerDevang Patel <dpatel@apple.com>2011-09-12 18:26:08 +0000
commit811ae5b09cc2727e9a7a8748c6124d5bbd30707f (patch)
treee6b43b2dbccb85f1389fa8ba3577d9d06e3ccf79 /lib/Analysis/DIBuilder.cpp
parent9f3b6a5a2af469f7cae7fa127d3a33741108a0a9 (diff)
Add asserts to keep front-ends honest while encoding debug info into LLVM IR using DIBuilder.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139515 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DIBuilder.cpp')
-rw-r--r--lib/Analysis/DIBuilder.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Analysis/DIBuilder.cpp b/lib/Analysis/DIBuilder.cpp
index 3213be51c4..d7206a6a06 100644
--- a/lib/Analysis/DIBuilder.cpp
+++ b/lib/Analysis/DIBuilder.cpp
@@ -76,6 +76,10 @@ void DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename,
StringRef Directory, StringRef Producer,
bool isOptimized, StringRef Flags,
unsigned RunTimeVer) {
+ assert (Lang <= dwarf::DW_LANG_D && Lang >= dwarf::DW_LANG_C89
+ && "Invalid Language tag");
+ assert (!Filename.empty()
+ && "Unable to create compile unit without filename");
Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
TempEnumTypes = MDNode::getTemporary(VMContext, TElts);
Value *THElts[] = { TempEnumTypes };
@@ -121,6 +125,7 @@ void DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename,
/// for a file.
DIFile DIBuilder::createFile(StringRef Filename, StringRef Directory) {
assert(TheCU && "Unable to create DW_TAG_file_type without CompileUnit");
+ assert(!Filename.empty() && "Unable to create file without name");
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_file_type),
MDString::get(VMContext, Filename),
@@ -132,6 +137,7 @@ DIFile DIBuilder::createFile(StringRef Filename, StringRef Directory) {
/// createEnumerator - Create a single enumerator value.
DIEnumerator DIBuilder::createEnumerator(StringRef Name, uint64_t Val) {
+ assert(!Name.empty() && "Unable to create enumerator without name");
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_enumerator),
MDString::get(VMContext, Name),
@@ -145,6 +151,7 @@ DIEnumerator DIBuilder::createEnumerator(StringRef Name, uint64_t Val) {
DIType DIBuilder::createBasicType(StringRef Name, uint64_t SizeInBits,
uint64_t AlignInBits,
unsigned Encoding) {
+ assert(!Name.empty() && "Unable to create type without name");
// Basic types are encoded in DIBasicType format. Line number, filename,
// offset and flags are always empty here.
Value *Elts[] = {
@@ -202,6 +209,7 @@ DIType DIBuilder::createPointerType(DIType PointeeTy, uint64_t SizeInBits,
/// createReferenceType - Create debugging information entry for a reference.
DIType DIBuilder::createReferenceType(DIType RTy) {
+ assert(RTy.Verify() && "Unable to create reference type");
// References are encoded in DIDerivedType format.
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_reference_type),
@@ -262,6 +270,7 @@ DIType DIBuilder::createFriend(DIType Ty, DIType FriendTy) {
/// inheritnace relationship between two types.
DIType DIBuilder::createInheritance(DIType Ty, DIType BaseTy,
uint64_t BaseOffset, unsigned Flags) {
+ assert(Ty.Verify() && "Unable to create inheritance");
// TAG_inheritance is encoded in DIDerivedType format.
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_inheritance),