| 1 | //===-- cxx_proto.proto - Protobuf description of C++ ---------------------===// |
| 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 | /// \file |
| 10 | /// This file describes a subset of C++ as a protobuf. It is used to |
| 11 | /// more easily find interesting inputs for fuzzing Clang. |
| 12 | /// |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | syntax = "proto2"; |
| 16 | |
| 17 | message VarRef { |
| 18 | required int32 varnum = 1; |
| 19 | } |
| 20 | |
| 21 | message Lvalue { |
| 22 | required VarRef varref = 1; |
| 23 | } |
| 24 | |
| 25 | message Const { |
| 26 | required int32 val = 1; |
| 27 | } |
| 28 | |
| 29 | message BinaryOp { |
| 30 | enum Op { |
| 31 | PLUS = 0; |
| 32 | MINUS = 1; |
| 33 | MUL = 2; |
| 34 | DIV = 3; |
| 35 | MOD = 4; |
| 36 | XOR = 5; |
| 37 | AND = 6; |
| 38 | OR = 7; |
| 39 | EQ = 8; |
| 40 | NE = 9; |
| 41 | LE = 10; |
| 42 | GE = 11; |
| 43 | LT = 12; |
| 44 | GT = 13; |
| 45 | }; |
| 46 | required Op op = 1; |
| 47 | required Rvalue left = 2; |
| 48 | required Rvalue right = 3; |
| 49 | } |
| 50 | |
| 51 | message Rvalue { |
| 52 | oneof rvalue_oneof { |
| 53 | VarRef varref = 1; |
| 54 | Const cons = 2; |
| 55 | BinaryOp binop = 3; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | message AssignmentStatement { |
| 60 | required Lvalue lvalue = 1; |
| 61 | required Rvalue rvalue = 2; |
| 62 | } |
| 63 | |
| 64 | |
| 65 | message IfElse { |
| 66 | required Rvalue cond = 1; |
| 67 | required StatementSeq if_body = 2; |
| 68 | required StatementSeq else_body = 3; |
| 69 | } |
| 70 | |
| 71 | message While { |
| 72 | required Rvalue cond = 1; |
| 73 | required StatementSeq body = 2; |
| 74 | } |
| 75 | |
| 76 | message Statement { |
| 77 | oneof stmt_oneof { |
| 78 | AssignmentStatement assignment = 1; |
| 79 | IfElse ifelse = 2; |
| 80 | While while_loop = 3; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | message StatementSeq { |
| 85 | repeated Statement statements = 1; |
| 86 | } |
| 87 | |
| 88 | message Function { |
| 89 | required StatementSeq statements = 1; |
| 90 | } |
| 91 | |
| 92 | package clang_fuzzer; |
| 93 | |