From 54197d373bdcb52ca3ba9788b104138a22cc4225 Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Tue, 7 Sep 2021 22:08:38 -0600 Subject: [PATCH] Replace uses of replaceInString method with IEGenLib's better version #21 --- include/Utils.hpp | 9 --------- src/StmtContext.cpp | 3 ++- src/Utils.cpp | 11 ----------- 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/include/Utils.hpp b/include/Utils.hpp index af42a4e..c8dfc3c 100644 --- a/include/Utils.hpp +++ b/include/Utils.hpp @@ -38,15 +38,6 @@ class Utils { //! Get the source code of a statement as a string static std::string stmtToString(clang::Stmt *stmt); - //! Get a copy of the given string with all instances of the substring to - //! find replaced as specified - //! \param[in] input String to perform substitutions on (will not be - //! modified) - //! \param[in] toFind String to find (and replace) within input - //! \param[in] replaceWith String to use as replacement - static std::string replaceInString(std::string input, const std::string &toFind, - const std::string &replaceWith); - //! Retrieve "all" array accesses, from left to right, contained in an //! expression. //! Recurses into BinaryOperators. diff --git a/src/StmtContext.cpp b/src/StmtContext.cpp index acaf67c..ee61b3f 100644 --- a/src/StmtContext.cpp +++ b/src/StmtContext.cpp @@ -11,6 +11,7 @@ #include "Driver.hpp" #include "ExecSchedule.hpp" #include "Utils.hpp" +#include "iegenlib.h" #include "clang/AST/Decl.h" #include "clang/AST/Expr.h" #include "clang/AST/OperationKinds.h" @@ -261,7 +262,7 @@ std::string StmtContext::exprToStringWithSafeArrays(Expr *expr) { DataAccessHandler::buildDataAccess(access, true, accessComponents); std::string accessStr = DataAccessHandler::makeStringForArrayAccess( &accessComponents.back().second, accessComponents); - initialStr = Utils::replaceInString( + initialStr = iegenlib::replaceInString( initialStr, Utils::stmtToString(access), accessStr); } return initialStr; diff --git a/src/Utils.cpp b/src/Utils.cpp index a3e7b4a..80cf750 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -40,17 +40,6 @@ std::string Utils::stmtToString(clang::Stmt *stmt) { .str(); } -std::string Utils::replaceInString(std::string input, const std::string &toFind, - const std::string &replaceWith) { - size_t pos = input.find(toFind); - if (pos == std::string::npos) { - return input; - } else { - return replaceInString(input.replace(pos, toFind.length(), replaceWith), - toFind, replaceWith); - } -} - void Utils::getExprArrayAccesses( Expr *expr, std::vector ¤tList) { Expr *usableExpr = expr->IgnoreParenImpCasts();