[llvm] 3222312 - [DwarfDebug][NFC] Factor out 'isInitialized' logic
Felipe de Azevedo Piovezan via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 21 12:15:32 PDT 2023
Author: Felipe de Azevedo Piovezan
Date: 2023-08-21T15:15:14-04:00
New Revision: 32223123d3643adb95872da6587b620ffae9a39b
URL: https://github.com/llvm/llvm-project/commit/32223123d3643adb95872da6587b620ffae9a39b
DIFF: https://github.com/llvm/llvm-project/commit/32223123d3643adb95872da6587b620ffae9a39b.diff
LOG: [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
Added:
Modified:
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 1af4b643eb178e..0fc7aa7bccf3d0 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -136,10 +136,13 @@ class DbgVariable : public DbgEntity {
DbgVariable(const DILocalVariable *V, const DILocation *IA)
: DbgEntity(V, IA, DbgVariableKind) {}
+ bool isInitialized() const {
+ return !FrameIndexExprs.empty() || ValueLoc;
+ }
+
/// Initialize from the MMI table.
void initializeMMI(const DIExpression *E, int FI) {
- assert(FrameIndexExprs.empty() && "Already initialized?");
- assert(!ValueLoc.get() && "Already initialized?");
+ assert(!isInitialized() && "Already initialized?");
assert((!E || E->isValid()) && "Expected valid expression");
assert(FI != std::numeric_limits<int>::max() && "Expected valid index");
@@ -149,8 +152,7 @@ class DbgVariable : public DbgEntity {
// Initialize variable's location.
void initializeDbgValue(DbgValueLoc Value) {
- assert(FrameIndexExprs.empty() && "Already initialized?");
- assert(!ValueLoc && "Already initialized?");
+ assert(!isInitialized() && "Already initialized?");
assert(!Value.getExpression()->isFragment() && "Fragments not supported.");
ValueLoc = std::make_unique<DbgValueLoc>(Value);
More information about the llvm-commits
mailing list