]> git.tdb.fi Git - libs/gl.git/commitdiff
Mark all expression result types as used
authorMikko Rasa <tdb@tdb.fi>
Mon, 5 Apr 2021 12:59:36 +0000 (15:59 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 5 Apr 2021 13:39:37 +0000 (16:39 +0300)
UnusedTypeRemover was missing several expression node types.  Now it
handles expressions through the general expression mechanism.

source/glsl/optimize.cpp
source/glsl/optimize.h

index 32f7ce67959b388fa1bc2c2fb58ecc344a11bb87..57182019012b731ba330e7fc38a1e86f1f2eeeaf 100644 (file)
@@ -914,33 +914,10 @@ bool UnusedTypeRemover::apply(Stage &stage)
        return !unused_nodes.empty();
 }
 
-void UnusedTypeRemover::visit(Literal &literal)
+void UnusedTypeRemover::visit(RefPtr<Expression> &expr)
 {
-       unused_nodes.erase(literal.type);
-}
-
-void UnusedTypeRemover::visit(UnaryExpression &unary)
-{
-       unused_nodes.erase(unary.type);
-       TraversingVisitor::visit(unary);
-}
-
-void UnusedTypeRemover::visit(BinaryExpression &binary)
-{
-       unused_nodes.erase(binary.type);
-       TraversingVisitor::visit(binary);
-}
-
-void UnusedTypeRemover::visit(TernaryExpression &ternary)
-{
-       unused_nodes.erase(ternary.type);
-       TraversingVisitor::visit(ternary);
-}
-
-void UnusedTypeRemover::visit(FunctionCall &call)
-{
-       unused_nodes.erase(call.type);
-       TraversingVisitor::visit(call);
+       unused_nodes.erase(expr->type);
+       TraversingVisitor::visit(expr);
 }
 
 void UnusedTypeRemover::visit(BasicTypeDeclaration &type)
@@ -966,6 +943,7 @@ void UnusedTypeRemover::visit(StructDeclaration &strct)
 void UnusedTypeRemover::visit(VariableDeclaration &var)
 {
        unused_nodes.erase(var.type_declaration);
+       TraversingVisitor::visit(var);
 }
 
 void UnusedTypeRemover::visit(InterfaceBlock &iface)
index 4113f21465a990e85a4fa701351b8277cec09cfe..1504acb224e27dd5290947e9700fa657750ba433 100644 (file)
@@ -237,11 +237,7 @@ public:
        bool apply(Stage &);
 
 private:
-       virtual void visit(Literal &);
-       virtual void visit(UnaryExpression &);
-       virtual void visit(BinaryExpression &);
-       virtual void visit(TernaryExpression &);
-       virtual void visit(FunctionCall &);
+       virtual void visit(RefPtr<Expression> &);
        virtual void visit(BasicTypeDeclaration &);
        virtual void visit(ImageTypeDeclaration &);
        virtual void visit(StructDeclaration &);