From: Mikko Rasa Date: Mon, 5 Apr 2021 12:59:36 +0000 (+0300) Subject: Mark all expression result types as used X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=0ded10909240623e33712be80855827d440f3caf;p=libs%2Fgl.git Mark all expression result types as used UnusedTypeRemover was missing several expression node types. Now it handles expressions through the general expression mechanism. --- diff --git a/source/glsl/optimize.cpp b/source/glsl/optimize.cpp index 32f7ce67..57182019 100644 --- a/source/glsl/optimize.cpp +++ b/source/glsl/optimize.cpp @@ -914,33 +914,10 @@ bool UnusedTypeRemover::apply(Stage &stage) return !unused_nodes.empty(); } -void UnusedTypeRemover::visit(Literal &literal) +void UnusedTypeRemover::visit(RefPtr &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) diff --git a/source/glsl/optimize.h b/source/glsl/optimize.h index 4113f214..1504acb2 100644 --- a/source/glsl/optimize.h +++ b/source/glsl/optimize.h @@ -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 &); virtual void visit(BasicTypeDeclaration &); virtual void visit(ImageTypeDeclaration &); virtual void visit(StructDeclaration &);