From a76d1c211b24853b6abb16673b34861bc2b2544e Mon Sep 17 00:00:00 2001 From: Ashwin Lele Date: Wed, 17 Jul 2019 14:40:58 -0700 Subject: [PATCH] Fix bug in printing trailing comma when dumping AST for a structure. --- Test/baseResults/310.vert.out | 8 ++++---- Test/baseResults/320.vert.out | 12 ++++++------ Test/baseResults/330.frag.out | 6 +++--- Test/baseResults/410.geom.out | 8 ++++---- Test/baseResults/420.vert.out | 4 ++-- Test/baseResults/430.vert.out | 6 +++--- Test/baseResults/440.vert.out | 4 ++-- glslang/Include/Types.h | 6 ++++-- 8 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Test/baseResults/310.vert.out b/Test/baseResults/310.vert.out index baf0987..a910e34 100644 --- a/Test/baseResults/310.vert.out +++ b/Test/baseResults/310.vert.out @@ -269,7 +269,7 @@ ERROR: node is still EOpNull! 0:117 'gl_InstanceID' ( gl_InstanceId highp int InstanceId) 0:118 move second child to first child ( temp highp 4-component vector of float) 0:118 gl_Position: direct index for structure ( gl_Position highp 4-component vector of float Position) -0:118 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position, }) +0:118 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position}) 0:118 Constant: 0:118 0 (const uint) 0:118 Constant: @@ -278,7 +278,7 @@ ERROR: node is still EOpNull! 0:118 1.000000 0:118 1.000000 0:119 gl_PointSize: direct index for structure ( gl_PointSize highp void PointSize) -0:119 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position, }) +0:119 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position}) 0:119 Constant: 0:119 1 (const uint) 0:153 Function Definition: pfooBad( ( global void) @@ -940,7 +940,7 @@ ERROR: node is still EOpNull! 0:? 'anon@0' ( out block{layout( location=12) out highp int aAnon, layout( location=13) out highp 4-component vector of float vAnon}) 0:? 'aliased' (layout( location=12) smooth out highp int) 0:? 'inbinst' ( in block{ in highp int a}) -0:? 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position, }) +0:? 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position}) 0:? 'smon' ( smooth out block{ out highp int i}) 0:? 'fmon' ( flat out block{ out highp int i}) 0:? 'cmon' ( centroid out block{ out highp int i}) @@ -1184,7 +1184,7 @@ ERROR: node is still EOpNull! 0:? 'anon@0' ( out block{layout( location=12) out highp int aAnon, layout( location=13) out highp 4-component vector of float vAnon}) 0:? 'aliased' (layout( location=12) smooth out highp int) 0:? 'inbinst' ( in block{ in highp int a}) -0:? 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position, }) +0:? 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position}) 0:? 'smon' ( smooth out block{ out highp int i}) 0:? 'fmon' ( flat out block{ out highp int i}) 0:? 'cmon' ( centroid out block{ out highp int i}) diff --git a/Test/baseResults/320.vert.out b/Test/baseResults/320.vert.out index 2838ab8..bf127d4 100644 --- a/Test/baseResults/320.vert.out +++ b/Test/baseResults/320.vert.out @@ -49,7 +49,7 @@ ERROR: node is still EOpNull! 0:26 'gl_InstanceID' ( gl_InstanceId highp int InstanceId) 0:27 move second child to first child ( temp highp 4-component vector of float) 0:27 gl_Position: direct index for structure ( gl_Position highp 4-component vector of float Position) -0:27 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position, }) +0:27 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position}) 0:27 Constant: 0:27 0 (const uint) 0:27 Constant: @@ -58,7 +58,7 @@ ERROR: node is still EOpNull! 0:27 1.000000 0:27 1.000000 0:28 gl_PointSize: direct index for structure ( gl_PointSize highp void PointSize) -0:28 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position, }) +0:28 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position}) 0:28 Constant: 0:28 1 (const uint) 0:62 Function Definition: pfoo( ( global void) @@ -623,7 +623,7 @@ ERROR: node is still EOpNull! 0:? 'anon@0' ( out block{layout( location=12) out highp int aAnon, layout( location=13) out highp 4-component vector of float vAnon}) 0:? 'aliased' (layout( location=12) smooth out highp int) 0:? 'inbinst' ( in block{ in highp int a}) -0:? 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position, }) +0:? 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position}) 0:? 'smon' ( smooth out block{ out highp int i}) 0:? 'fmon' ( flat out block{ out highp int i}) 0:? 'cmon' ( centroid out block{ out highp int i}) @@ -709,7 +709,7 @@ ERROR: node is still EOpNull! 0:26 'gl_InstanceID' ( gl_InstanceId highp int InstanceId) 0:27 move second child to first child ( temp highp 4-component vector of float) 0:27 gl_Position: direct index for structure ( gl_Position highp 4-component vector of float Position) -0:27 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position, }) +0:27 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position}) 0:27 Constant: 0:27 0 (const uint) 0:27 Constant: @@ -718,7 +718,7 @@ ERROR: node is still EOpNull! 0:27 1.000000 0:27 1.000000 0:28 gl_PointSize: direct index for structure ( gl_PointSize highp void PointSize) -0:28 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position, }) +0:28 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position}) 0:28 Constant: 0:28 1 (const uint) 0:? Linker Objects @@ -726,7 +726,7 @@ ERROR: node is still EOpNull! 0:? 'anon@0' ( out block{layout( location=12) out highp int aAnon, layout( location=13) out highp 4-component vector of float vAnon}) 0:? 'aliased' (layout( location=12) smooth out highp int) 0:? 'inbinst' ( in block{ in highp int a}) -0:? 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position, }) +0:? 'anon@1' ( out block{ gl_Position highp 4-component vector of float Position gl_Position}) 0:? 'smon' ( smooth out block{ out highp int i}) 0:? 'fmon' ( flat out block{ out highp int i}) 0:? 'cmon' ( centroid out block{ out highp int i}) diff --git a/Test/baseResults/330.frag.out b/Test/baseResults/330.frag.out index 7745631..36ba7a2 100644 --- a/Test/baseResults/330.frag.out +++ b/Test/baseResults/330.frag.out @@ -71,7 +71,7 @@ ERROR: node is still EOpNull! 0:23 move second child to first child ( temp 4-component vector of float) 0:23 'c' ( temp 4-component vector of float) 0:23 gl_Color: direct index for structure ( in 4-component vector of float Color) -0:23 'anon@0' ( in block{ in 4-component vector of float Color gl_Color, }) +0:23 'anon@0' ( in block{ in 4-component vector of float Color gl_Color}) 0:23 Constant: 0:23 2 (const uint) 0:24 move second child to first child ( temp 4-component vector of float) @@ -93,7 +93,7 @@ ERROR: node is still EOpNull! 0:? 'inVar' ( smooth in 4-component vector of float) 0:? 'outVar' (layout( location=0 index=0) out 4-component vector of float) 0:? 'varyingVar' ( smooth in 4-component vector of float) -0:? 'anon@0' ( in block{ in 4-component vector of float Color gl_Color, }) +0:? 'anon@0' ( in block{ in 4-component vector of float Color gl_Color}) 0:? 'gl_name' ( in block{ in int gl_i}) 0:? 'start' ( const int) 0:? 6 (const int) @@ -158,7 +158,7 @@ ERROR: node is still EOpNull! 0:? 'inVar' ( smooth in 4-component vector of float) 0:? 'outVar' (layout( location=0 index=0) out 4-component vector of float) 0:? 'varyingVar' ( smooth in 4-component vector of float) -0:? 'anon@0' ( in block{ in 4-component vector of float Color gl_Color, }) +0:? 'anon@0' ( in block{ in 4-component vector of float Color gl_Color}) 0:? 'gl_name' ( in block{ in int gl_i}) 0:? 'start' ( const int) 0:? 6 (const int) diff --git a/Test/baseResults/410.geom.out b/Test/baseResults/410.geom.out index ab5ad47..c38ba48 100644 --- a/Test/baseResults/410.geom.out +++ b/Test/baseResults/410.geom.out @@ -38,12 +38,12 @@ ERROR: node is still EOpNull! 0:30 0 (const int) 0:31 move second child to first child ( temp float) 0:31 gl_PointSize: direct index for structure (layout( stream=0) gl_PointSize float PointSize) -0:31 'anon@0' (layout( stream=0) out block{layout( stream=0) gl_PointSize float PointSize gl_PointSize, }) +0:31 'anon@0' (layout( stream=0) out block{layout( stream=0) gl_PointSize float PointSize gl_PointSize}) 0:31 Constant: 0:31 1 (const uint) 0:31 'p' ( temp float) 0:33 gl_Position: direct index for structure (layout( stream=0) gl_Position void Position) -0:33 'anon@0' (layout( stream=0) out block{layout( stream=0) gl_PointSize float PointSize gl_PointSize, }) +0:33 'anon@0' (layout( stream=0) out block{layout( stream=0) gl_PointSize float PointSize gl_PointSize}) 0:33 Constant: 0:33 0 (const uint) 0:36 Function Definition: foo5( ( global float) @@ -54,7 +54,7 @@ ERROR: node is still EOpNull! 0:38 4.000000 0:? Linker Objects 0:? 'gl_in' ( in unsized 2-element array of block{ in float PointSize gl_PointSize}) -0:? 'anon@0' (layout( stream=0) out block{layout( stream=0) gl_PointSize float PointSize gl_PointSize, }) +0:? 'anon@0' (layout( stream=0) out block{layout( stream=0) gl_PointSize float PointSize gl_PointSize}) Linked geometry stage: @@ -78,5 +78,5 @@ ERROR: node is still EOpNull! 0:5 7 (const int) 0:? Linker Objects 0:? 'gl_in' ( in 2-element array of block{ in float PointSize gl_PointSize}) -0:? 'anon@0' (layout( stream=0) out block{layout( stream=0) gl_PointSize float PointSize gl_PointSize, }) +0:? 'anon@0' (layout( stream=0) out block{layout( stream=0) gl_PointSize float PointSize gl_PointSize}) diff --git a/Test/baseResults/420.vert.out b/Test/baseResults/420.vert.out index c572d97..3d49327 100644 --- a/Test/baseResults/420.vert.out +++ b/Test/baseResults/420.vert.out @@ -281,7 +281,7 @@ ERROR: node is still EOpNull! 0:? 'sampb3' (layout( binding=80) uniform sampler2D) 0:? 'sampb4' (layout( binding=31) uniform sampler2D) 0:? 'sampb5' (layout( binding=79) uniform 2-element array of sampler2D) -0:? 'anon@3' ( out block{ out 4-element array of float ClipDistance gl_ClipDistance, }) +0:? 'anon@3' ( out block{ out 4-element array of float ClipDistance gl_ClipDistance}) 0:? 'patchIn' ( patch in 4-component vector of float) 0:? 'patchOut' ( smooth patch out 4-component vector of float) 0:? 'comma0' ( temp int) @@ -363,7 +363,7 @@ ERROR: node is still EOpNull! 0:? 'sampb3' (layout( binding=80) uniform sampler2D) 0:? 'sampb4' (layout( binding=31) uniform sampler2D) 0:? 'sampb5' (layout( binding=79) uniform 2-element array of sampler2D) -0:? 'anon@3' ( out block{ out 4-element array of float ClipDistance gl_ClipDistance, }) +0:? 'anon@3' ( out block{ out 4-element array of float ClipDistance gl_ClipDistance}) 0:? 'patchIn' ( patch in 4-component vector of float) 0:? 'patchOut' ( smooth patch out 4-component vector of float) 0:? 'comma0' ( temp int) diff --git a/Test/baseResults/430.vert.out b/Test/baseResults/430.vert.out index d741d35..4bac5fc 100644 --- a/Test/baseResults/430.vert.out +++ b/Test/baseResults/430.vert.out @@ -78,7 +78,7 @@ ERROR: node is still EOpNull! 0:16 move second child to first child ( temp float) 0:16 direct index ( temp float ClipDistance) 0:16 gl_ClipDistance: direct index for structure ( out 17-element array of float ClipDistance) -0:16 'anon@0' ( out block{ out 17-element array of float ClipDistance gl_ClipDistance, }) +0:16 'anon@0' ( out block{ out 17-element array of float ClipDistance gl_ClipDistance}) 0:16 Constant: 0:16 2 (const uint) 0:16 Constant: @@ -206,7 +206,7 @@ ERROR: node is still EOpNull! 0:? 'uv4' (layout( location=4) uniform 4-component vector of float) 0:? 'b1' (layout( location=2) in block{ in 4-component vector of float v}) 0:? 'b2' (layout( location=2) out block{ out 4-component vector of float v}) -0:? 'anon@0' ( out block{ out 17-element array of float ClipDistance gl_ClipDistance, }) +0:? 'anon@0' ( out block{ out 17-element array of float ClipDistance gl_ClipDistance}) 0:? 'cs' (layout( location=10) smooth out 2-element array of structure{ global 7-element array of 3X2 matrix of float m, global float f}) 0:? 'cf' (layout( location=54) smooth out float) 0:? 'cg' (layout( location=53) smooth out float) @@ -281,7 +281,7 @@ ERROR: node is still EOpNull! 0:? 'uv4' (layout( location=4) uniform 4-component vector of float) 0:? 'b1' (layout( location=2) in block{ in 4-component vector of float v}) 0:? 'b2' (layout( location=2) out block{ out 4-component vector of float v}) -0:? 'anon@0' ( out block{ out 17-element array of float ClipDistance gl_ClipDistance, }) +0:? 'anon@0' ( out block{ out 17-element array of float ClipDistance gl_ClipDistance}) 0:? 'cs' (layout( location=10) smooth out 2-element array of structure{ global 7-element array of 3X2 matrix of float m, global float f}) 0:? 'cf' (layout( location=54) smooth out float) 0:? 'cg' (layout( location=53) smooth out float) diff --git a/Test/baseResults/440.vert.out b/Test/baseResults/440.vert.out index 5af757a..6c975c0 100644 --- a/Test/baseResults/440.vert.out +++ b/Test/baseResults/440.vert.out @@ -156,7 +156,7 @@ ERROR: node is still EOpNull! 0:? 'bbinst9' ( out block{layout( xfb_buffer=4 xfb_offset=1) out bool b, layout( xfb_buffer=4 xfb_offset=12) out structure{ global bool b, global structure{ global int i, global double d, global float f} s, global 2-component vector of float v2} t, layout( xfb_buffer=4 xfb_offset=52) out 3X3 matrix of float m3, layout( xfb_buffer=4 xfb_offset=90) out int i, layout( xfb_buffer=4 xfb_offset=98) out double d, layout( xfb_buffer=4 xfb_offset=108) out structure{ global int a} s}) 0:? 'bm' (layout( xfb_buffer=5 xfb_offset=0) smooth out float) 0:? 'bbinst10' ( out block{layout( xfb_buffer=7 xfb_offset=0) out 4X4 matrix of double m1, layout( xfb_buffer=7 xfb_offset=128) out 4X4 matrix of double m2, layout( xfb_buffer=7 xfb_offset=256) out float f}) -0:? 'anon@0' ( out block{layout( xfb_buffer=3 xfb_offset=36) gl_Position 4-component vector of float Position gl_Position, layout( xfb_buffer=3 xfb_offset=32) gl_PointSize float PointSize gl_PointSize, }) +0:? 'anon@0' ( out block{layout( xfb_buffer=3 xfb_offset=36) gl_Position 4-component vector of float Position gl_Position, layout( xfb_buffer=3 xfb_offset=32) gl_PointSize float PointSize gl_PointSize}) 0:? 'gl_VertexID' ( gl_VertexId int VertexId) 0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId) @@ -241,7 +241,7 @@ ERROR: node is still EOpNull! 0:? 'bbinst9' ( out block{layout( xfb_buffer=4 xfb_offset=1) out bool b, layout( xfb_buffer=4 xfb_offset=12) out structure{ global bool b, global structure{ global int i, global double d, global float f} s, global 2-component vector of float v2} t, layout( xfb_buffer=4 xfb_offset=52) out 3X3 matrix of float m3, layout( xfb_buffer=4 xfb_offset=90) out int i, layout( xfb_buffer=4 xfb_offset=98) out double d, layout( xfb_buffer=4 xfb_offset=108) out structure{ global int a} s}) 0:? 'bm' (layout( xfb_buffer=5 xfb_offset=0) smooth out float) 0:? 'bbinst10' ( out block{layout( xfb_buffer=7 xfb_offset=0) out 4X4 matrix of double m1, layout( xfb_buffer=7 xfb_offset=128) out 4X4 matrix of double m2, layout( xfb_buffer=7 xfb_offset=256) out float f}) -0:? 'anon@0' ( out block{layout( xfb_buffer=3 xfb_offset=36) gl_Position 4-component vector of float Position gl_Position, layout( xfb_buffer=3 xfb_offset=32) gl_PointSize float PointSize gl_PointSize, }) +0:? 'anon@0' ( out block{layout( xfb_buffer=3 xfb_offset=36) gl_Position 4-component vector of float Position gl_Position, layout( xfb_buffer=3 xfb_offset=32) gl_PointSize float PointSize gl_PointSize}) 0:? 'gl_VertexID' ( gl_VertexId int VertexId) 0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId) diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index 989c34a..dbc2877 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -2050,13 +2050,15 @@ public: // Add struct/block members if (isStruct() && structure) { appendStr("{"); + bool hasHiddenMember = true; for (size_t i = 0; i < structure->size(); ++i) { if (! (*structure)[i].type->hiddenMember()) { + if (!hasHiddenMember) + appendStr(", "); typeString.append((*structure)[i].type->getCompleteString()); typeString.append(" "); typeString.append((*structure)[i].type->getFieldName()); - if (i < structure->size() - 1) - appendStr(", "); + hasHiddenMember = false; } } appendStr("}"); -- 2.7.4