]> granicus.if.org Git - clang/commitdiff
Add a castAs<U> accessor to CanQual<T>.
authorJohn McCall <rjmccall@apple.com>
Fri, 17 Feb 2012 03:32:17 +0000 (03:32 +0000)
committerJohn McCall <rjmccall@apple.com>
Fri, 17 Feb 2012 03:32:17 +0000 (03:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150786 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/CanonicalType.h

index 38e6b41977f87b26e5756f73cf5fa71189936c82..6cce88868db8f667a2c12e24da8d0527e81a09f9 100644 (file)
@@ -108,6 +108,8 @@ public:
   /// or a derived class thereof, a NULL canonical type.
   template<typename U> CanProxy<U> getAs() const;
 
+  template<typename U> CanProxy<U> castAs() const;
+
   /// \brief Overloaded arrow operator that produces a canonical type
   /// proxy.
   CanProxy<T> operator->() const;
@@ -752,6 +754,13 @@ CanProxy<U> CanQual<T>::getAs() const {
   return CanProxy<U>();
 }
 
+template<typename T>
+template<typename U>
+CanProxy<U> CanQual<T>::castAs() const {
+  assert(!Stored.isNull() && isa<U>(Stored.getTypePtr()));
+  return CanQual<U>::CreateUnsafe(Stored);
+}
+
 template<typename T>
 CanProxy<T> CanQual<T>::operator->() const {
   return CanProxy<T>(*this);