Skip to content

Commit

Permalink
DebugInfo: Don't crash if 'Debug Info Version' has a strange value
Browse files Browse the repository at this point in the history
llvm-svn: 229356
  • Loading branch information
majnemer committed Feb 16, 2015
1 parent 4b04292 commit e7a9cdb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/lib/IR/DebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions llvm/test/Assembler/invalid-debug-info-version.ll
Original file line number Diff line number Diff line change
@@ -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", !""}

0 comments on commit e7a9cdb

Please sign in to comment.