[Mesa-dev] [PATCH] glsl: Pass ast_type_qualifier by const reference.

Matt Turner mattst88 at gmail.com
Tue Nov 24 09:51:53 PST 2015


On Tue, Nov 24, 2015 at 2:34 AM, Iago Toral <itoral at igalia.com> wrote:
> On Mon, 2015-11-23 at 18:08 -0800, Matt Turner wrote:
>> Coverity noticed that we were passing this by value, and it's 152 bytes.
>> ---
>>  src/glsl/ast.h                  | 10 +++++-----
>>  src/glsl/ast_type.cpp           |  6 +++---
>>  src/glsl/glsl_parser_extras.cpp |  2 +-
>>  3 files changed, 9 insertions(+), 9 deletions(-)
>>
>> diff --git a/src/glsl/ast.h b/src/glsl/ast.h
>> index 3bea63e..adfc793 100644
>> --- a/src/glsl/ast.h
>> +++ b/src/glsl/ast.h
>> @@ -699,16 +699,16 @@ struct ast_type_qualifier {
>>
>>     bool merge_qualifier(YYLTYPE *loc,
>>                       _mesa_glsl_parse_state *state,
>> -                     ast_type_qualifier q);
>> +                     const ast_type_qualifier &q);
>>
>>     bool merge_out_qualifier(YYLTYPE *loc,
>>                             _mesa_glsl_parse_state *state,
>> -                           ast_type_qualifier q,
>> +                           const ast_type_qualifier &q,
>>                             ast_node* &node);
>>
>>     bool merge_in_qualifier(YYLTYPE *loc,
>>                             _mesa_glsl_parse_state *state,
>> -                           ast_type_qualifier q,
>> +                           const ast_type_qualifier &q,
>>                             ast_node* &node);
>>
>>     ast_subroutine_list *subroutine_list;
>> @@ -1152,7 +1152,7 @@ class ast_cs_input_layout : public ast_node
>>  {
>>  public:
>>     ast_cs_input_layout(const struct YYLTYPE &locp,
>> -                       ast_layout_expression **local_size)
>> +                       ast_layout_expression *const *local_size)
>
> I think this change does not belong in this patch. Otherwise:
>
> Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>

Actually, it does. ast_cs_input_layout() is called by
ast_type_qualifier::merge_in_qualifier() (one of the modified
functions) and is passed q.local_size as the second argument. Without
adding const, it fails to compile with

ast_type.cpp: In member function ‘bool
ast_type_qualifier::merge_in_qualifier(YYLTYPE*,
_mesa_glsl_parse_state*, const ast_type_qualifier&, ast_node*&)’:
ast_type.cpp:456:65: error: invalid conversion from
‘ast_layout_expression* const*’ to ‘ast_layout_expression**’
[-fpermissive]
       node = new(mem_ctx) ast_cs_input_layout(*loc, q.local_size);
                                                                 ^
In file included from ast_type.cpp:24:0:
ast.h:1154:4: note: initializing argument 2 of
‘ast_cs_input_layout::ast_cs_input_layout(const YYLTYPE&,
ast_layout_expression**)’
    ast_cs_input_layout(const struct YYLTYPE &locp,


More information about the mesa-dev mailing list