Skip to content

Commit 7b5dfd6

Browse files
authored
[AutoDiff upstream] NFC: update IndexSubset print/dump utilities. (#27775)
Cherry-pick #27772 from tensorflow branch.
1 parent 33e5c0d commit 7b5dfd6

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

include/swift/AST/IndexSubset.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,10 @@ class IndexSubset : public llvm::FoldingSetNode {
201201
id.AddInteger(index);
202202
}
203203

204-
void print(llvm::raw_ostream &s = llvm::outs()) const {
205-
s << '{';
206-
interleave(range(capacity), [this, &s](unsigned i) { s << contains(i); },
207-
[&s] { s << ", "; });
208-
s << '}';
209-
}
210-
211-
void dump(llvm::raw_ostream &s = llvm::errs()) const {
212-
s << "(index_subset capacity=" << capacity << " indices=(";
213-
interleave(getIndices(), [&s](unsigned i) { s << i; },
214-
[&s] { s << ", "; });
215-
s << "))";
216-
}
204+
void print(llvm::raw_ostream &s = llvm::outs()) const;
205+
LLVM_ATTRIBUTE_DEPRECATED(void dump(llvm::raw_ostream &s = llvm::errs())
206+
const LLVM_ATTRIBUTE_USED,
207+
"only for use within the debugger");
217208

218209
int findNext(int startIndex) const;
219210
int findFirst() const { return findNext(-1); }

lib/AST/IndexSubset.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,20 @@ IndexSubset *IndexSubset::extendingCapacity(
7979
return IndexSubset::get(ctx, indices);
8080
}
8181

82+
void IndexSubset::print(llvm::raw_ostream &s) const {
83+
s << '{';
84+
interleave(range(capacity), [this, &s](unsigned i) { s << contains(i); },
85+
[&s] { s << ", "; });
86+
s << '}';
87+
}
88+
89+
void IndexSubset::dump(llvm::raw_ostream &s) const {
90+
s << "(index_subset capacity=" << capacity << " indices=(";
91+
interleave(getIndices(), [&s](unsigned i) { s << i; },
92+
[&s] { s << ", "; });
93+
s << "))\n";
94+
}
95+
8296
int IndexSubset::findNext(int startIndex) const {
8397
assert(startIndex < (int)capacity && "Start index cannot be past the end");
8498
unsigned bitWordIndex = 0, offset = 0;

0 commit comments

Comments
 (0)