From c79eba57304d541938e0643651e29216df541687 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Wed, 16 Aug 2017 15:16:33 +0000 Subject: [PATCH] [Verifier] Reject globals without a type associated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311012 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/Verifier.cpp | 1 + test/DebugInfo/pr34186.ll | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 test/DebugInfo/pr34186.ll diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index 84c93c440fd..d08b69fd4aa 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -1150,6 +1150,7 @@ void Verifier::visitDIGlobalVariable(const DIGlobalVariable &N) { AssertDI(N.getTag() == dwarf::DW_TAG_variable, "invalid tag", &N); AssertDI(!N.getName().empty(), "missing global variable name", &N); + AssertDI(N.getType(), "missing global variable type", &N); if (auto *Member = N.getRawStaticDataMemberDeclaration()) { AssertDI(isa(Member), "invalid static data member declaration", &N, Member); diff --git a/test/DebugInfo/pr34186.ll b/test/DebugInfo/pr34186.ll new file mode 100644 index 00000000000..63d750659d1 --- /dev/null +++ b/test/DebugInfo/pr34186.ll @@ -0,0 +1,12 @@ +; RUN: not llc %s 2>&1 | FileCheck %s +; CHECK: missing global variable type + +!llvm.dbg.cu = !{!2} +!llvm.module.flags = !{!63, !64} +!1 = distinct !DIGlobalVariable(name: "pat", scope: !2, file: !3, line: 27, isLocal: true, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "", emissionKind: FullDebug, globals: !5) +!3 = !DIFile(filename: "patatino.c", directory: "/") +!5 = !{!6} +!6 = !DIGlobalVariableExpression(var: !1) +!63 = !{i32 2, !"Dwarf Version", i32 4} +!64 = !{i32 2, !"Debug Info Version", i32 3} -- 2.40.0