Skip to content

dredd doesn't mutate some CastExpr under --no-mutation-opts option #276

Description

@JonathanFoo0523

Applying dredd to

int main() {
  unsigned int x = 1;
}

mutate the declaration statement to

 unsigned int x = __dredd_replace_expr_unsigned_int(__dredd_replace_expr_int(1, 0), 6);

with the following AST.

FunctionDecl 0x55d773f60890 </home/ubuntu/dredd/examples/simple/cast.cc:1:1, line:3:1> line:1:5 main 'int ()'
  `-CompoundStmt 0x55d773f60a80 <col:12, line:3:1>
    `-DeclStmt 0x55d773f60a68 <line:2:3, col:21>
      `-VarDecl 0x55d773f609c8 <col:3, col:20> col:16 x 'unsigned int' cinit
        `-ImplicitCastExpr 0x55d773f60a50 <col:20> 'unsigned int' <IntegralCast>
          `-IntegerLiteral 0x55d773f60a30 <col:20> 'int' 1

Am I right to assume that __dredd_replace_expr_int is the result of mutation on IntegerLiteral, and __dredd_replace_expr_unsigned_int is the result of mutation on ImplicitCastExpr?

If that the case, consider another example with similar AST:

#include <initializer_list>
class foo {
public:
  foo(std::initializer_list<unsigned>) {}
};

int main() { 
  foo{2};
}

which mutate the one line in foo{2} to

foo{static_cast<unsigned int>(__dredd_replace_expr_int(2, 0))}

with the following AST:

FunctionDecl 0x55e2836e16a0 <line:7:1, line:9:1> line:7:5 main 'int ()'
  `-CompoundStmt 0x55e2836e2ce8 <col:12, line:9:1>
    `-ExprWithCleanups 0x55e2836e2cd0 <line:8:3, col:8> 'foo':'foo'
      `-CXXTemporaryObjectExpr 0x55e2836e2ba8 <col:3, col:8> 'foo':'foo' 'void (std::initializer_list<unsigned int>)' list std::initializer_list
        `-CXXStdInitializerListExpr 0x55e2836e2988 <col:6, col:8> 'std::initializer_list<unsigned int>':'std::initializer_list<unsigned int>'
          `-MaterializeTemporaryExpr 0x55e2836e2970 <col:6, col:8> 'const unsigned int[1]' xvalue
            `-InitListExpr 0x55e2836e1ce8 <col:6, col:8> 'const unsigned int[1]'
              `-ImplicitCastExpr 0x55e2836e1d30 <col:7> 'const unsigned int' <IntegralCast>
                `-IntegerLiteral 0x55e2836e1800 <col:7> 'int' 2

So, __dredd_replace_expr_int is the result of mutation on IntegerLiteral as previous. Why isn't there __dredd_replace_expr_unsigned_int acting on ImplicitCastExpr?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions