xref: /netbsd-src/external/apache2/llvm/dist/clang/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp (revision 7330f729ccf0bd976a06f95fad452fe774fc7fd1)
1 //==-- loop_proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion -----==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Implements a simple driver to print a C++ program from a protobuf with loops.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 
14 #include <fstream>
15 #include <iostream>
16 #include <streambuf>
17 #include <string>
18 
19 #include "proto_to_cxx.h"
20 
main(int argc,char ** argv)21 int main(int argc, char **argv) {
22   for (int i = 1; i < argc; i++) {
23     std::fstream in(argv[i]);
24     std::string str((std::istreambuf_iterator<char>(in)),
25                     std::istreambuf_iterator<char>());
26     std::cout << "// " << argv[i] << std::endl;
27     std::cout << clang_fuzzer::LoopProtoToCxx(
28         reinterpret_cast<const uint8_t *>(str.data()), str.size());
29   }
30 }
31