summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.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/CodeViewDebug.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/CodeViewDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 0b7fdfdda2a..e0f11714b84 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -960,11 +960,9 @@ void CodeViewDebug::calculateRanges(
assert(DVInst->isDebugValue() && "Invalid History entry");
// FIXME: Find a way to represent constant variables, since they are
// relatively common.
- DbgVariableLocation Location;
- bool Supported =
- DbgVariableLocation::extractFromMachineInstruction(Location, *DVInst);
- // If not Supported, don't even look at Location because it's invalid.
- if (!Supported)
+ Optional<DbgVariableLocation> Location =
+ DbgVariableLocation::extractFromMachineInstruction(*DVInst);
+ if (!Location)
continue;
// Because we cannot express DW_OP_deref in CodeView directly,
@@ -975,13 +973,13 @@ void CodeViewDebug::calculateRanges(
// we need to remove a level of indirection from incoming locations.
// E.g. [RSP+8] with DW_OP_deref becomes [RSP+8],
// and [RCX+0] without DW_OP_deref becomes RCX.
- if (!Location.Deref) {
- if (Location.InMemory)
- Location.InMemory = false;
+ if (!Location->Deref) {
+ if (Location->InMemory)
+ Location->InMemory = false;
else
- Supported = false;
+ continue;
}
- } else if (Location.Deref) {
+ } else if (Location->Deref) {
// We've encountered a Deref range when we had not applied the
// reference encoding. Start over using reference encoding.
Var.Deref = true;
@@ -991,19 +989,18 @@ void CodeViewDebug::calculateRanges(
}
// If we don't know how to handle this range, skip past it.
- if (!Supported || Location.Register == 0 ||
- (Location.Offset && !Location.InMemory))
+ if (Location->Register == 0 || (Location->Offset && !Location->InMemory))
continue;
// Handle the two cases we can handle: indirect in memory and in register.
{
LocalVarDefRange DR;
- DR.CVRegister = TRI->getCodeViewRegNum(Location.Register);
- DR.InMemory = Location.InMemory;
- DR.DataOffset = Location.Offset;
- if (Location.FragmentInfo) {
+ DR.CVRegister = TRI->getCodeViewRegNum(Location->Register);
+ DR.InMemory = Location->InMemory;
+ DR.DataOffset = Location->Offset;
+ if (Location->FragmentInfo) {
DR.IsSubfield = true;
- DR.StructOffset = Location.FragmentInfo->OffsetInBits / 8;
+ DR.StructOffset = Location->FragmentInfo->OffsetInBits / 8;
} else {
DR.IsSubfield = false;
DR.StructOffset = 0;
OpenPOWER on IntegriCloud