On Tue, Oct 2, 2012 at 7:22 PM, Alexander Kornienko <[email protected]> wrote:
> Let's put it this way: having a way to use "previous line" or "current line
> + offset" variable in FileCheck, and having a better FileCheck performance
> in debug mode, what would you prefer?
>
> TEST(StmtDumper, TestDeclStmt) {
>   ASSERT_TRUE(DumpedStmtCXX98Matches(
>     "void A() {\n"
>     "  int a = 1, b;\n"
>     "}",
>     "A",
>     "(DeclStmt 0xXXXXXXXX <input.cc:2:3, col:15>\n"
>     "  (VarDecl 0xXXXXXXXX <col:3, col:11> a 'int'\n"
>     "    (IntegerLiteral 0xXXXXXXXX <col:11> 'int' 1))\n"
>     "  (VarDecl 0xXXXXXXXX <col:3, col:14> b 'int'))\n"));
> }
>
> or
>
> // RUN: clang_cc1 -ast-dump --std=c++98 -DTEST33 %s | FileCheck
> --strict-whitespace --check-prefix CHECK33 %s
> #ifdef TEST33
> void A() {
> // CHECK33: {{^}}(DeclStmt 0x{{........}} <input.cc:[[__LINE_MINUS_1__]]:3,
> col:15>
>   int a = 1, b;
> // CHECK33-NEXT: {{^  }}(VarDecl 0x{{........}} <col:3, col:11> a 'int'{{$}}
> // CHECK33-NEXT: {{^    }}(IntegerLiteral 0x{{........}} <col:11> 'int'
> 1)){{$}}
> // CHECK33-NEXT: {{^  }}(VarDecl 0x{{........}} <col:3, col:14> b
> 'int')){{$}}
> }
> #endif

I would prefer the first one and here's why:

1. Obviously, it is smaller (less text), thus easier to parse.
2. In FileCheck one has to do all this escaping and regex dances for
every line.  In the first approach, it can be abstracted away.
3. (a general FileCheck weakness) CHECKXX prefixes should be matched
between RUN lines and CHECK lines.  It is not a big issue if the file
has a few different CHECKXX prefixes, but it starts to matter if we
introduce this kind of isolation into tests and will have lots of
different prefixes.

Anyway, with line number issue solved, I would be comfortable with
tests of the second kind.  (And I would definitely change
annotate-comments.cpp to use this feature!)

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <[email protected]>*/
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to