getSourceRange() for InitListExpr

Hi,

I’m getting some strange behaviour, when I’m trying to get source range for vector initalizations.

I have two different variable declarations:

__constant float4 base_factor = (float4)(1.0f,2.0f,3.0f,4.0f);
__constant float base_table = { 1.0f,2.0f,3.0f,4.0f };

whose corresponding initializers are:

(InitListExpr 0x7f8a9bcd3cf0 ‘float4’:‘float attribute((ext_vector_type(4)))’
(FloatingLiteral 0x7f8a9bcd3c18 ‘float’ 1.000000e+00)
(FloatingLiteral 0x7f8a9bcd3c38 ‘float’ 2.000000e+00)
(FloatingLiteral 0x7f8a9bcd3c58 ‘float’ 3.000000e+00)
(FloatingLiteral 0x7f8a9bcd3c78 ‘float’ 4.000000e+00))

and:

(InitListExpr 0x7fb470cd3fe8 ‘__constant float [4]’
(FloatingLiteral 0x7fb470cd3f08 ‘float’ 1.000000e+00)
(FloatingLiteral 0x7fb470cd3f28 ‘float’ 2.000000e+00)
(FloatingLiteral 0x7fb470cd3f48 ‘float’ 3.000000e+00)
(FloatingLiteral 0x7fb470cd3f68 ‘float’ 4.000000e+00))

However when I’m trying to get them as string from rewriter with getRewrittenText(init->getSourceRange())

I get:

(float4)

and

{ 1,2,3,4 }

So it seems that InitListExpr does not handle vector type initializations correctly. Or what am I doing wrong here?

Thanks, Mikael Lepistö