[llvm] r229356 - DebugInfo: Don't crash if 'Debug Info Version' has a strange value

David Majnemer david.majnemer at gmail.com
Sun Feb 15 22:04:53 PST 2015


Author: majnemer
Date: Mon Feb 16 00:04:53 2015
New Revision: 229356

URL: http://llvm.org/viewvc/llvm-project?rev=229356&view=rev
Log:
DebugInfo: Don't crash if 'Debug Info Version' has a strange value

Added:
    llvm/trunk/test/Assembler/invalid-debug-info-version.ll
Modified:
    llvm/trunk/lib/IR/DebugInfo.cpp

Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=229356&r1=229355&r2=229356&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Feb 16 00:04:53 2015
@@ -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;

Added: llvm/trunk/test/Assembler/invalid-debug-info-version.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-debug-info-version.ll?rev=229356&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-debug-info-version.ll (added)
+++ llvm/trunk/test/Assembler/invalid-debug-info-version.ll Mon Feb 16 00:04:53 2015
@@ -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", !""}





More information about the llvm-commits mailing list