1 /** 2 Copyright: Copyright (c) 2017, Joakim Brännström. All rights reserved. 3 License: MPL-2 4 Author: Joakim Brännström (joakim.brannstrom@gmx.com) 5 6 This Source Code Form is subject to the terms of the Mozilla Public License, 7 v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 8 one at http://mozilla.org/MPL/2.0/. 9 */ 10 module dextool.plugin.mutate.backend.type; 11 12 import dextool.hash : Murmur3; 13 14 @safe: 15 16 alias Checksum = Murmur3; 17 18 /** 19 * See: definitions.md for more information 20 */ 21 struct MutationPoint { 22 Offset offset; 23 Mutation[] mutations; 24 } 25 26 /// Offset range. It is a [) (closed->open). 27 struct Offset { 28 uint begin; 29 uint end; 30 } 31 32 /// Location in the source code. 33 struct SourceLoc { 34 uint line; 35 uint column; 36 } 37 38 /// A possible mutation and its status. 39 struct Mutation { 40 /// States what kind of mutations that can be performed on this mutation point. 41 // ONLY ADD NEW ITEMS TO THE END 42 enum Kind { 43 /// the kind is not initialized thus can only ignore the point 44 none, 45 /// Relational operator replacement 46 rorLT, 47 rorLE, 48 rorGT, 49 rorGE, 50 rorEQ, 51 rorNE, 52 /// Logical connector replacement 53 lcrAnd, 54 lcrOr, 55 /// Arithmetic operator replacement 56 aorMul, 57 aorDiv, 58 aorRem, 59 aorAdd, 60 aorSub, 61 aorMulAssign, 62 aorDivAssign, 63 aorRemAssign, 64 aorAddAssign, 65 aorSubAssign, 66 /// Unary operator insert on an lvalue 67 uoiPostInc, 68 uoiPostDec, 69 // these work for rvalue 70 uoiPreInc, 71 uoiPreDec, 72 uoiAddress, 73 uoiIndirection, 74 uoiPositive, 75 uoiNegative, 76 uoiComplement, 77 uoiNegation, 78 uoiSizeof_, 79 /// Absolute value replacement 80 absPos, 81 absNeg, 82 absZero, 83 /// statement deletion 84 stmtDel, 85 /// Conditional Operator Replacement (reduced set) 86 corAnd, 87 corOr, 88 corFalse, 89 corLhs, 90 corRhs, 91 corEQ, 92 corNE, 93 corTrue, 94 /// Relational operator replacement 95 rorTrue, 96 rorFalse, 97 /// Decision/Condition Coverage 98 dccTrue, 99 dccFalse, 100 dccBomb, 101 /// Decision/Condition Requirement 102 dcrCaseDel, 103 /// Relational operator replacement for pointers 104 rorpLT, 105 rorpLE, 106 rorpGT, 107 rorpGE, 108 rorpEQ, 109 rorpNE, 110 /// Logical Operator Replacement Bit-wise (lcrb) 111 lcrbAnd, 112 lcrbOr, 113 lcrbAndAssign, 114 lcrbOrAssign, 115 } 116 117 enum Status { 118 /// the mutation isn't tested 119 unknown, 120 /// killed by the test suite 121 killed, 122 /// not killed by the test suite 123 alive, 124 /// the mutation resulted in invalid code that didn't compile 125 killedByCompiler, 126 /// the mutant resulted in the test suite/sut reaching the timeout threshold 127 timeout, 128 } 129 130 Kind kind; 131 Status status; 132 } 133 134 /// Deducted type information for expressions on the sides of a relational operator 135 enum OpTypeInfo { 136 none, 137 /// Both sides are floating points 138 floatingPoint, 139 /// Either side is a pointer 140 pointer, 141 /// Both sides are bools 142 boolean, 143 /// lhs and rhs sides are the same enum decl 144 enumLhsRhsIsSame, 145 /// lhs is the minimal representation in the enum type 146 enumLhsIsMin, 147 /// lhs is the maximum representation in the enum type 148 enumLhsIsMax, 149 /// rhs is the minimum representation in the enum type 150 enumRhsIsMin, 151 /// rhs is the maximum representation in the enum type 152 enumRhsIsMax, 153 } 154 155 /// A test case that failed and thus killed a mutant. 156 struct TestCase { 157 string value; 158 alias value this; 159 }