Vitaly Buka | 410a6b2 | 2018-06-07 19:17:46 +0000 | [diff] [blame^] | 1 | //===-- cxx_loop_proto.proto - Protobuf description of C++ with for loops -===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// |
| 10 | /// \file |
| 11 | /// This file describes a subset of C++ as a protobuf. It is used to |
| 12 | /// more easily find interesting inputs for fuzzing Clang. This subset |
| 13 | /// extends the one defined in cxx_proto.proto by adding the option that |
| 14 | /// a VarRef can use the for loop's counter variable. |
| 15 | /// |
| 16 | //===----------------------------------------------------------------------===// |
| 17 | |
| 18 | |
| 19 | syntax = "proto2"; |
| 20 | |
| 21 | message VarRef { |
| 22 | required int32 varnum = 1; |
| 23 | required bool is_loop_var = 2; |
| 24 | } |
| 25 | |
| 26 | message Lvalue { |
| 27 | required VarRef varref = 1; |
| 28 | } |
| 29 | |
| 30 | message Const { |
| 31 | required int32 val = 1; |
| 32 | } |
| 33 | |
| 34 | message BinaryOp { |
| 35 | enum Op { |
| 36 | PLUS = 0; |
| 37 | MINUS = 1; |
| 38 | MUL = 2; |
| 39 | DIV = 3; |
| 40 | MOD = 4; |
| 41 | XOR = 5; |
| 42 | AND = 6; |
| 43 | OR = 7; |
| 44 | EQ = 8; |
| 45 | NE = 9; |
| 46 | LE = 10; |
| 47 | GE = 11; |
| 48 | LT = 12; |
| 49 | GT = 13; |
| 50 | }; |
| 51 | required Op op = 1; |
| 52 | required Rvalue left = 2; |
| 53 | required Rvalue right = 3; |
| 54 | } |
| 55 | |
| 56 | message Rvalue { |
| 57 | oneof rvalue_oneof { |
| 58 | VarRef varref = 1; |
| 59 | Const cons = 2; |
| 60 | BinaryOp binop = 3; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | message AssignmentStatement { |
| 65 | required Lvalue lvalue = 1; |
| 66 | required Rvalue rvalue = 2; |
| 67 | } |
| 68 | |
| 69 | |
| 70 | message IfElse { |
| 71 | required Rvalue cond = 1; |
| 72 | required StatementSeq if_body = 2; |
| 73 | required StatementSeq else_body = 3; |
| 74 | } |
| 75 | |
| 76 | message While { |
| 77 | required Rvalue cond = 1; |
| 78 | required StatementSeq body = 2; |
| 79 | } |
| 80 | |
| 81 | message Statement { |
| 82 | oneof stmt_oneof { |
| 83 | AssignmentStatement assignment = 1; |
| 84 | IfElse ifelse = 2; |
| 85 | While while_loop = 3; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | message StatementSeq { |
| 90 | repeated Statement statements = 1; |
| 91 | } |
| 92 | |
| 93 | message LoopFunction { |
| 94 | required StatementSeq statements = 1; |
| 95 | } |
| 96 | |
| 97 | package clang_fuzzer; |