On Oct 27, 2008, at 12:41 PM, Douglas Gregor wrote:
> Author: dgregor
> Date: Mon Oct 27 14:41:14 2008
> New Revision: 58264
>
> URL: http://llvm.org/viewvc/llvm-project?rev=58264&view=rev
> Log:
> Refactor the expression class hierarchy for casts. Most importantly:
> - CastExpr is the root of all casts
> - ImplicitCastExpr is (still) used for all explicit casts
> - ExplicitCastExpr is now the root of all *explicit* casts
>
> - ExplicitCCastExpr (new name needed!?) is a C-style cast in C or C++
How about "ParenCastExpr" or CParenCastExpr or CStyleCastExpr or
SimpleCastExpr ?
> - CXXFunctionalCastExpr inherits from ExplicitCastExpr
> - CXXNamedCastExpr inherits from ExplicitCastExpr and is the root
> of all
> of the C++ named cast expression types (static_cast,
> dynamic_cast, etc.)
> - Added classes CXXStaticCastExpr, CXXDynamicCastExpr,
> CXXReinterpretCastExpr, and CXXConstCastExpr to
Nice!
> +++ cfe/trunk/include/clang/AST/Expr.h Mon Oct 27 14:41:14 2008
> @@ -771,12 +771,10 @@
> static CompoundLiteralExpr* CreateImpl(llvm::Deserializer& D,
> ASTContext& C);
> };
>
> +/// CastExpr - Base class for type casts, including both implicit
> +/// casts (ImplicitCastExpr) and explicit casts that have some
> +/// representation in the source code (ExplicitCastExpr's derived
> +/// classes).
> class CastExpr : public Expr {
> Stmt *Op;
> protected:
> @@ -791,6 +789,12 @@
> switch (T->getStmtClass()) {
> case ImplicitCastExprClass:
> case ExplicitCastExprClass:
> + case ExplicitCCastExprClass:
> + case CXXNamedCastExprClass:
> + case CXXStaticCastExprClass:
> + case CXXDynamicCastExprClass:
> + case CXXReinterpretCastExprClass:
> + case CXXConstCastExprClass:
> case CXXFunctionalCastExprClass:
> return true;
> default:
Can this turn into a range test, like Expr::classof ?
> + /// getTypeAsWritten - Returns the type that this expression is
> + /// casting to, as written in the source code.
> + QualType getTypeAsWritten() const { return TypeAsWritten; }
> +
> + static bool classof(const Stmt *T) {
> + switch (T->getStmtClass()) {
> + case ExplicitCastExprClass:
> + case ExplicitCCastExprClass:
> + case CXXFunctionalCastExprClass:
> + case CXXStaticCastExprClass:
> + case CXXDynamicCastExprClass:
> + case CXXReinterpretCastExprClass:
> + case CXXConstCastExprClass:
> + return true;
> + default:
> + return false;
This would also be nice as a range test.
-Chris
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits