[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/Stm

Doug Gregor doug.gregor at gmail.com
Mon Oct 27 17:19:54 PDT 2008


On Mon, Oct 27, 2008 at 4:43 PM, Chris Lattner <clattner at apple.com> wrote:
>
> 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 ?

CStyleCastExpr is my favorite of those. I'll do that.

>> +/// 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 ?

Okay.

>> +  /// 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.

Sure.

  - Doug



More information about the cfe-commits mailing list