[llvm] r226684 - Let subprograms with instructions without parent scopes fail the
Adrian Prantl
aprantl at apple.com
Wed Jan 21 10:32:57 PST 2015
Author: adrian
Date: Wed Jan 21 12:32:56 2015
New Revision: 226684
URL: http://llvm.org/viewvc/llvm-project?rev=226684&view=rev
Log:
Let subprograms with instructions without parent scopes fail the
verification. Tested via a unit test.
Follow-up to r226616.
Modified:
llvm/trunk/lib/IR/DebugInfo.cpp
llvm/trunk/unittests/IR/IRBuilderTest.cpp
Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=226684&r1=226683&r2=226684&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Wed Jan 21 12:32:56 2015
@@ -536,7 +536,8 @@ bool DISubprogram::Verify() const {
Scope = D.isLexicalBlockFile()
? D.getScope()
: DebugLoc::getFromDILexicalBlock(Scope).getScope();
- assert(Scope && "lexical block file has no scope");
+ if (!Scope)
+ return false;
}
if (!DISubprogram(Scope).describes(F))
return false;
Modified: llvm/trunk/unittests/IR/IRBuilderTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/IRBuilderTest.cpp?rev=226684&r1=226683&r2=226684&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/IRBuilderTest.cpp (original)
+++ llvm/trunk/unittests/IR/IRBuilderTest.cpp Wed Jan 21 12:32:56 2015
@@ -10,6 +10,7 @@
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
@@ -287,5 +288,21 @@ TEST_F(IRBuilderTest, RAIIHelpersTest) {
EXPECT_EQ(BB, Builder.GetInsertBlock());
}
+TEST_F(IRBuilderTest, DIBuilder) {
+ IRBuilder<> Builder(BB);
+ DIBuilder DIB(*M);
+ auto File = DIB.createFile("F.CBL", "/");
+ auto CU = DIB.createCompileUnit(dwarf::DW_LANG_Cobol74, "F.CBL", "/",
+ "llvm-cobol74", true, "", 0);
+ auto Type = DIB.createSubroutineType(File, DIB.getOrCreateTypeArray({}));
+ auto SP = DIB.createFunction(CU, "foo", "", File, 1, Type,
+ false, true, 1, 0, true, F);
+ EXPECT_TRUE(SP.Verify());
+ AllocaInst *I = Builder.CreateAlloca(Builder.getInt8Ty());
+ auto BadScope = DIB.createLexicalBlockFile(DIDescriptor(), File, 0);
+ I->setDebugLoc(DebugLoc::get(2, 0, BadScope));
+ EXPECT_FALSE(SP.Verify());
+}
+
}
More information about the llvm-commits
mailing list