mc-imperial / dredd

Framework for evaluating C/C++ compiler testing tools
Apache License 2.0
11 stars 3 forks source link

Dredd mutator function hides declarations in namespace #296

Open JonathanFoo0523 opened 1 month ago

JonathanFoo0523 commented 1 month ago

Given files include.h

namespace baz {
namespace bar {
bool foo(short x);

enum : short {B = 1};
}
}

and file main.cc:

#include "include.h"

using namespace baz;

void func() {
    foo(bar::B);
}

Note that main.cc compile successfully, even though foo is not explicitly stated with namespace bar::foo. However, applying dredd to main.cc changes the sole statement to

if (!__dredd_enabled_mutation(3)) { foo(__dredd_replace_expr_short_one(bar::B, 0)); }

and results in compilation error:

error: use of undeclared identifier 'foo'
JonathanFoo0523 commented 3 weeks ago

Related info: Koenig lookup

afd commented 3 weeks ago

Perhaps this could be used to provide a work around and avoid mutating calls that use argument dependent lookup?

https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html#a16460619f757c5a63ca6b80999d768cd