Tools built with LibTooling default to using a compilation database if one is available, which is good.
In the case where a compilation database is not available, there is a problem: the default behavior is to exit with an error message, whereas in some cases the tool would be required to do the best it can anyway. This can be achieved by adding – to the end of the command line, but this wouldn’t be obvious to someone unfamiliar with Clang tools.
One solution would be for the program to append – to argv if it’s not already present, but would this disable the default useful behavior of reading the compilation database if it is available?
If so, is there a way for the program to say ‘okay, check for a compilation database as normal, but if it’s not present, let me know and I’ll fill in some best-guess default options’?
Tools built with LibTooling default to using a compilation database if one is available, which is good.
In the case where a compilation database is not available, there is a problem: the default behavior is to exit with an error message, whereas in some cases the tool would be required to do the best it can anyway. This can be achieved by adding – to the end of the command line, but this wouldn’t be obvious to someone unfamiliar with Clang tools.
One solution would be for the program to append – to argv if it’s not already present, but would this disable the default useful behavior of reading the compilation database if it is available?
If so, is there a way for the program to say ‘okay, check for a compilation database as normal, but if it’s not present, let me know and I’ll fill in some best-guess default options’?
The problem is that for C++ there really are no best guess default options. If you have ideas for what they should be, please make a proposal.
There are none that are guaranteed to work in all cases; nonetheless, if Clang, GCC or Microsoft C++ is presented with a ‘hello world’ test program with no other options, it will successfully compile it with its built-in defaults, so the defaults for a tool should be those that Clang would use in the same circumstances. (I do have some ideas for automated search for the correct options if the defaults fail, but in the meantime ‘do what the actual compiler would do’ would be a good baseline.)
There are none that are guaranteed to work in all cases; nonetheless, if Clang, GCC or Microsoft C++ is presented with a ‘hello world’ test program with no other options, it will successfully compile it with its built-in defaults, so the defaults for a tool should be those that Clang would use in the same circumstances. (I do have some ideas for automated search for the correct options if the defaults fail, but in the meantime ‘do what the actual compiler would do’ would be a good baseline.)
The problem is that if this happens, it’s hard to tell the user what they need to do to get the tool to work (set up a compilation database).
How about we add to the error if there is not compilation database how to run it in default mode (by adding – at the end)?
Okay, I’m looking through the code to see if I can put together a patch. In this project, is it considered preferable to minimize the number of lines changed in the patch, or minimize the size of the code after the patch?
Okay, I’m looking through the code to see if I can put together a patch. In this project, is it considered preferable to minimize the number of lines changed in the patch, or minimize the size of the code after the patch?
How about “maximize the quality of the code after the patch”