diff --git a/ctx.cpp b/ctx.cpp index 95ef805d..c805bcf1 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -313,27 +313,32 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym, flags, g->opt.level > 0, llvmFunction); + Assert(diFile.Verify()); /* And start a scope representing the initial function scope */ StartScope(); llvm::DIFile file = funcStartPos.GetDIFile(); Symbol *programIndexSymbol = m->symbolTable->LookupVariable("programIndex"); Assert(programIndexSymbol && programIndexSymbol->storagePtr); - m->diBuilder->createGlobalVariable(programIndexSymbol->name, - file, - funcStartPos.first_line, - programIndexSymbol->type->GetDIType(file), - true /* static */, - programIndexSymbol->storagePtr); + llvm::DIGlobalVariable var = + m->diBuilder->createGlobalVariable(programIndexSymbol->name, + file, + funcStartPos.first_line, + programIndexSymbol->type->GetDIType(file), + true /* static */, + programIndexSymbol->storagePtr); + Assert(var.Verify()); Symbol *programCountSymbol = m->symbolTable->LookupVariable("programCount"); Assert(programCountSymbol); - m->diBuilder->createGlobalVariable(programCountSymbol->name, - file, - funcStartPos.first_line, - programCountSymbol->type->GetDIType(file), - true /* static */, - programCountSymbol->storagePtr); + var = + m->diBuilder->createGlobalVariable(programCountSymbol->name, + file, + funcStartPos.first_line, + programCountSymbol->type->GetDIType(file), + true /* static */, + programCountSymbol->storagePtr); + Assert(var.Verify()); } } @@ -1440,6 +1445,7 @@ FunctionEmitContext::StartScope() { m->diBuilder->createLexicalBlock(parentScope, diFile, currentPos.first_line, currentPos.first_column); + Assert(lexicalBlock.Verify()); debugScopes.push_back(lexicalBlock); } } @@ -1467,14 +1473,17 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) { return; llvm::DIScope scope = GetDIScope(); + llvm::DIType diType = sym->type->GetDIType(scope); + Assert(diType.Verify()); llvm::DIVariable var = m->diBuilder->createLocalVariable(llvm::dwarf::DW_TAG_auto_variable, scope, sym->name, sym->pos.GetDIFile(), sym->pos.first_line, - sym->type->GetDIType(scope), + diType, true /* preserve through opts */); + Assert(var.Verify()); llvm::Instruction *declareInst = m->diBuilder->insertDeclare(sym->storagePtr, var, bblock); AddDebugPos(declareInst, &sym->pos, &scope); diff --git a/ispc.cpp b/ispc.cpp index dce3ed77..2fcf27ff 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -644,7 +644,9 @@ llvm::DIFile SourcePos::GetDIFile() const { std::string directory, filename; GetDirectoryAndFileName(g->currentDirectory, name, &directory, &filename); - return m->diBuilder->createFile(filename, directory); + llvm::DIFile ret = m->diBuilder->createFile(filename, directory); + Assert(ret.Verify()); + return ret; } diff --git a/module.cpp b/module.cpp index bb339e4d..f61182ca 100644 --- a/module.cpp +++ b/module.cpp @@ -395,12 +395,14 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE if (diBuilder) { llvm::DIFile file = pos.GetDIFile(); - diBuilder->createGlobalVariable(name, - file, - pos.first_line, - sym->type->GetDIType(file), - (sym->storageClass == SC_STATIC), - sym->storagePtr); + llvm::DIGlobalVariable var = + diBuilder->createGlobalVariable(name, + file, + pos.first_line, + sym->type->GetDIType(file), + (sym->storageClass == SC_STATIC), + sym->storagePtr); + Assert(var.Verify()); } }