Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Unified Diff: tools/clang/blink_gc_plugin/JsonWriter.h

Issue 1108173002: Roll //build, //native_client, and a few more targets of opportunity. Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Test fix Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/clang/blink_gc_plugin/Edge.h ('k') | tools/clang/plugins/CMakeLists.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/clang/blink_gc_plugin/JsonWriter.h
diff --git a/tools/clang/blink_gc_plugin/JsonWriter.h b/tools/clang/blink_gc_plugin/JsonWriter.h
index 54a87aae59e7cbf69fd48f345b977892088d51ba..09504b3aaf9feb7e011d0740959aab6c61624a89 100644
--- a/tools/clang/blink_gc_plugin/JsonWriter.h
+++ b/tools/clang/blink_gc_plugin/JsonWriter.h
@@ -7,66 +7,75 @@
#include "llvm/Support/raw_ostream.h"
+// TODO(hans): Remove this #ifdef after Clang is rolled past r234897.
+#ifdef LLVM_FORCE_HEAD_REVISION
+#define JSON_WRITER_STREAM std::unique_ptr<llvm::raw_ostream>
+#else
+#define JSON_WRITER_STREAM llvm::raw_fd_ostream*
+#endif
+
// Helper to write information for the points-to graph.
class JsonWriter {
public:
- static JsonWriter* from(llvm::raw_fd_ostream* os) {
- return os ? new JsonWriter(os) : 0;
+ static JsonWriter* from(JSON_WRITER_STREAM os) {
+ return os ? new JsonWriter(std::move(os)) : 0;
}
+#ifndef LLVM_FORCE_HEAD_REVISION
~JsonWriter() {
- os_.close();
+ delete os_;
}
+#endif
void OpenList() {
Separator();
- os_ << "[";
+ *os_ << "[";
state_.push(false);
}
void OpenList(const std::string key) {
Write(key);
- os_ << ":";
+ *os_ << ":";
OpenList();
}
void CloseList() {
- os_ << "]";
+ *os_ << "]";
state_.pop();
}
void OpenObject() {
Separator();
- os_ << "{";
+ *os_ << "{";
state_.push(false);
}
void CloseObject() {
- os_ << "}\n";
+ *os_ << "}\n";
state_.pop();
}
void Write(const size_t val) {
Separator();
- os_ << val;
+ *os_ << val;
}
void Write(const std::string val) {
Separator();
- os_ << "\"" << val << "\"";
+ *os_ << "\"" << val << "\"";
}
void Write(const std::string key, const size_t val) {
Separator();
- os_ << "\"" << key << "\":" << val;
+ *os_ << "\"" << key << "\":" << val;
}
void Write(const std::string key, const std::string val) {
Separator();
- os_ << "\"" << key << "\":\"" << val << "\"";
+ *os_ << "\"" << key << "\":\"" << val << "\"";
}
private:
- JsonWriter(llvm::raw_fd_ostream* os) : os_(*os) {}
+ JsonWriter(JSON_WRITER_STREAM os) : os_(std::move(os)) {}
void Separator() {
if (state_.empty())
return;
if (state_.top()) {
- os_ << ",";
+ *os_ << ",";
return;
}
state_.top() = true;
}
- llvm::raw_fd_ostream& os_;
+ JSON_WRITER_STREAM os_;
std::stack<bool> state_;
};
« no previous file with comments | « tools/clang/blink_gc_plugin/Edge.h ('k') | tools/clang/plugins/CMakeLists.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698