public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/84904] Implement an option to attempt to auto-apply fix-it hints
       [not found] <bug-84904-4@http.gcc.gnu.org/bugzilla/>
@ 2021-01-20 10:35 ` egallager at gcc dot gnu.org
  0 siblings, 0 replies; only message in thread
From: egallager at gcc dot gnu.org @ 2021-01-20 10:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84904

--- Comment #3 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Eric Gallager from comment #1)
> (In reply to David Malcolm from comment #0)
> > In my original edit_context patch kit I posted a
> > "-fdiagnostics-apply-fixits" option that would auto-apply fix-it hints:
> >   https://gcc.gnu.org/ml/gcc-patches/2016-08/msg01682.html
> > ...but there was no error-checking.
> > 
> > This is something of a brainstorm:
> > 
> > A really smart implementation of this would directly modify the token
> > stream, and fix the AST as we go.
> > 
> > Sadly I don't think that doing that would be feasible, for C, at least, so
> > any implementation is probably going to have to write a file to disk.
> > (maybe it's doable for C++, given that that has all the tokens in-memory
> > up-front?  but what about the preprocessor?)
> > 
> > Error-handling needs to be perfect: we must *never* lose or corrupt the
> > user's source code.
> > 
> > Would probably need to be something like:
> > * write the proposed new code to disk
> > * verify that it works
> > * make a backup copy of the old code
> > * copy the new code into place (various failures here need to be dealt with)
> > * tell the user where the backup is
> > * maybe keep the last, say, 10 copies around, with rolling backup (param to
> > control it)
> 
> As far as backups go, the standard way for GNU programs to do backups is
> Emacs backups; see autoupdate and autoheader in autoconf, gnulib-tool in
> gnulib, gettextize in gettext, and probably a few others I'm forgetting. See
> also gnulib modules backupfile and backup-rename:
> https://www.gnu.org/software/gnulib/MODULES.html#module=backupfile
> https://www.gnu.org/software/gnulib/MODULES.html#module=backup-rename

Update: apparently autoconf/automake check the environment variable
$SIMPLE_BACKUP_SUFFIX:
https://lists.gnu.org/archive/html/autoconf/2021-01/msg00005.html

> 
> > 
> > Further complications:
> > * fix-it hints could affect multiple files, not just the primary source file
> > * we might not have write access to some of the files (e.g. headers). 
> > (Reminiscent of fixincludes?)
> > 
> > There could be interaction with the driver: apply the fixes, reinvoke the
> > compiler, etc.  Maybe keep going until we can't fix.  If so, could need some
> > diagnostic-suppression to avoid spamming the user with the same diagnostic
> > over and over again.  Question: if we successfully get the user's code to
> > compile, but there were errors along the way, do we still generate a .o
> > file?
> > 
> > Maybe "-fixit" is a better name?
> 
> Sounds like "-fast", which got renamed to "-Ofast"

(to make what I was saying here a bit more explicit, what I meant was that
making intentional puns out of option names seems to be on its way out. Instead
of just "-fixit" I'd say at least extend it to "-ffixit" so the negative
becomes "-fno-fixit" rather than just "-fno-ixit", but really I think the
original longer name of "-fdiagnostics-apply-fixits" is still the best.)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-20 10:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-84904-4@http.gcc.gnu.org/bugzilla/>
2021-01-20 10:35 ` [Bug other/84904] Implement an option to attempt to auto-apply fix-it hints egallager at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).