diff options
Diffstat (limited to 'tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp')
-rw-r--r-- | tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp b/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp new file mode 100644 index 000000000000..73ef14b75589 --- /dev/null +++ b/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp @@ -0,0 +1,30 @@ +//==-- proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion ----------==// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Implements a simple driver to print a C++ program from a protobuf. +// +//===----------------------------------------------------------------------===// +#include <fstream> +#include <iostream> +#include <streambuf> +#include <string> + +#include "proto_to_cxx.h" + +int main(int argc, char **argv) { + for (int i = 1; i < argc; i++) { + std::fstream in(argv[i]); + std::string str((std::istreambuf_iterator<char>(in)), + std::istreambuf_iterator<char>()); + std::cout << "// " << argv[i] << std::endl; + std::cout << clang_fuzzer::ProtoToCxx( + reinterpret_cast<const uint8_t *>(str.data()), str.size()); + } +} + |