[cfe-dev] Tests and include paths

John Thompson john.thompson.jtsoftware at gmail.com
Thu Aug 13 19:03:17 PDT 2009


I've been looking into the problem with using grep with search strings
with double-quotes.

I wrote a little C program that just prints out its arguments, so I
could see what grep was possibly seeing (though it's argument parsing
internally might be different, being an MSYS program).

>From mangle.c, the script is given as:

RUN: dsparg '@"\\01foo"' %t

In the test report output:

Command 3: "c:\tools\bin\dsparg.EXE" "@"\\01foo""
"C:\Tools\llvm\tools\clang\test\Output\CodeGen\mangle.c.tmp"
Command 3 Result: 1
Command 3 Output:
argc = 3
argv[0] = [c:\tools\bin\dsparg.EXE]
argv[1] = [@"\\01foo"]
argv[2] = [C:\Tools\llvm\tools\clang\test\Output\CodeGen\mangle.c.tmp]

So, it appears that the search string is getting to the program, but
without the single quotes.

I tried running grep directly from the Windows command line, and this
is the only thing that worked:

C:\Tools\llvm\tools\clang\test\Output\CodeGen>grep '@"\\\\01foo"' mangle.c.tmp
@"\01foo" = common global i32 0, align 4                ; <i32*> [#uses=2]
        %tmp = load i32* @"\01foo"              ; <i32> [#uses=1]
        %tmp1 = load float* bitcast (i32* @"\01foo" to float*)
 ; <float> [#uses=1]

The grep program (coming from MSYS) appears to be confused by the
embedded quotes, so I'm not sure how to best deal with this.  Some
possibilities:

1. Find a different grep that will work.
2. Write or hack a specialized grep to use in the problematic places.
3. Make the Python script do the grep.
4. Limit the search string to avoid the double-quotes or other
problematic characters.  (I.e. look for just \\01foo in the above
case).
5. Change the test case to avoid having to search for problematic
things.  (Probably not an option here, since that format seems common
in the LLVM code.)
6. Switch to a test mechanism that just compares the output file to a
reference file.

-John

-- 
John Thompson
John.Thompson.JTSoftware at gmail.com



More information about the cfe-dev mailing list