tint: Rename SourceVariable() to RootIdentifier()

This is now a well-defined term in the WGSL spec, so we should use it.

Change-Id: Icc46a77f0a465afbfd39cdaec84e506b143c8c0c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/109220
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
diff --git a/src/tint/sem/expression.cc b/src/tint/sem/expression.cc
index cdaa2bc..d7fd255 100644
--- a/src/tint/sem/expression.cc
+++ b/src/tint/sem/expression.cc
@@ -28,9 +28,9 @@
                        const Statement* statement,
                        const Constant* constant,
                        bool has_side_effects,
-                       const Variable* source_var /* = nullptr */)
+                       const Variable* root_ident /* = nullptr */)
     : declaration_(declaration),
-      source_variable_(source_var),
+      root_identifier_(root_ident),
       type_(type),
       stage_(stage),
       statement_(statement),
diff --git a/src/tint/sem/expression.h b/src/tint/sem/expression.h
index 5942a71..cc87031 100644
--- a/src/tint/sem/expression.h
+++ b/src/tint/sem/expression.h
@@ -40,14 +40,14 @@
     /// @param statement the statement that owns this expression
     /// @param constant the constant value of the expression. May be null
     /// @param has_side_effects true if this expression may have side-effects
-    /// @param source_var the (optional) source variable for this expression
+    /// @param root_ident the (optional) root identifier for this expression
     Expression(const ast::Expression* declaration,
                const sem::Type* type,
                EvaluationStage stage,
                const Statement* statement,
                const Constant* constant,
                bool has_side_effects,
-               const Variable* source_var = nullptr);
+               const Variable* root_ident = nullptr);
 
     /// Destructor
     ~Expression() override;
@@ -71,8 +71,8 @@
     /// For reference and pointer expressions, this will either be the originating
     /// variable or a function parameter. For other types of expressions, it will
     /// either be the parameter or constant declaration, or nullptr.
-    /// @return the source variable of this expression, or nullptr
-    const Variable* SourceVariable() const { return source_variable_; }
+    /// @return the root identifier of this expression, or nullptr
+    const Variable* RootIdentifier() const { return root_identifier_; }
 
     /// @return the behaviors of this statement
     const sem::Behaviors& Behaviors() const { return behaviors_; }
@@ -89,8 +89,8 @@
   protected:
     /// The AST expression node for this semantic expression
     const ast::Expression* const declaration_;
-    /// The source variable for this semantic expression, or nullptr
-    const Variable* source_variable_;
+    /// The root identifier for this semantic expression, or nullptr
+    const Variable* root_identifier_;
 
   private:
     const sem::Type* const type_;
diff --git a/src/tint/sem/expression_test.cc b/src/tint/sem/expression_test.cc
index 63e01fb..845b279 100644
--- a/src/tint/sem/expression_test.cc
+++ b/src/tint/sem/expression_test.cc
@@ -46,7 +46,7 @@
     auto* a = create<Expression>(/* declaration */ nullptr, create<I32>(),
                                  sem::EvaluationStage::kRuntime, /* statement */ nullptr,
                                  /* constant_value */ nullptr,
-                                 /* has_side_effects */ false, /* source_var */ nullptr);
+                                 /* has_side_effects */ false, /* root_ident */ nullptr);
     auto* b = create<Materialize>(a, /* statement */ nullptr, &c);
 
     EXPECT_EQ(a, a->UnwrapMaterialize());
diff --git a/src/tint/sem/index_accessor_expression.cc b/src/tint/sem/index_accessor_expression.cc
index 70d1d5f..0565695 100644
--- a/src/tint/sem/index_accessor_expression.cc
+++ b/src/tint/sem/index_accessor_expression.cc
@@ -30,8 +30,8 @@
                                                  const Statement* statement,
                                                  const Constant* constant,
                                                  bool has_side_effects,
-                                                 const Variable* source_var /* = nullptr */)
-    : Base(declaration, type, stage, statement, constant, has_side_effects, source_var),
+                                                 const Variable* root_ident /* = nullptr */)
+    : Base(declaration, type, stage, statement, constant, has_side_effects, root_ident),
       object_(object),
       index_(index) {}
 
diff --git a/src/tint/sem/index_accessor_expression.h b/src/tint/sem/index_accessor_expression.h
index ea93df7..19ae82b 100644
--- a/src/tint/sem/index_accessor_expression.h
+++ b/src/tint/sem/index_accessor_expression.h
@@ -38,7 +38,7 @@
     /// @param statement the statement that owns this expression
     /// @param constant the constant value of the expression. May be null
     /// @param has_side_effects whether this expression may have side effects
-    /// @param source_var the (optional) source variable for this expression
+    /// @param root_ident the (optional) root identifier for this expression
     IndexAccessorExpression(const ast::IndexAccessorExpression* declaration,
                             const sem::Type* type,
                             EvaluationStage stage,
@@ -47,7 +47,7 @@
                             const Statement* statement,
                             const Constant* constant,
                             bool has_side_effects,
-                            const Variable* source_var = nullptr);
+                            const Variable* root_ident = nullptr);
 
     /// Destructor
     ~IndexAccessorExpression() override;
