From 1a4cbbe49fcaebe63246c784983556528bcb27d8 Mon Sep 17 00:00:00 2001 From: Bob Haarman Date: Wed, 30 Aug 2017 17:50:21 +0000 Subject: [codeview] make DbgVariableLocation::extractFromMachineInstruction use Optional Summary: DbgVariableLocation::extractFromMachineInstruction originally returned a boolean indicating success. This change makes it return an Optional so we cannot try to access the fields of the struct if they aren't valid. Reviewers: aprantl, rnk, zturner Subscribers: llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D37279 llvm-svn: 312143 --- llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp') diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp index 2a3c0d7e4c4..ee8b38f6502 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp @@ -13,6 +13,8 @@ //===----------------------------------------------------------------------===// #include "DebugHandlerBase.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/Twine.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstr.h" @@ -23,12 +25,14 @@ using namespace llvm; -bool DbgVariableLocation::extractFromMachineInstruction( - DbgVariableLocation &Location, const MachineInstr &Instruction) { +Optional +DbgVariableLocation::extractFromMachineInstruction( + const MachineInstr &Instruction) { + DbgVariableLocation Location; if (!Instruction.isDebugValue()) - return false; + return None; if (!Instruction.getOperand(0).isReg()) - return false; + return None; Location.Register = Instruction.getOperand(0).getReg(); Location.InMemory = Instruction.getOperand(1).isImm(); Location.Deref = false; @@ -66,13 +70,13 @@ bool DbgVariableLocation::extractFromMachineInstruction( Location.Deref = true; break; default: - return false; + return None; } ++Op; } Location.Offset = Offset; - return true; + return Location; } DebugHandlerBase::DebugHandlerBase(AsmPrinter *A) : Asm(A), MMI(Asm->MMI) {} -- cgit v1.2.3