diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp index 3f515788..325fa15a 100644 --- a/cpp2rust/converter/converter_lib.cpp +++ b/cpp2rust/converter/converter_lib.cpp @@ -380,7 +380,7 @@ clang::QualType GetReturnTypeOfFunction(const clang::CallExpr *expr) { return {}; } -std::string GetOverloadedOperator(const clang::FunctionDecl *decl) { +const char *GetOverloadedOperator(const clang::FunctionDecl *decl) { switch (decl->getOverloadedOperator()) { case clang::OO_Less: return "lt"; diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index 3696d680..668e5150 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -91,7 +91,7 @@ template llvm::SmallString<16> GetNumAsString(const T &num) { clang::QualType GetReturnTypeOfFunction(const clang::CallExpr *expr); -std::string GetOverloadedOperator(const clang::FunctionDecl *decl); +const char *GetOverloadedOperator(const clang::FunctionDecl *decl); bool IsOverloadedComparisonOperator(const clang::CXXMethodDecl *decl); diff --git a/cpp2rust/converter/mapper.cpp b/cpp2rust/converter/mapper.cpp index a100c969..e0e84c51 100644 --- a/cpp2rust/converter/mapper.cpp +++ b/cpp2rust/converter/mapper.cpp @@ -367,7 +367,7 @@ Map::const_iterator parallel_search(const Map &container, decltype(exprs_)::const_iterator search(const clang::Expr *expr) { auto qualified_name = ToString(expr); - auto result = parallel_search(exprs_, [&](std::string tpl) { + auto result = parallel_search(exprs_, [&](const std::string &tpl) { return matchTemplate(tpl, qualified_name); }); llvm::errs() << "search expr " << qualified_name << ", result:\n"; @@ -382,7 +382,7 @@ decltype(exprs_)::const_iterator search(const clang::Expr *expr) { decltype(types_)::const_iterator search(clang::QualType qual_type) { auto type = ToString(qual_type); auto result = parallel_search( - types_, [&](std::string tpl) { return matchTemplate(tpl, type); }); + types_, [&](const std::string &tpl) { return matchTemplate(tpl, type); }); llvm::errs() << "search type " << type << ", result: " << ((result == types_.end()) ? "None" : result->second.type_info.type) @@ -531,8 +531,9 @@ clang::QualType normalizeQualType(clang::QualType qual_type) { } std::string mapTypeStringRecursive(const std::string &cpp_type) { - auto rule = parallel_search( - types_, [&](std::string tpl) { return matchTemplate(tpl, cpp_type); }); + auto rule = parallel_search(types_, [&](const std::string &tpl) { + return matchTemplate(tpl, cpp_type); + }); if (rule == types_.end()) { llvm::errs() << "cpp_type: " << cpp_type << '\n'; assert(0 && "Type is not present in types_"); diff --git a/cpp2rust/converter/models/converter_refcount.h b/cpp2rust/converter/models/converter_refcount.h index 81025901..a3479480 100644 --- a/cpp2rust/converter/models/converter_refcount.h +++ b/cpp2rust/converter/models/converter_refcount.h @@ -196,7 +196,7 @@ class ConverterRefCount final : public Converter { FullRefCount, }; - std::string ConversionKindToString(ConversionKind k) { + const char *ConversionKindToString(ConversionKind k) { switch (k) { case ConversionKind::Unboxed: return "Unboxed";