Skip to content

Commit 5226812

Browse files
[DwarfDebug][NFC] Factor out 'isInitialized' logic
The class 'DbgVariable' can be in one of three states, and the "is any of them initialization" logic for them is repeated in a couple of places. We may want to expand this class in the future; as such, we factor out this common logic so that it is easier to modify. Differential Revision: https://reviews.llvm.org/D158438 (cherry picked from commit 3222312)
1 parent 3782f0c commit 5226812

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,13 @@ class DbgVariable : public DbgEntity {
136136
DbgVariable(const DILocalVariable *V, const DILocation *IA)
137137
: DbgEntity(V, IA, DbgVariableKind) {}
138138

139+
bool isInitialized() const {
140+
return !FrameIndexExprs.empty() || ValueLoc;
141+
}
142+
139143
/// Initialize from the MMI table.
140144
void initializeMMI(const DIExpression *E, int FI) {
141-
assert(FrameIndexExprs.empty() && "Already initialized?");
142-
assert(!ValueLoc.get() && "Already initialized?");
145+
assert(!isInitialized() && "Already initialized?");
143146

144147
assert((!E || E->isValid()) && "Expected valid expression");
145148
assert(FI != std::numeric_limits<int>::max() && "Expected valid index");
@@ -149,8 +152,7 @@ class DbgVariable : public DbgEntity {
149152

150153
// Initialize variable's location.
151154
void initializeDbgValue(DbgValueLoc Value) {
152-
assert(FrameIndexExprs.empty() && "Already initialized?");
153-
assert(!ValueLoc && "Already initialized?");
155+
assert(!isInitialized() && "Already initialized?");
154156
assert(!Value.getExpression()->isFragment() && "Fragments not supported.");
155157

156158
ValueLoc = std::make_unique<DbgValueLoc>(Value);

0 commit comments

Comments
 (0)