From: Argyrios Kyrtzidis Date: Sat, 30 Apr 2011 02:28:27 +0000 (+0000) Subject: Add a couple of assertions to make sure the bitfields can fit the value assigned... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=654f6b2b53af2c950c62ef0161fa021648accbcb;p=clang Add a couple of assertions to make sure the bitfields can fit the value assigned to them. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130573 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index ed207ace0c..f006f0ec6d 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -2243,6 +2243,12 @@ private: } 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 @@ protected: 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: diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index b368523eef..e3301c513a 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -426,6 +426,8 @@ public: 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;