[cfe-commits] r130573 - in /cfe/trunk/include/clang/AST: Expr.h Stmt.h

Fariborz Jahanian fjahanian at apple.com
Sat Apr 30 10:31:20 PDT 2011


Doesn't this deserve a warning somewhere? What can trigger this assertion?

- Fariborz

On Apr 29, 2011, at 7:28 PM, Argyrios Kyrtzidis wrote:

> Author: akirtzidis
> Date: Fri Apr 29 21:28:27 2011
> New Revision: 130573
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=130573&view=rev
> Log:
> Add a couple of assertions to make sure the bitfields can fit the value assigned to them. No functionality change.
> 
> Modified:
>   cfe/trunk/include/clang/AST/Expr.h
>   cfe/trunk/include/clang/AST/Stmt.h
> 
> Modified: cfe/trunk/include/clang/AST/Expr.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=130573&r1=130572&r2=130573&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/Expr.h (original)
> +++ cfe/trunk/include/clang/AST/Expr.h Fri Apr 29 21:28:27 2011
> @@ -2243,6 +2243,12 @@
>  }
>  CXXBaseSpecifier **path_buffer();
> 
> +  void setBasePathSize(unsigned basePathSize) {
> +    CastExprBits.BasePathSize = basePathSize;
> +    assert(CastExprBits.BasePathSize == basePathSize &&
> +           "basePathSize doesn't fit in bits of CastExprBits.BasePathSize!");
> +  }
> +
> protected:
>  CastExpr(StmtClass SC, QualType ty, ExprValueKind VK,
>           const CastKind kind, Expr *op, unsigned BasePathSize) :
> @@ -2258,14 +2264,14 @@
>    Op(op) {
>    assert(kind != CK_Invalid && "creating cast with invalid cast kind");
>    CastExprBits.Kind = kind;
> -    CastExprBits.BasePathSize = BasePathSize;
> +    setBasePathSize(BasePathSize);
>    CheckCastConsistency();
>  }
> 
>  /// \brief Construct an empty cast.
>  CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize)
>    : Expr(SC, Empty) {
> -    CastExprBits.BasePathSize = BasePathSize;
> +    setBasePathSize(BasePathSize);
>  }
> 
> public:
> 
> Modified: cfe/trunk/include/clang/AST/Stmt.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=130573&r1=130572&r2=130573&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/Stmt.h (original)
> +++ cfe/trunk/include/clang/AST/Stmt.h Fri Apr 29 21:28:27 2011
> @@ -426,6 +426,8 @@
>               SourceLocation LB, SourceLocation RB)
>  : Stmt(CompoundStmtClass), LBracLoc(LB), RBracLoc(RB) {
>    CompoundStmtBits.NumStmts = NumStmts;
> +    assert(CompoundStmtBits.NumStmts == NumStmts &&
> +           "NumStmts doesn't fit in bits of CompoundStmtBits.NumStmts!");
> 
>    if (NumStmts == 0) {
>      Body = 0;
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list