Index: clang/tools/clang-fuzzer/cxx_loop_proto.proto =================================================================== --- clang/tools/clang-fuzzer/cxx_loop_proto.proto +++ clang/tools/clang-fuzzer/cxx_loop_proto.proto @@ -74,7 +74,8 @@ } message LoopFunction { - required StatementSeq statements = 1; + required StatementSeq inner_statements = 1; + required StatementSeq outer_statements = 2; } package clang_fuzzer; Index: clang/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp =================================================================== --- clang/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp +++ clang/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp @@ -28,6 +28,8 @@ namespace clang_fuzzer { +static bool inner_loop; + // Forward decls. std::ostream &operator<<(std::ostream &os, const BinaryOp &x); std::ostream &operator<<(std::ostream &os, const StatementSeq &x); @@ -37,13 +39,14 @@ return os << "(" << x.val() << ")"; } std::ostream &operator<<(std::ostream &os, const VarRef &x) { + std::string var = inner_loop ? "i" : "j"; switch (x.arr()) { case VarRef::ARR_A: - return os << "a[i]"; + return os << "a[" << var << "]"; case VarRef::ARR_B: - return os << "b[i]"; + return os << "b[" << var << "]"; case VarRef::ARR_C: - return os << "c[i]"; + return os << "c[" << var << "]"; } } std::ostream &operator<<(std::ostream &os, const Rvalue &x) { @@ -109,9 +112,13 @@ return os; } std::ostream &operator<<(std::ostream &os, const LoopFunction &x) { - return os << "void foo(int *a, int *b, int *__restrict__ c, size_t s) {\n" - << "for (int i=0; i