[llvm-commits] [llvm] r126963 - in /llvm/trunk: lib/MC/ test/CodeGen/ARM/ test/CodeGen/Blackfin/ test/CodeGen/CellSPU/ test/CodeGen/Mips/ test/CodeGen/PowerPC/ test/CodeGen/X86/ test/CodeGen/XCore/ test/MC/ELF/

Joerg Sonnenberger joerg at britannica.bec.de
Fri Mar 4 09:48:43 PST 2011


On Fri, Mar 04, 2011 at 11:20:50AM -0500, Rafael Avila de Espindola wrote:
> *) Add a flag SuuportsQuotes and only quote if it is true. We would 
> still need to reject files that would require us to quote, so it dosn't 
> look like a big win from having the extra flag.

Agreed, which is why I was asking what the assembler does in that case.

> > (b) What is considered a "safe" subset for use without quoting.
> 
> I would suggest turning the loop you wrote in a needsQuote predicate:
> 
> +  for (const char *b = name.begin(), *e = name.end(); b<  e; ++b) {
>  > +    if (*b == '"') // Unquoted "
>  > +      OS<<  "\\\"";
>  > +    else if (*b != '\\') // Neither " or backslash
>  > +      OS<<  *b;
>  > +    else if (b + 1 == e) // Trailing backslash
>  > +      OS<<  "\\\\";
>  > +    else {
>  > +      OS<<  b[0]<<  b[1]; // Quoted character
>  > +      ++b;
>  > +    }
> 
> So it looks like a reasonable needsQuote would be
> 
> * has an unquoted "
> * has a trailing backslash
> * has a quoted character

Not good enough. The loop just handles whatever needs special attention.
Consider "foo bar", "foo,bar" etc for trivial examples that need
quoting. A-Za-z0-9._- would be a base subset, not sure if anything else
is needed.

Joerg



More information about the llvm-commits mailing list