[LLVMdev] tblgen: Assertion failed: "Buffer[Length-1] == '"'", file FileLexer.l, line 114

Misha Brukman
2004-08-18T23:11:49Z

On Thu, Aug 19, 2004 at 01:04:55AM +0200, Henrik Bach
wrote:
> I've been investigating which characters that cause troubles:
>
> Length = 23
> WhatsInBuffer=include "../Target.td"
> assert=false
> tblgen: Assertion failed: "Buffer[Length-1] == '"'",
file FileLexer.l, line
> 128
> idx	hex	char
> 0	69	i
> 1	6E	n
> 2	63	c
> 3	6C	l
> 4	75	u
> 5	64	d
> 6	65	e
> 7	20
> 8	22	"
> 9	2E	.
> 10	2E	.
> 11	2F	/
> 12	54	T
> 13	61	a
> 14	72	r
> 15	67	g
> 16	65	e
> 17	74	t
> 18	2E	.
> 19	74	t
> 20	64	d
> 21	22	"
> 22	D
>
> I can't see what's wrong here... Other than the " character at
the end
> of the include statement, which the assertion is complaining about.

What's wrong is the 'D' hex character at the end of the include line
becoming part of the parsed string.  'D' is \013 which is carriage
return.  It is whitespace and shouldn't be in the parsed string.

Since Length = 23, it expects Buffer[22] == ", but instead it's \013.
That's an error, because Length should really be 22, and Buffer[21]
really is the character ".

So, the lexer is confused about what your whitespace is.  However,
llvm/utils/TableGen/FileLexer.l includes the following line:

[ \t\n\r]+     { /* Ignore whitespace */ }

which covers carriage returns (\r), so I am not sure *HOW* Length is set
to 23, but it *IS* the problem.  Unfortunately, we do not have access to
Interix to replicate this problem.

--
Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu