1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

Add a couple of convenience accessors to DebugLocEntry::Value to further

simplify common usage patterns.

llvm-svn: 215407
This commit is contained in:
Adrian Prantl 2014-08-11 23:22:59 +00:00
parent 037c4a0074
commit 8221613b32
2 changed files with 12 additions and 13 deletions

View File

@ -67,7 +67,9 @@ public:
const ConstantFP *getConstantFP() const { return Constant.CFP; } const ConstantFP *getConstantFP() const { return Constant.CFP; }
const ConstantInt *getConstantInt() const { return Constant.CIP; } const ConstantInt *getConstantInt() const { return Constant.CIP; }
MachineLocation getLoc() const { return Loc; } MachineLocation getLoc() const { return Loc; }
const MDNode *getVariable() const { return Variable; } const MDNode *getVariableNode() const { return Variable; }
DIVariable getVariable() const { return DIVariable(Variable); }
bool isVariablePiece() const { return getVariable().isVariablePiece(); }
friend bool operator==(const Value &, const Value &); friend bool operator==(const Value &, const Value &);
friend bool operator<(const Value &, const Value &); friend bool operator<(const Value &, const Value &);
}; };
@ -121,7 +123,7 @@ public:
Values.append(Vals.begin(), Vals.end()); Values.append(Vals.begin(), Vals.end());
sortUniqueValues(); sortUniqueValues();
assert(std::all_of(Values.begin(), Values.end(), [](DebugLocEntry::Value V){ assert(std::all_of(Values.begin(), Values.end(), [](DebugLocEntry::Value V){
return DIVariable(V.Variable).isVariablePiece(); return V.isVariablePiece();
}) && "value must be a piece"); }) && "value must be a piece");
} }
@ -158,9 +160,7 @@ inline bool operator==(const DebugLocEntry::Value &A,
/// Compare two pieces based on their offset. /// Compare two pieces based on their offset.
inline bool operator<(const DebugLocEntry::Value &A, inline bool operator<(const DebugLocEntry::Value &A,
const DebugLocEntry::Value &B) { const DebugLocEntry::Value &B) {
DIVariable Var(A.getVariable()); return A.getVariable().getPieceOffset() < B.getVariable().getPieceOffset();
DIVariable OtherVar(B.getVariable());
return Var.getPieceOffset() < OtherVar.getPieceOffset();
} }
} }

View File

@ -1252,7 +1252,7 @@ DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
DIVariable DIVar = Begin->getDebugVariable(); DIVariable DIVar = Begin->getDebugVariable();
auto Last = std::remove_if(OpenRanges.begin(), OpenRanges.end(), auto Last = std::remove_if(OpenRanges.begin(), OpenRanges.end(),
[&](DebugLocEntry::Value R) { [&](DebugLocEntry::Value R) {
return piecesOverlap(DIVar, DIVariable(R.getVariable())); return piecesOverlap(DIVar, R.getVariable());
}); });
OpenRanges.erase(Last, OpenRanges.end()); OpenRanges.erase(Last, OpenRanges.end());
@ -2067,14 +2067,14 @@ void DwarfDebug::emitLocPieces(ByteStreamer &Streamer,
const DITypeIdentifierMap &Map, const DITypeIdentifierMap &Map,
ArrayRef<DebugLocEntry::Value> Values) { ArrayRef<DebugLocEntry::Value> Values) {
assert(std::all_of(Values.begin(), Values.end(), [](DebugLocEntry::Value P) { assert(std::all_of(Values.begin(), Values.end(), [](DebugLocEntry::Value P) {
return DIVariable(P.getVariable()).isVariablePiece(); return P.isVariablePiece();
}) && "all values are expected to be pieces"); }) && "all values are expected to be pieces");
assert(std::is_sorted(Values.begin(), Values.end()) && assert(std::is_sorted(Values.begin(), Values.end()) &&
"pieces are expected to be sorted"); "pieces are expected to be sorted");
unsigned Offset = 0; unsigned Offset = 0;
for (auto Piece : Values) { for (auto Piece : Values) {
DIVariable Var(Piece.getVariable()); DIVariable Var = Piece.getVariable();
unsigned PieceOffset = Var.getPieceOffset(); unsigned PieceOffset = Var.getPieceOffset();
unsigned PieceSize = Var.getPieceSize(); unsigned PieceSize = Var.getPieceSize();
assert(Offset <= PieceOffset && "overlapping or duplicate pieces"); assert(Offset <= PieceOffset && "overlapping or duplicate pieces");
@ -2110,8 +2110,7 @@ void DwarfDebug::emitLocPieces(ByteStreamer &Streamer,
void DwarfDebug::emitDebugLocEntry(ByteStreamer &Streamer, void DwarfDebug::emitDebugLocEntry(ByteStreamer &Streamer,
const DebugLocEntry &Entry) { const DebugLocEntry &Entry) {
const DebugLocEntry::Value Value = Entry.getValues()[0]; const DebugLocEntry::Value Value = Entry.getValues()[0];
DIVariable DV(Value.getVariable()); if (Value.isVariablePiece())
if (DV.isVariablePiece())
// Emit all pieces that belong to the same variable and range. // Emit all pieces that belong to the same variable and range.
return emitLocPieces(Streamer, TypeIdentifierMap, Entry.getValues()); return emitLocPieces(Streamer, TypeIdentifierMap, Entry.getValues());
@ -2121,7 +2120,7 @@ void DwarfDebug::emitDebugLocEntry(ByteStreamer &Streamer,
void DwarfDebug::emitDebugLocValue(ByteStreamer &Streamer, void DwarfDebug::emitDebugLocValue(ByteStreamer &Streamer,
const DebugLocEntry::Value &Value) { const DebugLocEntry::Value &Value) {
DIVariable DV(Value.getVariable()); DIVariable DV = Value.getVariable();
// Regular entry. // Regular entry.
if (Value.isInt()) { if (Value.isInt()) {
DIBasicType BTy(resolve(DV.getType())); DIBasicType BTy(resolve(DV.getType()));