diff --git a/swift/extractor/infra/SwiftDispatcher.h b/swift/extractor/infra/SwiftDispatcher.h index 33b0614e435..7a1548c4f53 100644 --- a/swift/extractor/infra/SwiftDispatcher.h +++ b/swift/extractor/infra/SwiftDispatcher.h @@ -5,6 +5,7 @@ #include #include #include +#include "absl/strings/str_cat.h" #include "swift/extractor/trap/TrapDomain.h" #include "swift/extractor/infra/SwiftTagTraits.h" @@ -83,7 +84,7 @@ class SwiftDispatcher { valid = false; } LOG_ERROR("{} has undefined field {}{}, {}", entry.NAME, field, - index >= 0 ? ('[' + std::to_string(index) + ']') : "", action); + index >= 0 ? absl::StrCat("[", index, "]") : "", action); } }); if (valid) { diff --git a/swift/extractor/infra/SwiftMangledName.cpp b/swift/extractor/infra/SwiftMangledName.cpp index 83bf2ff5708..d4c88c3d314 100644 --- a/swift/extractor/infra/SwiftMangledName.cpp +++ b/swift/extractor/infra/SwiftMangledName.cpp @@ -1,4 +1,5 @@ #include "swift/extractor/infra/SwiftMangledName.h" +#include "absl/strings/str_cat.h" namespace codeql { @@ -8,13 +9,11 @@ void appendPart(std::string& out, const std::string& prefix) { } void appendPart(std::string& out, UntypedTrapLabel label) { - out += '{'; - out += label.str(); - out += '}'; + absl::StrAppend(&out, "{", label.str(), "}"); } void appendPart(std::string& out, unsigned index) { - out += std::to_string(index); + absl::StrAppend(&out, index); } } // namespace diff --git a/swift/extractor/main.cpp b/swift/extractor/main.cpp index f195193e5d7..de8a0d3f5e5 100644 --- a/swift/extractor/main.cpp +++ b/swift/extractor/main.cpp @@ -10,6 +10,7 @@ #include #include "absl/strings/str_join.h" +#include "absl/strings/str_cat.h" #include "swift/extractor/SwiftExtractor.h" #include "swift/extractor/infra/TargetDomains.h" @@ -166,7 +167,7 @@ static void checkWhetherToRunUnderTool(int argc, char* const* argv) { // compilations, diagnostics, etc. codeql::TrapDomain invocationTrapDomain(codeql::SwiftExtractorState& state) { auto timestamp = std::chrono::system_clock::now().time_since_epoch().count(); - auto filename = std::to_string(timestamp) + '-' + std::to_string(getpid()); + auto filename = absl::StrCat(timestamp, "-", getpid()); auto target = std::filesystem::path("invocations") / std::filesystem::path(filename); auto maybeDomain = codeql::createTargetTrapDomain(state, target, codeql::TrapType::invocation); CODEQL_ASSERT(maybeDomain, "Cannot create invocation trap file for {}", target); diff --git a/swift/extractor/trap/TrapDomain.h b/swift/extractor/trap/TrapDomain.h index 2ca5efa113d..5741597d756 100644 --- a/swift/extractor/trap/TrapDomain.h +++ b/swift/extractor/trap/TrapDomain.h @@ -2,6 +2,7 @@ #include #include +#include "absl/strings/str_cat.h" #include "swift/extractor/trap/TrapLabel.h" #include "swift/extractor/infra/file/TargetFile.h" @@ -27,7 +28,7 @@ class TrapDomain { e.forEachLabel([&e, this](const char* field, int index, auto& label) { if (!label.valid()) { LOG_ERROR("{} has undefined field {}{}", e.NAME, field, - index >= 0 ? ('[' + std::to_string(index) + ']') : ""); + index >= 0 ? absl::StrCat("[", index, "]") : ""); } }); } diff --git a/swift/logging/SwiftLogging.cpp b/swift/logging/SwiftLogging.cpp index f742a63e25f..e13ab461a1d 100644 --- a/swift/logging/SwiftLogging.cpp +++ b/swift/logging/SwiftLogging.cpp @@ -4,6 +4,7 @@ #include #include #include +#include "absl/strings/str_cat.h" #define LEVEL_REGEX_PATTERN "trace|debug|info|warning|error|critical|no_logs" @@ -98,9 +99,8 @@ std::vector Log::collectLevelRulesAndReturnProblems(const char* env void Log::configure() { // as we are configuring logging right now, we collect problems and log them at the end auto problems = collectLevelRulesAndReturnProblems("CODEQL_EXTRACTOR_SWIFT_LOG_LEVELS"); - auto logBaseName = std::to_string(std::chrono::system_clock::now().time_since_epoch().count()); - logBaseName += '-'; - logBaseName += std::to_string(getpid()); + auto timestamp = std::chrono::system_clock::now().time_since_epoch().count(); + auto logBaseName = absl::StrCat(timestamp, "-", getpid()); if (text || binary) { std::filesystem::path logFile = getEnvOr("CODEQL_EXTRACTOR_SWIFT_LOG_DIR", "extractor-out/log"); logFile /= "swift";