diff --git a/patches/clang-compoundstmt-replaceStmts.diff b/patches/clang-compoundstmt-replaceStmts.diff deleted file mode 100644 index 8fbc7cde..00000000 --- a/patches/clang-compoundstmt-replaceStmts.diff +++ /dev/null @@ -1,101 +0,0 @@ -diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h -index 403b88ac3a..f852ee4b86 100644 ---- a/include/clang/AST/Stmt.h -+++ b/include/clang/AST/Stmt.h -@@ -131,7 +131,8 @@ protected: - - unsigned : NumStmtBits; - -- unsigned NumStmts : 32 - NumStmtBits; -+ unsigned WasReplaced : 1; -+ unsigned NumStmts : 32 - (NumStmtBits + 1); - - /// The location of the opening "{". - SourceLocation LBraceLoc; -@@ -1328,6 +1329,7 @@ public: - explicit CompoundStmt(SourceLocation Loc) - : Stmt(CompoundStmtClass), RBraceLoc(Loc) { - CompoundStmtBits.NumStmts = 0; -+ CompoundStmtBits.WasReplaced = 0; - CompoundStmtBits.LBraceLoc = Loc; - } - -@@ -1341,7 +1343,10 @@ public: - using body_range = llvm::iterator_range; - - body_range body() { return body_range(body_begin(), body_end()); } -- body_iterator body_begin() { return getTrailingObjects(); } -+ body_iterator body_begin() { -+ Stmt** begin = getTrailingObjects(); -+ return !CompoundStmtBits.WasReplaced ? begin : (body_iterator)begin[0]; -+ } - body_iterator body_end() { return body_begin() + size(); } - Stmt *body_front() { return !body_empty() ? body_begin()[0] : nullptr; } - -@@ -1357,7 +1362,7 @@ public: - } - - const_body_iterator body_begin() const { -- return getTrailingObjects(); -+ return const_cast(this)->body_begin(); - } - - const_body_iterator body_end() const { return body_begin() + size(); } -@@ -1391,6 +1396,8 @@ public: - return const_reverse_body_iterator(body_begin()); - } - -+ void replaceStmts(const ASTContext &C, llvm::ArrayRef Stmts); -+ - // Get the Stmt that StmtExpr would consider to be the result of this - // compound statement. This is used by StmtExpr to properly emulate the GCC - // compound expression extension, which ignores trailing NullStmts when -diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp -index 0a4d403106..86d47cf82d 100644 ---- a/lib/AST/Stmt.cpp -+++ b/lib/AST/Stmt.cpp -@@ -293,6 +293,7 @@ CompoundStmt::CompoundStmt(ArrayRef Stmts, SourceLocation LB, - SourceLocation RB) - : Stmt(CompoundStmtClass), RBraceLoc(RB) { - CompoundStmtBits.NumStmts = Stmts.size(); -+ CompoundStmtBits.WasReplaced = 0; - setStmts(Stmts); - CompoundStmtBits.LBraceLoc = LB; - } -@@ -300,7 +301,7 @@ CompoundStmt::CompoundStmt(ArrayRef Stmts, SourceLocation LB, - void CompoundStmt::setStmts(ArrayRef Stmts) { - assert(CompoundStmtBits.NumStmts == Stmts.size() && - "NumStmts doesn't fit in bits of CompoundStmtBits.NumStmts!"); -- -+ assert(!CompoundStmtBits.WasReplaced && "Call replaceStmts!"); - std::copy(Stmts.begin(), Stmts.end(), body_begin()); - } - -@@ -320,6 +321,27 @@ CompoundStmt *CompoundStmt::CreateEmpty(const ASTContext &C, - return New; - } - -+void CompoundStmt::replaceStmts(const ASTContext &C, -+ llvm::ArrayRef Stmts) { -+ Stmt** Body = body_begin(); -+ -+ if (CompoundStmtBits.WasReplaced) -+ C.Deallocate(Body); -+ else -+ memset(body_begin(), 0, size()); -+ -+ CompoundStmtBits.NumStmts = Stmts.size(); -+ assert(CompoundStmtBits.NumStmts == Stmts.size() && -+ "NumStmts doesn't fit in bits of CompoundStmtBits.NumStmts!"); -+ -+ Body = new (C) Stmt*[Stmts.size()]; -+ std::copy(Stmts.begin(), Stmts.end(), Body); -+ -+ getTrailingObjects()[0] = reinterpret_cast(Body); -+ -+ CompoundStmtBits.WasReplaced = 1; -+} -+ - const Expr *ValueStmt::getExprStmt() const { - const Stmt *S = this; - do {