llvm.org GIT mirror llvm / 9dc47c0
Let subprograms with instructions without parent scopes fail the verification. Tested via a unit test. Follow-up to r226616. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226684 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 5 years ago
2 changed file(s) with 21 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
535535 Scope = D.isLexicalBlockFile()
536536 ? D.getScope()
537537 : DebugLoc::getFromDILexicalBlock(Scope).getScope();
538 assert(Scope && "lexical block file has no scope");
538 if (!Scope)
539 return false;
539540 }
540541 if (!DISubprogram(Scope).describes(F))
541542 return false;
99 #include "llvm/IR/IRBuilder.h"
1010 #include "llvm/IR/BasicBlock.h"
1111 #include "llvm/IR/DataLayout.h"
12 #include "llvm/IR/DIBuilder.h"
1213 #include "llvm/IR/Function.h"
1314 #include "llvm/IR/IntrinsicInst.h"
1415 #include "llvm/IR/LLVMContext.h"
286287 EXPECT_EQ(BB, Builder.GetInsertBlock());
287288 }
288289
289
290 }
290 TEST_F(IRBuilderTest, DIBuilder) {
291 IRBuilder<> Builder(BB);
292 DIBuilder DIB(*M);
293 auto File = DIB.createFile("F.CBL", "/");
294 auto CU = DIB.createCompileUnit(dwarf::DW_LANG_Cobol74, "F.CBL", "/",
295 "llvm-cobol74", true, "", 0);
296 auto Type = DIB.createSubroutineType(File, DIB.getOrCreateTypeArray({}));
297 auto SP = DIB.createFunction(CU, "foo", "", File, 1, Type,
298 false, true, 1, 0, true, F);
299 EXPECT_TRUE(SP.Verify());
300 AllocaInst *I = Builder.CreateAlloca(Builder.getInt8Ty());
301 auto BadScope = DIB.createLexicalBlockFile(DIDescriptor(), File, 0);
302 I->setDebugLoc(DebugLoc::get(2, 0, BadScope));
303 EXPECT_FALSE(SP.Verify());
304 }
305
306
307 }