glsl: Use 'using' to be explicit about visitor overloads
authorKristian H. Kristensen <hoegsberg@google.com>
Mon, 3 Feb 2020 20:43:19 +0000 (12:43 -0800)
committerMarge Bot <eric+marge@anholt.net>
Tue, 4 Feb 2020 06:03:52 +0000 (06:03 +0000)
Clang has a warning about overloading virtuals that triggers when a
derived class defines a virtual function that's an overload of
function in the base class.  This kind of thing:

  struct chart; // let's pretend this exists
  struct Base
  {
      virtual void* get(char* e);
  };

  struct Derived: public Base {
      virtual void* get(chart* e); // typo, we wanted to override the same function
  };

The solution is to use

  using Base::get;

to be explicit about the intention to reuse the base class virtual.
We hit this a lot with out glsl ir_hierarchical_visitor visitor
pattern, so let's adds some 'using' to calm down the compiler.

See-also: https://stackoverflow.com/questions/18515183/c-overloaded-virtual-function-warning-by-clang)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3686>

src/compiler/glsl/linker.cpp
src/compiler/glsl/lower_jumps.cpp
src/compiler/glsl/opt_constant_variable.cpp
src/compiler/glsl/opt_dead_code_local.cpp

index 880f42ae17159a9b47cac592019fe7bc8472b65b..d69dff7bbd9dd0f22de5d09fcd07a35aba218ad2 100644 (file)
@@ -260,6 +260,8 @@ public:
 
 class array_resize_visitor : public deref_type_updater {
 public:
+   using deref_type_updater::visit;
+
    unsigned num_vertices;
    gl_shader_program *prog;
    gl_shader_stage stage;
@@ -1506,6 +1508,8 @@ move_non_declarations(exec_list *instructions, exec_node *last,
  */
 class array_sizing_visitor : public deref_type_updater {
 public:
+   using deref_type_updater::visit;
+
    array_sizing_visitor()
       : mem_ctx(ralloc_context(NULL)),
         unnamed_interfaces(_mesa_pointer_hash_table_create(NULL))
index 3286a1c57945824b4628e99350ed9782205d4908..389f5847b3ef88cac5065aba265c3d5c3fa01816 100644 (file)
@@ -268,6 +268,8 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor {
     * contains the jump.
     */
 
+   using ir_control_flow_visitor::visit;
+
    bool progress;
 
    struct function_record function;
index a1fffd4a5f124072b2f5c97001d4d0246c11cd9a..cc2760f560945ef0808633683c0d3dee31c88352 100644 (file)
@@ -49,6 +49,9 @@ struct assignment_entry {
 
 class ir_constant_variable_visitor : public ir_hierarchical_visitor {
 public:
+   using ir_hierarchical_visitor::visit;
+   using ir_hierarchical_visitor::visit_enter;
+
    virtual ir_visitor_status visit_enter(ir_dereference_variable *);
    virtual ir_visitor_status visit(ir_variable *);
    virtual ir_visitor_status visit_enter(ir_assignment *);
index 3cbc441ac9c0cd3d7dfd9457f6ffcd99ad0f919a..b2d35bbaff8bfd32aa5bc11fa43f16d92b2b84a4 100644 (file)
@@ -66,6 +66,8 @@ public:
 
 class kill_for_derefs_visitor : public ir_hierarchical_visitor {
 public:
+   using ir_hierarchical_visitor::visit;
+
    kill_for_derefs_visitor(exec_list *assignments)
    {
       this->assignments = assignments;