[cfe-commits] r150786 - /cfe/trunk/include/clang/AST/CanonicalType.h
John McCall
rjmccall at apple.com
Thu Feb 16 19:32:17 PST 2012
Author: rjmccall
Date: Thu Feb 16 21:32:17 2012
New Revision: 150786
URL: http://llvm.org/viewvc/llvm-project?rev=150786&view=rev
Log:
Add a castAs<U> accessor to CanQual<T>.
Modified:
cfe/trunk/include/clang/AST/CanonicalType.h
Modified: cfe/trunk/include/clang/AST/CanonicalType.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CanonicalType.h?rev=150786&r1=150785&r2=150786&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/CanonicalType.h (original)
+++ cfe/trunk/include/clang/AST/CanonicalType.h Thu Feb 16 21:32:17 2012
@@ -108,6 +108,8 @@
/// 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;
@@ -753,6 +755,13 @@
}
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);
}
More information about the cfe-commits
mailing list