diff --git a/src/tint/sem/materialize.cc b/src/tint/sem/materialize.cc
index 15c31ae..c735f6d 100644
--- a/src/tint/sem/materialize.cc
+++ b/src/tint/sem/materialize.cc
@@ -26,7 +26,7 @@
            /* statement */ statement,
            /* constant */ constant,
            /* has_side_effects */ false,
-           /* source_var */ expr->SourceVariable()),
+           /* root_ident */ expr->RootIdentifier()),
       expr_(expr) {}
 
 Materialize::~Materialize() = default;
diff --git a/src/tint/sem/member_accessor_expression.cc b/src/tint/sem/member_accessor_expression.cc
index 4d194a9..8d08008 100644
--- a/src/tint/sem/member_accessor_expression.cc
+++ b/src/tint/sem/member_accessor_expression.cc
@@ -30,8 +30,8 @@
                                                    const Constant* constant,
                                                    const Expression* object,
                                                    bool has_side_effects,
-                                                   const Variable* source_var /* = nullptr */)
-    : Base(declaration, type, stage, statement, constant, has_side_effects, source_var),
+                                                   const Variable* root_ident /* = nullptr */)
+    : Base(declaration, type, stage, statement, constant, has_side_effects, root_ident),
       object_(object) {}
 
 MemberAccessorExpression::~MemberAccessorExpression() = default;
@@ -43,7 +43,7 @@
                                        const Expression* object,
                                        const StructMember* member,
                                        bool has_side_effects,
-                                       const Variable* source_var /* = nullptr */)
+                                       const Variable* root_ident /* = nullptr */)
     : Base(declaration,
            type,
            object->Stage(),
@@ -51,7 +51,7 @@
            constant,
            object,
            has_side_effects,
-           source_var),
+           root_ident),
       member_(member) {}
 
 StructMemberAccess::~StructMemberAccess() = default;
@@ -63,7 +63,7 @@
                  const Expression* object,
                  utils::VectorRef<uint32_t> indices,
                  bool has_side_effects,
-                 const Variable* source_var /* = nullptr */)
+                 const Variable* root_ident /* = nullptr */)
     : Base(declaration,
            type,
            object->Stage(),
@@ -71,7 +71,7 @@
            constant,
            object,
            has_side_effects,
-           source_var),
+           root_ident),
       indices_(std::move(indices)) {}
 
 Swizzle::~Swizzle() = default;
diff --git a/src/tint/sem/member_accessor_expression.h b/src/tint/sem/member_accessor_expression.h
index 2541f33..5541d1c 100644
--- a/src/tint/sem/member_accessor_expression.h
+++ b/src/tint/sem/member_accessor_expression.h
@@ -48,7 +48,7 @@
     /// @param constant the constant value of the expression. May be null.
     /// @param object the object that holds the member being accessed
     /// @param has_side_effects whether this expression may have side effects
-    /// @param source_var the (optional) source variable for this expression
+    /// @param root_ident the (optional) root identifier for this expression
     MemberAccessorExpression(const ast::MemberAccessorExpression* declaration,
                              const sem::Type* type,
                              EvaluationStage stage,
@@ -56,7 +56,7 @@
                              const Constant* constant,
                              const Expression* object,
                              bool has_side_effects,
-                             const Variable* source_var = nullptr);
+                             const Variable* root_ident = nullptr);
 
   private:
     Expression const* const object_;
@@ -75,7 +75,7 @@
     /// @param object the object that holds the member being accessed
     /// @param member the structure member
     /// @param has_side_effects whether this expression may have side effects
-    /// @param source_var the (optional) source variable for this expression
+    /// @param root_ident the (optional) root identifier for this expression
     StructMemberAccess(const ast::MemberAccessorExpression* declaration,
                        const sem::Type* type,
                        const Statement* statement,
@@ -83,7 +83,7 @@
                        const Expression* object,
                        const StructMember* member,
                        bool has_side_effects,
-                       const Variable* source_var = nullptr);
+                       const Variable* root_ident = nullptr);
 
     /// Destructor
     ~StructMemberAccess() override;
@@ -107,7 +107,7 @@
     /// @param object the object that holds the member being accessed
     /// @param indices the swizzle indices
     /// @param has_side_effects whether this expression may have side effects
-    /// @param source_var the (optional) source variable for this expression
+    /// @param root_ident the (optional) root identifier for this expression
     Swizzle(const ast::MemberAccessorExpression* declaration,
             const sem::Type* type,
             const Statement* statement,
@@ -115,7 +115,7 @@
             const Expression* object,
             utils::VectorRef<uint32_t> indices,
             bool has_side_effects,
-            const Variable* source_var = nullptr);
+            const Variable* root_ident = nullptr);
 
     /// Destructor
     ~Swizzle() override;
diff --git a/src/tint/sem/variable.cc b/src/tint/sem/variable.cc
index 225e308..f83745f 100644
--- a/src/tint/sem/variable.cc
+++ b/src/tint/sem/variable.cc
@@ -97,9 +97,9 @@
       variable_(variable) {
     auto* type = variable->Type();
     if (type->Is<sem::Pointer>() && variable->Initializer()) {
-        source_variable_ = variable->Initializer()->SourceVariable();
+        root_identifier_ = variable->Initializer()->RootIdentifier();
     } else {
-        source_variable_ = variable;
+        root_identifier_ = variable;
     }
 }