diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-04-30 02:28:27 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-04-30 02:28:27 +0000 |
commit | 654f6b2b53af2c950c62ef0161fa021648accbcb (patch) | |
tree | 6aa75f2bd5c502f33c3a2961a7e5cd8c01b3ad46 | |
parent | e2bb7b930750dd662f7b664560b567ecf357b16c (diff) |
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
-rw-r--r-- | include/clang/AST/Expr.h | 10 | ||||
-rw-r--r-- | include/clang/AST/Stmt.h | 2 |
2 files changed, 10 insertions, 2 deletions
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; |