[cfe-dev] [PATCH] add regex/globbing to -verify diagnostics

Chris Lattner clattner at apple.com
Mon Apr 26 14:41:19 PDT 2010


On Apr 25, 2010, at 10:36 PM, mike-m wrote:
> Patch update uses suggested '-re' and '-glob' syntax, patch attached.
> 
> - lit tests pass with clang-debug, clang-release and selfclang-debug builds
> - no measurable performance impact on lit tests

I also prefer the "-re" suffix, thanks for doing that.

This is really cool, but I think it's a bit overkill.  I'd rather not support glob at all, it adds a bunch of complexity for no added advantage.

You converted some loops like this:

-    std::string Msg(CommentStart, ExpectedEnd);
-    std::string::size_type FindPos;
-    while ((FindPos = Msg.find("\\n")) != std::string::npos)
-      Msg.replace(FindPos, 2, "\n");
-    // Add is possibly multiple times.
-    for (int i = 0; i < Times; ++i)
-      ExpectedDiags.push_back(std::make_pair(Pos, Msg));

to explicit for loops with switches in them.  If you're going to change them, please convert them to using the StringRef API and its algorithms.

It looks like using an invalid regex in an directive line will cause an assertion, pleasem ake it be an error from -verify mode.

Thanks for working on this!

-Chris

> 
> ***Changes from last patch:
> 
> - updated syntax to use suffixes { -re | -glob } for regex and globbing, respectively
> - added glob sequence support: first element ']' treated as literal
> - reworked verify-string parser to be more resilient to errors
> - added lit test/Misc/verify.c
> 
> ***Examples matching error: "variable has incomplete type 'struct s'"
> 
> // expected-error {{variable has incomplete type 'struct s'}}
> // expected-error {{variable has incomplete type}}
> 
> // expected-error-re {{variable has has type 'struct .'}}
> // expected-error-re {{variable has has type 'struct .*'}}
> // expected-error-re {{variable has has type 'struct (.*)'}}
> // expected-error-re {{variable has has type 'struct[[:space:]](.*)'}}
> 
> // expected-error-glob {{variable has incomplete type 'struct ?'}}
> // expected-error-glob {{variable has incomplete type 'struct [stuv]'}}
> // expected-error-glob {{variable has incomplete type 'struct [!abcd]'}}
> // expected-error-glob {{variable has incomplete type 'struct *'}}
> 
> --mike-m
> 
> On 2010-04-25, at 1:11 PM, Justin Bogner wrote:
>> 
>> The expected-error, expected~error, and expected*error are so similar as
>> to be confusing. Why not simply have expected-error, expected-error-re,
>> and expected-error-glob? It's only a few extra characters, and much more
>> noticeable.
> 
> <verify.regex1.patch>_______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev





More information about the cfe-dev mailing list