weggli-rs / weggli

weggli is a fast and robust semantic search tool for C and C++ codebases. It is designed to help security researchers identify interesting functionality in large codebases.
Apache License 2.0
2.32k stars 127 forks source link

Incorrect cross-function match identified #51

Open offlinemark opened 2 years ago

offlinemark commented 2 years ago

Hello - when I run this query:

weggli -X '{
const _ $a = _;
std::move($a);
}' /tmp/x.cc

On this code:

MACRO

namespace {

void func() {
    const auto g = f2();
}

void func2() {
    auto g = f2();
    std::move(g);
}

}

I get this:

/tmp/x.cc:1
MACRO

namespace {

void func() {
    const auto g = f2();
}

void func2() {
    auto g = f2();
    std::move(g);
}

}

It seems weggli is unaware of the function boundary here. Both the macro and namespace are necessary for the bug.

Adding a ; after MACRO fixes it, but that's not something I can change in my codebase.

Thanks!