[cfe-commits] r40705 - in /cfe/trunk: AST/Expr.cpp include/clang/AST/Expr.h

Chris Lattner clattner at apple.com
Wed Aug 1 17:24:56 PDT 2007


> Hack Expr::isConstantExpr() to allow for __builtin_types_compatible_p.

Heh, the hack looks right :).  One minor thing:

> ====================================================================== 
> ========
> --- cfe/trunk/AST/Expr.cpp (original)
> +++ cfe/trunk/AST/Expr.cpp Wed Aug  1 19:13:27 2007
> @@ -305,6 +305,9 @@
>      Result.setIsUnsigned(!getType()->isSignedIntegerType());
>      break;
>    }
> +  case TypesCompatibleExprClass:
> +    Result = cast<TypesCompatibleExpr>(this)->typesAreCompatible();

Before setting the value, plz resize Result to be the correct width.   
Because we set it to 32, it's probably right in all normal cases  
right now.  However, just to be safe, please put:

     Result.zextOrTrunc(Ctx.getTypeSize(getType(),  
cast<TypesCompatibleExpr>(this)->getSomeLoc()));

before the assignment into result.  This ensures that the APInt is  
resized to whatever type Sema picked for the result of this node.

> +++ cfe/trunk/include/clang/AST/Expr.h Wed Aug  1 19:13:27 2007
> @@ -738,7 +738,7 @@
>    QualType getArgType1() { return Type1; }
>    QualType getArgType2() { return Type2; }
>
> -  int typesAreCompatible() { return Type::typesAreCompatible 
> (Type1,Type2); }
> +  int typesAreCompatible() const { return Type::typesAreCompatible 
> (Type1,Type2); }

Should this method return bool?

-Chris



More information about the cfe-commits mailing list