Skip to content

Commit 9f30815

Browse files
authored
[JSON][NFC] Support print and dump methods in json::Value (#129302)
1 parent 9cc477b commit 9f30815

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

llvm/include/llvm/Support/JSON.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,14 @@ class Value {
472472
return LLVM_LIKELY(Type == T_Array) ? &as<json::Array>() : nullptr;
473473
}
474474

475+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
476+
void print(llvm::raw_ostream &OS) const;
477+
LLVM_DUMP_METHOD void dump() const {
478+
print(llvm::dbgs());
479+
llvm::dbgs() << '\n';
480+
}
481+
#endif // !NDEBUG || LLVM_ENABLE_DUMP
482+
475483
private:
476484
void destroy();
477485
void copyFrom(const Value &M);

llvm/lib/Support/JSON.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ void Value::destroy() {
182182
}
183183
}
184184

185+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
186+
void Value::print(llvm::raw_ostream &OS) const { OS << *this; }
187+
#endif // !NDEBUG || LLVM_ENABLE_DUMP
188+
185189
bool operator==(const Value &L, const Value &R) {
186190
if (L.kind() != R.kind())
187191
return false;

0 commit comments

Comments
 (0)