[cfe-commits] PATCH: ASTMatchers-based refactoring callbacks to make common cases of refactoring easy

Daniel Jasper djasper at google.com
Sun Jul 15 23:41:59 PDT 2012


On Fri, Jul 13, 2012 at 6:58 PM, Manuel Klimek <klimek at google.com> wrote:

> On Fri, Jul 13, 2012 at 5:53 PM, Daniel Jasper <djasper at google.com> wrote:
> > New patch attached:
> > - More tests.
> > - Fixed line length.
> > - Better integer literal.
>
> Are you sure you want StringRef as class members here?
>

Oops. Sorry. Fixed.


>
> +    } else {
> +      // If we don't have the appropriate clause, then just delete
> the whole if.
> +      if (!PickTrueBranch)
> +        Replace.insert(replaceStmtWithText(*Result.SourceManager, *Node,
> ""));
> +    }
>
> I'd make that
> } else if (!PickTrueBranch) {
>   // If we want to use the 'else'-branch, but it doesn't exist, delete
> the whole 'if'.
>

Done.

+void run(const std::string &Code,
>
> I'd call that expectRewritten or something similar.
>

Done.

New patch attached.

Cheers,
Daniel


> Cheers,
> /Manuel
>
> >
> >
> > On Fri, Jul 13, 2012 at 5:07 PM, Daniel Jasper <djasper at google.com>
> wrote:
> >>
> >> :-D. Will change before submitting ...
> >>
> >>
> >> On Fri, Jul 13, 2012 at 4:34 PM, Jean-Daniel Dupas
> >> <devlists at shadowlab.org> wrote:
> >>>
> >>>
> >>> +//
> >>> +//  This will replace all integer literals with "2".
> >>> +//
> >>>
> >>> Isn't the universal answer 42 instead of 2 ? ;-)
> >>>
> >>> Le 13 juil. 2012 à 16:22, Daniel Jasper <djasper at google.com> a écrit :
> >>>
> >>> > With these callbacks, simple refactorings should be quite easy. It
> is a
> >>> > starting point and can be extended/improved in many ways.
> >>> >
> <refactoring-callbacks.patch>_______________________________________________
> >>> > cfe-commits mailing list
> >>> > cfe-commits at cs.uiuc.edu
> >>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> >>>
> >>> -- Jean-Daniel
> >>>
> >>>
> >>>
> >>>
> >>
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120716/7a1ac577/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: refactoring-callbacks.patch
Type: application/octet-stream
Size: 12535 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120716/7a1ac577/attachment.obj>


More information about the cfe-commits mailing list