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 |
Matt Morehouse | 1dc1ff8 | 2018-06-08 00:33:35 +0000 | [diff] [blame] | 13 | /// differs from the one defined in cxx_proto.proto by eliminating while |
Matt Morehouse | 3416773 | 2018-06-11 17:05:45 +0000 | [diff] [blame^] | 14 | /// loops and conditionals. The goal is that the C++ code generated will be |
Matt Morehouse | 1dc1ff8 | 2018-06-08 00:33:35 +0000 | [diff] [blame] | 15 | /// more likely to stress the LLVM loop vectorizer. |
Vitaly Buka | 410a6b2 | 2018-06-07 19:17:46 +0000 | [diff] [blame] | 16 | /// |
| 17 | //===----------------------------------------------------------------------===// |
| 18 | |
Vitaly Buka | 410a6b2 | 2018-06-07 19:17:46 +0000 | [diff] [blame] | 19 | syntax = "proto2"; |
| 20 | |
Vitaly Buka | 410a6b2 | 2018-06-07 19:17:46 +0000 | [diff] [blame] | 21 | message Const { |
| 22 | required int32 val = 1; |
| 23 | } |
| 24 | |
Matt Morehouse | 3416773 | 2018-06-11 17:05:45 +0000 | [diff] [blame^] | 25 | message VarRef { |
| 26 | // Add an enum for each array in function signature |
| 27 | enum Arr { |
| 28 | ARR_A = 0; |
| 29 | ARR_B = 1; |
| 30 | ARR_C = 2; |
| 31 | }; |
| 32 | required Arr arr = 1; |
| 33 | } |
| 34 | |
Vitaly Buka | 410a6b2 | 2018-06-07 19:17:46 +0000 | [diff] [blame] | 35 | message BinaryOp { |
| 36 | enum Op { |
| 37 | PLUS = 0; |
| 38 | MINUS = 1; |
| 39 | MUL = 2; |
| 40 | DIV = 3; |
| 41 | MOD = 4; |
| 42 | XOR = 5; |
| 43 | AND = 6; |
| 44 | OR = 7; |
| 45 | EQ = 8; |
| 46 | NE = 9; |
| 47 | LE = 10; |
| 48 | GE = 11; |
| 49 | LT = 12; |
| 50 | GT = 13; |
| 51 | }; |
| 52 | required Op op = 1; |
| 53 | required Rvalue left = 2; |
| 54 | required Rvalue right = 3; |
| 55 | } |
| 56 | |
| 57 | message Rvalue { |
| 58 | oneof rvalue_oneof { |
Matt Morehouse | 1dc1ff8 | 2018-06-08 00:33:35 +0000 | [diff] [blame] | 59 | Const cons = 1; |
| 60 | BinaryOp binop = 2; |
Matt Morehouse | 3416773 | 2018-06-11 17:05:45 +0000 | [diff] [blame^] | 61 | VarRef varref = 3; |
Vitaly Buka | 410a6b2 | 2018-06-07 19:17:46 +0000 | [diff] [blame] | 62 | } |
| 63 | } |
| 64 | |
| 65 | message AssignmentStatement { |
Matt Morehouse | 3416773 | 2018-06-11 17:05:45 +0000 | [diff] [blame^] | 66 | required VarRef varref = 1; |
Vitaly Buka | 410a6b2 | 2018-06-07 19:17:46 +0000 | [diff] [blame] | 67 | required Rvalue rvalue = 2; |
| 68 | } |
| 69 | |
Vitaly Buka | 410a6b2 | 2018-06-07 19:17:46 +0000 | [diff] [blame] | 70 | message IfElse { |
| 71 | required Rvalue cond = 1; |
| 72 | required StatementSeq if_body = 2; |
| 73 | required StatementSeq else_body = 3; |
| 74 | } |
| 75 | |
Vitaly Buka | 410a6b2 | 2018-06-07 19:17:46 +0000 | [diff] [blame] | 76 | message Statement { |
Matt Morehouse | 3416773 | 2018-06-11 17:05:45 +0000 | [diff] [blame^] | 77 | required AssignmentStatement assignment = 1; |
Vitaly Buka | 410a6b2 | 2018-06-07 19:17:46 +0000 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | message StatementSeq { |
| 81 | repeated Statement statements = 1; |
| 82 | } |
| 83 | |
| 84 | message LoopFunction { |
| 85 | required StatementSeq statements = 1; |
| 86 | } |
| 87 | |
| 88 | package clang_fuzzer; |