diff options
Diffstat (limited to 'tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp')
-rw-r--r-- | tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp b/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp new file mode 100644 index 0000000000000..a4b8e58c12737 --- /dev/null +++ b/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp @@ -0,0 +1,31 @@ +//==-- loop_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 with loops. +// +//===----------------------------------------------------------------------===// + + +#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::LoopProtoToCxx( + reinterpret_cast<const uint8_t *>(str.data()), str.size()); + } +} |