glsl: Rename class variable_entry to ir_variable_refcount_entry.
authorKenneth Graunke <kenneth@whitecape.org>
Sun, 29 Jan 2012 00:58:37 +0000 (16:58 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 31 Jan 2012 01:44:52 +0000 (17:44 -0800)
Exporting a publicly visible class with a generic name like
"variable_entry" via ir_variable_refcount.h is kind of mean.

Many IR transformers would like to define their own "variable_entry"
class.  If they accidentally include this header, the compiler/linker
may get confused and try to instantiate the wrong variable_entry class,
leading to bizarre runtime crashes.

The hope is that renaming this one will allow .cpp files to safely
declare and use their own file-scope "variable_entry" classes.

This avoids crashes caused by converting src/glsl to automake.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-and-tested-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/glsl/ir_variable_refcount.cpp
src/glsl/ir_variable_refcount.h
src/glsl/opt_dead_code.cpp
src/glsl/opt_tree_grafting.cpp

index 7d39abb3682e2d96a911c7814afc9f742fccc070..1633a735744126207d478b03dec5789f061a67e8 100644 (file)
@@ -36,7 +36,7 @@
 
 
 // constructor
-variable_entry::variable_entry(ir_variable *var)
+ir_variable_refcount_entry::ir_variable_refcount_entry(ir_variable *var)
 {
    this->var = var;
    assign = NULL;
@@ -46,17 +46,17 @@ variable_entry::variable_entry(ir_variable *var)
 }
 
 
-variable_entry *
+ir_variable_refcount_entry *
 ir_variable_refcount_visitor::get_variable_entry(ir_variable *var)
 {
    assert(var);
    foreach_iter(exec_list_iterator, iter, this->variable_list) {
-      variable_entry *entry = (variable_entry *)iter.get();
+      ir_variable_refcount_entry *entry = (ir_variable_refcount_entry *)iter.get();
       if (entry->var == var)
         return entry;
    }
 
-   variable_entry *entry = new(mem_ctx) variable_entry(var);
+   ir_variable_refcount_entry *entry = new(mem_ctx) ir_variable_refcount_entry(var);
    assert(entry->referenced_count == 0);
    this->variable_list.push_tail(entry);
    return entry;
@@ -66,7 +66,7 @@ ir_variable_refcount_visitor::get_variable_entry(ir_variable *var)
 ir_visitor_status
 ir_variable_refcount_visitor::visit(ir_variable *ir)
 {
-   variable_entry *entry = this->get_variable_entry(ir);
+   ir_variable_refcount_entry *entry = this->get_variable_entry(ir);
    if (entry)
       entry->declaration = true;
 
@@ -78,7 +78,7 @@ ir_visitor_status
 ir_variable_refcount_visitor::visit(ir_dereference_variable *ir)
 {
    ir_variable *const var = ir->variable_referenced();
-   variable_entry *entry = this->get_variable_entry(var);
+   ir_variable_refcount_entry *entry = this->get_variable_entry(var);
 
    if (entry)
       entry->referenced_count++;
@@ -101,7 +101,7 @@ ir_variable_refcount_visitor::visit_enter(ir_function_signature *ir)
 ir_visitor_status
 ir_variable_refcount_visitor::visit_leave(ir_assignment *ir)
 {
-   variable_entry *entry;
+   ir_variable_refcount_entry *entry;
    entry = this->get_variable_entry(ir->lhs->variable_referenced());
    if (entry) {
       entry->assigned_count++;
index 906135a9e1e370ad2d7bf64c65e864ccb58ec221..51a4945a135289f23d4cefa7b12a301507844344 100644 (file)
 #include "ir_visitor.h"
 #include "glsl_types.h"
 
-class variable_entry : public exec_node
+class ir_variable_refcount_entry : public exec_node
 {
 public:
-   variable_entry(ir_variable *var);
+   ir_variable_refcount_entry(ir_variable *var);
 
    ir_variable *var; /* The key: the variable's pointer. */
    ir_assignment *assign; /* An assignment to the variable, if any */
@@ -69,9 +69,9 @@ public:
    virtual ir_visitor_status visit_enter(ir_function_signature *);
    virtual ir_visitor_status visit_leave(ir_assignment *);
 
-   variable_entry *get_variable_entry(ir_variable *var);
+   ir_variable_refcount_entry *get_variable_entry(ir_variable *var);
 
-   /* List of variable_entry */
+   /* List of ir_variable_refcount_entry */
    exec_list variable_list;
 
    void *mem_ctx;
index 5b9546ad40984708217f6eb7db907cfb22807659..22c7af1c20a73e12eaaca34cd6b1ec6d8f6f8264 100644 (file)
@@ -50,7 +50,7 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned)
    v.run(instructions);
 
    foreach_iter(exec_list_iterator, iter, v.variable_list) {
-      variable_entry *entry = (variable_entry *)iter.get();
+      ir_variable_refcount_entry *entry = (ir_variable_refcount_entry *)iter.get();
 
       /* Since each assignment is a reference, the refereneced count must be
        * greater than or equal to the assignment count.  If they are equal,
index d32d14e88a901076bd978125f894aa79e417e01a..e2aff5f8071e721f1be9352161364cac36d963ae 100644 (file)
@@ -349,7 +349,7 @@ tree_grafting_basic_block(ir_instruction *bb_first,
          lhs_var->mode == ir_var_inout)
         continue;
 
-      variable_entry *entry = info->refs->get_variable_entry(lhs_var);
+      ir_variable_refcount_entry *entry = info->refs->get_variable_entry(lhs_var);
 
       if (!entry->declaration ||
          entry->assigned_count != 1 ||