]> granicus.if.org Git - llvm/commitdiff
DebugInfo: Don't crash if 'Debug Info Version' has a strange value
authorDavid Majnemer <david.majnemer@gmail.com>
Mon, 16 Feb 2015 06:04:53 +0000 (06:04 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Mon, 16 Feb 2015 06:04:53 +0000 (06:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229356 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/DebugInfo.cpp
test/Assembler/invalid-debug-info-version.ll [new file with mode: 0644]

index 31f1e19a94539a365a20f791b13ddfc61d53e760..deeaae7d5de2a90e3d3539062afbb9b08eb964b0 100644 (file)
@@ -1537,7 +1537,7 @@ bool llvm::StripDebugInfo(Module &M) {
 }
 
 unsigned llvm::getDebugMetadataVersionFromModule(const Module &M) {
-  if (auto *Val = mdconst::extract_or_null<ConstantInt>(
+  if (auto *Val = mdconst::dyn_extract_or_null<ConstantInt>(
           M.getModuleFlag("Debug Info Version")))
     return Val->getZExtValue();
   return 0;
diff --git a/test/Assembler/invalid-debug-info-version.ll b/test/Assembler/invalid-debug-info-version.ll
new file mode 100644 (file)
index 0000000..94a8153
--- /dev/null
@@ -0,0 +1,5 @@
+; RUN: opt < %s -S | FileCheck %s
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"Debug Info Version", !""}
+; CHECK: !{i32 1, !"Debug Info Version", !""}