summaryrefslogtreecommitdiffstats
path: root/include/clang/AST/CanonicalType.h
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2012-02-17 03:32:17 +0000
committerJohn McCall <rjmccall@apple.com>2012-02-17 03:32:17 +0000
commit84fa9cd13c2b260937625b6ad7445af7f7648565 (patch)
tree50cea45164a15b2f31be8ff330e530f4aec3856b /include/clang/AST/CanonicalType.h
parent27dd7d962bbf774988bc5e59d04a7743ed503514 (diff)
Add a castAs<U> accessor to CanQual<T>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150786 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST/CanonicalType.h')
-rw-r--r--include/clang/AST/CanonicalType.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/clang/AST/CanonicalType.h b/include/clang/AST/CanonicalType.h
index 38e6b41977..6cce88868d 100644
--- a/include/clang/AST/CanonicalType.h
+++ b/include/clang/AST/CanonicalType.h
@@ -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;
@@ -753,6 +755,13 @@ CanProxy<U> CanQual<T>::getAs() const {
}
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);
}