mutate_cpp icon indicating copy to clipboard operation
mutate_cpp copied to clipboard

What about using Clangd to reject mutations that would not compile

Open jan-revay opened this issue 2 years ago • 3 comments

The point is that Clangd can probably detect errors much quicker than compiler itself as it uses indexing, and it does not need to reparse the whole file after just a single line was changes. Only the mutations that passed Clangd syntactic check would be compiled.

jan-revay avatar Aug 24 '22 16:08 jan-revay

What is your exact proposal?

nlohmann avatar Aug 24 '22 17:08 nlohmann

The proposal is to start clangd as a part of the "Generate patches" run and use LSP to syntactically validate the patches before adding them to the database. I think that Clangd should be able to syntactically validate the patches much quicker than compiler would, as I think that Clangd does not need to reparse the whole document if only one line changed.

This would save hours of time as there is no point in trying to compile patches that are obviously syntactically invalid, e.g. a patch

std::string a = "lksjflskdjf";      ->     std::string a |= "lksjflskdjf";

should not even get to the compilation stage, IMO...

jan-revay avatar Aug 25 '22 03:08 jan-revay

Resp. to be super exact: Mutate_cpp would listen to Clangd LSP messages such as

{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"exponent_has_no_digits","message":"Exponent has no digits","range":{"end":{"character":50,"line":210},"start":{"character":49,"line":210}},"relatedInformation":[],"severity":1,"source":"clang"}

either during execution of the queue or during generation of the patchsets. It should be relatively easy to implement I guess.

jan-revay avatar Aug 25 '22 10:08 jan-revay