[cfe-commits] r58264 - in /cfe/trunk: Driver/RewriteObjC.cpp include/clang/AST/Expr.h include/clang/AST/ExprCXX.h include/clang/AST/StmtNodes.def include/clang/Parse/Action.h lib/AST/Expr.cpp lib/AST/ExprCXX.cpp lib/AST/StmtDumper.cpp lib/AST/StmtPrinter.cpp lib/AST/StmtSerialization.cpp lib/Analysis/Environment.cpp lib/Analysis/GRExprEngine.cpp lib/Parse/ParseExprCXX.cpp lib/Sema/Sema.h lib/Sema/SemaChecking.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaExprCXX.cpp test/SemaCXX/return-stack-addr.cpp
Chris Lattner
clattner at apple.com
Mon Oct 27 13:43:04 PDT 2008
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
More information about the cfe-commits
mailing list