From: John McCall Date: Fri, 17 Feb 2012 03:32:17 +0000 (+0000) Subject: Add a castAs accessor to CanQual. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=84fa9cd13c2b260937625b6ad7445af7f7648565;p=clang Add a castAs accessor to CanQual. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150786 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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 CanProxy getAs() const; + template CanProxy castAs() const; + /// \brief Overloaded arrow operator that produces a canonical type /// proxy. CanProxy operator->() const; @@ -752,6 +754,13 @@ CanProxy CanQual::getAs() const { return CanProxy(); } +template +template +CanProxy CanQual::castAs() const { + assert(!Stored.isNull() && isa(Stored.getTypePtr())); + return CanQual::CreateUnsafe(Stored); +} + template CanProxy CanQual::operator->() const { return CanProxy(*this);