Skip to content

Commit 2d304cf

Browse files
committed
Remove patch for clang::CompoundStmt::replaceStmts
1 parent 34590ae commit 2d304cf

File tree

3 files changed

+4
-135
lines changed

3 files changed

+4
-135
lines changed

interpreter/cling/patches/clang-compoundstmt-replaceStmts.diff

Lines changed: 0 additions & 101 deletions
This file was deleted.

interpreter/llvm/src/tools/clang/include/clang/AST/Stmt.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ class alignas(void *) Stmt {
131131

132132
unsigned : NumStmtBits;
133133

134-
unsigned WasReplaced : 1;
135-
unsigned NumStmts : 32 - (NumStmtBits + 1);
134+
unsigned NumStmts : 32 - NumStmtBits;
136135

137136
/// The location of the opening "{".
138137
SourceLocation LBraceLoc;
@@ -1329,7 +1328,6 @@ class CompoundStmt final : public Stmt,
13291328
explicit CompoundStmt(SourceLocation Loc)
13301329
: Stmt(CompoundStmtClass), RBraceLoc(Loc) {
13311330
CompoundStmtBits.NumStmts = 0;
1332-
CompoundStmtBits.WasReplaced = 0;
13331331
CompoundStmtBits.LBraceLoc = Loc;
13341332
}
13351333

@@ -1343,10 +1341,7 @@ class CompoundStmt final : public Stmt,
13431341
using body_range = llvm::iterator_range<body_iterator>;
13441342

13451343
body_range body() { return body_range(body_begin(), body_end()); }
1346-
body_iterator body_begin() {
1347-
Stmt** begin = getTrailingObjects<Stmt *>();
1348-
return !CompoundStmtBits.WasReplaced ? begin : (body_iterator)begin[0];
1349-
}
1344+
body_iterator body_begin() { return getTrailingObjects<Stmt *>(); }
13501345
body_iterator body_end() { return body_begin() + size(); }
13511346
Stmt *body_front() { return !body_empty() ? body_begin()[0] : nullptr; }
13521347

@@ -1362,7 +1357,7 @@ class CompoundStmt final : public Stmt,
13621357
}
13631358

13641359
const_body_iterator body_begin() const {
1365-
return const_cast<CompoundStmt*>(this)->body_begin();
1360+
return getTrailingObjects<Stmt *>();
13661361
}
13671362

13681363
const_body_iterator body_end() const { return body_begin() + size(); }
@@ -1396,8 +1391,6 @@ class CompoundStmt final : public Stmt,
13961391
return const_reverse_body_iterator(body_begin());
13971392
}
13981393

1399-
void replaceStmts(const ASTContext &C, llvm::ArrayRef<Stmt*> Stmts);
1400-
14011394
// Get the Stmt that StmtExpr would consider to be the result of this
14021395
// compound statement. This is used by StmtExpr to properly emulate the GCC
14031396
// compound expression extension, which ignores trailing NullStmts when

interpreter/llvm/src/tools/clang/lib/AST/Stmt.cpp

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,14 @@ CompoundStmt::CompoundStmt(ArrayRef<Stmt *> Stmts, SourceLocation LB,
293293
SourceLocation RB)
294294
: Stmt(CompoundStmtClass), RBraceLoc(RB) {
295295
CompoundStmtBits.NumStmts = Stmts.size();
296-
CompoundStmtBits.WasReplaced = 0;
297296
setStmts(Stmts);
298297
CompoundStmtBits.LBraceLoc = LB;
299298
}
300299

301300
void CompoundStmt::setStmts(ArrayRef<Stmt *> Stmts) {
302301
assert(CompoundStmtBits.NumStmts == Stmts.size() &&
303302
"NumStmts doesn't fit in bits of CompoundStmtBits.NumStmts!");
304-
assert(!CompoundStmtBits.WasReplaced && "Call replaceStmts!");
303+
305304
std::copy(Stmts.begin(), Stmts.end(), body_begin());
306305
}
307306

@@ -317,32 +316,10 @@ CompoundStmt *CompoundStmt::CreateEmpty(const ASTContext &C,
317316
void *Mem =
318317
C.Allocate(totalSizeToAlloc<Stmt *>(NumStmts), alignof(CompoundStmt));
319318
CompoundStmt *New = new (Mem) CompoundStmt(EmptyShell());
320-
New->CompoundStmtBits.WasReplaced = 0;
321319
New->CompoundStmtBits.NumStmts = NumStmts;
322320
return New;
323321
}
324322

325-
void CompoundStmt::replaceStmts(const ASTContext &C,
326-
llvm::ArrayRef<Stmt*> Stmts) {
327-
Stmt** Body = body_begin();
328-
329-
if (CompoundStmtBits.WasReplaced)
330-
C.Deallocate(Body);
331-
else
332-
memset(body_begin(), 0, size());
333-
334-
CompoundStmtBits.NumStmts = Stmts.size();
335-
assert(CompoundStmtBits.NumStmts == Stmts.size() &&
336-
"NumStmts doesn't fit in bits of CompoundStmtBits.NumStmts!");
337-
338-
Body = new (C) Stmt*[Stmts.size()];
339-
std::copy(Stmts.begin(), Stmts.end(), Body);
340-
341-
getTrailingObjects<Stmt *>()[0] = reinterpret_cast<Stmt*>(Body);
342-
343-
CompoundStmtBits.WasReplaced = 1;
344-
}
345-
346323
const Expr *ValueStmt::getExprStmt() const {
347324
const Stmt *S = this;
348325
do {

0 commit comments

Comments
 (0)