[clang-tools-extra] r245683 - Tweak clang-tidy-diff.py to recognize "filename" in the diff ourput.

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 1 13:22:11 PDT 2015


Thank you for the update!
On 1 Sep 2015 21:10, "Yaron Keren" <yaron.keren at gmail.com> wrote:

> Hi,
>
> In the other thread (search for ... 0ca9a2b from bartek-w) he provided a
> regex with two more changes beyond adding \n.
> Here are all three regexes:
>
> pre-r245683
>  match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
> r245683
>  match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\"]*)' % args.p, line)
> bartek-w
>  match = re.search('^+++\ \"?(.?/){%s}([^ \t\"\n])' % args.p, line)
>
> in bartek-w version, + are not escaped which I do not understand why as +
> is a special character in Python regex (see
> https://docs.python.org/2/library/re.html) and  and the star after [^
> \t\"\n] is missing.
> Not wishing to break any working code I asked for the broken diff example
> to test against before comitting and so far didn't get a reply.
>
> Anyhow, adding the \n is safe and I've commited it now on r246575 but I'm
> still not clear about the other two regex changes.
> I'll update the bug report accordingly.
>
> Yaron
>
>
>
> 2015-09-01 18:52 GMT+03:00 Alexander Kornienko <alexfh at google.com>:
> >
> > Looks like this patch broke handling of multiple files:
> https://llvm.org/PR24637
> >
> > Can you take a look at this?
> >
> > On Fri, Aug 21, 2015 at 12:56 PM, Yaron Keren <yaron.keren at gmail.com>
> wrote:
> >>
> >> Whenever is any special character in the filename, such as space or
> backslash (Windows), some examples:
> >>
> >> On Windows:
> >> --- ".\\a.cpp"  2015-08-21 00:22:57.885370200 +0300
> >> +++ b.cpp       2015-08-21 01:05:28.726269900 +0300
> >>
> >> --- ./a.cpp     2015-08-21 00:22:57.885370200 +0300
> >> +++ b.cpp       2015-08-21 01:05:28.726269900 +0300
> >>
> >> --- "a a.cpp"   2015-08-21 00:22:57.885370200 +0300
> >> +++ b.cpp       2015-08-21 01:05:28.726269900 +0300
> >>
> >> On Linux:
> >> ~$ diff -U0 ./a.cpp b\ b.cpp
> >> --- ./a.cpp     2015-08-14 00:27:03.569276652 +0300
> >> +++ "b b.cpp"   2015-08-21 13:54:26.787896719 +0300
> >>
> >> filename with space will break current clang-tidy-diff.py on all
> platforms, the regular expression does not match quotes.
> >> There is surely some Python package to process filenames correctly if
> this ever become a problem.
> >>
> >>
> >> 2015-08-21 13:37 GMT+03:00 Alexander Kornienko <alexfh at google.com>:
> >>>
> >>> On Fri, Aug 21, 2015 at 11:27 AM, Yaron Keren via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
> >>>>
> >>>> Author: yrnkrn
> >>>> Date: Fri Aug 21 04:27:24 2015
> >>>> New Revision: 245683
> >>>>
> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=245683&view=rev
> >>>> Log:
> >>>> Tweak clang-tidy-diff.py to recognize "filename" in the diff ourput
> >>>
> >>>
> >>> Out of curiosity, when does this happen? (I mean quotes around the
> file name)
> >>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> Modified:
> >>>>     clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
> >>>>
> >>>> Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
> >>>> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py?rev=245683&r1=245682&r2=245683&view=diff
> >>>>
> ==============================================================================
> >>>> --- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
> (original)
> >>>> +++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Fri
> Aug 21 04:27:24 2015
> >>>> @@ -67,7 +67,7 @@ def main():
> >>>>    filename = None
> >>>>    lines_by_file = {}
> >>>>    for line in sys.stdin:
> >>>> -    match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
> >>>> +    match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\"]*)' % args.p,
> line)
> >>>>      if match:
> >>>>        filename = match.group(2)
> >>>>      if filename == None:
> >>>>
> >>>>
> >>>> _______________________________________________
> >>>> cfe-commits mailing list
> >>>> cfe-commits at lists.llvm.org
> >>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >>>
> >>>
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150901/4beb1f66/attachment.html>


More information about the cfe-commits mailing list