Rename fDeclared to fVarExists.

We can't eliminate the field, but we can make it more obvious what it
tracks.

Change-Id: Ia2eb558d869cdf7911c591d0b66da89dd322384b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/583960
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/sksl/analysis/SkSLProgramUsage.cpp b/src/sksl/analysis/SkSLProgramUsage.cpp
index 01659d5..29ee0c8 100644
--- a/src/sksl/analysis/SkSLProgramUsage.cpp
+++ b/src/sksl/analysis/SkSLProgramUsage.cpp
@@ -61,8 +61,8 @@
             // Add all declared variables to the usage map (even if never otherwise accessed).
             const VarDeclaration& vd = s.as<VarDeclaration>();
             ProgramUsage::VariableCounts& counts = fUsage->fVariableCounts[&vd.var()];
-            counts.fDeclared += fDelta;
-            SkASSERT(counts.fDeclared >= 0);
+            counts.fVarExists += fDelta;
+            SkASSERT(counts.fVarExists >= 0 && counts.fVarExists <= 1);
             if (vd.value()) {
                 // The initial-value expression, when present, counts as a write.
                 counts.fWrite += fDelta;
diff --git a/src/sksl/analysis/SkSLProgramUsage.h b/src/sksl/analysis/SkSLProgramUsage.h
index db7b580..e04947b 100644
--- a/src/sksl/analysis/SkSLProgramUsage.h
+++ b/src/sksl/analysis/SkSLProgramUsage.h
@@ -25,7 +25,7 @@
 class ProgramUsage {
 public:
     struct VariableCounts {
-        int fDeclared = 0;
+        int fVarExists = 0;  // if this is zero, the Variable might have already been deleted
         int fRead = 0;
         int fWrite = 0;
     };
diff --git a/src/sksl/transform/SkSLEliminateDeadLocalVariables.cpp b/src/sksl/transform/SkSLEliminateDeadLocalVariables.cpp
index 795701e..c4f8564 100644
--- a/src/sksl/transform/SkSLEliminateDeadLocalVariables.cpp
+++ b/src/sksl/transform/SkSLEliminateDeadLocalVariables.cpp
@@ -72,7 +72,7 @@
                 const Variable* var = &varDecl.var();
                 ProgramUsage::VariableCounts* counts = fUsage->fVariableCounts.find(var);
                 SkASSERT(counts);
-                SkASSERT(counts->fDeclared);
+                SkASSERT(counts->fVarExists);
                 if (CanEliminate(var, *counts)) {
                     fDeadVariables.add(var);
                     if (var->initialValue()) {
@@ -114,7 +114,7 @@
         }
 
         static bool CanEliminate(const Variable* var, const ProgramUsage::VariableCounts& counts) {
-            return counts.fDeclared && !counts.fRead && var->storage() == VariableStorage::kLocal;
+            return counts.fVarExists && !counts.fRead && var->storage() == VariableStorage::kLocal;
         }
 
         bool fMadeChanges = false;