diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-04-10 22:49:28 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-04-10 22:49:28 +0000 |
commit | e1b2abc2ed3f2c98985b06b4ad01c977bd584020 (patch) | |
tree | 00c5639500ef04b3f6555f66d8e790513d935632 /lib/AST/Expr.cpp | |
parent | edec2ee3bcde5ade31a76e329dcc4ac0fa7c7d11 (diff) |
AtomicExpr: make ASTStmtReader a friend and remove setters. Also fix saving
of an uninitialized Stmt* in serialization of __atomic_init and add a test of
atomics serialization.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154448 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Expr.cpp')
-rw-r--r-- | lib/AST/Expr.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 1947e61d12..2bb79a0a4a 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -3841,6 +3841,7 @@ AtomicExpr::AtomicExpr(SourceLocation BLoc, Expr **args, unsigned nexpr, false, false, false, false), NumSubExprs(nexpr), BuiltinLoc(BLoc), RParenLoc(RP), Op(op) { + assert(nexpr == getNumSubExprs(op) && "wrong number of subexpressions"); for (unsigned i = 0; i < nexpr; i++) { if (args[i]->isTypeDependent()) ExprBits.TypeDependent = true; @@ -3854,3 +3855,23 @@ AtomicExpr::AtomicExpr(SourceLocation BLoc, Expr **args, unsigned nexpr, SubExprs[i] = args[i]; } } + +unsigned AtomicExpr::getNumSubExprs(AtomicOp Op) { + switch (Op) { + case Init: + case Load: + return 2; + case Store: + case Xchg: + case Add: + case Sub: + case And: + case Or: + case Xor: + return 3; + case CmpXchgStrong: + case CmpXchgWeak: + return 5; + } + llvm_unreachable("unknown atomic op"); +} |