From 2280a09a286bbff2eb41783f8023863f320a3736 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 5 Apr 2021 15:22:40 +0300 Subject: [PATCH] Don't return references from apply functions It's somewhat error prone, even though it hasn't caused any problems yet. --- source/glsl/debug.cpp | 2 +- source/glsl/debug.h | 2 +- source/glsl/optimize.cpp | 2 +- source/glsl/optimize.h | 4 ++-- source/glsl/output.cpp | 2 +- source/glsl/output.h | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/glsl/debug.cpp b/source/glsl/debug.cpp index 8bdce457..2f243dc7 100644 --- a/source/glsl/debug.cpp +++ b/source/glsl/debug.cpp @@ -8,7 +8,7 @@ namespace Msp { namespace GL { namespace SL { -const std::string &DumpTree::apply(Stage &stage) +std::string DumpTree::apply(Stage &stage) { formatted = format("Stage: %s\n", Stage::get_stage_name(stage.type)); tree.push_back(BRANCH); diff --git a/source/glsl/debug.h b/source/glsl/debug.h index 73976904..da888198 100644 --- a/source/glsl/debug.h +++ b/source/glsl/debug.h @@ -37,7 +37,7 @@ private: std::vector tree; public: - const std::string &apply(Stage &); + std::string apply(Stage &); private: void append(const std::string &); diff --git a/source/glsl/optimize.cpp b/source/glsl/optimize.cpp index 475e8b64..32f7ce67 100644 --- a/source/glsl/optimize.cpp +++ b/source/glsl/optimize.cpp @@ -123,7 +123,7 @@ InlineContentInjector::InlineContentInjector(): pass(REFERENCED) { } -const string &InlineContentInjector::apply(Stage &stage, FunctionDeclaration &target_func, Block &tgt_blk, const NodeList::iterator &ins_pt, FunctionCall &call) +string InlineContentInjector::apply(Stage &stage, FunctionDeclaration &target_func, Block &tgt_blk, const NodeList::iterator &ins_pt, FunctionCall &call) { source_func = call.declaration->definition; diff --git a/source/glsl/optimize.h b/source/glsl/optimize.h index d434c68a..4113f214 100644 --- a/source/glsl/optimize.h +++ b/source/glsl/optimize.h @@ -39,7 +39,7 @@ private: public: InlineableFunctionLocator(); - const std::set &apply(Stage &s) { s.content.visit(*this); return inlineable; } + std::set apply(Stage &s) { s.content.visit(*this); return inlineable; } private: virtual void visit(FunctionCall &); @@ -73,7 +73,7 @@ private: public: InlineContentInjector(); - const std::string &apply(Stage &, FunctionDeclaration &, Block &, const NodeList::iterator &, FunctionCall &); + std::string apply(Stage &, FunctionDeclaration &, Block &, const NodeList::iterator &, FunctionCall &); private: virtual void visit(VariableReference &); diff --git a/source/glsl/output.cpp b/source/glsl/output.cpp index 38adb5bd..c15c8c04 100644 --- a/source/glsl/output.cpp +++ b/source/glsl/output.cpp @@ -18,7 +18,7 @@ Formatter::Formatter(): r_empty_name(false) { } -const string &Formatter::apply(Stage &s) +string Formatter::apply(Stage &s) { stage = &s; omit_builtin = true; diff --git a/source/glsl/output.h b/source/glsl/output.h index ef936987..1e59a445 100644 --- a/source/glsl/output.h +++ b/source/glsl/output.h @@ -25,8 +25,8 @@ private: public: Formatter(); - const std::string &apply(Stage &); - const std::string &apply(Node &n) { n.visit(*this); return formatted; } + std::string apply(Stage &); + std::string apply(Node &n) { n.visit(*this); return formatted; } private: void append(const std::string &); -- 2.43.0