summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
diff options
context:
space:
mode:
authorBob Haarman <llvm@inglorion.net>2017-08-30 17:50:21 +0000
committerBob Haarman <llvm@inglorion.net>2017-08-30 17:50:21 +0000
commit1a4cbbe49fcaebe63246c784983556528bcb27d8 (patch)
tree26ebda46b76fefeac1bb84988e1857039237066c /llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
parentecd4d828811671a608b115b4de66504bcca4e785 (diff)
downloadbcm5719-llvm-1a4cbbe49fcaebe63246c784983556528bcb27d8.tar.gz
bcm5719-llvm-1a4cbbe49fcaebe63246c784983556528bcb27d8.zip
[codeview] make DbgVariableLocation::extractFromMachineInstruction use Optional
Summary: DbgVariableLocation::extractFromMachineInstruction originally returned a boolean indicating success. This change makes it return an Optional<DbgVariableLocation> 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
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp16
1 files changed, 10 insertions, 6 deletions
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>
+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) {}
OpenPOWER on IntegriCloud