Add typ::Ptr<T>

A simple raw pointer wrapper that will allow us to migrate typ aliases to ast::Types without immediately having to fix up all the `auto` declarations to `auto*`.

Bug: tint:724
Change-Id: Icff7e009b768d9e54c8c73059c700af788962e77
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49346
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/typepair.h b/src/typepair.h
index c3fa0f5..9bddaf7 100644
--- a/src/typepair.h
+++ b/src/typepair.h
@@ -73,6 +73,40 @@
 
 namespace typ {  //  type-pair
 
+/// A simple wrapper around a raw pointer. Used to prevent a whole bunch of
+/// warnings about `auto` needing to be declared as `auto*` while we're
+/// migrating code.
+template <typename T>
+struct Ptr {
+  /// The raw pointer
+  T* const ptr;
+
+  /// Constructor
+  Ptr() = default;
+
+  /// Copy constructor
+  /// @param other the Ptr to copy
+  template <typename OTHER>
+  Ptr(const Ptr<OTHER>& other) : ptr(static_cast<T*>(other.ptr)) {}
+
+  /// Constructor
+  /// @param p the pointer to wrap in a Ptr
+  template <typename U>
+  Ptr(U* p) : ptr(p) {}  // NOLINT: explicit
+
+  /// @returns the pointer
+  operator T*() { return ptr; }
+
+  /// @returns the pointer
+  operator const T*() const { return ptr; }
+
+  /// @returns the pointer
+  T* operator->() { return ptr; }
+
+  /// @returns the pointer
+  const T* operator->() const { return ptr; }
+};
+
 /// TypePair is a pair of ast::Type and sem::Type pointers used to simplify
 /// migration to the new ast::Type nodes.
 ///
@@ -110,6 +144,10 @@
   /// @param s the sem::Type pointer
   TypePair(const AST* a, const SEM* s) : ast(a), sem(s) {}
   /// Constructor
+  /// @param ptr the Ptr<T>
+  template <typename T>
+  TypePair(Ptr<T> ptr) : TypePair(ptr.ptr) {}  // NOLINT: explicit
+  /// Constructor
   TypePair(std::nullptr_t) {}  // NOLINT: explicit
 
   /// @returns the ast::Type pointer