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
diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp
index 1c9817b..2eeb090 100644
--- a/lib/Serialization/ASTReaderStmt.cpp
+++ b/lib/Serialization/ASTReaderStmt.cpp
@@ -790,21 +790,12 @@
void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
VisitExpr(E);
- E->setOp(AtomicExpr::AtomicOp(Record[Idx++]));
- E->setPtr(Reader.ReadSubExpr());
- E->setOrder(Reader.ReadSubExpr());
- E->setNumSubExprs(2);
- if (E->getOp() != AtomicExpr::Load) {
- E->setVal1(Reader.ReadSubExpr());
- E->setNumSubExprs(3);
- }
- if (E->isCmpXChg()) {
- E->setOrderFail(Reader.ReadSubExpr());
- E->setVal2(Reader.ReadSubExpr());
- E->setNumSubExprs(5);
- }
- E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
- E->setRParenLoc(ReadSourceLocation(Record, Idx));
+ E->Op = AtomicExpr::AtomicOp(Record[Idx++]);
+ E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
+ for (unsigned I = 0; I != E->NumSubExprs; ++I)
+ E->SubExprs[I] = Reader.ReadSubExpr();
+ E->BuiltinLoc = ReadSourceLocation(Record, Idx);
+ E->RParenLoc = ReadSourceLocation(Record, Idx);
}
//===----------------------------------------------------------------------===//