mc-imperial / dredd

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

Insert Dredd declartions before first function #220

Closed JamesLee-Jones closed 1 month ago

JamesLee-Jones commented 5 months ago

Inserting Dredd's declarations at the beginning of the file can cause issues with header files that have to be before any system headers. So instead, insert Dredd's declarations at the top level before the first mutation that we find.

Fixes: #219, #215

JamesLee-Jones commented 5 months ago

Although this is unlikely to ever be unreasonably expensive, there is probably an optimizations that could be made. If the Clang AST is always traversed top down, then we just need to find the place that Dredd is going to modify and insert the prelude before this at the global scope. This means once start_location_of_first_function_in_source_file_ is valid, we could skip the rest of the function as this will always have the earliest starting source location.

afd commented 2 months ago

@JamesLee-Jones Can you rebase this one please? From what I recall it should be good to go, except there was one simplification you were looking at making (see open discussion).

afd commented 2 months ago

@JamesLee-Jones This will need a rebase. Does my suggested refactoring make sense and are you good to do it?

JamesLee-Jones commented 1 month ago

@JamesLee-Jones This will need a rebase. Does my suggested refactoring make sense and are you good to do it?

Your suggestion makes sense, I'll refactor it today!