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 | c8c7945a40fb6016dfaf30e20d8f85e146196f8b (patch) | |
| tree | 04dc3788c000626ef220fd90f4d6d506918d79cd | |
| parent | b9a8525babd49b753dc512ebc8f9fb704120cabb (diff) | |
| download | bcm5719-llvm-c8c7945a40fb6016dfaf30e20d8f85e146196f8b.tar.gz bcm5719-llvm-c8c7945a40fb6016dfaf30e20d8f85e146196f8b.zip | |
Add a couple of assertions to make sure the bitfields can fit the value assigned to them. No functionality change.
llvm-svn: 130573
| -rw-r--r-- | clang/include/clang/AST/Expr.h | 10 | ||||
| -rw-r--r-- | clang/include/clang/AST/Stmt.h | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index ed207ace0c3..f006f0ec6df 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/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/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h index b368523eef8..e3301c513a7 100644 --- a/clang/include/clang/AST/Stmt.h +++ b/clang/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; |

